diff options
author | Owen Anderson <resistor@mac.com> | 2006-05-03 01:29:57 +0000 |
---|---|---|
committer | Owen Anderson <resistor@mac.com> | 2006-05-03 01:29:57 +0000 |
commit | a69571c7991813c93cba64e88eced6899ce93d81 (patch) | |
tree | 06bc81338c35527b69a6e8e7434e7c1a824bc4ca /include | |
parent | 0eb4d6b52e1b5db9a4c86e5a954356ae3507a287 (diff) | |
download | external_llvm-a69571c7991813c93cba64e88eced6899ce93d81.zip external_llvm-a69571c7991813c93cba64e88eced6899ce93d81.tar.gz external_llvm-a69571c7991813c93cba64e88eced6899ce93d81.tar.bz2 |
Refactor TargetMachine, pushing handling of TargetData into the target-specific subclasses. This has one caller-visible change: getTargetData() now returns a pointer instead of a reference.
This fixes PR 759.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@28074 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include')
-rw-r--r-- | include/llvm/CodeGen/DwarfWriter.h | 2 | ||||
-rw-r--r-- | include/llvm/CodeGen/MachineConstantPool.h | 4 | ||||
-rw-r--r-- | include/llvm/CodeGen/MachineJumpTableInfo.h | 4 | ||||
-rw-r--r-- | include/llvm/ExecutionEngine/ExecutionEngine.h | 6 | ||||
-rw-r--r-- | include/llvm/Target/TargetData.h | 22 | ||||
-rw-r--r-- | include/llvm/Target/TargetLowering.h | 4 | ||||
-rw-r--r-- | include/llvm/Target/TargetMachine.h | 12 |
7 files changed, 23 insertions, 31 deletions
diff --git a/include/llvm/CodeGen/DwarfWriter.h b/include/llvm/CodeGen/DwarfWriter.h index e588277..c08cf4e 100644 --- a/include/llvm/CodeGen/DwarfWriter.h +++ b/include/llvm/CodeGen/DwarfWriter.h @@ -85,7 +85,7 @@ protected: AsmPrinter *Asm; /// TD - Target data. - const TargetData &TD; + const TargetData *TD; /// RI - Register Information. const MRegisterInfo *RI; diff --git a/include/llvm/CodeGen/MachineConstantPool.h b/include/llvm/CodeGen/MachineConstantPool.h index bb88a86..bccb146 100644 --- a/include/llvm/CodeGen/MachineConstantPool.h +++ b/include/llvm/CodeGen/MachineConstantPool.h @@ -42,11 +42,11 @@ struct MachineConstantPoolEntry { }; class MachineConstantPool { - const TargetData &TD; + const TargetData *TD; unsigned PoolAlignment; std::vector<MachineConstantPoolEntry> Constants; public: - MachineConstantPool(const TargetData &td) : TD(td), PoolAlignment(1) {} + MachineConstantPool(const TargetData *td) : TD(td), PoolAlignment(1) {} /// getConstantPoolAlignment - Return the log2 of the alignment required by /// the whole constant pool, of which the first element must be aligned. diff --git a/include/llvm/CodeGen/MachineJumpTableInfo.h b/include/llvm/CodeGen/MachineJumpTableInfo.h index 2cb268a..c0f4af3 100644 --- a/include/llvm/CodeGen/MachineJumpTableInfo.h +++ b/include/llvm/CodeGen/MachineJumpTableInfo.h @@ -37,10 +37,10 @@ struct MachineJumpTableEntry { }; class MachineJumpTableInfo { - const TargetData &TD; + const TargetData *TD; std::vector<MachineJumpTableEntry> JumpTables; public: - MachineJumpTableInfo(const TargetData &td) : TD(td) {} + MachineJumpTableInfo(const TargetData *td) : TD(td) {} /// getJumpTableIndex - Create a new jump table or return an existing one. /// diff --git a/include/llvm/ExecutionEngine/ExecutionEngine.h b/include/llvm/ExecutionEngine/ExecutionEngine.h index 051d839..0974915 100644 --- a/include/llvm/ExecutionEngine/ExecutionEngine.h +++ b/include/llvm/ExecutionEngine/ExecutionEngine.h @@ -67,8 +67,8 @@ class ExecutionEngine { protected: ModuleProvider *MP; - void setTargetData(const TargetData &td) { - TD = &td; + void setTargetData(const TargetData *td) { + TD = td; } // To avoid having libexecutionengine depend on the JIT and interpreter @@ -88,7 +88,7 @@ public: virtual ~ExecutionEngine(); Module &getModule() const { return CurMod; } - const TargetData &getTargetData() const { return *TD; } + const TargetData *getTargetData() const { return TD; } /// create - This is the factory method for creating an execution engine which /// is appropriate for the current machine. diff --git a/include/llvm/Target/TargetData.h b/include/llvm/Target/TargetData.h index 1f031f2..32f0572 100644 --- a/include/llvm/Target/TargetData.h +++ b/include/llvm/Target/TargetData.h @@ -54,18 +54,18 @@ public: unsigned char ByteAl = 1, unsigned char BoolAl = 1); // Copy constructor - TargetData (const TargetData &TD) : + TargetData (const TargetData *TD) : ImmutablePass(), - LittleEndian(TD.isLittleEndian()), - BoolAlignment(TD.getBoolAlignment()), - ByteAlignment(TD.getByteAlignment()), - ShortAlignment(TD.getShortAlignment()), - IntAlignment(TD.getIntAlignment()), - LongAlignment(TD.getLongAlignment()), - FloatAlignment(TD.getFloatAlignment()), - DoubleAlignment(TD.getDoubleAlignment()), - PointerSize(TD.getPointerSize()), - PointerAlignment(TD.getPointerAlignment()) { + LittleEndian(TD->isLittleEndian()), + BoolAlignment(TD->getBoolAlignment()), + ByteAlignment(TD->getByteAlignment()), + ShortAlignment(TD->getShortAlignment()), + IntAlignment(TD->getIntAlignment()), + LongAlignment(TD->getLongAlignment()), + FloatAlignment(TD->getFloatAlignment()), + DoubleAlignment(TD->getDoubleAlignment()), + PointerSize(TD->getPointerSize()), + PointerAlignment(TD->getPointerAlignment()) { } TargetData(const std::string &ToolName, const Module *M); diff --git a/include/llvm/Target/TargetLowering.h b/include/llvm/Target/TargetLowering.h index 0a3fb03..1b4960e 100644 --- a/include/llvm/Target/TargetLowering.h +++ b/include/llvm/Target/TargetLowering.h @@ -78,7 +78,7 @@ public: virtual ~TargetLowering(); TargetMachine &getTargetMachine() const { return TM; } - const TargetData &getTargetData() const { return TD; } + const TargetData *getTargetData() const { return TD; } bool isLittleEndian() const { return IsLittleEndian; } MVT::ValueType getPointerTy() const { return PointerTy; } @@ -648,7 +648,7 @@ private: std::vector<unsigned> LegalAddressScales; TargetMachine &TM; - const TargetData &TD; + const TargetData *TD; /// IsLittleEndian - True if this is a little endian target. /// diff --git a/include/llvm/Target/TargetMachine.h b/include/llvm/Target/TargetMachine.h index dd30861..31f5f3c 100644 --- a/include/llvm/Target/TargetMachine.h +++ b/include/llvm/Target/TargetMachine.h @@ -50,19 +50,11 @@ namespace Reloc { /// class TargetMachine { const std::string Name; - const TargetData DataLayout; // Calculates type size & alignment TargetMachine(const TargetMachine&); // DO NOT IMPLEMENT void operator=(const TargetMachine&); // DO NOT IMPLEMENT protected: // Can only create subclasses... - TargetMachine(const std::string &name, bool LittleEndian = false, - unsigned char PtrSize = 8, unsigned char PtrAl = 8, - unsigned char DoubleAl = 8, unsigned char FloatAl = 4, - unsigned char LongAl = 8, unsigned char IntAl = 4, - unsigned char ShortAl = 2, unsigned char ByteAl = 1, - unsigned char BoolAl = 1); - - TargetMachine(const std::string &name, const TargetData &TD); + TargetMachine(const std::string &name) : Name(name) { }; /// This constructor is used for targets that support arbitrary TargetData /// layouts, like the C backend. It initializes the TargetData to match that @@ -101,7 +93,7 @@ public: virtual const TargetInstrInfo *getInstrInfo() const { return 0; } virtual const TargetFrameInfo *getFrameInfo() const { return 0; } virtual TargetLowering *getTargetLowering() const { return 0; } - const TargetData &getTargetData() const { return DataLayout; } + virtual const TargetData *getTargetData() const { return 0; } /// getSubtarget - This method returns a pointer to the specified type of /// TargetSubtarget. In debug builds, it verifies that the object being |