mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-22 18:54:02 +01:00
Move DataLayout back to the TargetMachine from TargetSubtargetInfo
derived classes. Since global data alignment, layout, and mangling is often based on the DataLayout, move it to the TargetMachine. This ensures that global data is going to be layed out and mangled consistently if the subtarget changes on a per function basis. Prior to this all targets(*) have had subtarget dependent code moved out and onto the TargetMachine. *One target hasn't been migrated as part of this change: R600. The R600 port has, as a subtarget feature, the size of pointers and this affects global data layout. I've currently hacked in a FIXME to enable progress, but the port needs to be updated to either pass the 64-bitness to the TargetMachine, or fix the DataLayout to avoid subtarget dependent features. llvm-svn: 227113
This commit is contained in:
parent
fe255a8e29
commit
aacfef65cf
@ -117,6 +117,12 @@ public:
|
||||
return *static_cast<const STC*>(getSubtargetImpl());
|
||||
}
|
||||
|
||||
/// getDataLayout - This method returns a pointer to the DataLayout for
|
||||
/// the target. It should be unchanging for every subtarget.
|
||||
virtual const DataLayout *getDataLayout() const {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
/// \brief Reset the target options based on the function's attributes.
|
||||
// FIXME: Remove TargetOptions that affect per-function code generation
|
||||
// from TargetMachine.
|
||||
|
@ -71,7 +71,6 @@ public:
|
||||
virtual const TargetSelectionDAGInfo *getSelectionDAGInfo() const {
|
||||
return nullptr;
|
||||
}
|
||||
virtual const DataLayout *getDataLayout() const { return nullptr; }
|
||||
|
||||
/// getRegisterInfo - If register information is available, return it. If
|
||||
/// not, return null. This is kept separate from RegInfo until RegInfo has
|
||||
|
@ -134,7 +134,7 @@ const TargetLoweringObjectFile &AsmPrinter::getObjFileLowering() const {
|
||||
|
||||
/// getDataLayout - Return information about data layout.
|
||||
const DataLayout &AsmPrinter::getDataLayout() const {
|
||||
return *TM.getSubtargetImpl()->getDataLayout();
|
||||
return *TM.getDataLayout();
|
||||
}
|
||||
|
||||
const MCSubtargetInfo &AsmPrinter::getSubtargetInfo() const {
|
||||
@ -175,7 +175,7 @@ bool AsmPrinter::doInitialization(Module &M) {
|
||||
|
||||
OutStreamer.InitSections(false);
|
||||
|
||||
Mang = new Mangler(TM.getSubtargetImpl()->getDataLayout());
|
||||
Mang = new Mangler(TM.getDataLayout());
|
||||
|
||||
// Emit the version-min deplyment target directive if needed.
|
||||
//
|
||||
@ -359,7 +359,7 @@ void AsmPrinter::EmitGlobalVariable(const GlobalVariable *GV) {
|
||||
|
||||
SectionKind GVKind = TargetLoweringObjectFile::getKindForGlobal(GV, TM);
|
||||
|
||||
const DataLayout *DL = TM.getSubtargetImpl()->getDataLayout();
|
||||
const DataLayout *DL = TM.getDataLayout();
|
||||
uint64_t Size = DL->getTypeAllocSize(GV->getType()->getElementType());
|
||||
|
||||
// If the alignment is specified, we *must* obey it. Overaligning a global
|
||||
@ -1035,8 +1035,7 @@ bool AsmPrinter::doFinalization(Module &M) {
|
||||
OutContext.GetOrCreateSymbol(StringRef("__morestack_addr"));
|
||||
OutStreamer.EmitLabel(AddrSymbol);
|
||||
|
||||
const DataLayout &DL = *TM.getSubtargetImpl()->getDataLayout();
|
||||
unsigned PtrSize = DL.getPointerSize(0);
|
||||
unsigned PtrSize = TM.getDataLayout()->getPointerSize(0);
|
||||
OutStreamer.EmitSymbolValue(GetExternalSymbolSymbol("__morestack"),
|
||||
PtrSize);
|
||||
}
|
||||
@ -1099,7 +1098,7 @@ void AsmPrinter::EmitConstantPool() {
|
||||
unsigned Align = CPE.getAlignment();
|
||||
|
||||
SectionKind Kind =
|
||||
CPE.getSectionKind(TM.getSubtargetImpl()->getDataLayout());
|
||||
CPE.getSectionKind(TM.getDataLayout());
|
||||
|
||||
const Constant *C = nullptr;
|
||||
if (!CPE.isMachineConstantPoolEntry())
|
||||
@ -1153,7 +1152,7 @@ void AsmPrinter::EmitConstantPool() {
|
||||
|
||||
Type *Ty = CPE.getType();
|
||||
Offset = NewOffset +
|
||||
TM.getSubtargetImpl()->getDataLayout()->getTypeAllocSize(Ty);
|
||||
TM.getDataLayout()->getTypeAllocSize(Ty);
|
||||
|
||||
OutStreamer.EmitLabel(Sym);
|
||||
if (CPE.isMachineConstantPoolEntry())
|
||||
@ -1168,7 +1167,7 @@ void AsmPrinter::EmitConstantPool() {
|
||||
/// by the current function to the current output stream.
|
||||
///
|
||||
void AsmPrinter::EmitJumpTableInfo() {
|
||||
const DataLayout *DL = MF->getSubtarget().getDataLayout();
|
||||
const DataLayout *DL = MF->getTarget().getDataLayout();
|
||||
const MachineJumpTableInfo *MJTI = MF->getJumpTableInfo();
|
||||
if (!MJTI) return;
|
||||
if (MJTI->getEntryKind() == MachineJumpTableInfo::EK_Inline) return;
|
||||
@ -1200,7 +1199,7 @@ void AsmPrinter::EmitJumpTableInfo() {
|
||||
}
|
||||
|
||||
EmitAlignment(Log2_32(
|
||||
MJTI->getEntryAlignment(*TM.getSubtargetImpl()->getDataLayout())));
|
||||
MJTI->getEntryAlignment(*TM.getDataLayout())));
|
||||
|
||||
// Jump tables in code sections are marked with a data_region directive
|
||||
// where that's supported.
|
||||
@ -1313,7 +1312,7 @@ void AsmPrinter::EmitJumpTableEntry(const MachineJumpTableInfo *MJTI,
|
||||
assert(Value && "Unknown entry kind!");
|
||||
|
||||
unsigned EntrySize =
|
||||
MJTI->getEntrySize(*TM.getSubtargetImpl()->getDataLayout());
|
||||
MJTI->getEntrySize(*TM.getDataLayout());
|
||||
OutStreamer.EmitValue(Value, EntrySize);
|
||||
}
|
||||
|
||||
@ -1423,7 +1422,7 @@ void AsmPrinter::EmitXXStructorList(const Constant *List, bool isCtor) {
|
||||
}
|
||||
|
||||
// Emit the function pointers in the target-specific order
|
||||
const DataLayout *DL = TM.getSubtargetImpl()->getDataLayout();
|
||||
const DataLayout *DL = TM.getDataLayout();
|
||||
unsigned Align = Log2_32(DL->getPointerPrefAlignment());
|
||||
std::stable_sort(Structors.begin(), Structors.end(),
|
||||
[](const Structor &L,
|
||||
@ -1538,7 +1537,7 @@ void AsmPrinter::EmitLabelPlusOffset(const MCSymbol *Label, uint64_t Offset,
|
||||
//
|
||||
void AsmPrinter::EmitAlignment(unsigned NumBits, const GlobalObject *GV) const {
|
||||
if (GV)
|
||||
NumBits = getGVAlignmentLog2(GV, *TM.getSubtargetImpl()->getDataLayout(),
|
||||
NumBits = getGVAlignmentLog2(GV, *TM.getDataLayout(),
|
||||
NumBits);
|
||||
|
||||
if (NumBits == 0) return; // 1-byte aligned: no need to emit alignment.
|
||||
@ -1586,7 +1585,7 @@ const MCExpr *AsmPrinter::lowerConstant(const Constant *CV) {
|
||||
// opportunities. Attempt to fold the expression using DataLayout as a
|
||||
// last resort before giving up.
|
||||
if (Constant *C = ConstantFoldConstantExpression(
|
||||
CE, TM.getSubtargetImpl()->getDataLayout()))
|
||||
CE, TM.getDataLayout()))
|
||||
if (C != CE)
|
||||
return lowerConstant(C);
|
||||
|
||||
@ -1600,7 +1599,8 @@ const MCExpr *AsmPrinter::lowerConstant(const Constant *CV) {
|
||||
report_fatal_error(OS.str());
|
||||
}
|
||||
case Instruction::GetElementPtr: {
|
||||
const DataLayout &DL = *TM.getSubtargetImpl()->getDataLayout();
|
||||
const DataLayout &DL = *TM.getDataLayout();
|
||||
|
||||
// Generate a symbolic expression for the byte address
|
||||
APInt OffsetAI(DL.getPointerTypeSizeInBits(CE->getType()), 0);
|
||||
cast<GEPOperator>(CE)->accumulateConstantOffset(DL, OffsetAI);
|
||||
@ -1624,7 +1624,8 @@ const MCExpr *AsmPrinter::lowerConstant(const Constant *CV) {
|
||||
return lowerConstant(CE->getOperand(0));
|
||||
|
||||
case Instruction::IntToPtr: {
|
||||
const DataLayout &DL = *TM.getSubtargetImpl()->getDataLayout();
|
||||
const DataLayout &DL = *TM.getDataLayout();
|
||||
|
||||
// Handle casts to pointers by changing them into casts to the appropriate
|
||||
// integer type. This promotes constant folding and simplifies this code.
|
||||
Constant *Op = CE->getOperand(0);
|
||||
@ -1634,7 +1635,8 @@ const MCExpr *AsmPrinter::lowerConstant(const Constant *CV) {
|
||||
}
|
||||
|
||||
case Instruction::PtrToInt: {
|
||||
const DataLayout &DL = *TM.getSubtargetImpl()->getDataLayout();
|
||||
const DataLayout &DL = *TM.getDataLayout();
|
||||
|
||||
// Support only foldable casts to/from pointers that can be eliminated by
|
||||
// changing the pointer to the appropriately sized integer type.
|
||||
Constant *Op = CE->getOperand(0);
|
||||
@ -1708,7 +1710,7 @@ static int isRepeatedByteSequence(const Value *V, TargetMachine &TM) {
|
||||
if (CI->getBitWidth() > 64) return -1;
|
||||
|
||||
uint64_t Size =
|
||||
TM.getSubtargetImpl()->getDataLayout()->getTypeAllocSize(V->getType());
|
||||
TM.getDataLayout()->getTypeAllocSize(V->getType());
|
||||
uint64_t Value = CI->getZExtValue();
|
||||
|
||||
// Make sure the constant is at least 8 bits long and has a power
|
||||
@ -1753,7 +1755,7 @@ static void emitGlobalConstantDataSequential(const ConstantDataSequential *CDS,
|
||||
int Value = isRepeatedByteSequence(CDS, AP.TM);
|
||||
if (Value != -1) {
|
||||
uint64_t Bytes =
|
||||
AP.TM.getSubtargetImpl()->getDataLayout()->getTypeAllocSize(
|
||||
AP.TM.getDataLayout()->getTypeAllocSize(
|
||||
CDS->getType());
|
||||
// Don't emit a 1-byte object as a .fill.
|
||||
if (Bytes > 1)
|
||||
@ -1804,7 +1806,7 @@ static void emitGlobalConstantDataSequential(const ConstantDataSequential *CDS,
|
||||
}
|
||||
}
|
||||
|
||||
const DataLayout &DL = *AP.TM.getSubtargetImpl()->getDataLayout();
|
||||
const DataLayout &DL = *AP.TM.getDataLayout();
|
||||
unsigned Size = DL.getTypeAllocSize(CDS->getType());
|
||||
unsigned EmittedSize = DL.getTypeAllocSize(CDS->getType()->getElementType()) *
|
||||
CDS->getNumElements();
|
||||
@ -1820,7 +1822,7 @@ static void emitGlobalConstantArray(const ConstantArray *CA, AsmPrinter &AP) {
|
||||
|
||||
if (Value != -1) {
|
||||
uint64_t Bytes =
|
||||
AP.TM.getSubtargetImpl()->getDataLayout()->getTypeAllocSize(
|
||||
AP.TM.getDataLayout()->getTypeAllocSize(
|
||||
CA->getType());
|
||||
AP.OutStreamer.EmitFill(Bytes, Value);
|
||||
}
|
||||
@ -1834,7 +1836,7 @@ static void emitGlobalConstantVector(const ConstantVector *CV, AsmPrinter &AP) {
|
||||
for (unsigned i = 0, e = CV->getType()->getNumElements(); i != e; ++i)
|
||||
emitGlobalConstantImpl(CV->getOperand(i), AP);
|
||||
|
||||
const DataLayout &DL = *AP.TM.getSubtargetImpl()->getDataLayout();
|
||||
const DataLayout &DL = *AP.TM.getDataLayout();
|
||||
unsigned Size = DL.getTypeAllocSize(CV->getType());
|
||||
unsigned EmittedSize = DL.getTypeAllocSize(CV->getType()->getElementType()) *
|
||||
CV->getType()->getNumElements();
|
||||
@ -1844,7 +1846,7 @@ static void emitGlobalConstantVector(const ConstantVector *CV, AsmPrinter &AP) {
|
||||
|
||||
static void emitGlobalConstantStruct(const ConstantStruct *CS, AsmPrinter &AP) {
|
||||
// Print the fields in successive locations. Pad to align if needed!
|
||||
const DataLayout *DL = AP.TM.getSubtargetImpl()->getDataLayout();
|
||||
const DataLayout *DL = AP.TM.getDataLayout();
|
||||
unsigned Size = DL->getTypeAllocSize(CS->getType());
|
||||
const StructLayout *Layout = DL->getStructLayout(CS->getType());
|
||||
uint64_t SizeSoFar = 0;
|
||||
@ -1894,7 +1896,7 @@ static void emitGlobalConstantFP(const ConstantFP *CFP, AsmPrinter &AP) {
|
||||
|
||||
// PPC's long double has odd notions of endianness compared to how LLVM
|
||||
// handles it: p[0] goes first for *big* endian on PPC.
|
||||
if (AP.TM.getSubtargetImpl()->getDataLayout()->isBigEndian() &&
|
||||
if (AP.TM.getDataLayout()->isBigEndian() &&
|
||||
!CFP->getType()->isPPC_FP128Ty()) {
|
||||
int Chunk = API.getNumWords() - 1;
|
||||
|
||||
@ -1913,13 +1915,13 @@ static void emitGlobalConstantFP(const ConstantFP *CFP, AsmPrinter &AP) {
|
||||
}
|
||||
|
||||
// Emit the tail padding for the long double.
|
||||
const DataLayout &DL = *AP.TM.getSubtargetImpl()->getDataLayout();
|
||||
const DataLayout &DL = *AP.TM.getDataLayout();
|
||||
AP.OutStreamer.EmitZeros(DL.getTypeAllocSize(CFP->getType()) -
|
||||
DL.getTypeStoreSize(CFP->getType()));
|
||||
}
|
||||
|
||||
static void emitGlobalConstantLargeInt(const ConstantInt *CI, AsmPrinter &AP) {
|
||||
const DataLayout *DL = AP.TM.getSubtargetImpl()->getDataLayout();
|
||||
const DataLayout *DL = AP.TM.getDataLayout();
|
||||
unsigned BitWidth = CI->getBitWidth();
|
||||
|
||||
// Copy the value as we may massage the layout for constants whose bit width
|
||||
@ -1965,7 +1967,7 @@ static void emitGlobalConstantLargeInt(const ConstantInt *CI, AsmPrinter &AP) {
|
||||
// Emit the extra bits after the 64-bits chunks.
|
||||
|
||||
// Emit a directive that fills the expected size.
|
||||
uint64_t Size = AP.TM.getSubtargetImpl()->getDataLayout()->getTypeAllocSize(
|
||||
uint64_t Size = AP.TM.getDataLayout()->getTypeAllocSize(
|
||||
CI->getType());
|
||||
Size -= (BitWidth / 64) * 8;
|
||||
assert(Size && Size * 8 >= ExtraBitsSize &&
|
||||
@ -1976,7 +1978,7 @@ static void emitGlobalConstantLargeInt(const ConstantInt *CI, AsmPrinter &AP) {
|
||||
}
|
||||
|
||||
static void emitGlobalConstantImpl(const Constant *CV, AsmPrinter &AP) {
|
||||
const DataLayout *DL = AP.TM.getSubtargetImpl()->getDataLayout();
|
||||
const DataLayout *DL = AP.TM.getDataLayout();
|
||||
uint64_t Size = DL->getTypeAllocSize(CV->getType());
|
||||
if (isa<ConstantAggregateZero>(CV) || isa<UndefValue>(CV))
|
||||
return AP.OutStreamer.EmitZeros(Size);
|
||||
@ -2042,7 +2044,7 @@ static void emitGlobalConstantImpl(const Constant *CV, AsmPrinter &AP) {
|
||||
/// EmitGlobalConstant - Print a general LLVM constant to the .s file.
|
||||
void AsmPrinter::EmitGlobalConstant(const Constant *CV) {
|
||||
uint64_t Size =
|
||||
TM.getSubtargetImpl()->getDataLayout()->getTypeAllocSize(CV->getType());
|
||||
TM.getDataLayout()->getTypeAllocSize(CV->getType());
|
||||
if (Size)
|
||||
emitGlobalConstantImpl(CV, *this);
|
||||
else if (MAI->hasSubsectionsViaSymbols()) {
|
||||
@ -2071,7 +2073,7 @@ void AsmPrinter::printOffset(int64_t Offset, raw_ostream &OS) const {
|
||||
/// GetTempSymbol - Return the MCSymbol corresponding to the assembler
|
||||
/// temporary label with the specified stem and unique ID.
|
||||
MCSymbol *AsmPrinter::GetTempSymbol(Twine Name, unsigned ID) const {
|
||||
const DataLayout *DL = TM.getSubtargetImpl()->getDataLayout();
|
||||
const DataLayout *DL = TM.getDataLayout();
|
||||
return OutContext.GetOrCreateSymbol(Twine(DL->getPrivateGlobalPrefix()) +
|
||||
Name + Twine(ID));
|
||||
}
|
||||
@ -2079,7 +2081,7 @@ MCSymbol *AsmPrinter::GetTempSymbol(Twine Name, unsigned ID) const {
|
||||
/// GetTempSymbol - Return an assembler temporary label with the specified
|
||||
/// stem.
|
||||
MCSymbol *AsmPrinter::GetTempSymbol(Twine Name) const {
|
||||
const DataLayout *DL = TM.getSubtargetImpl()->getDataLayout();
|
||||
const DataLayout *DL = TM.getDataLayout();
|
||||
return OutContext.GetOrCreateSymbol(Twine(DL->getPrivateGlobalPrefix())+
|
||||
Name);
|
||||
}
|
||||
@ -2095,7 +2097,7 @@ MCSymbol *AsmPrinter::GetBlockAddressSymbol(const BasicBlock *BB) const {
|
||||
|
||||
/// GetCPISymbol - Return the symbol for the specified constant pool entry.
|
||||
MCSymbol *AsmPrinter::GetCPISymbol(unsigned CPID) const {
|
||||
const DataLayout *DL = TM.getSubtargetImpl()->getDataLayout();
|
||||
const DataLayout *DL = TM.getDataLayout();
|
||||
return OutContext.GetOrCreateSymbol
|
||||
(Twine(DL->getPrivateGlobalPrefix()) + "CPI" + Twine(getFunctionNumber())
|
||||
+ "_" + Twine(CPID));
|
||||
@ -2109,7 +2111,7 @@ MCSymbol *AsmPrinter::GetJTISymbol(unsigned JTID, bool isLinkerPrivate) const {
|
||||
/// GetJTSetSymbol - Return the symbol for the specified jump table .set
|
||||
/// FIXME: privatize to AsmPrinter.
|
||||
MCSymbol *AsmPrinter::GetJTSetSymbol(unsigned UID, unsigned MBBID) const {
|
||||
const DataLayout *DL = TM.getSubtargetImpl()->getDataLayout();
|
||||
const DataLayout *DL = TM.getDataLayout();
|
||||
return OutContext.GetOrCreateSymbol
|
||||
(Twine(DL->getPrivateGlobalPrefix()) + Twine(getFunctionNumber()) + "_" +
|
||||
Twine(UID) + "_set_" + Twine(MBBID));
|
||||
|
@ -150,7 +150,7 @@ unsigned AsmPrinter::GetSizeOfEncodedValue(unsigned Encoding) const {
|
||||
default:
|
||||
llvm_unreachable("Invalid encoded value.");
|
||||
case dwarf::DW_EH_PE_absptr:
|
||||
return TM.getSubtargetImpl()->getDataLayout()->getPointerSize();
|
||||
return TM.getDataLayout()->getPointerSize();
|
||||
case dwarf::DW_EH_PE_udata2:
|
||||
return 2;
|
||||
case dwarf::DW_EH_PE_udata4:
|
||||
|
@ -508,7 +508,7 @@ void AsmPrinter::EmitInlineAsm(const MachineInstr *MI) const {
|
||||
/// for their own strange codes.
|
||||
void AsmPrinter::PrintSpecial(const MachineInstr *MI, raw_ostream &OS,
|
||||
const char *Code) const {
|
||||
const DataLayout *DL = TM.getSubtargetImpl()->getDataLayout();
|
||||
const DataLayout *DL = TM.getDataLayout();
|
||||
if (!strcmp(Code, "private")) {
|
||||
OS << DL->getPrivateGlobalPrefix();
|
||||
} else if (!strcmp(Code, "comment")) {
|
||||
|
@ -48,8 +48,7 @@ void llvm::linkErlangGCPrinter() {}
|
||||
void ErlangGCPrinter::finishAssembly(Module &M, GCModuleInfo &Info,
|
||||
AsmPrinter &AP) {
|
||||
MCStreamer &OS = AP.OutStreamer;
|
||||
unsigned IntPtrSize =
|
||||
AP.TM.getSubtargetImpl()->getDataLayout()->getPointerSize();
|
||||
unsigned IntPtrSize = AP.TM.getDataLayout()->getPointerSize();
|
||||
|
||||
// Put this in a custom .note section.
|
||||
AP.OutStreamer.SwitchSection(
|
||||
|
@ -93,8 +93,7 @@ void OcamlGCMetadataPrinter::beginAssembly(Module &M, GCModuleInfo &Info,
|
||||
///
|
||||
void OcamlGCMetadataPrinter::finishAssembly(Module &M, GCModuleInfo &Info,
|
||||
AsmPrinter &AP) {
|
||||
unsigned IntPtrSize =
|
||||
AP.TM.getSubtargetImpl()->getDataLayout()->getPointerSize();
|
||||
unsigned IntPtrSize = AP.TM.getDataLayout()->getPointerSize();
|
||||
|
||||
AP.OutStreamer.SwitchSection(AP.getObjFileLowering().getTextSection());
|
||||
EmitCamlGlobal(M, AP, "code_end");
|
||||
|
@ -462,7 +462,7 @@ unsigned MachineFunction::addLiveIn(unsigned PReg,
|
||||
/// normal 'L' label is returned.
|
||||
MCSymbol *MachineFunction::getJTISymbol(unsigned JTI, MCContext &Ctx,
|
||||
bool isLinkerPrivate) const {
|
||||
const DataLayout *DL = getSubtarget().getDataLayout();
|
||||
const DataLayout *DL = getTarget().getDataLayout();
|
||||
assert(JumpTableInfo && "No jump tables");
|
||||
assert(JTI < JumpTableInfo->getJumpTables().size() && "Invalid JTI!");
|
||||
|
||||
@ -477,7 +477,7 @@ MCSymbol *MachineFunction::getJTISymbol(unsigned JTI, MCContext &Ctx,
|
||||
/// getPICBaseSymbol - Return a function-local symbol to represent the PIC
|
||||
/// base.
|
||||
MCSymbol *MachineFunction::getPICBaseSymbol() const {
|
||||
const DataLayout *DL = getSubtarget().getDataLayout();
|
||||
const DataLayout *DL = getTarget().getDataLayout();
|
||||
return Ctx.GetOrCreateSymbol(Twine(DL->getPrivateGlobalPrefix())+
|
||||
Twine(getFunctionNumber())+"$pb");
|
||||
}
|
||||
@ -821,7 +821,7 @@ void MachineJumpTableInfo::dump() const { print(dbgs()); }
|
||||
void MachineConstantPoolValue::anchor() { }
|
||||
|
||||
const DataLayout *MachineConstantPool::getDataLayout() const {
|
||||
return TM.getSubtargetImpl()->getDataLayout();
|
||||
return TM.getDataLayout();
|
||||
}
|
||||
|
||||
Type *MachineConstantPoolEntry::getType() const {
|
||||
|
@ -1580,7 +1580,7 @@ FastISel::FastISel(FunctionLoweringInfo &FuncInfo,
|
||||
bool SkipTargetIndependentISel)
|
||||
: FuncInfo(FuncInfo), MF(FuncInfo.MF), MRI(FuncInfo.MF->getRegInfo()),
|
||||
MFI(*FuncInfo.MF->getFrameInfo()), MCP(*FuncInfo.MF->getConstantPool()),
|
||||
TM(FuncInfo.MF->getTarget()), DL(*MF->getSubtarget().getDataLayout()),
|
||||
TM(FuncInfo.MF->getTarget()), DL(*TM.getDataLayout()),
|
||||
TII(*MF->getSubtarget().getInstrInfo()),
|
||||
TLI(*MF->getSubtarget().getTargetLowering()),
|
||||
TRI(*MF->getSubtarget().getRegisterInfo()), LibInfo(LibInfo),
|
||||
|
@ -406,10 +406,10 @@ void InstrEmitter::AddOperand(MachineInstrBuilder &MIB,
|
||||
Type *Type = CP->getType();
|
||||
// MachineConstantPool wants an explicit alignment.
|
||||
if (Align == 0) {
|
||||
Align = MF->getSubtarget().getDataLayout()->getPrefTypeAlignment(Type);
|
||||
Align = MF->getTarget().getDataLayout()->getPrefTypeAlignment(Type);
|
||||
if (Align == 0) {
|
||||
// Alignment of vector types. FIXME!
|
||||
Align = MF->getSubtarget().getDataLayout()->getTypeAllocSize(Type);
|
||||
Align = MF->getTarget().getDataLayout()->getTypeAllocSize(Type);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -869,7 +869,7 @@ void SelectionDAGBuilder::init(GCFunctionInfo *gfi, AliasAnalysis &aa,
|
||||
AA = &aa;
|
||||
GFI = gfi;
|
||||
LibInfo = li;
|
||||
DL = DAG.getSubtarget().getDataLayout();
|
||||
DL = DAG.getTarget().getDataLayout();
|
||||
Context = DAG.getContext();
|
||||
LPadToCallSiteMap.clear();
|
||||
}
|
||||
|
@ -84,8 +84,7 @@ StackMaps::parseOperand(MachineInstr::const_mop_iterator MOI,
|
||||
switch (MOI->getImm()) {
|
||||
default: llvm_unreachable("Unrecognized operand type.");
|
||||
case StackMaps::DirectMemRefOp: {
|
||||
unsigned Size =
|
||||
AP.TM.getSubtargetImpl()->getDataLayout()->getPointerSizeInBits();
|
||||
unsigned Size = AP.TM.getDataLayout()->getPointerSizeInBits();
|
||||
assert((Size % 8) == 0 && "Need pointer size in bytes.");
|
||||
Size /= 8;
|
||||
unsigned Reg = (++MOI)->getReg();
|
||||
|
@ -308,7 +308,7 @@ bool TargetInstrInfo::getStackSlotRange(const TargetRegisterClass *RC,
|
||||
|
||||
assert(RC->getSize() >= (Offset + Size) && "bad subregister range");
|
||||
|
||||
if (!TM->getSubtargetImpl()->getDataLayout()->isLittleEndian()) {
|
||||
if (!TM->getDataLayout()->isLittleEndian()) {
|
||||
Offset = RC->getSize() - (Offset + Size);
|
||||
}
|
||||
return true;
|
||||
|
@ -696,7 +696,7 @@ static void InitCmpLibcallCCs(ISD::CondCode *CCs) {
|
||||
|
||||
/// NOTE: The TargetMachine owns TLOF.
|
||||
TargetLoweringBase::TargetLoweringBase(const TargetMachine &tm)
|
||||
: TM(tm), DL(TM.getSubtargetImpl()->getDataLayout()) {
|
||||
: TM(tm), DL(TM.getDataLayout()) {
|
||||
initActions();
|
||||
|
||||
// Perform these initializations only once.
|
||||
@ -997,8 +997,7 @@ TargetLoweringBase::emitPatchPoint(MachineInstr *MI,
|
||||
}
|
||||
MachineMemOperand *MMO = MF.getMachineMemOperand(
|
||||
MachinePointerInfo::getFixedStack(FI), Flags,
|
||||
TM.getSubtargetImpl()->getDataLayout()->getPointerSize(),
|
||||
MFI.getObjectAlignment(FI));
|
||||
TM.getDataLayout()->getPointerSize(), MFI.getObjectAlignment(FI));
|
||||
MIB->addMemOperand(MF, MMO);
|
||||
|
||||
// Replace the instruction and update the operand index.
|
||||
|
@ -73,10 +73,9 @@ void TargetLoweringObjectFileELF::emitPersonalityValue(MCStreamer &Streamer,
|
||||
Flags,
|
||||
SectionKind::getDataRel(),
|
||||
0, Label->getName());
|
||||
unsigned Size = TM.getSubtargetImpl()->getDataLayout()->getPointerSize();
|
||||
unsigned Size = TM.getDataLayout()->getPointerSize();
|
||||
Streamer.SwitchSection(Sec);
|
||||
Streamer.EmitValueToAlignment(
|
||||
TM.getSubtargetImpl()->getDataLayout()->getPointerABIAlignment());
|
||||
Streamer.EmitValueToAlignment(TM.getDataLayout()->getPointerABIAlignment());
|
||||
Streamer.EmitSymbolAttribute(Label, MCSA_ELF_TypeObject);
|
||||
const MCExpr *E = MCConstantExpr::Create(Size, getContext());
|
||||
Streamer.EmitELFSize(Label, E);
|
||||
@ -285,8 +284,7 @@ SelectSectionForGlobal(const GlobalValue *GV, SectionKind Kind,
|
||||
// FIXME: this is getting the alignment of the character, not the
|
||||
// alignment of the global!
|
||||
unsigned Align =
|
||||
TM.getSubtargetImpl()->getDataLayout()->getPreferredAlignment(
|
||||
cast<GlobalVariable>(GV));
|
||||
TM.getDataLayout()->getPreferredAlignment(cast<GlobalVariable>(GV));
|
||||
|
||||
const char *SizeSpec = ".rodata.str1.";
|
||||
if (Kind.isMergeable2ByteCString())
|
||||
@ -591,16 +589,14 @@ SelectSectionForGlobal(const GlobalValue *GV, SectionKind Kind,
|
||||
|
||||
// FIXME: Alignment check should be handled by section classifier.
|
||||
if (Kind.isMergeable1ByteCString() &&
|
||||
TM.getSubtargetImpl()->getDataLayout()->getPreferredAlignment(
|
||||
cast<GlobalVariable>(GV)) < 32)
|
||||
TM.getDataLayout()->getPreferredAlignment(cast<GlobalVariable>(GV)) < 32)
|
||||
return CStringSection;
|
||||
|
||||
// Do not put 16-bit arrays in the UString section if they have an
|
||||
// externally visible label, this runs into issues with certain linker
|
||||
// versions.
|
||||
if (Kind.isMergeable2ByteCString() && !GV->hasExternalLinkage() &&
|
||||
TM.getSubtargetImpl()->getDataLayout()->getPreferredAlignment(
|
||||
cast<GlobalVariable>(GV)) < 32)
|
||||
TM.getDataLayout()->getPreferredAlignment(cast<GlobalVariable>(GV)) < 32)
|
||||
return UStringSection;
|
||||
|
||||
// With MachO only variables whose corresponding symbol starts with 'l' or
|
||||
|
@ -77,7 +77,7 @@ MCJIT::MCJIT(std::unique_ptr<Module> M, std::unique_ptr<TargetMachine> tm,
|
||||
Modules.clear();
|
||||
|
||||
OwnedModules.addModule(std::move(First));
|
||||
setDataLayout(TM->getSubtargetImpl()->getDataLayout());
|
||||
setDataLayout(TM->getDataLayout());
|
||||
RegisterJITEventListener(JITEventListener::createGDBRegistrationListener());
|
||||
}
|
||||
|
||||
@ -139,7 +139,7 @@ std::unique_ptr<MemoryBuffer> MCJIT::emitObject(Module *M) {
|
||||
|
||||
PassManager PM;
|
||||
|
||||
M->setDataLayout(TM->getSubtargetImpl()->getDataLayout());
|
||||
M->setDataLayout(TM->getDataLayout());
|
||||
PM.add(new DataLayoutPass());
|
||||
|
||||
// The RuntimeDyld will take ownership of this shortly
|
||||
@ -257,7 +257,7 @@ void MCJIT::finalizeModule(Module *M) {
|
||||
}
|
||||
|
||||
uint64_t MCJIT::getExistingSymbolAddress(const std::string &Name) {
|
||||
Mangler Mang(TM->getSubtargetImpl()->getDataLayout());
|
||||
Mangler Mang(TM->getDataLayout());
|
||||
SmallString<128> FullName;
|
||||
Mang.getNameWithPrefix(FullName, Name);
|
||||
return Dyld.getSymbolLoadAddress(FullName);
|
||||
@ -357,7 +357,7 @@ uint64_t MCJIT::getFunctionAddress(const std::string &Name) {
|
||||
void *MCJIT::getPointerToFunction(Function *F) {
|
||||
MutexGuard locked(lock);
|
||||
|
||||
Mangler Mang(TM->getSubtargetImpl()->getDataLayout());
|
||||
Mangler Mang(TM->getDataLayout());
|
||||
SmallString<128> Name;
|
||||
TM->getNameWithPrefix(Name, F, Mang);
|
||||
|
||||
|
@ -119,14 +119,13 @@ public:
|
||||
|
||||
OrcMCJITReplacement(std::unique_ptr<RTDyldMemoryManager> MM,
|
||||
std::unique_ptr<TargetMachine> TM)
|
||||
: TM(std::move(TM)), MM(std::move(MM)),
|
||||
Mang(this->TM->getSubtargetImpl()->getDataLayout()),
|
||||
: TM(std::move(TM)), MM(std::move(MM)), Mang(this->TM->getDataLayout()),
|
||||
NotifyObjectLoaded(*this), NotifyFinalized(*this),
|
||||
ObjectLayer(ObjectLayerT::CreateRTDyldMMFtor(), NotifyObjectLoaded,
|
||||
NotifyFinalized),
|
||||
CompileLayer(ObjectLayer, SimpleCompiler(*this->TM)),
|
||||
LazyEmitLayer(CompileLayer) {
|
||||
setDataLayout(this->TM->getSubtargetImpl()->getDataLayout());
|
||||
setDataLayout(this->TM->getDataLayout());
|
||||
}
|
||||
|
||||
void addModule(std::unique_ptr<Module> M) override {
|
||||
|
@ -406,7 +406,7 @@ void LTOCodeGenerator::applyScopeRestrictions() {
|
||||
passes.add(createDebugInfoVerifierPass());
|
||||
|
||||
// mark which symbols can not be internalized
|
||||
Mangler Mangler(TargetMach->getSubtargetImpl()->getDataLayout());
|
||||
Mangler Mangler(TargetMach->getDataLayout());
|
||||
std::vector<const char*> MustPreserveList;
|
||||
SmallPtrSet<GlobalValue*, 8> AsmUsed;
|
||||
std::vector<StringRef> Libcalls;
|
||||
@ -476,7 +476,7 @@ bool LTOCodeGenerator::generateObjectFile(raw_ostream &out,
|
||||
PassManager passes;
|
||||
|
||||
// Add an appropriate DataLayout instance for this module...
|
||||
mergedModule->setDataLayout(TargetMach->getSubtargetImpl()->getDataLayout());
|
||||
mergedModule->setDataLayout(TargetMach->getDataLayout());
|
||||
|
||||
Triple TargetTriple(TargetMach->getTargetTriple());
|
||||
PassManagerBuilder PMB;
|
||||
|
@ -229,7 +229,7 @@ LTOModule *LTOModule::makeLTOModule(MemoryBufferRef Buffer,
|
||||
|
||||
TargetMachine *target = march->createTargetMachine(TripleStr, CPU, FeatureStr,
|
||||
options);
|
||||
M->setDataLayout(target->getSubtargetImpl()->getDataLayout());
|
||||
M->setDataLayout(target->getDataLayout());
|
||||
|
||||
std::unique_ptr<object::IRObjectFile> IRObj(
|
||||
new object::IRObjectFile(Buffer, std::move(M)));
|
||||
|
@ -145,7 +145,7 @@ void AArch64AsmPrinter::EmitEndOfAsmFile(Module &M) {
|
||||
MachineModuleInfoELF::SymbolListTy Stubs = MMIELF.GetGVStubList();
|
||||
if (!Stubs.empty()) {
|
||||
OutStreamer.SwitchSection(TLOFELF.getDataRelSection());
|
||||
const DataLayout *TD = TM.getSubtargetImpl()->getDataLayout();
|
||||
const DataLayout *TD = TM.getDataLayout();
|
||||
|
||||
for (unsigned i = 0, e = Stubs.size(); i != e; ++i) {
|
||||
OutStreamer.EmitLabel(Stubs[i].first);
|
||||
|
@ -46,7 +46,7 @@ static bool finishStackBlock(SmallVectorImpl<CCValAssign> &PendingMembers,
|
||||
CCState &State, unsigned SlotAlign) {
|
||||
unsigned Size = LocVT.getSizeInBits() / 8;
|
||||
unsigned StackAlign = State.getMachineFunction()
|
||||
.getSubtarget()
|
||||
.getTarget()
|
||||
.getDataLayout()
|
||||
->getStackAlignment();
|
||||
unsigned Align = std::min(ArgFlags.getOrigAlign(), StackAlign);
|
||||
|
@ -16,7 +16,7 @@ class CCIfAlign<string Align, CCAction A> :
|
||||
CCIf<!strconcat("ArgFlags.getOrigAlign() == ", Align), A>;
|
||||
/// CCIfBigEndian - Match only if we're in big endian mode.
|
||||
class CCIfBigEndian<CCAction A> :
|
||||
CCIf<"State.getMachineFunction().getSubtarget().getDataLayout()->isBigEndian()", A>;
|
||||
CCIf<"State.getMachineFunction().getTarget().getDataLayout()->isBigEndian()", A>;
|
||||
|
||||
//===----------------------------------------------------------------------===//
|
||||
// ARM AAPCS64 Calling Convention
|
||||
|
@ -167,7 +167,7 @@ void AArch64FrameLowering::emitCalleeSavedFrameMoves(
|
||||
if (CSI.empty())
|
||||
return;
|
||||
|
||||
const DataLayout *TD = MF.getSubtarget().getDataLayout();
|
||||
const DataLayout *TD = MF.getTarget().getDataLayout();
|
||||
bool HasFP = hasFP(MF);
|
||||
|
||||
// Calculate amount of bytes used for return address storing.
|
||||
@ -308,7 +308,7 @@ void AArch64FrameLowering::emitPrologue(MachineFunction &MF) const {
|
||||
TII->copyPhysReg(MBB, MBBI, DL, AArch64::X19, AArch64::SP, false);
|
||||
|
||||
if (needsFrameMoves) {
|
||||
const DataLayout *TD = MF.getSubtarget().getDataLayout();
|
||||
const DataLayout *TD = MF.getTarget().getDataLayout();
|
||||
const int StackGrowth = -TD->getPointerSize(0);
|
||||
unsigned FramePtr = RegInfo->getFrameRegister(MF);
|
||||
|
||||
|
@ -48,17 +48,10 @@ AArch64Subtarget::AArch64Subtarget(const std::string &TT,
|
||||
const TargetMachine &TM, bool LittleEndian)
|
||||
: AArch64GenSubtargetInfo(TT, CPU, FS), ARMProcFamily(Others),
|
||||
HasFPARMv8(false), HasNEON(false), HasCrypto(false), HasCRC(false),
|
||||
HasZeroCycleRegMove(false), HasZeroCycleZeroing(false), CPUString(CPU),
|
||||
TargetTriple(TT),
|
||||
// This nested ternary is horrible, but DL needs to be properly
|
||||
// initialized
|
||||
// before TLInfo is constructed.
|
||||
DL(isTargetMachO()
|
||||
? "e-m:o-i64:64-i128:128-n32:64-S128"
|
||||
: (LittleEndian ? "e-m:e-i64:64-i128:128-n32:64-S128"
|
||||
: "E-m:e-i64:64-i128:128-n32:64-S128")),
|
||||
FrameLowering(), InstrInfo(initializeSubtargetDependencies(FS)),
|
||||
TSInfo(&DL), TLInfo(TM) {}
|
||||
HasZeroCycleRegMove(false), HasZeroCycleZeroing(false),
|
||||
IsLittle(LittleEndian), CPUString(CPU), TargetTriple(TT), FrameLowering(),
|
||||
InstrInfo(initializeSubtargetDependencies(FS)),
|
||||
TSInfo(TM.getDataLayout()), TLInfo(TM) {}
|
||||
|
||||
/// ClassifyGlobalReference - Find the target operand flags that describe
|
||||
/// how a global value should be referenced for the current subtarget.
|
||||
|
@ -48,13 +48,14 @@ protected:
|
||||
// HasZeroCycleZeroing - Has zero-cycle zeroing instructions.
|
||||
bool HasZeroCycleZeroing;
|
||||
|
||||
bool IsLittle;
|
||||
|
||||
/// CPUString - String name of used CPU.
|
||||
std::string CPUString;
|
||||
|
||||
/// TargetTriple - What processor and OS we're targeting.
|
||||
Triple TargetTriple;
|
||||
|
||||
const DataLayout DL;
|
||||
AArch64FrameLowering FrameLowering;
|
||||
AArch64InstrInfo InstrInfo;
|
||||
AArch64SelectionDAGInfo TSInfo;
|
||||
@ -82,7 +83,6 @@ public:
|
||||
return &TLInfo;
|
||||
}
|
||||
const AArch64InstrInfo *getInstrInfo() const override { return &InstrInfo; }
|
||||
const DataLayout *getDataLayout() const override { return &DL; }
|
||||
const AArch64RegisterInfo *getRegisterInfo() const override {
|
||||
return &getInstrInfo()->getRegisterInfo();
|
||||
}
|
||||
@ -100,7 +100,7 @@ public:
|
||||
bool hasCrypto() const { return HasCrypto; }
|
||||
bool hasCRC() const { return HasCRC; }
|
||||
|
||||
bool isLittleEndian() const { return DL.isLittleEndian(); }
|
||||
bool isLittleEndian() const { return IsLittle; }
|
||||
|
||||
bool isTargetDarwin() const { return TargetTriple.isOSDarwin(); }
|
||||
bool isTargetIOS() const { return TargetTriple.isiOS(); }
|
||||
|
@ -112,6 +112,13 @@ AArch64TargetMachine::AArch64TargetMachine(const Target &T, StringRef TT,
|
||||
CodeGenOpt::Level OL,
|
||||
bool LittleEndian)
|
||||
: LLVMTargetMachine(T, TT, CPU, FS, Options, RM, CM, OL),
|
||||
// This nested ternary is horrible, but DL needs to be properly
|
||||
// initialized
|
||||
// before TLInfo is constructed.
|
||||
DL(Triple(TT).isOSBinFormatMachO()
|
||||
? "e-m:o-i64:64-i128:128-n32:64-S128"
|
||||
: (LittleEndian ? "e-m:e-i64:64-i128:128-n32:64-S128"
|
||||
: "E-m:e-i64:64-i128:128-n32:64-S128")),
|
||||
TLOF(createTLOF(Triple(getTargetTriple()))),
|
||||
Subtarget(TT, CPU, FS, *this, LittleEndian), isLittle(LittleEndian) {
|
||||
initAsmInfo();
|
||||
|
@ -23,6 +23,7 @@ namespace llvm {
|
||||
|
||||
class AArch64TargetMachine : public LLVMTargetMachine {
|
||||
protected:
|
||||
const DataLayout DL;
|
||||
std::unique_ptr<TargetLoweringObjectFile> TLOF;
|
||||
AArch64Subtarget Subtarget;
|
||||
mutable StringMap<std::unique_ptr<AArch64Subtarget>> SubtargetMap;
|
||||
@ -35,6 +36,7 @@ public:
|
||||
|
||||
~AArch64TargetMachine() override;
|
||||
|
||||
const DataLayout *getDataLayout() const override { return &DL; }
|
||||
const AArch64Subtarget *getSubtargetImpl() const override {
|
||||
return &Subtarget;
|
||||
}
|
||||
|
@ -83,8 +83,7 @@ void ARMAsmPrinter::EmitFunctionEntryLabel() {
|
||||
}
|
||||
|
||||
void ARMAsmPrinter::EmitXXStructor(const Constant *CV) {
|
||||
uint64_t Size =
|
||||
TM.getSubtargetImpl()->getDataLayout()->getTypeAllocSize(CV->getType());
|
||||
uint64_t Size = TM.getDataLayout()->getTypeAllocSize(CV->getType());
|
||||
assert(Size && "C++ constructor pointer had zero size!");
|
||||
|
||||
const GlobalValue *GV = dyn_cast<GlobalValue>(CV->stripPointerCasts());
|
||||
@ -207,7 +206,7 @@ void ARMAsmPrinter::printOperand(const MachineInstr *MI, int OpNum,
|
||||
|
||||
MCSymbol *ARMAsmPrinter::
|
||||
GetARMJTIPICJumpTableLabel2(unsigned uid, unsigned uid2) const {
|
||||
const DataLayout *DL = TM.getSubtargetImpl()->getDataLayout();
|
||||
const DataLayout *DL = TM.getDataLayout();
|
||||
SmallString<60> Name;
|
||||
raw_svector_ostream(Name) << DL->getPrivateGlobalPrefix() << "JTI"
|
||||
<< getFunctionNumber() << '_' << uid << '_' << uid2;
|
||||
@ -216,7 +215,7 @@ GetARMJTIPICJumpTableLabel2(unsigned uid, unsigned uid2) const {
|
||||
|
||||
|
||||
MCSymbol *ARMAsmPrinter::GetARMSJLJEHLabel() const {
|
||||
const DataLayout *DL = TM.getSubtargetImpl()->getDataLayout();
|
||||
const DataLayout *DL = TM.getDataLayout();
|
||||
SmallString<60> Name;
|
||||
raw_svector_ostream(Name) << DL->getPrivateGlobalPrefix() << "SJLJEH"
|
||||
<< getFunctionNumber();
|
||||
@ -586,7 +585,7 @@ void ARMAsmPrinter::EmitEndOfAsmFile(Module &M) {
|
||||
MachineModuleInfoELF::SymbolListTy Stubs = MMIELF.GetGVStubList();
|
||||
if (!Stubs.empty()) {
|
||||
OutStreamer.SwitchSection(TLOFELF.getDataRelSection());
|
||||
const DataLayout *TD = TM.getSubtargetImpl()->getDataLayout();
|
||||
const DataLayout *TD = TM.getDataLayout();
|
||||
|
||||
for (auto &stub: Stubs) {
|
||||
OutStreamer.EmitLabel(stub.first);
|
||||
@ -924,9 +923,8 @@ MCSymbol *ARMAsmPrinter::GetARMGVSymbol(const GlobalValue *GV,
|
||||
|
||||
void ARMAsmPrinter::
|
||||
EmitMachineConstantPoolValue(MachineConstantPoolValue *MCPV) {
|
||||
const DataLayout *DL = TM.getSubtargetImpl()->getDataLayout();
|
||||
int Size =
|
||||
TM.getSubtargetImpl()->getDataLayout()->getTypeAllocSize(MCPV->getType());
|
||||
const DataLayout *DL = TM.getDataLayout();
|
||||
int Size = TM.getDataLayout()->getTypeAllocSize(MCPV->getType());
|
||||
|
||||
ARMConstantPoolValue *ACPV = static_cast<ARMConstantPoolValue*>(MCPV);
|
||||
|
||||
@ -1242,7 +1240,7 @@ void ARMAsmPrinter::EmitUnwindingInstruction(const MachineInstr *MI) {
|
||||
#include "ARMGenMCPseudoLowering.inc"
|
||||
|
||||
void ARMAsmPrinter::EmitInstruction(const MachineInstr *MI) {
|
||||
const DataLayout *DL = TM.getSubtargetImpl()->getDataLayout();
|
||||
const DataLayout *DL = TM.getDataLayout();
|
||||
|
||||
// If we just ended a constant pool, mark it as such.
|
||||
if (InConstantPool && MI->getOpcode() != ARM::CONSTPOOL_ENTRY) {
|
||||
|
@ -532,7 +532,7 @@ ARMConstantIslands::doInitialPlacement(std::vector<MachineInstr*> &CPEMIs) {
|
||||
// identity mapping of CPI's to CPE's.
|
||||
const std::vector<MachineConstantPoolEntry> &CPs = MCP->getConstants();
|
||||
|
||||
const DataLayout &TD = *MF->getSubtarget().getDataLayout();
|
||||
const DataLayout &TD = *MF->getTarget().getDataLayout();
|
||||
for (unsigned i = 0, e = CPs.size(); i != e; ++i) {
|
||||
unsigned Size = TD.getTypeAllocSize(CPs[i].getType());
|
||||
assert(Size >= 4 && "Too small constant pool entry");
|
||||
|
@ -156,9 +156,8 @@ namespace {
|
||||
ARMConstantPoolValue *CPV = ARMConstantPoolSymbol::Create(
|
||||
*Context, "_GLOBAL_OFFSET_TABLE_", ARMPCLabelIndex, PCAdj);
|
||||
|
||||
unsigned Align =
|
||||
TM->getSubtargetImpl()->getDataLayout()->getPrefTypeAlignment(
|
||||
Type::getInt32PtrTy(*Context));
|
||||
unsigned Align = TM->getDataLayout()->getPrefTypeAlignment(
|
||||
Type::getInt32PtrTy(*Context));
|
||||
unsigned Idx = MF.getConstantPool()->getConstantPoolIndex(CPV, Align);
|
||||
|
||||
MachineBasicBlock &FirstMBB = MF.front();
|
||||
|
@ -1861,7 +1861,7 @@ namespace {
|
||||
}
|
||||
|
||||
bool ARMPreAllocLoadStoreOpt::runOnMachineFunction(MachineFunction &Fn) {
|
||||
TD = Fn.getSubtarget().getDataLayout();
|
||||
TD = Fn.getTarget().getDataLayout();
|
||||
TII = Fn.getSubtarget().getInstrInfo();
|
||||
TRI = Fn.getSubtarget().getRegisterInfo();
|
||||
STI = &static_cast<const ARMSubtarget &>(Fn.getSubtarget());
|
||||
|
@ -88,56 +88,6 @@ IT(cl::desc("IT block support"), cl::Hidden, cl::init(DefaultIT),
|
||||
"Allow IT blocks based on ARMv7"),
|
||||
clEnumValEnd));
|
||||
|
||||
static std::string computeDataLayout(ARMSubtarget &ST) {
|
||||
std::string Ret = "";
|
||||
|
||||
if (ST.isLittle())
|
||||
// Little endian.
|
||||
Ret += "e";
|
||||
else
|
||||
// Big endian.
|
||||
Ret += "E";
|
||||
|
||||
Ret += DataLayout::getManglingComponent(ST.getTargetTriple());
|
||||
|
||||
// Pointers are 32 bits and aligned to 32 bits.
|
||||
Ret += "-p:32:32";
|
||||
|
||||
// ABIs other than APCS have 64 bit integers with natural alignment.
|
||||
if (!ST.isAPCS_ABI())
|
||||
Ret += "-i64:64";
|
||||
|
||||
// We have 64 bits floats. The APCS ABI requires them to be aligned to 32
|
||||
// bits, others to 64 bits. We always try to align to 64 bits.
|
||||
if (ST.isAPCS_ABI())
|
||||
Ret += "-f64:32:64";
|
||||
|
||||
// We have 128 and 64 bit vectors. The APCS ABI aligns them to 32 bits, others
|
||||
// to 64. We always ty to give them natural alignment.
|
||||
if (ST.isAPCS_ABI())
|
||||
Ret += "-v64:32:64-v128:32:128";
|
||||
else
|
||||
Ret += "-v128:64:128";
|
||||
|
||||
// Try to align aggregates to 32 bits (the default is 64 bits, which has no
|
||||
// particular hardware support on 32-bit ARM).
|
||||
Ret += "-a:0:32";
|
||||
|
||||
// Integer registers are 32 bits.
|
||||
Ret += "-n32";
|
||||
|
||||
// The stack is 128 bit aligned on NaCl, 64 bit aligned on AAPCS and 32 bit
|
||||
// aligned everywhere else.
|
||||
if (ST.isTargetNaCl())
|
||||
Ret += "-S128";
|
||||
else if (ST.isAAPCS_ABI())
|
||||
Ret += "-S64";
|
||||
else
|
||||
Ret += "-S32";
|
||||
|
||||
return Ret;
|
||||
}
|
||||
|
||||
/// initializeSubtargetDependencies - Initializes using a CPU and feature string
|
||||
/// so that we can use initializer lists for subtarget initialization.
|
||||
ARMSubtarget &ARMSubtarget::initializeSubtargetDependencies(StringRef CPU,
|
||||
@ -147,23 +97,31 @@ ARMSubtarget &ARMSubtarget::initializeSubtargetDependencies(StringRef CPU,
|
||||
return *this;
|
||||
}
|
||||
|
||||
ARMFrameLowering *ARMSubtarget::initializeFrameLowering(StringRef CPU,
|
||||
StringRef FS) {
|
||||
ARMSubtarget &STI = initializeSubtargetDependencies(CPU, FS);
|
||||
if (STI.isThumb1Only())
|
||||
return (ARMFrameLowering *)new Thumb1FrameLowering(STI);
|
||||
|
||||
return new ARMFrameLowering(STI);
|
||||
}
|
||||
|
||||
ARMSubtarget::ARMSubtarget(const std::string &TT, const std::string &CPU,
|
||||
const std::string &FS, const ARMBaseTargetMachine &TM,
|
||||
bool IsLittle)
|
||||
const std::string &FS,
|
||||
const ARMBaseTargetMachine &TM, bool IsLittle)
|
||||
: ARMGenSubtargetInfo(TT, CPU, FS), ARMProcFamily(Others),
|
||||
ARMProcClass(None), stackAlignment(4), CPUString(CPU), IsLittle(IsLittle),
|
||||
TargetTriple(TT), Options(TM.Options), TM(TM),
|
||||
DL(computeDataLayout(initializeSubtargetDependencies(CPU, FS))),
|
||||
TSInfo(DL),
|
||||
TSInfo(*TM.getDataLayout()),
|
||||
FrameLowering(initializeFrameLowering(CPU, FS)),
|
||||
// At this point initializeSubtargetDependencies has been called so
|
||||
// we can query directly.
|
||||
InstrInfo(isThumb1Only()
|
||||
? (ARMBaseInstrInfo *)new Thumb1InstrInfo(*this)
|
||||
: !isThumb()
|
||||
? (ARMBaseInstrInfo *)new ARMInstrInfo(*this)
|
||||
: (ARMBaseInstrInfo *)new Thumb2InstrInfo(*this)),
|
||||
TLInfo(TM),
|
||||
FrameLowering(!isThumb1Only()
|
||||
? new ARMFrameLowering(*this)
|
||||
: (ARMFrameLowering *)new Thumb1FrameLowering(*this)) {}
|
||||
TLInfo(TM) {}
|
||||
|
||||
void ARMSubtarget::initializeEnvironment() {
|
||||
HasV4TOps = false;
|
||||
|
@ -248,7 +248,6 @@ public:
|
||||
/// so that we can use initializer lists for subtarget initialization.
|
||||
ARMSubtarget &initializeSubtargetDependencies(StringRef CPU, StringRef FS);
|
||||
|
||||
const DataLayout *getDataLayout() const override { return &DL; }
|
||||
const ARMSelectionDAGInfo *getSelectionDAGInfo() const override {
|
||||
return &TSInfo;
|
||||
}
|
||||
@ -266,16 +265,17 @@ public:
|
||||
}
|
||||
|
||||
private:
|
||||
const DataLayout DL;
|
||||
ARMSelectionDAGInfo TSInfo;
|
||||
// Either Thumb1FrameLowering or ARMFrameLowering.
|
||||
std::unique_ptr<ARMFrameLowering> FrameLowering;
|
||||
// Either Thumb1InstrInfo or Thumb2InstrInfo.
|
||||
std::unique_ptr<ARMBaseInstrInfo> InstrInfo;
|
||||
ARMTargetLowering TLInfo;
|
||||
// Either Thumb1FrameLowering or ARMFrameLowering.
|
||||
std::unique_ptr<ARMFrameLowering> FrameLowering;
|
||||
|
||||
void initializeEnvironment();
|
||||
void initSubtargetFeatures(StringRef CPU, StringRef FS);
|
||||
ARMFrameLowering *initializeFrameLowering(StringRef CPU, StringRef FS);
|
||||
|
||||
public:
|
||||
void computeIssueWidth();
|
||||
|
||||
|
@ -104,6 +104,58 @@ computeTargetABI(const Triple &TT, StringRef CPU,
|
||||
return TargetABI;
|
||||
}
|
||||
|
||||
static std::string computeDataLayout(const Triple &TT,
|
||||
ARMBaseTargetMachine::ARMABI ABI,
|
||||
bool isLittle) {
|
||||
std::string Ret = "";
|
||||
|
||||
if (isLittle)
|
||||
// Little endian.
|
||||
Ret += "e";
|
||||
else
|
||||
// Big endian.
|
||||
Ret += "E";
|
||||
|
||||
Ret += DataLayout::getManglingComponent(TT);
|
||||
|
||||
// Pointers are 32 bits and aligned to 32 bits.
|
||||
Ret += "-p:32:32";
|
||||
|
||||
// ABIs other than APCS have 64 bit integers with natural alignment.
|
||||
if (ABI != ARMBaseTargetMachine::ARM_ABI_APCS)
|
||||
Ret += "-i64:64";
|
||||
|
||||
// We have 64 bits floats. The APCS ABI requires them to be aligned to 32
|
||||
// bits, others to 64 bits. We always try to align to 64 bits.
|
||||
if (ABI == ARMBaseTargetMachine::ARM_ABI_APCS)
|
||||
Ret += "-f64:32:64";
|
||||
|
||||
// We have 128 and 64 bit vectors. The APCS ABI aligns them to 32 bits, others
|
||||
// to 64. We always ty to give them natural alignment.
|
||||
if (ABI == ARMBaseTargetMachine::ARM_ABI_APCS)
|
||||
Ret += "-v64:32:64-v128:32:128";
|
||||
else
|
||||
Ret += "-v128:64:128";
|
||||
|
||||
// Try to align aggregates to 32 bits (the default is 64 bits, which has no
|
||||
// particular hardware support on 32-bit ARM).
|
||||
Ret += "-a:0:32";
|
||||
|
||||
// Integer registers are 32 bits.
|
||||
Ret += "-n32";
|
||||
|
||||
// The stack is 128 bit aligned on NaCl, 64 bit aligned on AAPCS and 32 bit
|
||||
// aligned everywhere else.
|
||||
if (TT.isOSNaCl())
|
||||
Ret += "-S128";
|
||||
else if (ABI == ARMBaseTargetMachine::ARM_ABI_AAPCS)
|
||||
Ret += "-S64";
|
||||
else
|
||||
Ret += "-S32";
|
||||
|
||||
return Ret;
|
||||
}
|
||||
|
||||
/// TargetMachine ctor - Create an ARM architecture model.
|
||||
///
|
||||
ARMBaseTargetMachine::ARMBaseTargetMachine(const Target &T, StringRef TT,
|
||||
@ -113,6 +165,7 @@ ARMBaseTargetMachine::ARMBaseTargetMachine(const Target &T, StringRef TT,
|
||||
CodeGenOpt::Level OL, bool isLittle)
|
||||
: LLVMTargetMachine(T, TT, CPU, FS, Options, RM, CM, OL),
|
||||
TargetABI(computeTargetABI(Triple(TT), CPU, Options)),
|
||||
DL(computeDataLayout(Triple(TT), TargetABI, isLittle)),
|
||||
TLOF(createTLOF(Triple(getTargetTriple()))),
|
||||
Subtarget(TT, CPU, FS, *this, isLittle), isLittle(isLittle) {
|
||||
|
||||
|
@ -30,6 +30,7 @@ public:
|
||||
} TargetABI;
|
||||
|
||||
protected:
|
||||
const DataLayout DL;
|
||||
std::unique_ptr<TargetLoweringObjectFile> TLOF;
|
||||
ARMSubtarget Subtarget;
|
||||
bool isLittle;
|
||||
@ -46,6 +47,7 @@ public:
|
||||
|
||||
const ARMSubtarget *getSubtargetImpl() const override { return &Subtarget; }
|
||||
const ARMSubtarget *getSubtargetImpl(const Function &F) const override;
|
||||
const DataLayout *getDataLayout() const override { return &DL; }
|
||||
|
||||
/// \brief Register ARM analysis passes with a pass manager.
|
||||
void addAnalysisPasses(PassManagerBase &PM) override;
|
||||
|
@ -74,9 +74,8 @@ HexagonSubtarget::initializeSubtargetDependencies(StringRef CPU, StringRef FS) {
|
||||
HexagonSubtarget::HexagonSubtarget(StringRef TT, StringRef CPU, StringRef FS,
|
||||
const TargetMachine &TM)
|
||||
: HexagonGenSubtargetInfo(TT, CPU, FS), CPUString(CPU.str()),
|
||||
DL("e-m:e-p:32:32-i1:32-i64:64-a:0-n32"),
|
||||
InstrInfo(initializeSubtargetDependencies(CPU, FS)), TLInfo(TM),
|
||||
TSInfo(DL), FrameLowering() {
|
||||
TSInfo(*TM.getDataLayout()), FrameLowering() {
|
||||
|
||||
// Initialize scheduling itinerary for the specified CPU.
|
||||
InstrItins = getInstrItineraryForCPU(CPUString);
|
||||
|
@ -45,7 +45,6 @@ public:
|
||||
HexagonArchEnum HexagonArchVersion;
|
||||
private:
|
||||
std::string CPUString;
|
||||
const DataLayout DL; // Calculates type size & alignment.
|
||||
HexagonInstrInfo InstrInfo;
|
||||
HexagonTargetLowering TLInfo;
|
||||
HexagonSelectionDAGInfo TSInfo;
|
||||
@ -74,7 +73,6 @@ public:
|
||||
const HexagonSelectionDAGInfo *getSelectionDAGInfo() const override {
|
||||
return &TSInfo;
|
||||
}
|
||||
const DataLayout *getDataLayout() const override { return &DL; }
|
||||
|
||||
HexagonSubtarget &initializeSubtargetDependencies(StringRef CPU,
|
||||
StringRef FS);
|
||||
|
@ -71,7 +71,7 @@ HexagonTargetMachine::HexagonTargetMachine(const Target &T, StringRef TT,
|
||||
CodeGenOpt::Level OL)
|
||||
: LLVMTargetMachine(T, TT, CPU, FS, Options, RM, CM, OL),
|
||||
TLOF(make_unique<HexagonTargetObjectFile>()),
|
||||
Subtarget(TT, CPU, FS, *this) {
|
||||
DL("e-m:e-p:32:32-i1:32-i64:64-a:0-n32"), Subtarget(TT, CPU, FS, *this) {
|
||||
initAsmInfo();
|
||||
}
|
||||
|
||||
|
@ -24,6 +24,7 @@ class Module;
|
||||
|
||||
class HexagonTargetMachine : public LLVMTargetMachine {
|
||||
std::unique_ptr<TargetLoweringObjectFile> TLOF;
|
||||
const DataLayout DL; // Calculates type size & alignment.
|
||||
HexagonSubtarget Subtarget;
|
||||
|
||||
public:
|
||||
@ -32,7 +33,7 @@ public:
|
||||
Reloc::Model RM, CodeModel::Model CM,
|
||||
CodeGenOpt::Level OL);
|
||||
~HexagonTargetMachine() override;
|
||||
|
||||
const DataLayout *getDataLayout() const override { return &DL; }
|
||||
const HexagonSubtarget *getSubtargetImpl() const override {
|
||||
return &Subtarget;
|
||||
}
|
||||
|
@ -79,8 +79,7 @@ IsGlobalInSmallSection(const GlobalValue *GV, const TargetMachine &TM,
|
||||
|
||||
if (Kind.isBSS() || Kind.isDataNoRel() || Kind.isCommon()) {
|
||||
Type *Ty = GV->getType()->getElementType();
|
||||
return IsInSmallSection(
|
||||
TM.getSubtargetImpl()->getDataLayout()->getTypeAllocSize(Ty));
|
||||
return IsInSmallSection(TM.getDataLayout()->getTypeAllocSize(Ty));
|
||||
}
|
||||
|
||||
return false;
|
||||
|
@ -51,7 +51,7 @@ GetExternalSymbolSymbol(const MachineOperand &MO) const {
|
||||
|
||||
MCSymbol *MSP430MCInstLower::
|
||||
GetJumpTableSymbol(const MachineOperand &MO) const {
|
||||
const DataLayout *DL = Printer.TM.getSubtargetImpl()->getDataLayout();
|
||||
const DataLayout *DL = Printer.TM.getDataLayout();
|
||||
SmallString<256> Name;
|
||||
raw_svector_ostream(Name) << DL->getPrivateGlobalPrefix() << "JTI"
|
||||
<< Printer.getFunctionNumber() << '_'
|
||||
@ -68,7 +68,7 @@ GetJumpTableSymbol(const MachineOperand &MO) const {
|
||||
|
||||
MCSymbol *MSP430MCInstLower::
|
||||
GetConstantPoolIndexSymbol(const MachineOperand &MO) const {
|
||||
const DataLayout *DL = Printer.TM.getSubtargetImpl()->getDataLayout();
|
||||
const DataLayout *DL = Printer.TM.getDataLayout();
|
||||
SmallString<256> Name;
|
||||
raw_svector_ostream(Name) << DL->getPrivateGlobalPrefix() << "CPI"
|
||||
<< Printer.getFunctionNumber() << '_'
|
||||
|
@ -32,8 +32,6 @@ MSP430Subtarget &MSP430Subtarget::initializeSubtargetDependencies(StringRef CPU,
|
||||
|
||||
MSP430Subtarget::MSP430Subtarget(const std::string &TT, const std::string &CPU,
|
||||
const std::string &FS, const TargetMachine &TM)
|
||||
: MSP430GenSubtargetInfo(TT, CPU, FS),
|
||||
// FIXME: Check DataLayout string.
|
||||
DL("e-m:e-p:16:16-i32:16:32-a:16-n8:16"), FrameLowering(),
|
||||
: MSP430GenSubtargetInfo(TT, CPU, FS), FrameLowering(),
|
||||
InstrInfo(initializeSubtargetDependencies(CPU, FS)), TLInfo(TM),
|
||||
TSInfo(DL) {}
|
||||
TSInfo(*TM.getDataLayout()) {}
|
||||
|
@ -32,7 +32,6 @@ class StringRef;
|
||||
class MSP430Subtarget : public MSP430GenSubtargetInfo {
|
||||
virtual void anchor();
|
||||
bool ExtendedInsts;
|
||||
const DataLayout DL; // Calculates type size & alignment
|
||||
MSP430FrameLowering FrameLowering;
|
||||
MSP430InstrInfo InstrInfo;
|
||||
MSP430TargetLowering TLInfo;
|
||||
@ -55,7 +54,6 @@ public:
|
||||
return &FrameLowering;
|
||||
}
|
||||
const MSP430InstrInfo *getInstrInfo() const override { return &InstrInfo; }
|
||||
const DataLayout *getDataLayout() const override { return &DL; }
|
||||
const TargetRegisterInfo *getRegisterInfo() const override {
|
||||
return &InstrInfo.getRegisterInfo();
|
||||
}
|
||||
|
@ -32,7 +32,8 @@ MSP430TargetMachine::MSP430TargetMachine(const Target &T, StringRef TT,
|
||||
CodeGenOpt::Level OL)
|
||||
: LLVMTargetMachine(T, TT, CPU, FS, Options, RM, CM, OL),
|
||||
TLOF(make_unique<TargetLoweringObjectFileELF>()),
|
||||
Subtarget(TT, CPU, FS, *this) {
|
||||
// FIXME: Check DataLayout string.
|
||||
DL("e-m:e-p:16:16-i32:16:32-a:16-n8:16"), Subtarget(TT, CPU, FS, *this) {
|
||||
initAsmInfo();
|
||||
}
|
||||
|
||||
|
@ -25,6 +25,7 @@ namespace llvm {
|
||||
///
|
||||
class MSP430TargetMachine : public LLVMTargetMachine {
|
||||
std::unique_ptr<TargetLoweringObjectFile> TLOF;
|
||||
const DataLayout DL; // Calculates type size & alignment
|
||||
MSP430Subtarget Subtarget;
|
||||
|
||||
public:
|
||||
@ -34,6 +35,7 @@ public:
|
||||
CodeGenOpt::Level OL);
|
||||
~MSP430TargetMachine() override;
|
||||
|
||||
const DataLayout *getDataLayout() const override { return &DL; }
|
||||
const MSP430Subtarget *getSubtargetImpl() const override {
|
||||
return &Subtarget;
|
||||
}
|
||||
|
@ -561,7 +561,7 @@ bool MipsAsmPrinter::PrintAsmMemoryOperand(const MachineInstr *MI,
|
||||
|
||||
void MipsAsmPrinter::printOperand(const MachineInstr *MI, int opNum,
|
||||
raw_ostream &O) {
|
||||
const DataLayout *DL = TM.getSubtargetImpl()->getDataLayout();
|
||||
const DataLayout *DL = TM.getDataLayout();
|
||||
const MachineOperand &MO = MI->getOperand(opNum);
|
||||
bool closeP = false;
|
||||
|
||||
|
@ -562,7 +562,7 @@ MipsConstantIslands::doInitialPlacement(std::vector<MachineInstr*> &CPEMIs) {
|
||||
// identity mapping of CPI's to CPE's.
|
||||
const std::vector<MachineConstantPoolEntry> &CPs = MCP->getConstants();
|
||||
|
||||
const DataLayout &TD = *MF->getSubtarget().getDataLayout();
|
||||
const DataLayout &TD = *MF->getTarget().getDataLayout();
|
||||
for (unsigned i = 0, e = CPs.size(); i != e; ++i) {
|
||||
unsigned Size = TD.getTypeAllocSize(CPs[i].getType());
|
||||
assert(Size >= 4 && "Too small constant pool entry");
|
||||
|
@ -64,36 +64,6 @@ GPOpt("mgpopt", cl::Hidden,
|
||||
|
||||
void MipsSubtarget::anchor() { }
|
||||
|
||||
static std::string computeDataLayout(const MipsSubtarget &ST) {
|
||||
std::string Ret = "";
|
||||
|
||||
// There are both little and big endian mips.
|
||||
if (ST.isLittle())
|
||||
Ret += "e";
|
||||
else
|
||||
Ret += "E";
|
||||
|
||||
Ret += "-m:m";
|
||||
|
||||
// Pointers are 32 bit on some ABIs.
|
||||
if (!ST.isABI_N64())
|
||||
Ret += "-p:32:32";
|
||||
|
||||
// 8 and 16 bit integers only need no have natural alignment, but try to
|
||||
// align them to 32 bits. 64 bit integers have natural alignment.
|
||||
Ret += "-i8:8:32-i16:16:32-i64:64";
|
||||
|
||||
// 32 bit registers are always available and the stack is at least 64 bit
|
||||
// aligned. On N64 64 bit registers are also available and the stack is
|
||||
// 128 bit aligned.
|
||||
if (ST.isABI_N64() || ST.isABI_N32())
|
||||
Ret += "-n32:64-S128";
|
||||
else
|
||||
Ret += "-n32-S64";
|
||||
|
||||
return Ret;
|
||||
}
|
||||
|
||||
MipsSubtarget::MipsSubtarget(const std::string &TT, const std::string &CPU,
|
||||
const std::string &FS, bool little,
|
||||
const MipsTargetMachine &TM)
|
||||
@ -105,9 +75,9 @@ MipsSubtarget::MipsSubtarget(const std::string &TT, const std::string &CPU,
|
||||
HasMips5_32r2(false), InMips16Mode(false),
|
||||
InMips16HardFloat(Mips16HardFloat), InMicroMipsMode(false), HasDSP(false),
|
||||
HasDSPR2(false), AllowMixed16_32(Mixed16_32 | Mips_Os16), Os16(Mips_Os16),
|
||||
HasMSA(false), TM(TM), TargetTriple(TT),
|
||||
DL(computeDataLayout(initializeSubtargetDependencies(CPU, FS, TM))),
|
||||
TSInfo(DL), InstrInfo(MipsInstrInfo::create(*this)),
|
||||
HasMSA(false), TM(TM), TargetTriple(TT), TSInfo(*TM.getDataLayout()),
|
||||
InstrInfo(
|
||||
MipsInstrInfo::create(initializeSubtargetDependencies(CPU, FS, TM))),
|
||||
FrameLowering(MipsFrameLowering::create(*this)),
|
||||
TLInfo(MipsTargetLowering::create(TM, *this)) {
|
||||
|
||||
|
@ -137,7 +137,6 @@ class MipsSubtarget : public MipsGenSubtargetInfo {
|
||||
|
||||
Triple TargetTriple;
|
||||
|
||||
const DataLayout DL; // Calculates type size & alignment
|
||||
const MipsSelectionDAGInfo TSInfo;
|
||||
std::unique_ptr<const MipsInstrInfo> InstrInfo;
|
||||
std::unique_ptr<const MipsFrameLowering> FrameLowering;
|
||||
@ -267,7 +266,6 @@ public:
|
||||
const MipsSelectionDAGInfo *getSelectionDAGInfo() const override {
|
||||
return &TSInfo;
|
||||
}
|
||||
const DataLayout *getDataLayout() const override { return &DL; }
|
||||
const MipsInstrInfo *getInstrInfo() const override { return InstrInfo.get(); }
|
||||
const TargetFrameLowering *getFrameLowering() const override {
|
||||
return FrameLowering.get();
|
||||
|
@ -46,6 +46,36 @@ extern "C" void LLVMInitializeMipsTarget() {
|
||||
RegisterTargetMachine<MipselTargetMachine> B(TheMips64elTarget);
|
||||
}
|
||||
|
||||
static std::string computeDataLayout(bool isLittle, MipsABIInfo &ABI) {
|
||||
std::string Ret = "";
|
||||
|
||||
// There are both little and big endian mips.
|
||||
if (isLittle)
|
||||
Ret += "e";
|
||||
else
|
||||
Ret += "E";
|
||||
|
||||
Ret += "-m:m";
|
||||
|
||||
// Pointers are 32 bit on some ABIs.
|
||||
if (!ABI.IsN64())
|
||||
Ret += "-p:32:32";
|
||||
|
||||
// 8 and 16 bit integers only need no have natural alignment, but try to
|
||||
// align them to 32 bits. 64 bit integers have natural alignment.
|
||||
Ret += "-i8:8:32-i16:16:32-i64:64";
|
||||
|
||||
// 32 bit registers are always available and the stack is at least 64 bit
|
||||
// aligned. On N64 64 bit registers are also available and the stack is
|
||||
// 128 bit aligned.
|
||||
if (ABI.IsN64() || ABI.IsN32())
|
||||
Ret += "-n32:64-S128";
|
||||
else
|
||||
Ret += "-n32-S64";
|
||||
|
||||
return Ret;
|
||||
}
|
||||
|
||||
// On function prologue, the stack is created by decrementing
|
||||
// its pointer. Once decremented, all references are done with positive
|
||||
// offset from the stack/frame pointer, using StackGrowsUp enables
|
||||
@ -59,7 +89,8 @@ MipsTargetMachine::MipsTargetMachine(const Target &T, StringRef TT,
|
||||
: LLVMTargetMachine(T, TT, CPU, FS, Options, RM, CM, OL),
|
||||
isLittle(isLittle), TLOF(make_unique<MipsTargetObjectFile>()),
|
||||
ABI(MipsABIInfo::computeTargetABI(Triple(TT), CPU, Options.MCOptions)),
|
||||
Subtarget(nullptr), DefaultSubtarget(TT, CPU, FS, isLittle, *this),
|
||||
DL(computeDataLayout(isLittle, ABI)), Subtarget(nullptr),
|
||||
DefaultSubtarget(TT, CPU, FS, isLittle, *this),
|
||||
NoMips16Subtarget(TT, CPU, FS.empty() ? "-mips16" : FS.str() + ",-mips16",
|
||||
isLittle, *this),
|
||||
Mips16Subtarget(TT, CPU, FS.empty() ? "+mips16" : FS.str() + ",+mips16",
|
||||
|
@ -30,6 +30,7 @@ class MipsTargetMachine : public LLVMTargetMachine {
|
||||
std::unique_ptr<TargetLoweringObjectFile> TLOF;
|
||||
// Selected ABI
|
||||
MipsABIInfo ABI;
|
||||
const DataLayout DL; // Calculates type size & alignment
|
||||
MipsSubtarget *Subtarget;
|
||||
MipsSubtarget DefaultSubtarget;
|
||||
MipsSubtarget NoMips16Subtarget;
|
||||
@ -45,6 +46,7 @@ public:
|
||||
|
||||
void addAnalysisPasses(PassManagerBase &PM) override;
|
||||
|
||||
const DataLayout *getDataLayout() const override { return &DL; }
|
||||
const MipsSubtarget *getSubtargetImpl() const override {
|
||||
if (Subtarget)
|
||||
return Subtarget;
|
||||
|
@ -109,8 +109,7 @@ IsGlobalInSmallSectionImpl(const GlobalValue *GV,
|
||||
return false;
|
||||
|
||||
Type *Ty = GV->getType()->getElementType();
|
||||
return IsInSmallSection(
|
||||
TM.getSubtargetImpl()->getDataLayout()->getTypeAllocSize(Ty));
|
||||
return IsInSmallSection(TM.getDataLayout()->getTypeAllocSize(Ty));
|
||||
}
|
||||
|
||||
const MCSection *MipsTargetObjectFile::
|
||||
@ -132,10 +131,9 @@ SelectSectionForGlobal(const GlobalValue *GV, SectionKind Kind,
|
||||
/// Return true if this constant should be placed into small data section.
|
||||
bool MipsTargetObjectFile::
|
||||
IsConstantInSmallSection(const Constant *CN, const TargetMachine &TM) const {
|
||||
return (TM.getSubtarget<MipsSubtarget>().useSmallSection() &&
|
||||
LocalSData &&
|
||||
IsInSmallSection(TM.getSubtargetImpl()->getDataLayout()
|
||||
->getTypeAllocSize(CN->getType())));
|
||||
return (
|
||||
TM.getSubtarget<MipsSubtarget>().useSmallSection() && LocalSData &&
|
||||
IsInSmallSection(TM.getDataLayout()->getTypeAllocSize(CN->getType())));
|
||||
}
|
||||
|
||||
const MCSection *MipsTargetObjectFile::
|
||||
|
@ -346,7 +346,7 @@ MCOperand NVPTXAsmPrinter::GetSymbolRef(const MCSymbol *Symbol) {
|
||||
}
|
||||
|
||||
void NVPTXAsmPrinter::printReturnValStr(const Function *F, raw_ostream &O) {
|
||||
const DataLayout *TD = TM.getSubtargetImpl()->getDataLayout();
|
||||
const DataLayout *TD = TM.getDataLayout();
|
||||
const TargetLowering *TLI = TM.getSubtargetImpl()->getTargetLowering();
|
||||
|
||||
Type *Ty = F->getReturnType();
|
||||
@ -791,7 +791,7 @@ bool NVPTXAsmPrinter::doInitialization(Module &M) {
|
||||
const_cast<TargetLoweringObjectFile &>(getObjFileLowering())
|
||||
.Initialize(OutContext, TM);
|
||||
|
||||
Mang = new Mangler(TM.getSubtargetImpl()->getDataLayout());
|
||||
Mang = new Mangler(TM.getDataLayout());
|
||||
|
||||
// Emit header before any dwarf directives are emitted below.
|
||||
emitHeader(M, OS1);
|
||||
@ -992,7 +992,7 @@ void NVPTXAsmPrinter::printModuleLevelGV(const GlobalVariable *GVar,
|
||||
GVar->getName().startswith("nvvm."))
|
||||
return;
|
||||
|
||||
const DataLayout *TD = TM.getSubtargetImpl()->getDataLayout();
|
||||
const DataLayout *TD = TM.getDataLayout();
|
||||
|
||||
// GlobalVariables are always constant pointers themselves.
|
||||
const PointerType *PTy = GVar->getType();
|
||||
@ -1295,7 +1295,7 @@ NVPTXAsmPrinter::getPTXFundamentalTypeStr(const Type *Ty, bool useB4PTR) const {
|
||||
void NVPTXAsmPrinter::emitPTXGlobalVariable(const GlobalVariable *GVar,
|
||||
raw_ostream &O) {
|
||||
|
||||
const DataLayout *TD = TM.getSubtargetImpl()->getDataLayout();
|
||||
const DataLayout *TD = TM.getDataLayout();
|
||||
|
||||
// GlobalVariables are always constant pointers themselves.
|
||||
const PointerType *PTy = GVar->getType();
|
||||
@ -1405,7 +1405,7 @@ void NVPTXAsmPrinter::printParamName(int paramIndex, raw_ostream &O) {
|
||||
}
|
||||
|
||||
void NVPTXAsmPrinter::emitFunctionParamList(const Function *F, raw_ostream &O) {
|
||||
const DataLayout *TD = TM.getSubtargetImpl()->getDataLayout();
|
||||
const DataLayout *TD = TM.getDataLayout();
|
||||
const AttributeSet &PAL = F->getAttributes();
|
||||
const TargetLowering *TLI = TM.getSubtargetImpl()->getTargetLowering();
|
||||
Function::const_arg_iterator I, E;
|
||||
@ -1738,7 +1738,7 @@ void NVPTXAsmPrinter::printScalarConstant(const Constant *CPV, raw_ostream &O) {
|
||||
void NVPTXAsmPrinter::bufferLEByte(const Constant *CPV, int Bytes,
|
||||
AggBuffer *aggBuffer) {
|
||||
|
||||
const DataLayout *TD = TM.getSubtargetImpl()->getDataLayout();
|
||||
const DataLayout *TD = TM.getDataLayout();
|
||||
|
||||
if (isa<UndefValue>(CPV) || CPV->isNullValue()) {
|
||||
int s = TD->getTypeAllocSize(CPV->getType());
|
||||
@ -1862,7 +1862,7 @@ void NVPTXAsmPrinter::bufferLEByte(const Constant *CPV, int Bytes,
|
||||
|
||||
void NVPTXAsmPrinter::bufferAggregateConstant(const Constant *CPV,
|
||||
AggBuffer *aggBuffer) {
|
||||
const DataLayout *TD = TM.getSubtargetImpl()->getDataLayout();
|
||||
const DataLayout *TD = TM.getDataLayout();
|
||||
int Bytes;
|
||||
|
||||
// Old constants
|
||||
|
@ -25,17 +25,6 @@ using namespace llvm;
|
||||
// Pin the vtable to this file.
|
||||
void NVPTXSubtarget::anchor() {}
|
||||
|
||||
static std::string computeDataLayout(bool is64Bit) {
|
||||
std::string Ret = "e";
|
||||
|
||||
if (!is64Bit)
|
||||
Ret += "-p:32:32";
|
||||
|
||||
Ret += "-i64:64-v16:16-v32:32-n16:32:64";
|
||||
|
||||
return Ret;
|
||||
}
|
||||
|
||||
NVPTXSubtarget &NVPTXSubtarget::initializeSubtargetDependencies(StringRef CPU,
|
||||
StringRef FS) {
|
||||
// Provide the default CPU if we don't have one.
|
||||
@ -57,9 +46,8 @@ NVPTXSubtarget::NVPTXSubtarget(const std::string &TT, const std::string &CPU,
|
||||
const std::string &FS, const TargetMachine &TM,
|
||||
bool is64Bit)
|
||||
: NVPTXGenSubtargetInfo(TT, CPU, FS), Is64Bit(is64Bit), PTXVersion(0),
|
||||
SmVersion(20), DL(computeDataLayout(is64Bit)),
|
||||
InstrInfo(initializeSubtargetDependencies(CPU, FS)),
|
||||
TLInfo((const NVPTXTargetMachine &)TM), TSInfo(&DL),
|
||||
SmVersion(20), InstrInfo(initializeSubtargetDependencies(CPU, FS)),
|
||||
TLInfo((const NVPTXTargetMachine &)TM), TSInfo(TM.getDataLayout()),
|
||||
FrameLowering(*this) {
|
||||
|
||||
Triple T(TT);
|
||||
|
@ -41,7 +41,6 @@ class NVPTXSubtarget : public NVPTXGenSubtargetInfo {
|
||||
// SM version x.y is represented as 10*x+y, e.g. 3.1 == 31
|
||||
unsigned int SmVersion;
|
||||
|
||||
const DataLayout DL; // Calculates type size & alignment
|
||||
NVPTXInstrInfo InstrInfo;
|
||||
NVPTXTargetLowering TLInfo;
|
||||
TargetSelectionDAGInfo TSInfo;
|
||||
@ -61,7 +60,6 @@ public:
|
||||
return &FrameLowering;
|
||||
}
|
||||
const NVPTXInstrInfo *getInstrInfo() const override { return &InstrInfo; }
|
||||
const DataLayout *getDataLayout() const override { return &DL; }
|
||||
const NVPTXRegisterInfo *getRegisterInfo() const override {
|
||||
return &InstrInfo.getRegisterInfo();
|
||||
}
|
||||
|
@ -69,6 +69,17 @@ extern "C" void LLVMInitializeNVPTXTarget() {
|
||||
initializeNVPTXLowerStructArgsPass(*PassRegistry::getPassRegistry());
|
||||
}
|
||||
|
||||
static std::string computeDataLayout(bool is64Bit) {
|
||||
std::string Ret = "e";
|
||||
|
||||
if (!is64Bit)
|
||||
Ret += "-p:32:32";
|
||||
|
||||
Ret += "-i64:64-v16:16-v32:32-n16:32:64";
|
||||
|
||||
return Ret;
|
||||
}
|
||||
|
||||
NVPTXTargetMachine::NVPTXTargetMachine(const Target &T, StringRef TT,
|
||||
StringRef CPU, StringRef FS,
|
||||
const TargetOptions &Options,
|
||||
@ -76,6 +87,7 @@ NVPTXTargetMachine::NVPTXTargetMachine(const Target &T, StringRef TT,
|
||||
CodeGenOpt::Level OL, bool is64bit)
|
||||
: LLVMTargetMachine(T, TT, CPU, FS, Options, RM, CM, OL),
|
||||
TLOF(make_unique<NVPTXTargetObjectFile>()),
|
||||
DL(computeDataLayout(is64bit)),
|
||||
Subtarget(TT, CPU, FS, *this, is64bit) {
|
||||
initAsmInfo();
|
||||
}
|
||||
|
@ -26,6 +26,7 @@ namespace llvm {
|
||||
///
|
||||
class NVPTXTargetMachine : public LLVMTargetMachine {
|
||||
std::unique_ptr<TargetLoweringObjectFile> TLOF;
|
||||
const DataLayout DL; // Calculates type size & alignment
|
||||
NVPTXSubtarget Subtarget;
|
||||
|
||||
// Hold Strings that can be free'd all together with NVPTXTargetMachine
|
||||
@ -37,7 +38,7 @@ public:
|
||||
CodeModel::Model CM, CodeGenOpt::Level OP, bool is64bit);
|
||||
|
||||
~NVPTXTargetMachine() override;
|
||||
|
||||
const DataLayout *getDataLayout() const override { return &DL; }
|
||||
const NVPTXSubtarget *getSubtargetImpl() const override { return &Subtarget; }
|
||||
|
||||
ManagedStringPool *getManagedStrPool() const {
|
||||
|
@ -160,7 +160,7 @@ static const char *stripRegisterPrefix(const char *RegName) {
|
||||
|
||||
void PPCAsmPrinter::printOperand(const MachineInstr *MI, unsigned OpNo,
|
||||
raw_ostream &O) {
|
||||
const DataLayout *DL = TM.getSubtargetImpl()->getDataLayout();
|
||||
const DataLayout *DL = TM.getDataLayout();
|
||||
const MachineOperand &MO = MI->getOperand(OpNo);
|
||||
|
||||
switch (MO.getType()) {
|
||||
@ -315,7 +315,7 @@ bool PPCAsmPrinter::PrintAsmMemoryOperand(const MachineInstr *MI, unsigned OpNo,
|
||||
/// exists for it. If not, create one. Then return a symbol that references
|
||||
/// the TOC entry.
|
||||
MCSymbol *PPCAsmPrinter::lookUpOrCreateTOCEntry(MCSymbol *Sym) {
|
||||
const DataLayout *DL = TM.getSubtargetImpl()->getDataLayout();
|
||||
const DataLayout *DL = TM.getDataLayout();
|
||||
MCSymbol *&TOCEntry = TOC[Sym];
|
||||
|
||||
// To avoid name clash check if the name already exists.
|
||||
@ -1036,7 +1036,7 @@ void PPCLinuxAsmPrinter::EmitFunctionEntryLabel() {
|
||||
|
||||
|
||||
bool PPCLinuxAsmPrinter::doFinalization(Module &M) {
|
||||
const DataLayout *TD = TM.getSubtargetImpl()->getDataLayout();
|
||||
const DataLayout *TD = TM.getDataLayout();
|
||||
|
||||
bool isPPC64 = TD->getPointerSizeInBits() == 64;
|
||||
|
||||
@ -1242,8 +1242,7 @@ static MCSymbol *GetAnonSym(MCSymbol *Sym, MCContext &Ctx) {
|
||||
|
||||
void PPCDarwinAsmPrinter::
|
||||
EmitFunctionStubs(const MachineModuleInfoMachO::SymbolListTy &Stubs) {
|
||||
bool isPPC64 =
|
||||
TM.getSubtargetImpl()->getDataLayout()->getPointerSizeInBits() == 64;
|
||||
bool isPPC64 = TM.getDataLayout()->getPointerSizeInBits() == 64;
|
||||
bool isDarwin = Subtarget.isDarwin();
|
||||
|
||||
const TargetLoweringObjectFileMachO &TLOFMacho =
|
||||
@ -1379,8 +1378,7 @@ EmitFunctionStubs(const MachineModuleInfoMachO::SymbolListTy &Stubs) {
|
||||
|
||||
|
||||
bool PPCDarwinAsmPrinter::doFinalization(Module &M) {
|
||||
bool isPPC64 =
|
||||
TM.getSubtargetImpl()->getDataLayout()->getPointerSizeInBits() == 64;
|
||||
bool isPPC64 = TM.getDataLayout()->getPointerSizeInBits() == 64;
|
||||
|
||||
// Darwin/PPC always uses mach-o.
|
||||
const TargetLoweringObjectFileMachO &TLOFMacho =
|
||||
|
@ -877,7 +877,7 @@ static bool isConstantOrUndef(int Op, int Val) {
|
||||
/// For the latter, the input operands are swapped (see PPCInstrAltivec.td).
|
||||
bool PPC::isVPKUHUMShuffleMask(ShuffleVectorSDNode *N, unsigned ShuffleKind,
|
||||
SelectionDAG &DAG) {
|
||||
bool IsLE = DAG.getSubtarget().getDataLayout()->isLittleEndian();
|
||||
bool IsLE = DAG.getTarget().getDataLayout()->isLittleEndian();
|
||||
if (ShuffleKind == 0) {
|
||||
if (IsLE)
|
||||
return false;
|
||||
@ -908,7 +908,7 @@ bool PPC::isVPKUHUMShuffleMask(ShuffleVectorSDNode *N, unsigned ShuffleKind,
|
||||
/// For the latter, the input operands are swapped (see PPCInstrAltivec.td).
|
||||
bool PPC::isVPKUWUMShuffleMask(ShuffleVectorSDNode *N, unsigned ShuffleKind,
|
||||
SelectionDAG &DAG) {
|
||||
bool IsLE = DAG.getSubtarget().getDataLayout()->isLittleEndian();
|
||||
bool IsLE = DAG.getTarget().getDataLayout()->isLittleEndian();
|
||||
if (ShuffleKind == 0) {
|
||||
if (IsLE)
|
||||
return false;
|
||||
@ -963,7 +963,7 @@ static bool isVMerge(ShuffleVectorSDNode *N, unsigned UnitSize,
|
||||
/// the input operands are swapped (see PPCInstrAltivec.td).
|
||||
bool PPC::isVMRGLShuffleMask(ShuffleVectorSDNode *N, unsigned UnitSize,
|
||||
unsigned ShuffleKind, SelectionDAG &DAG) {
|
||||
if (DAG.getSubtarget().getDataLayout()->isLittleEndian()) {
|
||||
if (DAG.getTarget().getDataLayout()->isLittleEndian()) {
|
||||
if (ShuffleKind == 1) // unary
|
||||
return isVMerge(N, UnitSize, 0, 0);
|
||||
else if (ShuffleKind == 2) // swapped
|
||||
@ -988,7 +988,7 @@ bool PPC::isVMRGLShuffleMask(ShuffleVectorSDNode *N, unsigned UnitSize,
|
||||
/// the input operands are swapped (see PPCInstrAltivec.td).
|
||||
bool PPC::isVMRGHShuffleMask(ShuffleVectorSDNode *N, unsigned UnitSize,
|
||||
unsigned ShuffleKind, SelectionDAG &DAG) {
|
||||
if (DAG.getSubtarget().getDataLayout()->isLittleEndian()) {
|
||||
if (DAG.getTarget().getDataLayout()->isLittleEndian()) {
|
||||
if (ShuffleKind == 1) // unary
|
||||
return isVMerge(N, UnitSize, 8, 8);
|
||||
else if (ShuffleKind == 2) // swapped
|
||||
@ -1032,8 +1032,7 @@ int PPC::isVSLDOIShuffleMask(SDNode *N, unsigned ShuffleKind,
|
||||
if (ShiftAmt < i) return -1;
|
||||
|
||||
ShiftAmt -= i;
|
||||
bool isLE = DAG.getTarget().getSubtargetImpl()->getDataLayout()->
|
||||
isLittleEndian();
|
||||
bool isLE = DAG.getTarget().getDataLayout()->isLittleEndian();
|
||||
|
||||
if ((ShuffleKind == 0 && !isLE) || (ShuffleKind == 2 && isLE)) {
|
||||
// Check the rest of the elements to see if they are consecutive.
|
||||
@ -1106,7 +1105,7 @@ unsigned PPC::getVSPLTImmediate(SDNode *N, unsigned EltSize,
|
||||
SelectionDAG &DAG) {
|
||||
ShuffleVectorSDNode *SVOp = cast<ShuffleVectorSDNode>(N);
|
||||
assert(isSplatShuffleMask(SVOp, EltSize));
|
||||
if (DAG.getSubtarget().getDataLayout()->isLittleEndian())
|
||||
if (DAG.getTarget().getDataLayout()->isLittleEndian())
|
||||
return (16 / EltSize) - 1 - (SVOp->getMaskElt(0) / EltSize);
|
||||
else
|
||||
return SVOp->getMaskElt(0) / EltSize;
|
||||
|
@ -38,7 +38,7 @@ static MachineModuleInfoMachO &getMachOMMI(AsmPrinter &AP) {
|
||||
static MCSymbol *GetSymbolFromOperand(const MachineOperand &MO, AsmPrinter &AP){
|
||||
const TargetMachine &TM = AP.TM;
|
||||
Mangler *Mang = AP.Mang;
|
||||
const DataLayout *DL = TM.getSubtargetImpl()->getDataLayout();
|
||||
const DataLayout *DL = TM.getDataLayout();
|
||||
MCContext &Ctx = AP.OutContext;
|
||||
bool isDarwin = Triple(TM.getTargetTriple()).isOSDarwin();
|
||||
|
||||
|
@ -18,7 +18,8 @@ using namespace llvm;
|
||||
void PPCFunctionInfo::anchor() { }
|
||||
|
||||
MCSymbol *PPCFunctionInfo::getPICOffsetSymbol() const {
|
||||
const DataLayout *DL = MF.getSubtarget().getDataLayout();
|
||||
return MF.getContext().GetOrCreateSymbol(Twine(DL->getPrivateGlobalPrefix())+
|
||||
Twine(MF.getFunctionNumber())+"$poff");
|
||||
const DataLayout *DL = MF.getTarget().getDataLayout();
|
||||
return MF.getContext().GetOrCreateSymbol(Twine(DL->getPrivateGlobalPrefix()) +
|
||||
Twine(MF.getFunctionNumber()) +
|
||||
"$poff");
|
||||
}
|
||||
|
@ -14,6 +14,7 @@
|
||||
#include "PPCSubtarget.h"
|
||||
#include "PPC.h"
|
||||
#include "PPCRegisterInfo.h"
|
||||
#include "PPCTargetMachine.h"
|
||||
#include "llvm/CodeGen/MachineFunction.h"
|
||||
#include "llvm/CodeGen/MachineScheduler.h"
|
||||
#include "llvm/IR/Attributes.h"
|
||||
@ -36,40 +37,6 @@ using namespace llvm;
|
||||
static cl::opt<bool> UseSubRegLiveness("ppc-track-subreg-liveness",
|
||||
cl::desc("Enable subregister liveness tracking for PPC"), cl::Hidden);
|
||||
|
||||
/// Return the datalayout string of a subtarget.
|
||||
static std::string getDataLayoutString(const Triple &T) {
|
||||
bool is64Bit = T.getArch() == Triple::ppc64 || T.getArch() == Triple::ppc64le;
|
||||
std::string Ret;
|
||||
|
||||
// Most PPC* platforms are big endian, PPC64LE is little endian.
|
||||
if (T.getArch() == Triple::ppc64le)
|
||||
Ret = "e";
|
||||
else
|
||||
Ret = "E";
|
||||
|
||||
Ret += DataLayout::getManglingComponent(T);
|
||||
|
||||
// PPC32 has 32 bit pointers. The PS3 (OS Lv2) is a PPC64 machine with 32 bit
|
||||
// pointers.
|
||||
if (!is64Bit || T.getOS() == Triple::Lv2)
|
||||
Ret += "-p:32:32";
|
||||
|
||||
// Note, the alignment values for f64 and i64 on ppc64 in Darwin
|
||||
// documentation are wrong; these are correct (i.e. "what gcc does").
|
||||
if (is64Bit || !T.isOSDarwin())
|
||||
Ret += "-i64:64";
|
||||
else
|
||||
Ret += "-f64:32:64";
|
||||
|
||||
// PPC64 has 32 and 64 bit registers, PPC32 has only 32 bit ones.
|
||||
if (is64Bit)
|
||||
Ret += "-n32:64";
|
||||
else
|
||||
Ret += "-n32";
|
||||
|
||||
return Ret;
|
||||
}
|
||||
|
||||
PPCSubtarget &PPCSubtarget::initializeSubtargetDependencies(StringRef CPU,
|
||||
StringRef FS) {
|
||||
initializeEnvironment();
|
||||
@ -80,12 +47,11 @@ PPCSubtarget &PPCSubtarget::initializeSubtargetDependencies(StringRef CPU,
|
||||
PPCSubtarget::PPCSubtarget(const std::string &TT, const std::string &CPU,
|
||||
const std::string &FS, const PPCTargetMachine &TM)
|
||||
: PPCGenSubtargetInfo(TT, CPU, FS), TargetTriple(TT),
|
||||
DL(getDataLayoutString(TargetTriple)),
|
||||
IsPPC64(TargetTriple.getArch() == Triple::ppc64 ||
|
||||
TargetTriple.getArch() == Triple::ppc64le),
|
||||
TargetABI(PPC_ABI_UNKNOWN),
|
||||
FrameLowering(initializeSubtargetDependencies(CPU, FS)), InstrInfo(*this),
|
||||
TLInfo(TM), TSInfo(&DL) {}
|
||||
TLInfo(TM), TSInfo(TM.getDataLayout()) {}
|
||||
|
||||
void PPCSubtarget::initializeEnvironment() {
|
||||
StackAlignment = 16;
|
||||
|
@ -68,9 +68,6 @@ protected:
|
||||
/// TargetTriple - What processor and OS we're targeting.
|
||||
Triple TargetTriple;
|
||||
|
||||
// Calculates type size & alignment
|
||||
const DataLayout DL;
|
||||
|
||||
/// stackAlignment - The minimum alignment known to hold of the stack frame on
|
||||
/// entry to the function and which must be maintained by every function.
|
||||
unsigned StackAlignment;
|
||||
@ -156,7 +153,6 @@ public:
|
||||
const PPCFrameLowering *getFrameLowering() const override {
|
||||
return &FrameLowering;
|
||||
}
|
||||
const DataLayout *getDataLayout() const override { return &DL; }
|
||||
const PPCInstrInfo *getInstrInfo() const override { return &InstrInfo; }
|
||||
const PPCTargetLowering *getTargetLowering() const override {
|
||||
return &TLInfo;
|
||||
|
@ -45,6 +45,40 @@ extern "C" void LLVMInitializePowerPCTarget() {
|
||||
RegisterTargetMachine<PPC64TargetMachine> C(ThePPC64LETarget);
|
||||
}
|
||||
|
||||
/// Return the datalayout string of a subtarget.
|
||||
static std::string getDataLayoutString(const Triple &T) {
|
||||
bool is64Bit = T.getArch() == Triple::ppc64 || T.getArch() == Triple::ppc64le;
|
||||
std::string Ret;
|
||||
|
||||
// Most PPC* platforms are big endian, PPC64LE is little endian.
|
||||
if (T.getArch() == Triple::ppc64le)
|
||||
Ret = "e";
|
||||
else
|
||||
Ret = "E";
|
||||
|
||||
Ret += DataLayout::getManglingComponent(T);
|
||||
|
||||
// PPC32 has 32 bit pointers. The PS3 (OS Lv2) is a PPC64 machine with 32 bit
|
||||
// pointers.
|
||||
if (!is64Bit || T.getOS() == Triple::Lv2)
|
||||
Ret += "-p:32:32";
|
||||
|
||||
// Note, the alignment values for f64 and i64 on ppc64 in Darwin
|
||||
// documentation are wrong; these are correct (i.e. "what gcc does").
|
||||
if (is64Bit || !T.isOSDarwin())
|
||||
Ret += "-i64:64";
|
||||
else
|
||||
Ret += "-f64:32:64";
|
||||
|
||||
// PPC64 has 32 and 64 bit registers, PPC32 has only 32 bit ones.
|
||||
if (is64Bit)
|
||||
Ret += "-n32:64";
|
||||
else
|
||||
Ret += "-n32";
|
||||
|
||||
return Ret;
|
||||
}
|
||||
|
||||
static std::string computeFSAdditions(StringRef FS, CodeGenOpt::Level OL, StringRef TT) {
|
||||
std::string FullFS = FS;
|
||||
Triple TargetTriple(TT);
|
||||
@ -95,7 +129,7 @@ PPCTargetMachine::PPCTargetMachine(const Target &T, StringRef TT, StringRef CPU,
|
||||
: LLVMTargetMachine(T, TT, CPU, computeFSAdditions(FS, OL, TT), Options, RM,
|
||||
CM, OL),
|
||||
TLOF(createTLOF(Triple(getTargetTriple()))),
|
||||
Subtarget(TT, CPU, TargetFS, *this) {
|
||||
DL(getDataLayoutString(Triple(TT))), Subtarget(TT, CPU, TargetFS, *this) {
|
||||
initAsmInfo();
|
||||
}
|
||||
|
||||
@ -251,4 +285,3 @@ void PPCTargetMachine::addAnalysisPasses(PassManagerBase &PM) {
|
||||
PM.add(createBasicTargetTransformInfoPass(this));
|
||||
PM.add(createPPCTargetTransformInfoPass(this));
|
||||
}
|
||||
|
||||
|
@ -25,18 +25,20 @@ namespace llvm {
|
||||
///
|
||||
class PPCTargetMachine : public LLVMTargetMachine {
|
||||
std::unique_ptr<TargetLoweringObjectFile> TLOF;
|
||||
// Calculates type size & alignment
|
||||
const DataLayout DL;
|
||||
PPCSubtarget Subtarget;
|
||||
|
||||
mutable StringMap<std::unique_ptr<PPCSubtarget>> SubtargetMap;
|
||||
|
||||
public:
|
||||
PPCTargetMachine(const Target &T, StringRef TT,
|
||||
StringRef CPU, StringRef FS, const TargetOptions &Options,
|
||||
Reloc::Model RM, CodeModel::Model CM,
|
||||
CodeGenOpt::Level OL);
|
||||
PPCTargetMachine(const Target &T, StringRef TT, StringRef CPU, StringRef FS,
|
||||
const TargetOptions &Options, Reloc::Model RM,
|
||||
CodeModel::Model CM, CodeGenOpt::Level OL);
|
||||
|
||||
~PPCTargetMachine() override;
|
||||
|
||||
const DataLayout *getDataLayout() const override { return &DL; }
|
||||
const PPCSubtarget *getSubtargetImpl() const override { return &Subtarget; }
|
||||
const PPCSubtarget *getSubtargetImpl(const Function &F) const override;
|
||||
|
||||
|
@ -669,7 +669,7 @@ SDValue AMDGPUTargetLowering::LowerConstantInitializer(const Constant* Init,
|
||||
const SDValue &InitPtr,
|
||||
SDValue Chain,
|
||||
SelectionDAG &DAG) const {
|
||||
const DataLayout *TD = getTargetMachine().getSubtargetImpl()->getDataLayout();
|
||||
const DataLayout *TD = getDataLayout();
|
||||
SDLoc DL(InitPtr);
|
||||
Type *InitTy = Init->getType();
|
||||
|
||||
@ -757,7 +757,7 @@ SDValue AMDGPUTargetLowering::LowerGlobalAddress(AMDGPUMachineFunction* MFI,
|
||||
SDValue Op,
|
||||
SelectionDAG &DAG) const {
|
||||
|
||||
const DataLayout *TD = getTargetMachine().getSubtargetImpl()->getDataLayout();
|
||||
const DataLayout *TD = getDataLayout();
|
||||
GlobalAddressSDNode *G = cast<GlobalAddressSDNode>(Op);
|
||||
const GlobalValue *GV = G->getGlobal();
|
||||
|
||||
|
@ -30,20 +30,6 @@ using namespace llvm;
|
||||
#define GET_SUBTARGETINFO_CTOR
|
||||
#include "AMDGPUGenSubtargetInfo.inc"
|
||||
|
||||
static std::string computeDataLayout(const AMDGPUSubtarget &ST) {
|
||||
std::string Ret = "e-p:32:32";
|
||||
|
||||
if (ST.is64bit()) {
|
||||
// 32-bit private, local, and region pointers. 64-bit global and constant.
|
||||
Ret += "-p1:64:64-p2:64:64-p3:32:32-p4:64:64-p5:32:32-p24:64:64";
|
||||
}
|
||||
|
||||
Ret += "-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-v256:256"
|
||||
"-v512:512-v1024:1024-v2048:2048-n32:64";
|
||||
|
||||
return Ret;
|
||||
}
|
||||
|
||||
AMDGPUSubtarget &
|
||||
AMDGPUSubtarget::initializeSubtargetDependencies(StringRef GPU, StringRef FS) {
|
||||
// Determine default and user-specified characteristics
|
||||
@ -70,6 +56,20 @@ AMDGPUSubtarget::initializeSubtargetDependencies(StringRef GPU, StringRef FS) {
|
||||
return *this;
|
||||
}
|
||||
|
||||
static std::string computeDataLayout(const AMDGPUSubtarget &ST) {
|
||||
std::string Ret = "e-p:32:32";
|
||||
|
||||
if (ST.is64bit()) {
|
||||
// 32-bit private, local, and region pointers. 64-bit global and constant.
|
||||
Ret += "-p1:64:64-p2:64:64-p3:32:32-p4:64:64-p5:32:32-p24:64:64";
|
||||
}
|
||||
|
||||
Ret += "-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-v256:256"
|
||||
"-v512:512-v1024:1024-v2048:2048-n32:64";
|
||||
|
||||
return Ret;
|
||||
}
|
||||
|
||||
AMDGPUSubtarget::AMDGPUSubtarget(StringRef TT, StringRef GPU, StringRef FS,
|
||||
TargetMachine &TM)
|
||||
: AMDGPUGenSubtargetInfo(TT, GPU, FS), DevName(GPU), Is64bit(false),
|
||||
|
@ -67,7 +67,7 @@ private:
|
||||
int LocalMemorySize;
|
||||
bool EnableVGPRSpilling;
|
||||
|
||||
const DataLayout DL;
|
||||
DataLayout DL;
|
||||
AMDGPUFrameLowering FrameLowering;
|
||||
std::unique_ptr<AMDGPUTargetLowering> TLInfo;
|
||||
std::unique_ptr<AMDGPUInstrInfo> InstrInfo;
|
||||
@ -78,6 +78,10 @@ public:
|
||||
AMDGPUSubtarget(StringRef TT, StringRef CPU, StringRef FS, TargetMachine &TM);
|
||||
AMDGPUSubtarget &initializeSubtargetDependencies(StringRef GPU, StringRef FS);
|
||||
|
||||
// FIXME: This routine needs to go away. See comments in
|
||||
// AMDGPUTargetMachine.h.
|
||||
const DataLayout *getDataLayout() const { return &DL; }
|
||||
|
||||
const AMDGPUFrameLowering *getFrameLowering() const override {
|
||||
return &FrameLowering;
|
||||
}
|
||||
@ -90,7 +94,6 @@ public:
|
||||
AMDGPUTargetLowering *getTargetLowering() const override {
|
||||
return TLInfo.get();
|
||||
}
|
||||
const DataLayout *getDataLayout() const override { return &DL; }
|
||||
const InstrItineraryData *getInstrItineraryData() const override {
|
||||
return &InstrItins;
|
||||
}
|
||||
|
@ -39,6 +39,11 @@ public:
|
||||
StringRef CPU, TargetOptions Options, Reloc::Model RM,
|
||||
CodeModel::Model CM, CodeGenOpt::Level OL);
|
||||
~AMDGPUTargetMachine();
|
||||
// FIXME: This is currently broken, the DataLayout needs to move to
|
||||
// the target machine.
|
||||
const DataLayout *getDataLayout() const override {
|
||||
return getSubtargetImpl()->getDataLayout();
|
||||
}
|
||||
const AMDGPUSubtarget *getSubtargetImpl() const override {
|
||||
return &Subtarget;
|
||||
}
|
||||
|
@ -297,7 +297,7 @@ void SparcAsmPrinter::EmitFunctionBodyStart() {
|
||||
|
||||
void SparcAsmPrinter::printOperand(const MachineInstr *MI, int opNum,
|
||||
raw_ostream &O) {
|
||||
const DataLayout *DL = TM.getSubtargetImpl()->getDataLayout();
|
||||
const DataLayout *DL = TM.getDataLayout();
|
||||
const MachineOperand &MO = MI->getOperand (opNum);
|
||||
SparcMCExpr::VariantKind TF = (SparcMCExpr::VariantKind) MO.getTargetFlags();
|
||||
|
||||
@ -451,8 +451,7 @@ void SparcAsmPrinter::EmitEndOfAsmFile(Module &M) {
|
||||
MachineModuleInfoELF::SymbolListTy Stubs = MMIELF.GetGVStubList();
|
||||
if (!Stubs.empty()) {
|
||||
OutStreamer.SwitchSection(TLOFELF.getDataSection());
|
||||
unsigned PtrSize =
|
||||
TM.getSubtargetImpl()->getDataLayout()->getPointerSize(0);
|
||||
unsigned PtrSize = TM.getDataLayout()->getPointerSize(0);
|
||||
for (unsigned i = 0, e = Stubs.size(); i != e; ++i) {
|
||||
OutStreamer.EmitLabel(Stubs[i].first);
|
||||
OutStreamer.EmitSymbolValue(Stubs[i].second.getPointer(), PtrSize);
|
||||
|
@ -26,32 +26,6 @@ using namespace llvm;
|
||||
|
||||
void SparcSubtarget::anchor() { }
|
||||
|
||||
static std::string computeDataLayout(const SparcSubtarget &ST) {
|
||||
// Sparc is big endian.
|
||||
std::string Ret = "E-m:e";
|
||||
|
||||
// Some ABIs have 32bit pointers.
|
||||
if (!ST.is64Bit())
|
||||
Ret += "-p:32:32";
|
||||
|
||||
// Alignments for 64 bit integers.
|
||||
Ret += "-i64:64";
|
||||
|
||||
// On SparcV9 128 floats are aligned to 128 bits, on others only to 64.
|
||||
// On SparcV9 registers can hold 64 or 32 bits, on others only 32.
|
||||
if (ST.is64Bit())
|
||||
Ret += "-n32:64";
|
||||
else
|
||||
Ret += "-f128:64-n32";
|
||||
|
||||
if (ST.is64Bit())
|
||||
Ret += "-S128";
|
||||
else
|
||||
Ret += "-S64";
|
||||
|
||||
return Ret;
|
||||
}
|
||||
|
||||
SparcSubtarget &SparcSubtarget::initializeSubtargetDependencies(StringRef CPU,
|
||||
StringRef FS) {
|
||||
IsV9 = false;
|
||||
@ -79,8 +53,8 @@ SparcSubtarget::SparcSubtarget(const std::string &TT, const std::string &CPU,
|
||||
const std::string &FS, TargetMachine &TM,
|
||||
bool is64Bit)
|
||||
: SparcGenSubtargetInfo(TT, CPU, FS), Is64Bit(is64Bit),
|
||||
DL(computeDataLayout(initializeSubtargetDependencies(CPU, FS))),
|
||||
InstrInfo(*this), TLInfo(TM), TSInfo(DL), FrameLowering(*this) {}
|
||||
InstrInfo(initializeSubtargetDependencies(CPU, FS)), TLInfo(TM),
|
||||
TSInfo(*TM.getDataLayout()), FrameLowering(*this) {}
|
||||
|
||||
int SparcSubtarget::getAdjustedFrameSize(int frameSize) const {
|
||||
|
||||
|
@ -37,7 +37,6 @@ class SparcSubtarget : public SparcGenSubtargetInfo {
|
||||
bool Is64Bit;
|
||||
bool HasHardQuad;
|
||||
bool UsePopc;
|
||||
const DataLayout DL; // Calculates type size & alignment
|
||||
SparcInstrInfo InstrInfo;
|
||||
SparcTargetLowering TLInfo;
|
||||
SparcSelectionDAGInfo TSInfo;
|
||||
@ -60,7 +59,6 @@ public:
|
||||
const SparcSelectionDAGInfo *getSelectionDAGInfo() const override {
|
||||
return &TSInfo;
|
||||
}
|
||||
const DataLayout *getDataLayout() const override { return &DL; }
|
||||
|
||||
bool isV9() const { return IsV9; }
|
||||
bool isVIS() const { return IsVIS; }
|
||||
|
@ -24,6 +24,32 @@ extern "C" void LLVMInitializeSparcTarget() {
|
||||
RegisterTargetMachine<SparcV9TargetMachine> Y(TheSparcV9Target);
|
||||
}
|
||||
|
||||
static std::string computeDataLayout(bool is64Bit) {
|
||||
// Sparc is big endian.
|
||||
std::string Ret = "E-m:e";
|
||||
|
||||
// Some ABIs have 32bit pointers.
|
||||
if (!is64Bit)
|
||||
Ret += "-p:32:32";
|
||||
|
||||
// Alignments for 64 bit integers.
|
||||
Ret += "-i64:64";
|
||||
|
||||
// On SparcV9 128 floats are aligned to 128 bits, on others only to 64.
|
||||
// On SparcV9 registers can hold 64 or 32 bits, on others only 32.
|
||||
if (is64Bit)
|
||||
Ret += "-n32:64";
|
||||
else
|
||||
Ret += "-f128:64-n32";
|
||||
|
||||
if (is64Bit)
|
||||
Ret += "-S128";
|
||||
else
|
||||
Ret += "-S64";
|
||||
|
||||
return Ret;
|
||||
}
|
||||
|
||||
/// SparcTargetMachine ctor - Create an ILP32 architecture model
|
||||
///
|
||||
SparcTargetMachine::SparcTargetMachine(const Target &T, StringRef TT,
|
||||
@ -34,6 +60,7 @@ SparcTargetMachine::SparcTargetMachine(const Target &T, StringRef TT,
|
||||
bool is64bit)
|
||||
: LLVMTargetMachine(T, TT, CPU, FS, Options, RM, CM, OL),
|
||||
TLOF(make_unique<SparcELFTargetObjectFile>()),
|
||||
DL(computeDataLayout(is64bit)),
|
||||
Subtarget(TT, CPU, FS, *this, is64bit) {
|
||||
initAsmInfo();
|
||||
}
|
||||
|
@ -22,6 +22,7 @@ namespace llvm {
|
||||
|
||||
class SparcTargetMachine : public LLVMTargetMachine {
|
||||
std::unique_ptr<TargetLoweringObjectFile> TLOF;
|
||||
const DataLayout DL;
|
||||
SparcSubtarget Subtarget;
|
||||
public:
|
||||
SparcTargetMachine(const Target &T, StringRef TT,
|
||||
@ -30,6 +31,7 @@ public:
|
||||
CodeGenOpt::Level OL, bool is64bit);
|
||||
~SparcTargetMachine() override;
|
||||
|
||||
const DataLayout *getDataLayout() const override { return &DL; }
|
||||
const SparcSubtarget *getSubtargetImpl() const override { return &Subtarget; }
|
||||
|
||||
// Pass Pipeline Configuration
|
||||
|
@ -185,8 +185,7 @@ EmitMachineConstantPoolValue(MachineConstantPoolValue *MCPV) {
|
||||
MCSymbolRefExpr::Create(getSymbol(ZCPV->getGlobalValue()),
|
||||
getModifierVariantKind(ZCPV->getModifier()),
|
||||
OutContext);
|
||||
uint64_t Size =
|
||||
TM.getSubtargetImpl()->getDataLayout()->getTypeAllocSize(ZCPV->getType());
|
||||
uint64_t Size = TM.getDataLayout()->getTypeAllocSize(ZCPV->getType());
|
||||
|
||||
OutStreamer.EmitValue(Expr, Size);
|
||||
}
|
||||
@ -230,7 +229,7 @@ void SystemZAsmPrinter::EmitEndOfAsmFile(Module &M) {
|
||||
MachineModuleInfoELF::SymbolListTy Stubs = MMIELF.GetGVStubList();
|
||||
if (!Stubs.empty()) {
|
||||
OutStreamer.SwitchSection(TLOFELF.getDataRelSection());
|
||||
const DataLayout *TD = TM.getSubtargetImpl()->getDataLayout();
|
||||
const DataLayout *TD = TM.getDataLayout();
|
||||
|
||||
for (unsigned i = 0, e = Stubs.size(); i != e; ++i) {
|
||||
OutStreamer.EmitLabel(Stubs[i].first);
|
||||
|
@ -44,13 +44,8 @@ SystemZSubtarget::SystemZSubtarget(const std::string &TT,
|
||||
: SystemZGenSubtargetInfo(TT, CPU, FS), HasDistinctOps(false),
|
||||
HasLoadStoreOnCond(false), HasHighWord(false), HasFPExtension(false),
|
||||
HasFastSerialization(false), HasInterlockedAccess1(false),
|
||||
TargetTriple(TT),
|
||||
// Make sure that global data has at least 16 bits of alignment by
|
||||
// default, so that we can refer to it using LARL. We don't have any
|
||||
// special requirements for stack variables though.
|
||||
DL("E-m:e-i1:8:16-i8:8:16-i64:64-f128:64-a:8:16-n32:64"),
|
||||
InstrInfo(initializeSubtargetDependencies(CPU, FS)), TLInfo(TM),
|
||||
TSInfo(DL), FrameLowering() {}
|
||||
TargetTriple(TT), InstrInfo(initializeSubtargetDependencies(CPU, FS)),
|
||||
TLInfo(TM), TSInfo(*TM.getDataLayout()), FrameLowering() {}
|
||||
|
||||
// Return true if GV binds locally under reloc model RM.
|
||||
static bool bindsLocally(const GlobalValue *GV, Reloc::Model RM) {
|
||||
|
@ -43,7 +43,6 @@ protected:
|
||||
|
||||
private:
|
||||
Triple TargetTriple;
|
||||
const DataLayout DL;
|
||||
SystemZInstrInfo InstrInfo;
|
||||
SystemZTargetLowering TLInfo;
|
||||
SystemZSelectionDAGInfo TSInfo;
|
||||
@ -59,7 +58,6 @@ public:
|
||||
return &FrameLowering;
|
||||
}
|
||||
const SystemZInstrInfo *getInstrInfo() const override { return &InstrInfo; }
|
||||
const DataLayout *getDataLayout() const override { return &DL; }
|
||||
const SystemZRegisterInfo *getRegisterInfo() const override {
|
||||
return &InstrInfo.getRegisterInfo();
|
||||
}
|
||||
|
@ -27,6 +27,10 @@ SystemZTargetMachine::SystemZTargetMachine(const Target &T, StringRef TT,
|
||||
CodeGenOpt::Level OL)
|
||||
: LLVMTargetMachine(T, TT, CPU, FS, Options, RM, CM, OL),
|
||||
TLOF(make_unique<TargetLoweringObjectFileELF>()),
|
||||
// Make sure that global data has at least 16 bits of alignment by
|
||||
// default, so that we can refer to it using LARL. We don't have any
|
||||
// special requirements for stack variables though.
|
||||
DL("E-m:e-i1:8:16-i8:8:16-i64:64-f128:64-a:8:16-n32:64"),
|
||||
Subtarget(TT, CPU, FS, *this) {
|
||||
initAsmInfo();
|
||||
}
|
||||
|
@ -24,6 +24,7 @@ class TargetFrameLowering;
|
||||
|
||||
class SystemZTargetMachine : public LLVMTargetMachine {
|
||||
std::unique_ptr<TargetLoweringObjectFile> TLOF;
|
||||
const DataLayout DL;
|
||||
SystemZSubtarget Subtarget;
|
||||
|
||||
public:
|
||||
@ -34,6 +35,7 @@ public:
|
||||
~SystemZTargetMachine() override;
|
||||
|
||||
// Override TargetMachine.
|
||||
const DataLayout *getDataLayout() const override { return &DL; }
|
||||
const SystemZSubtarget *getSubtargetImpl() const override {
|
||||
return &Subtarget;
|
||||
}
|
||||
|
@ -43,7 +43,7 @@ using namespace llvm;
|
||||
void TargetLoweringObjectFile::Initialize(MCContext &ctx,
|
||||
const TargetMachine &TM) {
|
||||
Ctx = &ctx;
|
||||
DL = TM.getSubtargetImpl()->getDataLayout();
|
||||
DL = TM.getDataLayout();
|
||||
InitMCObjectFileInfo(TM.getTargetTriple(),
|
||||
TM.getRelocationModel(), TM.getCodeModel(), *Ctx);
|
||||
}
|
||||
@ -200,8 +200,7 @@ SectionKind TargetLoweringObjectFile::getKindForGlobal(const GlobalValue *GV,
|
||||
// Otherwise, just drop it into a mergable constant section. If we have
|
||||
// a section for this size, use it, otherwise use the arbitrary sized
|
||||
// mergable section.
|
||||
switch (TM.getSubtargetImpl()->getDataLayout()->getTypeAllocSize(
|
||||
C->getType())) {
|
||||
switch (TM.getDataLayout()->getTypeAllocSize(C->getType())) {
|
||||
case 4: return SectionKind::getMergeableConst4();
|
||||
case 8: return SectionKind::getMergeableConst8();
|
||||
case 16: return SectionKind::getMergeableConst16();
|
||||
|
@ -173,7 +173,7 @@ char* LLVMGetTargetMachineFeatureString(LLVMTargetMachineRef T) {
|
||||
}
|
||||
|
||||
LLVMTargetDataRef LLVMGetTargetMachineData(LLVMTargetMachineRef T) {
|
||||
return wrap(unwrap(T)->getSubtargetImpl()->getDataLayout());
|
||||
return wrap(unwrap(T)->getDataLayout());
|
||||
}
|
||||
|
||||
void LLVMSetTargetMachineAsmVerbosity(LLVMTargetMachineRef T,
|
||||
@ -190,7 +190,7 @@ static LLVMBool LLVMTargetMachineEmit(LLVMTargetMachineRef T, LLVMModuleRef M,
|
||||
|
||||
std::string error;
|
||||
|
||||
const DataLayout *td = TM->getSubtargetImpl()->getDataLayout();
|
||||
const DataLayout *td = TM->getDataLayout();
|
||||
|
||||
if (!td) {
|
||||
error = "No DataLayout in TargetMachine";
|
||||
|
@ -558,8 +558,7 @@ MCSymbol *X86AsmPrinter::GetCPISymbol(unsigned CPID) const {
|
||||
const MachineConstantPoolEntry &CPE =
|
||||
MF->getConstantPool()->getConstants()[CPID];
|
||||
if (!CPE.isMachineConstantPoolEntry()) {
|
||||
SectionKind Kind =
|
||||
CPE.getSectionKind(TM.getSubtargetImpl()->getDataLayout());
|
||||
SectionKind Kind = CPE.getSectionKind(TM.getDataLayout());
|
||||
const Constant *C = CPE.Val.ConstVal;
|
||||
if (const MCSectionCOFF *S = dyn_cast<MCSectionCOFF>(
|
||||
getObjFileLowering().getSectionForConstant(Kind, C))) {
|
||||
@ -729,7 +728,7 @@ void X86AsmPrinter::EmitEndOfAsmFile(Module &M) {
|
||||
MachineModuleInfoELF::SymbolListTy Stubs = MMIELF.GetGVStubList();
|
||||
if (!Stubs.empty()) {
|
||||
OutStreamer.SwitchSection(TLOFELF.getDataRelSection());
|
||||
const DataLayout *TD = TM.getSubtargetImpl()->getDataLayout();
|
||||
const DataLayout *TD = TM.getDataLayout();
|
||||
|
||||
for (const auto &Stub : Stubs) {
|
||||
OutStreamer.EmitLabel(Stub.first);
|
||||
|
@ -3189,8 +3189,8 @@ unsigned X86FastISel::X86MaterializeFP(const ConstantFP *CFP, MVT VT) {
|
||||
TII.get(Opc), ResultReg);
|
||||
addDirectMem(MIB, AddrReg);
|
||||
MachineMemOperand *MMO = FuncInfo.MF->getMachineMemOperand(
|
||||
MachinePointerInfo::getConstantPool(), MachineMemOperand::MOLoad,
|
||||
TM.getSubtargetImpl()->getDataLayout()->getPointerSize(), Align);
|
||||
MachinePointerInfo::getConstantPool(), MachineMemOperand::MOLoad,
|
||||
TM.getDataLayout()->getPointerSize(), Align);
|
||||
MIB->addMemOperand(*FuncInfo.MF, MMO);
|
||||
return ResultReg;
|
||||
}
|
||||
|
@ -124,7 +124,7 @@ MachineModuleInfoMachO &X86MCInstLower::getMachOMMI() const {
|
||||
/// operand to an MCSymbol.
|
||||
MCSymbol *X86MCInstLower::
|
||||
GetSymbolFromOperand(const MachineOperand &MO) const {
|
||||
const DataLayout *DL = TM.getSubtargetImpl()->getDataLayout();
|
||||
const DataLayout *DL = TM.getDataLayout();
|
||||
assert((MO.isGlobal() || MO.isSymbol() || MO.isMBB()) && "Isn't a symbol reference");
|
||||
|
||||
SmallString<128> Name;
|
||||
|
@ -282,46 +282,6 @@ void X86Subtarget::initializeEnvironment() {
|
||||
MaxInlineSizeThreshold = 128;
|
||||
}
|
||||
|
||||
static std::string computeDataLayout(const Triple &TT) {
|
||||
// X86 is little endian
|
||||
std::string Ret = "e";
|
||||
|
||||
Ret += DataLayout::getManglingComponent(TT);
|
||||
// X86 and x32 have 32 bit pointers.
|
||||
if ((TT.isArch64Bit() &&
|
||||
(TT.getEnvironment() == Triple::GNUX32 || TT.isOSNaCl())) ||
|
||||
!TT.isArch64Bit())
|
||||
Ret += "-p:32:32";
|
||||
|
||||
// Some ABIs align 64 bit integers and doubles to 64 bits, others to 32.
|
||||
if (TT.isArch64Bit() || TT.isOSWindows() || TT.isOSNaCl())
|
||||
Ret += "-i64:64";
|
||||
else
|
||||
Ret += "-f64:32:64";
|
||||
|
||||
// Some ABIs align long double to 128 bits, others to 32.
|
||||
if (TT.isOSNaCl())
|
||||
; // No f80
|
||||
else if (TT.isArch64Bit() || TT.isOSDarwin())
|
||||
Ret += "-f80:128";
|
||||
else
|
||||
Ret += "-f80:32";
|
||||
|
||||
// The registers can hold 8, 16, 32 or, in x86-64, 64 bits.
|
||||
if (TT.isArch64Bit())
|
||||
Ret += "-n8:16:32:64";
|
||||
else
|
||||
Ret += "-n8:16:32";
|
||||
|
||||
// The stack is aligned to 32 bits on some ABIs and 128 bits on others.
|
||||
if (!TT.isArch64Bit() && TT.isOSWindows())
|
||||
Ret += "-S32";
|
||||
else
|
||||
Ret += "-S128";
|
||||
|
||||
return Ret;
|
||||
}
|
||||
|
||||
X86Subtarget &X86Subtarget::initializeSubtargetDependencies(StringRef CPU,
|
||||
StringRef FS) {
|
||||
initializeEnvironment();
|
||||
@ -334,16 +294,16 @@ X86Subtarget::X86Subtarget(const std::string &TT, const std::string &CPU,
|
||||
unsigned StackAlignOverride)
|
||||
: X86GenSubtargetInfo(TT, CPU, FS), X86ProcFamily(Others),
|
||||
PICStyle(PICStyles::None), TargetTriple(TT),
|
||||
DL(computeDataLayout(TargetTriple)),
|
||||
StackAlignOverride(StackAlignOverride),
|
||||
In64BitMode(TargetTriple.getArch() == Triple::x86_64),
|
||||
In32BitMode(TargetTriple.getArch() == Triple::x86 &&
|
||||
TargetTriple.getEnvironment() != Triple::CODE16),
|
||||
In16BitMode(TargetTriple.getArch() == Triple::x86 &&
|
||||
TargetTriple.getEnvironment() == Triple::CODE16),
|
||||
TSInfo(DL), InstrInfo(initializeSubtargetDependencies(CPU, FS)),
|
||||
TLInfo(TM), FrameLowering(TargetFrameLowering::StackGrowsDown,
|
||||
getStackAlignment(), is64Bit() ? -8 : -4) {
|
||||
TSInfo(*TM.getDataLayout()),
|
||||
InstrInfo(initializeSubtargetDependencies(CPU, FS)), TLInfo(TM),
|
||||
FrameLowering(TargetFrameLowering::StackGrowsDown, getStackAlignment(),
|
||||
is64Bit() ? -8 : -4) {
|
||||
// Determine the PICStyle based on the target selected.
|
||||
if (TM.getRelocationModel() == Reloc::Static) {
|
||||
// Unless we're in PIC or DynamicNoPIC mode, set the PIC style to None.
|
||||
|
@ -242,8 +242,6 @@ protected:
|
||||
InstrItineraryData InstrItins;
|
||||
|
||||
private:
|
||||
// Calculates type size & alignment
|
||||
const DataLayout DL;
|
||||
|
||||
/// StackAlignOverride - Override the stack alignment.
|
||||
unsigned StackAlignOverride;
|
||||
@ -276,7 +274,6 @@ public:
|
||||
return &TLInfo;
|
||||
}
|
||||
const X86InstrInfo *getInstrInfo() const override { return &InstrInfo; }
|
||||
const DataLayout *getDataLayout() const override { return &DL; }
|
||||
const X86FrameLowering *getFrameLowering() const override {
|
||||
return &FrameLowering;
|
||||
}
|
||||
|
@ -47,6 +47,46 @@ static std::unique_ptr<TargetLoweringObjectFile> createTLOF(const Triple &TT) {
|
||||
llvm_unreachable("unknown subtarget type");
|
||||
}
|
||||
|
||||
static std::string computeDataLayout(const Triple &TT) {
|
||||
// X86 is little endian
|
||||
std::string Ret = "e";
|
||||
|
||||
Ret += DataLayout::getManglingComponent(TT);
|
||||
// X86 and x32 have 32 bit pointers.
|
||||
if ((TT.isArch64Bit() &&
|
||||
(TT.getEnvironment() == Triple::GNUX32 || TT.isOSNaCl())) ||
|
||||
!TT.isArch64Bit())
|
||||
Ret += "-p:32:32";
|
||||
|
||||
// Some ABIs align 64 bit integers and doubles to 64 bits, others to 32.
|
||||
if (TT.isArch64Bit() || TT.isOSWindows() || TT.isOSNaCl())
|
||||
Ret += "-i64:64";
|
||||
else
|
||||
Ret += "-f64:32:64";
|
||||
|
||||
// Some ABIs align long double to 128 bits, others to 32.
|
||||
if (TT.isOSNaCl())
|
||||
; // No f80
|
||||
else if (TT.isArch64Bit() || TT.isOSDarwin())
|
||||
Ret += "-f80:128";
|
||||
else
|
||||
Ret += "-f80:32";
|
||||
|
||||
// The registers can hold 8, 16, 32 or, in x86-64, 64 bits.
|
||||
if (TT.isArch64Bit())
|
||||
Ret += "-n8:16:32:64";
|
||||
else
|
||||
Ret += "-n8:16:32";
|
||||
|
||||
// The stack is aligned to 32 bits on some ABIs and 128 bits on others.
|
||||
if (!TT.isArch64Bit() && TT.isOSWindows())
|
||||
Ret += "-S32";
|
||||
else
|
||||
Ret += "-S128";
|
||||
|
||||
return Ret;
|
||||
}
|
||||
|
||||
/// X86TargetMachine ctor - Create an X86 target.
|
||||
///
|
||||
X86TargetMachine::X86TargetMachine(const Target &T, StringRef TT, StringRef CPU,
|
||||
@ -55,6 +95,7 @@ X86TargetMachine::X86TargetMachine(const Target &T, StringRef TT, StringRef CPU,
|
||||
CodeGenOpt::Level OL)
|
||||
: LLVMTargetMachine(T, TT, CPU, FS, Options, RM, CM, OL),
|
||||
TLOF(createTLOF(Triple(getTargetTriple()))),
|
||||
DL(computeDataLayout(Triple(TT))),
|
||||
Subtarget(TT, CPU, FS, *this, Options.StackAlignmentOverride) {
|
||||
// default to hard float ABI
|
||||
if (Options.FloatABIType == FloatABI::Default)
|
||||
|
@ -24,17 +24,18 @@ class StringRef;
|
||||
|
||||
class X86TargetMachine final : public LLVMTargetMachine {
|
||||
std::unique_ptr<TargetLoweringObjectFile> TLOF;
|
||||
X86Subtarget Subtarget;
|
||||
// Calculates type size & alignment
|
||||
const DataLayout DL;
|
||||
X86Subtarget Subtarget;
|
||||
|
||||
mutable StringMap<std::unique_ptr<X86Subtarget>> SubtargetMap;
|
||||
|
||||
public:
|
||||
X86TargetMachine(const Target &T, StringRef TT,
|
||||
StringRef CPU, StringRef FS, const TargetOptions &Options,
|
||||
Reloc::Model RM, CodeModel::Model CM,
|
||||
CodeGenOpt::Level OL);
|
||||
X86TargetMachine(const Target &T, StringRef TT, StringRef CPU, StringRef FS,
|
||||
const TargetOptions &Options, Reloc::Model RM,
|
||||
CodeModel::Model CM, CodeGenOpt::Level OL);
|
||||
~X86TargetMachine() override;
|
||||
|
||||
const DataLayout *getDataLayout() const override { return &DL; }
|
||||
const X86Subtarget *getSubtargetImpl() const override { return &Subtarget; }
|
||||
const X86Subtarget *getSubtargetImpl(const Function &F) const override;
|
||||
|
||||
|
@ -117,7 +117,7 @@ void XCoreAsmPrinter::EmitGlobalVariable(const GlobalVariable *GV) {
|
||||
EmitSpecialLLVMGlobal(GV))
|
||||
return;
|
||||
|
||||
const DataLayout *TD = TM.getSubtargetImpl()->getDataLayout();
|
||||
const DataLayout *TD = TM.getDataLayout();
|
||||
OutStreamer.SwitchSection(
|
||||
getObjFileLowering().SectionForGlobal(GV, *Mang, TM));
|
||||
|
||||
@ -209,7 +209,7 @@ printInlineJT(const MachineInstr *MI, int opNum, raw_ostream &O,
|
||||
|
||||
void XCoreAsmPrinter::printOperand(const MachineInstr *MI, int opNum,
|
||||
raw_ostream &O) {
|
||||
const DataLayout *DL = TM.getSubtargetImpl()->getDataLayout();
|
||||
const DataLayout *DL = TM.getDataLayout();
|
||||
const MachineOperand &MO = MI->getOperand(opNum);
|
||||
switch (MO.getType()) {
|
||||
case MachineOperand::MO_Register:
|
||||
|
@ -1924,7 +1924,7 @@ XCoreTargetLowering::isLegalAddressingMode(const AddrMode &AM,
|
||||
if (Ty->getTypeID() == Type::VoidTyID)
|
||||
return AM.Scale == 0 && isImmUs(AM.BaseOffs) && isImmUs4(AM.BaseOffs);
|
||||
|
||||
const DataLayout *TD = TM.getSubtargetImpl()->getDataLayout();
|
||||
const DataLayout *TD = TM.getDataLayout();
|
||||
unsigned Size = TD->getTypeAllocSize(Ty);
|
||||
if (AM.BaseGV) {
|
||||
return Size >= 4 && !AM.HasBaseReg && AM.Scale == 0 &&
|
||||
|
@ -27,6 +27,5 @@ void XCoreSubtarget::anchor() { }
|
||||
|
||||
XCoreSubtarget::XCoreSubtarget(const std::string &TT, const std::string &CPU,
|
||||
const std::string &FS, const TargetMachine &TM)
|
||||
: XCoreGenSubtargetInfo(TT, CPU, FS),
|
||||
DL("e-m:e-p:32:32-i1:8:32-i8:8:32-i16:16:32-i64:32-f64:32-a:0:32-n32"),
|
||||
InstrInfo(), FrameLowering(*this), TLInfo(TM), TSInfo(DL) {}
|
||||
: XCoreGenSubtargetInfo(TT, CPU, FS), InstrInfo(), FrameLowering(*this),
|
||||
TLInfo(TM), TSInfo(*TM.getDataLayout()) {}
|
||||
|
@ -31,7 +31,6 @@ class StringRef;
|
||||
|
||||
class XCoreSubtarget : public XCoreGenSubtargetInfo {
|
||||
virtual void anchor();
|
||||
const DataLayout DL; // Calculates type size & alignment
|
||||
XCoreInstrInfo InstrInfo;
|
||||
XCoreFrameLowering FrameLowering;
|
||||
XCoreTargetLowering TLInfo;
|
||||
@ -61,7 +60,6 @@ public:
|
||||
const TargetRegisterInfo *getRegisterInfo() const override {
|
||||
return &InstrInfo.getRegisterInfo();
|
||||
}
|
||||
const DataLayout *getDataLayout() const override { return &DL; }
|
||||
};
|
||||
} // End llvm namespace
|
||||
|
||||
|
@ -28,6 +28,7 @@ XCoreTargetMachine::XCoreTargetMachine(const Target &T, StringRef TT,
|
||||
CodeGenOpt::Level OL)
|
||||
: LLVMTargetMachine(T, TT, CPU, FS, Options, RM, CM, OL),
|
||||
TLOF(make_unique<XCoreTargetObjectFile>()),
|
||||
DL("e-m:e-p:32:32-i1:8:32-i8:8:32-i16:16:32-i64:32-f64:32-a:0:32-n32"),
|
||||
Subtarget(TT, CPU, FS, *this) {
|
||||
initAsmInfo();
|
||||
}
|
||||
|
@ -21,6 +21,7 @@ namespace llvm {
|
||||
|
||||
class XCoreTargetMachine : public LLVMTargetMachine {
|
||||
std::unique_ptr<TargetLoweringObjectFile> TLOF;
|
||||
const DataLayout DL; // Calculates type size & alignment
|
||||
XCoreSubtarget Subtarget;
|
||||
public:
|
||||
XCoreTargetMachine(const Target &T, StringRef TT,
|
||||
@ -29,6 +30,7 @@ public:
|
||||
CodeGenOpt::Level OL);
|
||||
~XCoreTargetMachine() override;
|
||||
|
||||
const DataLayout *getDataLayout() const override { return &DL; }
|
||||
const XCoreSubtarget *getSubtargetImpl() const override { return &Subtarget; }
|
||||
|
||||
// Pass Pipeline Configuration
|
||||
|
@ -146,8 +146,7 @@ SelectSectionForGlobal(const GlobalValue *GV, SectionKind Kind, Mangler &Mang,
|
||||
}
|
||||
Type *ObjType = GV->getType()->getPointerElementType();
|
||||
if (TM.getCodeModel() == CodeModel::Small || !ObjType->isSized() ||
|
||||
TM.getSubtargetImpl()->getDataLayout()->getTypeAllocSize(ObjType) <
|
||||
CodeModelLargeSize) {
|
||||
TM.getDataLayout()->getTypeAllocSize(ObjType) < CodeModelLargeSize) {
|
||||
if (Kind.isReadOnly()) return UseCPRel? ReadOnlySection
|
||||
: DataRelROSection;
|
||||
if (Kind.isBSS() || Kind.isCommon())return BSSSection;
|
||||
|
@ -304,7 +304,7 @@ static int compileModule(char **argv, LLVMContext &Context) {
|
||||
PM.add(new TargetLibraryInfoWrapperPass(TLII));
|
||||
|
||||
// Add the target data from the target machine, if it exists, or the module.
|
||||
if (const DataLayout *DL = Target->getSubtargetImpl()->getDataLayout())
|
||||
if (const DataLayout *DL = Target->getDataLayout())
|
||||
M->setDataLayout(DL);
|
||||
PM.add(new DataLayoutPass());
|
||||
|
||||
|
@ -182,14 +182,14 @@ void CallingConvEmitter::EmitAction(Record *Action,
|
||||
O << Size << ", ";
|
||||
else
|
||||
O << "\n" << IndentStr
|
||||
<< " State.getMachineFunction().getSubtarget().getDataLayout()"
|
||||
<< " State.getMachineFunction().getTarget().getDataLayout()"
|
||||
"->getTypeAllocSize(EVT(LocVT).getTypeForEVT(State.getContext())),"
|
||||
" ";
|
||||
if (Align)
|
||||
O << Align;
|
||||
else
|
||||
O << "\n" << IndentStr
|
||||
<< " State.getMachineFunction().getSubtarget().getDataLayout()"
|
||||
<< " State.getMachineFunction().getTarget().getDataLayout()"
|
||||
"->getABITypeAlignment(EVT(LocVT).getTypeForEVT(State.getContext()"
|
||||
"))";
|
||||
O << ");\n" << IndentStr
|
||||
|
Loading…
Reference in New Issue
Block a user