Index: include/llvm/Analysis/TargetTransformInfo.h =================================================================== --- include/llvm/Analysis/TargetTransformInfo.h +++ include/llvm/Analysis/TargetTransformInfo.h @@ -598,6 +598,25 @@ /// @} + /// Returns true iff i32 parameters to library functions should have + /// signext or zeroext attributes if they correspond to C-level int or + /// unsigned int, respectively. + bool shouldExtI32Param() const; + + /// Returns true iff i32 results from library functions should have + /// signext or zeroext attributes if they correspond to C-level int or + /// unsigned int, respectively. + bool shouldExtI32Result() const; + + /// Returns true iff i32 parameters to library functions should have + /// signext attribute if they correspond to C-level int or unsigned int. + bool shouldSignExtI32Param() const; + + /// Returns true iff the TTI was provided by a target (and thus the returned + /// information can be trusted), false if it's the default TTI constructed + /// for an unknown target. + bool knownTarget() const; + private: /// \brief The abstract base class used to type erase specific TTI /// implementations. @@ -716,6 +735,10 @@ Type *ExpectedType) = 0; virtual bool areInlineCompatible(const Function *Caller, const Function *Callee) const = 0; + virtual bool shouldExtI32Param() const = 0; + virtual bool shouldExtI32Result() const = 0; + virtual bool shouldSignExtI32Param() const = 0; + virtual bool knownTarget() const = 0; }; template @@ -948,6 +971,18 @@ const Function *Callee) const override { return Impl.areInlineCompatible(Caller, Callee); } + bool shouldExtI32Param() const override { + return Impl.shouldExtI32Param(); + } + bool shouldExtI32Result() const override { + return Impl.shouldExtI32Result(); + } + bool shouldSignExtI32Param() const override { + return Impl.shouldSignExtI32Param(); + } + bool knownTarget() const override { + return Impl.knownTarget(); + } }; template Index: include/llvm/Analysis/TargetTransformInfoImpl.h =================================================================== --- include/llvm/Analysis/TargetTransformInfoImpl.h +++ include/llvm/Analysis/TargetTransformInfoImpl.h @@ -371,6 +371,14 @@ (Caller->getFnAttribute("target-features") == Callee->getFnAttribute("target-features")); } + + bool shouldExtI32Param() const { return false; } + + bool shouldExtI32Result() const { return false; } + + bool shouldSignExtI32Param() const { return false; } + + bool knownTarget() const { return true; } }; /// \brief CRTP base class for use as a mix-in that aids implementing Index: lib/Analysis/TargetTransformInfo.cpp =================================================================== --- lib/Analysis/TargetTransformInfo.cpp +++ lib/Analysis/TargetTransformInfo.cpp @@ -31,6 +31,7 @@ struct NoTTIImpl : TargetTransformInfoImplCRTPBase { explicit NoTTIImpl(const DataLayout &DL) : TargetTransformInfoImplCRTPBase(DL) {} + bool knownTarget() const { return false; } }; } @@ -396,6 +397,22 @@ return TTIImpl->areInlineCompatible(Caller, Callee); } +bool TargetTransformInfo::shouldExtI32Param() const { + return TTIImpl->shouldExtI32Param(); +} + +bool TargetTransformInfo::shouldExtI32Result() const { + return TTIImpl->shouldExtI32Result(); +} + +bool TargetTransformInfo::shouldSignExtI32Param() const { + return TTIImpl->shouldSignExtI32Param(); +} + +bool TargetTransformInfo::knownTarget() const { + return TTIImpl->knownTarget(); +} + TargetTransformInfo::Concept::~Concept() {} TargetIRAnalysis::TargetIRAnalysis() : TTICallback(&getDefaultTTI) {}