[llvm-commits] CVS: llvm/lib/Target/Alpha/AlphaAsmPrinter.cpp AlphaTargetMachine.cpp AlphaTargetMachine.h
Owen Anderson
resistor at mac.com
Tue May 2 18:30:21 PDT 2006
Changes in directory llvm/lib/Target/Alpha:
AlphaAsmPrinter.cpp updated: 1.35 -> 1.36
AlphaTargetMachine.cpp updated: 1.23 -> 1.24
AlphaTargetMachine.h updated: 1.12 -> 1.13
---
Log message:
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: http://llvm.cs.uiuc.edu/PR759 .
---
Diffs of the changes: (+9 -6)
AlphaAsmPrinter.cpp | 8 ++++----
AlphaTargetMachine.cpp | 3 ++-
AlphaTargetMachine.h | 4 +++-
3 files changed, 9 insertions(+), 6 deletions(-)
Index: llvm/lib/Target/Alpha/AlphaAsmPrinter.cpp
diff -u llvm/lib/Target/Alpha/AlphaAsmPrinter.cpp:1.35 llvm/lib/Target/Alpha/AlphaAsmPrinter.cpp:1.36
--- llvm/lib/Target/Alpha/AlphaAsmPrinter.cpp:1.35 Tue May 2 00:37:32 2006
+++ llvm/lib/Target/Alpha/AlphaAsmPrinter.cpp Tue May 2 20:29:57 2006
@@ -221,7 +221,7 @@
}
bool AlphaAsmPrinter::doFinalization(Module &M) {
- const TargetData &TD = TM.getTargetData();
+ const TargetData *TD = TM.getTargetData();
for (Module::const_global_iterator I = M.global_begin(), E = M.global_end(); I != E; ++I)
if (I->hasInitializer()) { // External global require no code
@@ -232,8 +232,8 @@
O << "\n\n";
std::string name = Mang->getValueName(I);
Constant *C = I->getInitializer();
- unsigned Size = TD.getTypeSize(C->getType());
- // unsigned Align = TD.getTypeAlignmentShift(C->getType());
+ unsigned Size = TD->getTypeSize(C->getType());
+ // unsigned Align = TD->getTypeAlignmentShift(C->getType());
unsigned Align = getPreferredAlignmentLog(I);
if (C->isNullValue() &&
@@ -243,7 +243,7 @@
if (I->hasInternalLinkage())
O << "\t.local " << name << "\n";
- O << "\t.comm " << name << "," << TD.getTypeSize(C->getType())
+ O << "\t.comm " << name << "," << TD->getTypeSize(C->getType())
<< "," << (1 << Align)
<< "\n";
} else {
Index: llvm/lib/Target/Alpha/AlphaTargetMachine.cpp
diff -u llvm/lib/Target/Alpha/AlphaTargetMachine.cpp:1.23 llvm/lib/Target/Alpha/AlphaTargetMachine.cpp:1.24
--- llvm/lib/Target/Alpha/AlphaTargetMachine.cpp:1.23 Sat Apr 8 14:46:55 2006
+++ llvm/lib/Target/Alpha/AlphaTargetMachine.cpp Tue May 2 20:29:57 2006
@@ -54,7 +54,8 @@
}
AlphaTargetMachine::AlphaTargetMachine(const Module &M, const std::string &FS)
- : TargetMachine("alpha", true),
+ : TargetMachine("alpha"),
+ DataLayout("alpha", true),
FrameInfo(TargetFrameInfo::StackGrowsDown, 16, 0),
JITInfo(*this),
Subtarget(M, FS)
Index: llvm/lib/Target/Alpha/AlphaTargetMachine.h
diff -u llvm/lib/Target/Alpha/AlphaTargetMachine.h:1.12 llvm/lib/Target/Alpha/AlphaTargetMachine.h:1.13
--- llvm/lib/Target/Alpha/AlphaTargetMachine.h:1.12 Wed Mar 22 23:43:15 2006
+++ llvm/lib/Target/Alpha/AlphaTargetMachine.h Tue May 2 20:29:57 2006
@@ -26,11 +26,12 @@
class GlobalValue;
class AlphaTargetMachine : public TargetMachine {
+ const TargetData DataLayout; // Calculates type size & alignment
AlphaInstrInfo InstrInfo;
TargetFrameInfo FrameInfo;
AlphaJITInfo JITInfo;
AlphaSubtarget Subtarget;
-
+
public:
AlphaTargetMachine(const Module &M, const std::string &FS);
@@ -40,6 +41,7 @@
virtual const MRegisterInfo *getRegisterInfo() const {
return &InstrInfo.getRegisterInfo();
}
+ virtual const TargetData *getTargetData() const { return &DataLayout; }
virtual TargetJITInfo* getJITInfo() {
return &JITInfo;
}
More information about the llvm-commits
mailing list