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.
llvm-svn: 28074
diff --git a/llvm/lib/Target/CBackend/CTargetMachine.h b/llvm/lib/Target/CBackend/CTargetMachine.h
index f947f65..271a2bf 100644
--- a/llvm/lib/Target/CBackend/CTargetMachine.h
+++ b/llvm/lib/Target/CBackend/CTargetMachine.h
@@ -19,8 +19,11 @@
namespace llvm {
struct CTargetMachine : public TargetMachine {
+ const TargetData DataLayout; // Calculates type size & alignment
+
CTargetMachine(const Module &M, const std::string &FS)
- : TargetMachine("CBackend", M) {}
+ : TargetMachine("CBackend", M),
+ DataLayout("CBackend") {}
// This is the only thing that actually does anything here.
virtual bool addPassesToEmitFile(PassManager &PM, std::ostream &Out,
@@ -28,6 +31,8 @@
// This class always works, but shouldn't be the default in most cases.
static unsigned getModuleMatchQuality(const Module &M) { return 1; }
+
+ virtual const TargetData *getTargetData() const { return &DataLayout; }
};
} // End llvm namespace