[llvm-commits] CVS: llvm/lib/Target/Sparc/SparcAsmPrinter.cpp SparcTargetMachine.cpp SparcTargetMachine.h
Owen Anderson
resistor at mac.com
Tue May 2 18:30:22 PDT 2006
Changes in directory llvm/lib/Target/Sparc:
SparcAsmPrinter.cpp updated: 1.59 -> 1.60
SparcTargetMachine.cpp updated: 1.44 -> 1.45
SparcTargetMachine.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 -7)
SparcAsmPrinter.cpp | 10 +++++-----
SparcTargetMachine.cpp | 3 ++-
SparcTargetMachine.h | 3 ++-
3 files changed, 9 insertions(+), 7 deletions(-)
Index: llvm/lib/Target/Sparc/SparcAsmPrinter.cpp
diff -u llvm/lib/Target/Sparc/SparcAsmPrinter.cpp:1.59 llvm/lib/Target/Sparc/SparcAsmPrinter.cpp:1.60
--- llvm/lib/Target/Sparc/SparcAsmPrinter.cpp:1.59 Tue May 2 00:37:32 2006
+++ llvm/lib/Target/Sparc/SparcAsmPrinter.cpp Tue May 2 20:29:57 2006
@@ -232,7 +232,7 @@
}
bool SparcAsmPrinter::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();
@@ -245,8 +245,8 @@
O << "\n\n";
std::string name = Mang->getValueName(I);
Constant *C = I->getInitializer();
- unsigned Size = TD.getTypeSize(C->getType());
- unsigned Align = TD.getTypeAlignment(C->getType());
+ unsigned Size = TD->getTypeSize(C->getType());
+ unsigned Align = TD->getTypeAlignment(C->getType());
if (C->isNullValue() &&
(I->hasLinkOnceLinkage() || I->hasInternalLinkage() ||
@@ -255,8 +255,8 @@
if (I->hasInternalLinkage())
O << "\t.local " << name << "\n";
- O << "\t.comm " << name << "," << TD.getTypeSize(C->getType())
- << "," << (unsigned)TD.getTypeAlignment(C->getType());
+ O << "\t.comm " << name << "," << TD->getTypeSize(C->getType())
+ << "," << (unsigned)TD->getTypeAlignment(C->getType());
O << "\t\t! ";
WriteAsOperand(O, I, true, true, &M);
O << "\n";
Index: llvm/lib/Target/Sparc/SparcTargetMachine.cpp
diff -u llvm/lib/Target/Sparc/SparcTargetMachine.cpp:1.44 llvm/lib/Target/Sparc/SparcTargetMachine.cpp:1.45
--- llvm/lib/Target/Sparc/SparcTargetMachine.cpp:1.44 Sat Apr 8 14:46:55 2006
+++ llvm/lib/Target/Sparc/SparcTargetMachine.cpp Tue May 2 20:29:57 2006
@@ -31,7 +31,8 @@
/// SparcTargetMachine ctor - Create an ILP32 architecture model
///
SparcTargetMachine::SparcTargetMachine(const Module &M, const std::string &FS)
- : TargetMachine("Sparc", false, 4, 4),
+ : TargetMachine("Sparc"),
+ DataLayout("Sparc", false, 4, 4),
Subtarget(M, FS), InstrInfo(Subtarget),
FrameInfo(TargetFrameInfo::StackGrowsDown, 8, 0) {
}
Index: llvm/lib/Target/Sparc/SparcTargetMachine.h
diff -u llvm/lib/Target/Sparc/SparcTargetMachine.h:1.12 llvm/lib/Target/Sparc/SparcTargetMachine.h:1.13
--- llvm/lib/Target/Sparc/SparcTargetMachine.h:1.12 Wed Mar 22 23:43:15 2006
+++ llvm/lib/Target/Sparc/SparcTargetMachine.h Tue May 2 20:29:57 2006
@@ -25,6 +25,7 @@
class Module;
class SparcTargetMachine : public TargetMachine {
+ const TargetData DataLayout; // Calculates type size & alignment
SparcSubtarget Subtarget;
SparcInstrInfo InstrInfo;
TargetFrameInfo FrameInfo;
@@ -37,7 +38,7 @@
virtual const MRegisterInfo *getRegisterInfo() const {
return &InstrInfo.getRegisterInfo();
}
-
+ virtual const TargetData *getTargetData() const { return &DataLayout; }
static unsigned getModuleMatchQuality(const Module &M);
virtual bool addPassesToEmitFile(PassManager &PM, std::ostream &Out,
More information about the llvm-commits
mailing list