llvm.org GIT mirror llvm / 159a755
Move DataLayout from the PPCTargetMachine to the subtarget. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@210824 91177308-0d34-0410-b5e6-96231b3b80d8 Eric Christopher 5 years ago
4 changed file(s) with 46 addition(s) and 40 deletion(s). Raw diff Collapse all Expand all
3131 #define GET_SUBTARGETINFO_CTOR
3232 #include "PPCGenSubtargetInfo.inc"
3333
34 /// Return the datalayout string of a subtarget.
35 static std::string getDataLayoutString(const PPCSubtarget &ST) {
36 const Triple &T = ST.getTargetTriple();
37
38 std::string Ret;
39
40 // Most PPC* platforms are big endian, PPC64LE is little endian.
41 if (ST.isLittleEndian())
42 Ret = "e";
43 else
44 Ret = "E";
45
46 Ret += DataLayout::getManglingComponent(T);
47
48 // PPC32 has 32 bit pointers. The PS3 (OS Lv2) is a PPC64 machine with 32 bit
49 // pointers.
50 if (!ST.isPPC64() || T.getOS() == Triple::Lv2)
51 Ret += "-p:32:32";
52
53 // Note, the alignment values for f64 and i64 on ppc64 in Darwin
54 // documentation are wrong; these are correct (i.e. "what gcc does").
55 if (ST.isPPC64() || ST.isSVR4ABI())
56 Ret += "-i64:64";
57 else
58 Ret += "-f64:32:64";
59
60 // PPC64 has 32 and 64 bit registers, PPC32 has only 32 bit ones.
61 if (ST.isPPC64())
62 Ret += "-n32:64";
63 else
64 Ret += "-n32";
65
66 return Ret;
67 }
68
3469 PPCSubtarget &PPCSubtarget::initializeSubtargetDependencies(StringRef CPU,
3570 StringRef FS) {
3671 initializeEnvironment();
4378 CodeGenOpt::Level OptLevel)
4479 : PPCGenSubtargetInfo(TT, CPU, FS), IsPPC64(is64Bit), TargetTriple(TT),
4580 OptLevel(OptLevel),
46 FrameLowering(initializeSubtargetDependencies(CPU, FS)) {}
81 FrameLowering(initializeSubtargetDependencies(CPU, FS)),
82 DL(getDataLayoutString(*this)) {}
4783
4884 /// SetJITMode - This is called to inform the subtarget info that we are
4985 /// producing code for the JIT.
1515
1616 #include "PPCFrameLowering.h"
1717 #include "llvm/ADT/Triple.h"
18 #include "llvm/IR/DataLayout.h"
1819 #include "llvm/MC/MCInstrItineraries.h"
1920 #include "llvm/Target/TargetSubtargetInfo.h"
2021 #include
103104 CodeGenOpt::Level OptLevel;
104105
105106 PPCFrameLowering FrameLowering;
107 const DataLayout DL;
108
106109 public:
107110 /// This constructor initializes the data members to match that
108111 /// of the specified triple.
133136 const InstrItineraryData &getInstrItineraryData() const { return InstrItins; }
134137
135138 const PPCFrameLowering *getFrameLowering() const { return &FrameLowering; }
139 const DataLayout *getDataLayout() const { return &DL; }
136140
137141 /// initializeSubtargetDependencies - Initializes using a CPU and feature string
138142 /// so that we can use initializer lists for subtarget initialization.
3636 RegisterTargetMachine C(ThePPC64LETarget);
3737 }
3838
39 /// Return the datalayout string of a subtarget.
40 static std::string getDataLayoutString(const PPCSubtarget &ST) {
41 const Triple &T = ST.getTargetTriple();
42
43 std::string Ret;
44
45 // Most PPC* platforms are big endian, PPC64LE is little endian.
46 if (ST.isLittleEndian())
47 Ret = "e";
48 else
49 Ret = "E";
50
51 Ret += DataLayout::getManglingComponent(T);
52
53 // PPC32 has 32 bit pointers. The PS3 (OS Lv2) is a PPC64 machine with 32 bit
54 // pointers.
55 if (!ST.isPPC64() || T.getOS() == Triple::Lv2)
56 Ret += "-p:32:32";
57
58 // Note, the alignment values for f64 and i64 on ppc64 in Darwin
59 // documentation are wrong; these are correct (i.e. "what gcc does").
60 if (ST.isPPC64() || ST.isSVR4ABI())
61 Ret += "-i64:64";
62 else
63 Ret += "-f64:32:64";
64
65 // PPC64 has 32 and 64 bit registers, PPC32 has only 32 bit ones.
66 if (ST.isPPC64())
67 Ret += "-n32:64";
68 else
69 Ret += "-n32";
70
71 return Ret;
72 }
73
7439 PPCTargetMachine::PPCTargetMachine(const Target &T, StringRef TT, StringRef CPU,
7540 StringRef FS, const TargetOptions &Options,
7641 Reloc::Model RM, CodeModel::Model CM,
7742 CodeGenOpt::Level OL, bool is64Bit)
7843 : LLVMTargetMachine(T, TT, CPU, FS, Options, RM, CM, OL),
79 Subtarget(TT, CPU, FS, is64Bit, OL), DL(getDataLayoutString(Subtarget)),
80 InstrInfo(*this), JITInfo(*this, is64Bit), TLInfo(*this), TSInfo(*this) {
44 Subtarget(TT, CPU, FS, is64Bit, OL), InstrInfo(*this),
45 JITInfo(*this, is64Bit), TLInfo(*this), TSInfo(*this) {
8146 initAsmInfo();
8247 }
8348
2828 ///
2929 class PPCTargetMachine : public LLVMTargetMachine {
3030 PPCSubtarget Subtarget;
31 const DataLayout DL; // Calculates type size & alignment
3231 PPCInstrInfo InstrInfo;
3332 PPCJITInfo JITInfo;
3433 PPCTargetLowering TLInfo;
5554 return &InstrInfo.getRegisterInfo();
5655 }
5756
58 const DataLayout *getDataLayout() const override { return &DL; }
57 const DataLayout *getDataLayout() const override {
58 return getSubtargetImpl()->getDataLayout();
59 }
5960 const PPCSubtarget *getSubtargetImpl() const override { return &Subtarget; }
6061 const InstrItineraryData *getInstrItineraryData() const override {
6162 return &getSubtargetImpl()->getInstrItineraryData();