diff options
author | Eric Christopher <echristo@gmail.com> | 2015-01-26 19:03:15 +0000 |
---|---|---|
committer | Eric Christopher <echristo@gmail.com> | 2015-01-26 19:03:15 +0000 |
commit | 8b7706517cbdbf1f17481884227a6d3e0df57f13 (patch) | |
tree | c28d4d5cfb9a6d6ffe4fa9f48a7c8ebfb600b639 /llvm/lib/Target/PowerPC/PPCTargetMachine.cpp | |
parent | a7ad6a589c30bf316b2e0e9456f521de12d7a679 (diff) | |
download | bcm5719-llvm-8b7706517cbdbf1f17481884227a6d3e0df57f13.tar.gz bcm5719-llvm-8b7706517cbdbf1f17481884227a6d3e0df57f13.zip |
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
Diffstat (limited to 'llvm/lib/Target/PowerPC/PPCTargetMachine.cpp')
-rw-r--r-- | llvm/lib/Target/PowerPC/PPCTargetMachine.cpp | 37 |
1 files changed, 35 insertions, 2 deletions
diff --git a/llvm/lib/Target/PowerPC/PPCTargetMachine.cpp b/llvm/lib/Target/PowerPC/PPCTargetMachine.cpp index 31df9a5e56c..aa6f991ce73 100644 --- a/llvm/lib/Target/PowerPC/PPCTargetMachine.cpp +++ b/llvm/lib/Target/PowerPC/PPCTargetMachine.cpp @@ -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)); } - |