[llvm-commits] CVS: llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp PPCTargetMachine.cpp PPCTargetMachine.h
Owen Anderson
resistor at mac.com
Tue May 2 18:30:21 PDT 2006
Changes in directory llvm/lib/Target/PowerPC:
PPCAsmPrinter.cpp updated: 1.166 -> 1.167
PPCTargetMachine.cpp updated: 1.88 -> 1.89
PPCTargetMachine.h updated: 1.18 -> 1.19
---
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: (+10 -7)
PPCAsmPrinter.cpp | 12 ++++++------
PPCTargetMachine.cpp | 3 ++-
PPCTargetMachine.h | 2 ++
3 files changed, 10 insertions(+), 7 deletions(-)
Index: llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp
diff -u llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp:1.166 llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp:1.167
--- llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp:1.166 Tue May 2 12:34:51 2006
+++ llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp Tue May 2 20:29:57 2006
@@ -582,7 +582,7 @@
}
bool DarwinAsmPrinter::doFinalization(Module &M) {
- const TargetData &TD = TM.getTargetData();
+ const TargetData *TD = TM.getTargetData();
// Print out module-level global variables here.
for (Module::const_global_iterator I = M.global_begin(), E = M.global_end();
@@ -595,7 +595,7 @@
std::string name = Mang->getValueName(I);
Constant *C = I->getInitializer();
- unsigned Size = TD.getTypeSize(C->getType());
+ unsigned Size = TD->getTypeSize(C->getType());
unsigned Align = getPreferredAlignmentLog(I);
if (C->isNullValue() && /* FIXME: Verify correct */
@@ -761,7 +761,7 @@
bool AIXAsmPrinter::doInitialization(Module &M) {
SwitchSection("", 0);
- const TargetData &TD = TM.getTargetData();
+ const TargetData *TD = TM.getTargetData();
O << "\t.machine \"ppc64\"\n"
<< "\t.toc\n"
@@ -810,7 +810,7 @@
}
bool AIXAsmPrinter::doFinalization(Module &M) {
- const TargetData &TD = TM.getTargetData();
+ const TargetData *TD = TM.getTargetData();
// Print out module-level global variables
for (Module::const_global_iterator I = M.global_begin(), E = M.global_end();
I != E; ++I) {
@@ -821,8 +821,8 @@
if (I->hasInternalLinkage()) {
O << "\t.lcomm " << Name << ",16,_global.bss_c";
} else {
- O << "\t.comm " << Name << "," << TD.getTypeSize(I->getType())
- << "," << Log2_32((unsigned)TD.getTypeAlignment(I->getType()));
+ O << "\t.comm " << Name << "," << TD->getTypeSize(I->getType())
+ << "," << Log2_32((unsigned)TD->getTypeAlignment(I->getType()));
}
O << "\t\t" << CommentString << " ";
WriteAsOperand(O, I, false, true, &M);
Index: llvm/lib/Target/PowerPC/PPCTargetMachine.cpp
diff -u llvm/lib/Target/PowerPC/PPCTargetMachine.cpp:1.88 llvm/lib/Target/PowerPC/PPCTargetMachine.cpp:1.89
--- llvm/lib/Target/PowerPC/PPCTargetMachine.cpp:1.88 Fri Apr 21 17:11:27 2006
+++ llvm/lib/Target/PowerPC/PPCTargetMachine.cpp Tue May 2 20:29:57 2006
@@ -58,7 +58,8 @@
}
PPCTargetMachine::PPCTargetMachine(const Module &M, const std::string &FS)
-: TargetMachine("PowerPC", false, 4, 4, 4, 4, 4, 4, 2, 1, 1),
+: TargetMachine("PowerPC"),
+ DataLayout("PowerPC", false, 4, 4, 4, 4, 4),
Subtarget(M, FS), FrameInfo(*this, false), JITInfo(*this),
TLInfo(*this), InstrItins(Subtarget.getInstrItineraryData()) {
if (TargetDefault == PPCTarget) {
Index: llvm/lib/Target/PowerPC/PPCTargetMachine.h
diff -u llvm/lib/Target/PowerPC/PPCTargetMachine.h:1.18 llvm/lib/Target/PowerPC/PPCTargetMachine.h:1.19
--- llvm/lib/Target/PowerPC/PPCTargetMachine.h:1.18 Wed Mar 22 23:43:15 2006
+++ llvm/lib/Target/PowerPC/PPCTargetMachine.h Tue May 2 20:29:57 2006
@@ -26,6 +26,7 @@
class GlobalValue;
class PPCTargetMachine : public TargetMachine {
+ const TargetData DataLayout; // Calculates type size & alignment
PPCInstrInfo InstrInfo;
PPCSubtarget Subtarget;
PPCFrameInfo FrameInfo;
@@ -43,6 +44,7 @@
virtual const MRegisterInfo *getRegisterInfo() const {
return &InstrInfo.getRegisterInfo();
}
+ virtual const TargetData *getTargetData() const { return &DataLayout; }
virtual const InstrItineraryData getInstrItineraryData() const {
return InstrItins;
}
More information about the llvm-commits
mailing list