protected:
typedef TargetTransformInfo TTI;
- const DataLayout *DL;
+ const DataLayout &DL;
- explicit TargetTransformInfoImplBase(const DataLayout *DL)
- : DL(DL) {}
+ explicit TargetTransformInfoImplBase(const DataLayout &DL) : DL(DL) {}
public:
// Provide value semantics. MSVC requires that we spell all of these out.
TargetTransformInfoImplBase(const TargetTransformInfoImplBase &Arg)
: DL(Arg.DL) {}
- TargetTransformInfoImplBase(TargetTransformInfoImplBase &&Arg)
- : DL(std::move(Arg.DL)) {}
- TargetTransformInfoImplBase &
- operator=(const TargetTransformInfoImplBase &RHS) {
- DL = RHS.DL;
- return *this;
- }
- TargetTransformInfoImplBase &operator=(TargetTransformInfoImplBase &&RHS) {
- DL = std::move(RHS.DL);
- return *this;
- }
+ TargetTransformInfoImplBase(TargetTransformInfoImplBase &&Arg) : DL(Arg.DL) {}
+
+ const DataLayout &getDataLayout() const { return DL; }
unsigned getOperationCost(unsigned Opcode, Type *Ty, Type *OpTy) {
switch (Opcode) {
return TTI::TCC_Basic;
case Instruction::IntToPtr: {
- if (!DL)
- return TTI::TCC_Basic;
-
// An inttoptr cast is free so long as the input is a legal integer type
// which doesn't contain values outside the range of a pointer.
unsigned OpSize = OpTy->getScalarSizeInBits();
- if (DL->isLegalInteger(OpSize) &&
- OpSize <= DL->getPointerTypeSizeInBits(Ty))
+ if (DL.isLegalInteger(OpSize) &&
+ OpSize <= DL.getPointerTypeSizeInBits(Ty))
return TTI::TCC_Free;
// Otherwise it's not a no-op.
return TTI::TCC_Basic;
}
case Instruction::PtrToInt: {
- if (!DL)
- return TTI::TCC_Basic;
-
// A ptrtoint cast is free so long as the result is large enough to store
// the pointer, and a legal integer type.
unsigned DestSize = Ty->getScalarSizeInBits();
- if (DL->isLegalInteger(DestSize) &&
- DestSize >= DL->getPointerTypeSizeInBits(OpTy))
+ if (DL.isLegalInteger(DestSize) &&
+ DestSize >= DL.getPointerTypeSizeInBits(OpTy))
return TTI::TCC_Free;
// Otherwise it's not a no-op.
case Instruction::Trunc:
// trunc to a native type is free (assuming the target has compare and
// shift-right of the same width).
- if (DL && DL->isLegalInteger(DL->getTypeSizeInBits(Ty)))
+ if (DL.isLegalInteger(DL.getTypeSizeInBits(Ty)))
return TTI::TCC_Free;
return TTI::TCC_Basic;
Type *ExpectedType) {
return nullptr;
}
+
+ bool hasCompatibleFunctionAttributes(const Function *Caller,
+ const Function *Callee) const {
+ return (Caller->getFnAttribute("target-cpu") ==
+ Callee->getFnAttribute("target-cpu")) &&
+ (Caller->getFnAttribute("target-features") ==
+ Callee->getFnAttribute("target-features"));
+ }
};
/// \brief CRTP base class for use as a mix-in that aids implementing
typedef TargetTransformInfoImplBase BaseT;
protected:
- explicit TargetTransformInfoImplCRTPBase(const DataLayout *DL)
- : BaseT(DL) {}
+ explicit TargetTransformInfoImplCRTPBase(const DataLayout &DL) : BaseT(DL) {}
public:
// Provide value semantics. MSVC requires that we spell all of these out.
: BaseT(static_cast<const BaseT &>(Arg)) {}
TargetTransformInfoImplCRTPBase(TargetTransformInfoImplCRTPBase &&Arg)
: BaseT(std::move(static_cast<BaseT &>(Arg))) {}
- TargetTransformInfoImplCRTPBase &
- operator=(const TargetTransformInfoImplCRTPBase &RHS) {
- BaseT::operator=(static_cast<const BaseT &>(RHS));
- return *this;
- }
- TargetTransformInfoImplCRTPBase &
- operator=(TargetTransformInfoImplCRTPBase &&RHS) {
- BaseT::operator=(std::move(static_cast<BaseT &>(RHS)));
- return *this;
- }
using BaseT::getCallCost;
U->getNumOperands() == 1 ? U->getOperand(0)->getType() : nullptr);
}
};
-} // namespace llvm
+}
#endif