Changeset View
Changeset View
Standalone View
Standalone View
include/llvm/Analysis/TargetTransformInfo.h
Show First 20 Lines • Show All 130 Lines • ▼ Show 20 Lines | public: | ||||
unsigned getOperationCost(unsigned Opcode, Type *Ty, | unsigned getOperationCost(unsigned Opcode, Type *Ty, | ||||
Type *OpTy = nullptr) const; | Type *OpTy = nullptr) const; | ||||
/// \brief Estimate the cost of a GEP operation when lowered. | /// \brief Estimate the cost of a GEP operation when lowered. | ||||
/// | /// | ||||
/// The contract for this function is the same as \c getOperationCost except | /// The contract for this function is the same as \c getOperationCost except | ||||
/// that it supports an interface that provides extra information specific to | /// that it supports an interface that provides extra information specific to | ||||
/// the GEP operation. | /// the GEP operation. | ||||
unsigned getGEPCost(const Value *Ptr, ArrayRef<const Value *> Operands) const; | unsigned getGEPCost(Type *PointeeType, const Value *Ptr, | ||||
ArrayRef<const Value *> Operands) const; | |||||
hfinkel: I see no reason to change the interface here. We can localize the const_casts to the… | |||||
/// \brief Estimate the cost of a function call when lowered. | /// \brief Estimate the cost of a function call when lowered. | ||||
/// | /// | ||||
/// The contract for this is the same as \c getOperationCost except that it | /// The contract for this is the same as \c getOperationCost except that it | ||||
/// supports an interface that provides extra information specific to call | /// supports an interface that provides extra information specific to call | ||||
/// instructions. | /// instructions. | ||||
/// | /// | ||||
/// This is the most basic query for estimating call cost: it only knows the | /// This is the most basic query for estimating call cost: it only knows the | ||||
▲ Show 20 Lines • Show All 369 Lines • ▼ Show 20 Lines | private: | ||||
std::unique_ptr<Concept> TTIImpl; | std::unique_ptr<Concept> TTIImpl; | ||||
}; | }; | ||||
class TargetTransformInfo::Concept { | class TargetTransformInfo::Concept { | ||||
public: | public: | ||||
virtual ~Concept() = 0; | virtual ~Concept() = 0; | ||||
virtual unsigned getOperationCost(unsigned Opcode, Type *Ty, Type *OpTy) = 0; | virtual unsigned getOperationCost(unsigned Opcode, Type *Ty, Type *OpTy) = 0; | ||||
virtual unsigned getGEPCost(const Value *Ptr, | virtual unsigned getGEPCost(Type *PointeeType, const Value *Ptr, | ||||
ArrayRef<const Value *> Operands) = 0; | ArrayRef<const Value *> Operands) = 0; | ||||
virtual unsigned getCallCost(FunctionType *FTy, int NumArgs) = 0; | virtual unsigned getCallCost(FunctionType *FTy, int NumArgs) = 0; | ||||
virtual unsigned getCallCost(const Function *F, int NumArgs) = 0; | virtual unsigned getCallCost(const Function *F, int NumArgs) = 0; | ||||
virtual unsigned getCallCost(const Function *F, | virtual unsigned getCallCost(const Function *F, | ||||
ArrayRef<const Value *> Arguments) = 0; | ArrayRef<const Value *> Arguments) = 0; | ||||
virtual unsigned getIntrinsicCost(Intrinsic::ID IID, Type *RetTy, | virtual unsigned getIntrinsicCost(Intrinsic::ID IID, Type *RetTy, | ||||
ArrayRef<Type *> ParamTys) = 0; | ArrayRef<Type *> ParamTys) = 0; | ||||
virtual unsigned getIntrinsicCost(Intrinsic::ID IID, Type *RetTy, | virtual unsigned getIntrinsicCost(Intrinsic::ID IID, Type *RetTy, | ||||
▲ Show 20 Lines • Show All 71 Lines • ▼ Show 20 Lines | |||||
public: | public: | ||||
Model(T Impl) : Impl(std::move(Impl)) {} | Model(T Impl) : Impl(std::move(Impl)) {} | ||||
~Model() override {} | ~Model() override {} | ||||
unsigned getOperationCost(unsigned Opcode, Type *Ty, Type *OpTy) override { | unsigned getOperationCost(unsigned Opcode, Type *Ty, Type *OpTy) override { | ||||
return Impl.getOperationCost(Opcode, Ty, OpTy); | return Impl.getOperationCost(Opcode, Ty, OpTy); | ||||
} | } | ||||
unsigned getGEPCost(const Value *Ptr, | unsigned getGEPCost(Type *PointeeType, const Value *Ptr, | ||||
ArrayRef<const Value *> Operands) override { | ArrayRef<const Value *> Operands) override { | ||||
return Impl.getGEPCost(Ptr, Operands); | return Impl.getGEPCost(PointeeType, Ptr, Operands); | ||||
} | } | ||||
unsigned getCallCost(FunctionType *FTy, int NumArgs) override { | unsigned getCallCost(FunctionType *FTy, int NumArgs) override { | ||||
return Impl.getCallCost(FTy, NumArgs); | return Impl.getCallCost(FTy, NumArgs); | ||||
} | } | ||||
unsigned getCallCost(const Function *F, int NumArgs) override { | unsigned getCallCost(const Function *F, int NumArgs) override { | ||||
return Impl.getCallCost(F, NumArgs); | return Impl.getCallCost(F, NumArgs); | ||||
} | } | ||||
unsigned getCallCost(const Function *F, | unsigned getCallCost(const Function *F, | ||||
▲ Show 20 Lines • Show All 257 Lines • Show Last 20 Lines |
I see no reason to change the interface here. We can localize the const_casts to the implementation, instead of forcing them into all callers that have const references/pointers.