diff --git a/llvm/include/llvm/Analysis/TargetTransformInfo.h b/llvm/include/llvm/Analysis/TargetTransformInfo.h --- a/llvm/include/llvm/Analysis/TargetTransformInfo.h +++ b/llvm/include/llvm/Analysis/TargetTransformInfo.h @@ -878,6 +878,45 @@ /// prefetching is performed. unsigned getMaxPrefetchIterationsAhead() const; + /// \brief Get maximum # of store operations permitted for llvm.memset + /// + /// This function returns the maximum number of store operations permitted + /// to replace a call to llvm.memset. The value is set by the target at the + /// performance threshold for such a replacement. If OptSize is true, + /// return the limit for functions that have OptSize attribute. + unsigned getMaxStoresPerMemset(bool OptSize) const; + + /// \brief Get maximum # of store operations permitted for llvm.memcpy + /// + /// This function returns the maximum number of store operations permitted + /// to replace a call to llvm.memcpy. The value is set by the target at the + /// performance threshold for such a replacement. If OptSize is true, + /// return the limit for functions that have OptSize attribute. + unsigned getMaxStoresPerMemcpy(bool OptSize) const; + + /// \brief Get maximum # of store operations to be glued together + /// + /// This function returns the maximum number of store operations permitted + /// to glue together during lowering of llvm.memcpy. The value is set by + // the target at the performance threshold for such a replacement. + unsigned getMaxGluedStoresPerMemcpy() const; + + /// \brief Get maximum # of load operations permitted for memcmp + /// + /// This function returns the maximum number of load operations permitted + /// to replace a call to memcmp. The value is set by the target at the + /// performance threshold for such a replacement. If OptSize is true, + /// return the limit for functions that have OptSize attribute. + unsigned getMaxExpandSizeMemcmp(bool OptSize) const; + + /// \brief Get maximum # of store operations permitted for llvm.memmove + /// + /// This function returns the maximum number of store operations permitted + /// to replace a call to llvm.memmove. The value is set by the target at the + /// performance threshold for such a replacement. If OptSize is true, + /// return the limit for functions that have OptSize attribute. + unsigned getMaxStoresPerMemmove(bool OptSize) const; + /// \return The maximum interleave factor that any transform should try to /// perform for this target. This number depends on the level of parallelism /// and the number of execution units in the CPU. @@ -1308,6 +1347,12 @@ /// prefetching is performed. virtual unsigned getMaxPrefetchIterationsAhead() const = 0; + virtual unsigned getMaxStoresPerMemset(bool OptSize) const = 0; + virtual unsigned getMaxStoresPerMemcpy(bool OptSize) const = 0; + virtual unsigned getMaxGluedStoresPerMemcpy() const = 0; + virtual unsigned getMaxExpandSizeMemcmp(bool OptSize) const = 0; + virtual unsigned getMaxStoresPerMemmove(bool OptSize) const = 0; + virtual unsigned getMaxInterleaveFactor(unsigned VF) = 0; virtual unsigned getArithmeticInstrCost(unsigned Opcode, Type *Ty, OperandValueKind Opd1Info, @@ -1700,6 +1745,26 @@ return Impl.getMaxPrefetchIterationsAhead(); } + unsigned getMaxStoresPerMemset(bool OptSize) const override { + return Impl.getMaxStoresPerMemset(OptSize); + } + + unsigned getMaxStoresPerMemcpy(bool OptSize) const override { + return Impl.getMaxStoresPerMemcpy(OptSize); + } + + unsigned getMaxGluedStoresPerMemcpy() const override { + return Impl.getMaxGluedStoresPerMemcpy(); + } + + unsigned getMaxExpandSizeMemcmp(bool OptSize) const override { + return Impl.getMaxExpandSizeMemcmp(OptSize); + } + + unsigned getMaxStoresPerMemmove(bool OptSize) const override { + return Impl.getMaxStoresPerMemmove(OptSize); + } + unsigned getMaxInterleaveFactor(unsigned VF) override { return Impl.getMaxInterleaveFactor(VF); } diff --git a/llvm/include/llvm/Analysis/TargetTransformInfoImpl.h b/llvm/include/llvm/Analysis/TargetTransformInfoImpl.h --- a/llvm/include/llvm/Analysis/TargetTransformInfoImpl.h +++ b/llvm/include/llvm/Analysis/TargetTransformInfoImpl.h @@ -423,6 +423,12 @@ unsigned getMinPrefetchStride() const { return 1; } unsigned getMaxPrefetchIterationsAhead() const { return UINT_MAX; } + unsigned getMaxStoresPerMemset(bool OptSize) const { return 0; } + unsigned getMaxStoresPerMemcpy(bool OptSize) const { return 0; } + unsigned getMaxGluedStoresPerMemcpy() const { return 0; } + unsigned getMaxExpandSizeMemcmp(bool OptSize) const { return 0; } + unsigned getMaxStoresPerMemmove(bool OptSize) const { return 0; } + unsigned getMaxInterleaveFactor(unsigned VF) { return 1; } unsigned getArithmeticInstrCost(unsigned Opcode, Type *Ty, diff --git a/llvm/include/llvm/CodeGen/BasicTTIImpl.h b/llvm/include/llvm/CodeGen/BasicTTIImpl.h --- a/llvm/include/llvm/CodeGen/BasicTTIImpl.h +++ b/llvm/include/llvm/CodeGen/BasicTTIImpl.h @@ -557,6 +557,26 @@ return getST()->getMaxPrefetchIterationsAhead(); } + virtual unsigned getMaxStoresPerMemset(bool OptSize) const { + return getTLI()->getMaxStoresPerMemset(OptSize); + } + + virtual unsigned getMaxStoresPerMemcpy(bool OptSize) const { + return getTLI()->getMaxStoresPerMemcpy(OptSize); + } + + virtual unsigned getMaxGluedStoresPerMemcpy() const { + return getTLI()->getMaxGluedStoresPerMemcpy(); + } + + virtual unsigned getMaxExpandSizeMemcmp(bool OptSize) const { + return getTLI()->getMaxExpandSizeMemcmp(OptSize); + } + + virtual unsigned getMaxStoresPerMemmove(bool OptSize) const { + return getTLI()->getMaxStoresPerMemmove(OptSize); + } + /// @} /// \name Vector TTI Implementations diff --git a/llvm/lib/Analysis/TargetTransformInfo.cpp b/llvm/lib/Analysis/TargetTransformInfo.cpp --- a/llvm/lib/Analysis/TargetTransformInfo.cpp +++ b/llvm/lib/Analysis/TargetTransformInfo.cpp @@ -535,6 +535,26 @@ return TTIImpl->getMaxPrefetchIterationsAhead(); } +unsigned TargetTransformInfo::getMaxStoresPerMemset(bool OptSize) const { + return TTIImpl->getMaxStoresPerMemset(OptSize); +} + +unsigned TargetTransformInfo::getMaxStoresPerMemcpy(bool OptSize) const { + return TTIImpl->getMaxStoresPerMemcpy(OptSize); +} + +unsigned TargetTransformInfo::getMaxGluedStoresPerMemcpy() const { + return TTIImpl->getMaxGluedStoresPerMemcpy(); +} + +unsigned TargetTransformInfo::getMaxExpandSizeMemcmp(bool OptSize) const { + return TTIImpl->getMaxExpandSizeMemcmp(OptSize); +} + +unsigned TargetTransformInfo::getMaxStoresPerMemmove(bool OptSize) const { + return TTIImpl->getMaxStoresPerMemmove(OptSize); +} + unsigned TargetTransformInfo::getMaxInterleaveFactor(unsigned VF) const { return TTIImpl->getMaxInterleaveFactor(VF); }