summaryrefslogtreecommitdiff
path: root/include/llvm
diff options
context:
space:
mode:
authorOwen Anderson <resistor@mac.com>2006-05-03 01:29:57 +0000
committerOwen Anderson <resistor@mac.com>2006-05-03 01:29:57 +0000
commita69571c7991813c93cba64e88eced6899ce93d81 (patch)
tree06bc81338c35527b69a6e8e7434e7c1a824bc4ca /include/llvm
parent0eb4d6b52e1b5db9a4c86e5a954356ae3507a287 (diff)
downloadllvm-a69571c7991813c93cba64e88eced6899ce93d81.tar.gz
llvm-a69571c7991813c93cba64e88eced6899ce93d81.tar.bz2
llvm-a69571c7991813c93cba64e88eced6899ce93d81.tar.xz
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/llvm')
-rw-r--r--include/llvm/CodeGen/DwarfWriter.h2
-rw-r--r--include/llvm/CodeGen/MachineConstantPool.h4
-rw-r--r--include/llvm/CodeGen/MachineJumpTableInfo.h4
-rw-r--r--include/llvm/ExecutionEngine/ExecutionEngine.h6
-rw-r--r--include/llvm/Target/TargetData.h22
-rw-r--r--include/llvm/Target/TargetLowering.h4
-rw-r--r--include/llvm/Target/TargetMachine.h12
7 files changed, 23 insertions, 31 deletions
diff --git a/include/llvm/CodeGen/DwarfWriter.h b/include/llvm/CodeGen/DwarfWriter.h
index e5882777db..c08cf4ebec 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 bb88a86d15..bccb1467a4 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 2cb268ad53..c0f4af34c2 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 051d839628..0974915154 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 1f031f2cc9..32f0572546 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 0a3fb03ece..1b4960e686 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 dd30861b99..31f5f3c913 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