mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-10-25 10:27:04 +00:00
Make TargetLowering::getPointerTy() taking DataLayout as an argument
Summary: This change is part of a series of commits dedicated to have a single DataLayout during compilation by using always the one owned by the module. Reviewers: echristo Subscribers: jholewinski, ted, yaron.keren, rafael, llvm-commits Differential Revision: http://reviews.llvm.org/D11028 From: Mehdi Amini <mehdi.amini@apple.com> git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@241775 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -94,6 +94,8 @@ protected:
|
||||
explicit BasicTTIImplBase(const TargetMachine *TM, const DataLayout &DL)
|
||||
: BaseT(DL) {}
|
||||
|
||||
using TargetTransformInfoImplBase::DL;
|
||||
|
||||
public:
|
||||
// Provide value semantics. MSVC requires that we spell all of these out.
|
||||
BasicTTIImplBase(const BasicTTIImplBase &Arg)
|
||||
@@ -146,7 +148,7 @@ public:
|
||||
}
|
||||
|
||||
bool isTypeLegal(Type *Ty) {
|
||||
EVT VT = getTLI()->getValueType(Ty);
|
||||
EVT VT = getTLI()->getValueType(DL, Ty);
|
||||
return getTLI()->isTypeLegal(VT);
|
||||
}
|
||||
|
||||
@@ -184,7 +186,7 @@ public:
|
||||
|
||||
bool haveFastSqrt(Type *Ty) {
|
||||
const TargetLoweringBase *TLI = getTLI();
|
||||
EVT VT = TLI->getValueType(Ty);
|
||||
EVT VT = TLI->getValueType(DL, Ty);
|
||||
return TLI->isTypeLegal(VT) &&
|
||||
TLI->isOperationLegalOrCustom(ISD::FSQRT, VT);
|
||||
}
|
||||
@@ -291,7 +293,7 @@ public:
|
||||
int ISD = TLI->InstructionOpcodeToISD(Opcode);
|
||||
assert(ISD && "Invalid opcode");
|
||||
|
||||
std::pair<unsigned, MVT> LT = TLI->getTypeLegalizationCost(Ty);
|
||||
std::pair<unsigned, MVT> LT = TLI->getTypeLegalizationCost(DL, Ty);
|
||||
|
||||
bool IsFloat = Ty->getScalarType()->isFloatingPointTy();
|
||||
// Assume that floating point arithmetic operations cost twice as much as
|
||||
@@ -341,9 +343,8 @@ public:
|
||||
const TargetLoweringBase *TLI = getTLI();
|
||||
int ISD = TLI->InstructionOpcodeToISD(Opcode);
|
||||
assert(ISD && "Invalid opcode");
|
||||
|
||||
std::pair<unsigned, MVT> SrcLT = TLI->getTypeLegalizationCost(Src);
|
||||
std::pair<unsigned, MVT> DstLT = TLI->getTypeLegalizationCost(Dst);
|
||||
std::pair<unsigned, MVT> SrcLT = TLI->getTypeLegalizationCost(DL, Src);
|
||||
std::pair<unsigned, MVT> DstLT = TLI->getTypeLegalizationCost(DL, Dst);
|
||||
|
||||
// Check for NOOP conversions.
|
||||
if (SrcLT.first == DstLT.first &&
|
||||
@@ -447,8 +448,7 @@ public:
|
||||
if (CondTy->isVectorTy())
|
||||
ISD = ISD::VSELECT;
|
||||
}
|
||||
|
||||
std::pair<unsigned, MVT> LT = TLI->getTypeLegalizationCost(ValTy);
|
||||
std::pair<unsigned, MVT> LT = TLI->getTypeLegalizationCost(DL, ValTy);
|
||||
|
||||
if (!(ValTy->isVectorTy() && !LT.second.isVector()) &&
|
||||
!TLI->isOperationExpand(ISD, LT.second)) {
|
||||
@@ -477,7 +477,7 @@ public:
|
||||
|
||||
unsigned getVectorInstrCost(unsigned Opcode, Type *Val, unsigned Index) {
|
||||
std::pair<unsigned, MVT> LT =
|
||||
getTLI()->getTypeLegalizationCost(Val->getScalarType());
|
||||
getTLI()->getTypeLegalizationCost(DL, Val->getScalarType());
|
||||
|
||||
return LT.first;
|
||||
}
|
||||
@@ -485,7 +485,7 @@ public:
|
||||
unsigned getMemoryOpCost(unsigned Opcode, Type *Src, unsigned Alignment,
|
||||
unsigned AddressSpace) {
|
||||
assert(!Src->isVoidTy() && "Invalid type");
|
||||
std::pair<unsigned, MVT> LT = getTLI()->getTypeLegalizationCost(Src);
|
||||
std::pair<unsigned, MVT> LT = getTLI()->getTypeLegalizationCost(DL, Src);
|
||||
|
||||
// Assuming that all loads of legal types cost 1.
|
||||
unsigned Cost = LT.first;
|
||||
@@ -496,7 +496,7 @@ public:
|
||||
// itself. Unless the corresponding extending load or truncating store is
|
||||
// legal, then this will scalarize.
|
||||
TargetLowering::LegalizeAction LA = TargetLowering::Expand;
|
||||
EVT MemVT = getTLI()->getValueType(Src, true);
|
||||
EVT MemVT = getTLI()->getValueType(DL, Src, true);
|
||||
if (MemVT.isSimple() && MemVT != MVT::Other) {
|
||||
if (Opcode == Instruction::Store)
|
||||
LA = getTLI()->getTruncStoreAction(LT.second, MemVT.getSimpleVT());
|
||||
@@ -692,7 +692,7 @@ public:
|
||||
}
|
||||
|
||||
const TargetLoweringBase *TLI = getTLI();
|
||||
std::pair<unsigned, MVT> LT = TLI->getTypeLegalizationCost(RetTy);
|
||||
std::pair<unsigned, MVT> LT = TLI->getTypeLegalizationCost(DL, RetTy);
|
||||
|
||||
if (TLI->isOperationLegalOrPromote(ISD, LT.second)) {
|
||||
// The operation is legal. Assume it costs 1.
|
||||
@@ -763,7 +763,7 @@ public:
|
||||
}
|
||||
|
||||
unsigned getNumberOfParts(Type *Tp) {
|
||||
std::pair<unsigned, MVT> LT = getTLI()->getTypeLegalizationCost(Tp);
|
||||
std::pair<unsigned, MVT> LT = getTLI()->getTypeLegalizationCost(DL, Tp);
|
||||
return LT.first;
|
||||
}
|
||||
|
||||
|
||||
@@ -168,9 +168,9 @@ public:
|
||||
/// Return the pointer type for the given address space, defaults to
|
||||
/// the pointer type from the data layout.
|
||||
/// FIXME: The default needs to be removed once all the code is updated.
|
||||
virtual MVT getPointerTy(uint32_t /*AS*/ = 0) const;
|
||||
unsigned getPointerSizeInBits(uint32_t AS = 0) const;
|
||||
unsigned getPointerTypeSizeInBits(Type *Ty) const;
|
||||
MVT getPointerTy(const DataLayout &DL, uint32_t AS = 0) const {
|
||||
return MVT::getIntegerVT(DL.getPointerSizeInBits(AS));
|
||||
}
|
||||
virtual MVT getScalarShiftAmountTy(EVT LHSTy) const;
|
||||
|
||||
EVT getShiftAmountTy(EVT LHSTy) const;
|
||||
@@ -178,8 +178,8 @@ public:
|
||||
/// Returns the type to be used for the index operand of:
|
||||
/// ISD::INSERT_VECTOR_ELT, ISD::EXTRACT_VECTOR_ELT,
|
||||
/// ISD::INSERT_SUBVECTOR, and ISD::EXTRACT_SUBVECTOR
|
||||
virtual MVT getVectorIdxTy() const {
|
||||
return getPointerTy();
|
||||
virtual MVT getVectorIdxTy(const DataLayout &DL) const {
|
||||
return getPointerTy(DL);
|
||||
}
|
||||
|
||||
/// Return true if the select operation is expensive for this target.
|
||||
@@ -325,7 +325,8 @@ public:
|
||||
}
|
||||
|
||||
/// Return the ValueType of the result of SETCC operations.
|
||||
virtual EVT getSetCCResultType(LLVMContext &Context, EVT VT) const;
|
||||
virtual EVT getSetCCResultType(const DataLayout &DL, LLVMContext &Context,
|
||||
EVT VT) const;
|
||||
|
||||
/// Return the ValueType for comparison libcalls. Comparions libcalls include
|
||||
/// floating point comparion calls, and Ordered/Unordered check calls on
|
||||
@@ -713,17 +714,18 @@ public:
|
||||
/// operations except for the pointer size. If AllowUnknown is true, this
|
||||
/// will return MVT::Other for types with no EVT counterpart (e.g. structs),
|
||||
/// otherwise it will assert.
|
||||
EVT getValueType(Type *Ty, bool AllowUnknown = false) const {
|
||||
EVT getValueType(const DataLayout &DL, Type *Ty,
|
||||
bool AllowUnknown = false) const {
|
||||
// Lower scalar pointers to native pointer types.
|
||||
if (PointerType *PTy = dyn_cast<PointerType>(Ty))
|
||||
return getPointerTy(PTy->getAddressSpace());
|
||||
return getPointerTy(DL, PTy->getAddressSpace());
|
||||
|
||||
if (Ty->isVectorTy()) {
|
||||
VectorType *VTy = cast<VectorType>(Ty);
|
||||
Type *Elm = VTy->getElementType();
|
||||
// Lower vectors of pointers to native pointer types.
|
||||
if (PointerType *PT = dyn_cast<PointerType>(Elm)) {
|
||||
EVT PointerTy(getPointerTy(PT->getAddressSpace()));
|
||||
EVT PointerTy(getPointerTy(DL, PT->getAddressSpace()));
|
||||
Elm = PointerTy.getTypeForEVT(Ty->getContext());
|
||||
}
|
||||
|
||||
@@ -734,8 +736,9 @@ public:
|
||||
}
|
||||
|
||||
/// Return the MVT corresponding to this LLVM type. See getValueType.
|
||||
MVT getSimpleValueType(Type *Ty, bool AllowUnknown = false) const {
|
||||
return getValueType(Ty, AllowUnknown).getSimpleVT();
|
||||
MVT getSimpleValueType(const DataLayout &DL, Type *Ty,
|
||||
bool AllowUnknown = false) const {
|
||||
return getValueType(DL, Ty, AllowUnknown).getSimpleVT();
|
||||
}
|
||||
|
||||
/// Return the desired alignment for ByVal or InAlloca aggregate function
|
||||
@@ -1004,7 +1007,8 @@ public:
|
||||
int InstructionOpcodeToISD(unsigned Opcode) const;
|
||||
|
||||
/// Estimate the cost of type-legalization and the legalized type.
|
||||
std::pair<unsigned, MVT> getTypeLegalizationCost(Type *Ty) const;
|
||||
std::pair<unsigned, MVT> getTypeLegalizationCost(const DataLayout &DL,
|
||||
Type *Ty) const;
|
||||
|
||||
/// @}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user