[llvm-commits] CVS: llvm/lib/CodeGen/AsmPrinter.cpp DwarfWriter.cpp ELFWriter.cpp MachineFunction.cpp
Owen Anderson
resistor at mac.com
Tue May 2 18:30:21 PDT 2006
Changes in directory llvm/lib/CodeGen:
AsmPrinter.cpp updated: 1.65 -> 1.66
DwarfWriter.cpp updated: 1.57 -> 1.58
ELFWriter.cpp updated: 1.23 -> 1.24
MachineFunction.cpp updated: 1.89 -> 1.90
---
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: (+25 -25)
AsmPrinter.cpp | 32 ++++++++++++++++----------------
DwarfWriter.cpp | 4 ++--
ELFWriter.cpp | 8 ++++----
MachineFunction.cpp | 6 +++---
4 files changed, 25 insertions(+), 25 deletions(-)
Index: llvm/lib/CodeGen/AsmPrinter.cpp
diff -u llvm/lib/CodeGen/AsmPrinter.cpp:1.65 llvm/lib/CodeGen/AsmPrinter.cpp:1.66
--- llvm/lib/CodeGen/AsmPrinter.cpp:1.65 Tue May 2 12:36:46 2006
+++ llvm/lib/CodeGen/AsmPrinter.cpp Tue May 2 20:29:56 2006
@@ -144,7 +144,7 @@
void AsmPrinter::EmitConstantPool(MachineConstantPool *MCP) {
const std::vector<MachineConstantPoolEntry> &CP = MCP->getConstants();
if (CP.empty()) return;
- const TargetData &TD = TM.getTargetData();
+ const TargetData *TD = TM.getTargetData();
SwitchSection(ConstantPoolSection, 0);
EmitAlignment(MCP->getConstantPoolAlignment());
@@ -154,7 +154,7 @@
WriteTypeSymbolic(O, CP[i].Val->getType(), 0) << '\n';
EmitGlobalConstant(CP[i].Val);
if (i != e-1) {
- unsigned EntSize = TM.getTargetData().getTypeSize(CP[i].Val->getType());
+ unsigned EntSize = TM.getTargetData()->getTypeSize(CP[i].Val->getType());
unsigned ValEnd = CP[i].Offset + EntSize;
// Emit inter-object padding for alignment.
EmitZeros(CP[i+1].Offset-ValEnd);
@@ -168,7 +168,7 @@
void AsmPrinter::EmitJumpTableInfo(MachineJumpTableInfo *MJTI) {
const std::vector<MachineJumpTableEntry> &JT = MJTI->getJumpTables();
if (JT.empty()) return;
- const TargetData &TD = TM.getTargetData();
+ const TargetData *TD = TM.getTargetData();
// FIXME: someday we need to handle PIC jump tables
assert((TM.getRelocationModel() == Reloc::Static ||
@@ -176,7 +176,7 @@
"Unhandled relocation model emitting jump table information!");
SwitchSection(JumpTableSection, 0);
- EmitAlignment(Log2_32(TD.getPointerAlignment()));
+ EmitAlignment(Log2_32(TD->getPointerAlignment()));
for (unsigned i = 0, e = JT.size(); i != e; ++i) {
O << PrivateGlobalPrefix << "JTI" << getFunctionNumber() << '_' << i
<< ":\n";
@@ -242,7 +242,7 @@
/// specified global, returned in log form. This includes an explicitly
/// requested alignment (if the global has one).
unsigned AsmPrinter::getPreferredAlignmentLog(const GlobalVariable *GV) const {
- unsigned Alignment = TM.getTargetData().getTypeAlignmentShift(GV->getType());
+ unsigned Alignment = TM.getTargetData()->getTypeAlignmentShift(GV->getType());
if (GV->getAlignment() > (1U << Alignment))
Alignment = Log2_32(GV->getAlignment());
@@ -253,7 +253,7 @@
if (Alignment < 4) {
// If the global is not external, see if it is large. If so, give it a
// larger alignment.
- if (TM.getTargetData().getTypeSize(GV->getType()->getElementType()) > 128)
+ if (TM.getTargetData()->getTypeSize(GV->getType()->getElementType()) > 128)
Alignment = 4; // 16-byte alignment.
}
}
@@ -310,13 +310,13 @@
else
O << GlobalVarAddrPrefix << Mang->getValueName(GV) << GlobalVarAddrSuffix;
} else if (const ConstantExpr *CE = dyn_cast<ConstantExpr>(CV)) {
- const TargetData &TD = TM.getTargetData();
+ const TargetData *TD = TM.getTargetData();
switch(CE->getOpcode()) {
case Instruction::GetElementPtr: {
// generate a symbolic expression for the byte address
const Constant *ptrVal = CE->getOperand(0);
std::vector<Value*> idxVec(CE->op_begin()+1, CE->op_end());
- if (int64_t Offset = TD.getIndexedOffset(ptrVal->getType(), idxVec)) {
+ if (int64_t Offset = TD->getIndexedOffset(ptrVal->getType(), idxVec)) {
if (Offset)
O << "(";
EmitConstantValueOnly(ptrVal);
@@ -344,7 +344,7 @@
|| (isa<PointerType>(Ty)
&& (OpTy == Type::LongTy || OpTy == Type::ULongTy
|| OpTy == Type::IntTy || OpTy == Type::UIntTy))
- || (((TD.getTypeSize(Ty) >= TD.getTypeSize(OpTy))
+ || (((TD->getTypeSize(Ty) >= TD->getTypeSize(OpTy))
&& OpTy->isLosslesslyConvertibleTo(Ty))))
&& "FIXME: Don't yet support this kind of constant cast expr");
EmitConstantValueOnly(Op);
@@ -426,10 +426,10 @@
/// EmitGlobalConstant - Print a general LLVM constant to the .s file.
///
void AsmPrinter::EmitGlobalConstant(const Constant *CV) {
- const TargetData &TD = TM.getTargetData();
+ const TargetData *TD = TM.getTargetData();
if (CV->isNullValue() || isa<UndefValue>(CV)) {
- EmitZeros(TD.getTypeSize(CV->getType()));
+ EmitZeros(TD->getTypeSize(CV->getType()));
return;
} else if (const ConstantArray *CVA = dyn_cast<ConstantArray>(CV)) {
if (CVA->isString()) {
@@ -441,13 +441,13 @@
return;
} else if (const ConstantStruct *CVS = dyn_cast<ConstantStruct>(CV)) {
// Print the fields in successive locations. Pad to align if needed!
- const StructLayout *cvsLayout = TD.getStructLayout(CVS->getType());
+ const StructLayout *cvsLayout = TD->getStructLayout(CVS->getType());
uint64_t sizeSoFar = 0;
for (unsigned i = 0, e = CVS->getNumOperands(); i != e; ++i) {
const Constant* field = CVS->getOperand(i);
// Check if padding is needed and insert one or more 0s.
- uint64_t fieldSize = TD.getTypeSize(field->getType());
+ uint64_t fieldSize = TD->getTypeSize(field->getType());
uint64_t padSize = ((i == e-1? cvsLayout->StructSize
: cvsLayout->MemberOffsets[i+1])
- cvsLayout->MemberOffsets[i]) - fieldSize;
@@ -470,7 +470,7 @@
if (Data64bitsDirective)
O << Data64bitsDirective << DoubleToBits(Val) << "\t" << CommentString
<< " double value: " << Val << "\n";
- else if (TD.isBigEndian()) {
+ else if (TD->isBigEndian()) {
O << Data32bitsDirective << unsigned(DoubleToBits(Val) >> 32)
<< "\t" << CommentString << " double most significant word "
<< Val << "\n";
@@ -497,7 +497,7 @@
if (Data64bitsDirective)
O << Data64bitsDirective << Val << "\n";
- else if (TD.isBigEndian()) {
+ else if (TD->isBigEndian()) {
O << Data32bitsDirective << unsigned(Val >> 32)
<< "\t" << CommentString << " Double-word most significant word "
<< Val << "\n";
@@ -533,7 +533,7 @@
O << Data16bitsDirective;
break;
case Type::PointerTyID:
- if (TD.getPointerSize() == 8) {
+ if (TD->getPointerSize() == 8) {
O << Data64bitsDirective;
break;
}
Index: llvm/lib/CodeGen/DwarfWriter.cpp
diff -u llvm/lib/CodeGen/DwarfWriter.cpp:1.57 llvm/lib/CodeGen/DwarfWriter.cpp:1.58
--- llvm/lib/CodeGen/DwarfWriter.cpp:1.57 Mon Apr 10 18:09:19 2006
+++ llvm/lib/CodeGen/DwarfWriter.cpp Tue May 2 20:29:56 2006
@@ -1075,7 +1075,7 @@
if (Asm->Data64bitsDirective) {
O << Asm->Data64bitsDirective << "0x" << std::hex << Value << std::dec;
} else {
- if (TD.isBigEndian()) {
+ if (TD->isBigEndian()) {
EmitInt32(unsigned(Value >> 32)); O << "\n";
EmitInt32(unsigned(Value));
} else {
@@ -1361,7 +1361,7 @@
Offset -= FieldOffset;
// Maybe we need to work from the other end.
- if (TD.isLittleEndian()) Offset = FieldSize - (Offset + Size);
+ if (TD->isLittleEndian()) Offset = FieldSize - (Offset + Size);
Member->AddUInt(DW_AT_byte_size, 0, FieldSize >> 3);
Member->AddUInt(DW_AT_bit_size, 0, Size);
Index: llvm/lib/CodeGen/ELFWriter.cpp
diff -u llvm/lib/CodeGen/ELFWriter.cpp:1.23 llvm/lib/CodeGen/ELFWriter.cpp:1.24
--- llvm/lib/CodeGen/ELFWriter.cpp:1.23 Tue May 2 19:28:15 2006
+++ llvm/lib/CodeGen/ELFWriter.cpp Tue May 2 20:29:56 2006
@@ -158,8 +158,8 @@
e_machine = 0; // e_machine defaults to 'No Machine'
e_flags = 0; // e_flags defaults to 0, no flags.
- is64Bit = TM.getTargetData().getPointerSizeInBits() == 64;
- isLittleEndian = TM.getTargetData().isLittleEndian();
+ is64Bit = TM.getTargetData()->getPointerSizeInBits() == 64;
+ isLittleEndian = TM.getTargetData()->isLittleEndian();
// Create the machine code emitter object for this target.
MCE = new ELFCodeEmitter(*this);
@@ -233,8 +233,8 @@
}
const Type *GVType = (const Type*)GV->getType();
- unsigned Align = TM.getTargetData().getTypeAlignment(GVType);
- unsigned Size = TM.getTargetData().getTypeSize(GVType);
+ unsigned Align = TM.getTargetData()->getTypeAlignment(GVType);
+ unsigned Size = TM.getTargetData()->getTypeSize(GVType);
// If this global has a zero initializer, it is part of the .bss or common
// section.
Index: llvm/lib/CodeGen/MachineFunction.cpp
diff -u llvm/lib/CodeGen/MachineFunction.cpp:1.89 llvm/lib/CodeGen/MachineFunction.cpp:1.90
--- llvm/lib/CodeGen/MachineFunction.cpp:1.89 Sat Apr 22 18:52:35 2006
+++ llvm/lib/CodeGen/MachineFunction.cpp Tue May 2 20:29:56 2006
@@ -367,11 +367,11 @@
}
unsigned MachineJumpTableInfo::getEntrySize() const {
- return TD.getPointerSize();
+ return TD->getPointerSize();
}
unsigned MachineJumpTableInfo::getAlignment() const {
- return TD.getPointerAlignment();
+ return TD->getPointerAlignment();
}
void MachineJumpTableInfo::dump() const { print(std::cerr); }
@@ -400,7 +400,7 @@
unsigned Offset = 0;
if (!Constants.empty()) {
Offset = Constants.back().Offset;
- Offset += TD.getTypeSize(Constants.back().Val->getType());
+ Offset += TD->getTypeSize(Constants.back().Val->getType());
Offset = (Offset+AlignMask)&~AlignMask;
}
More information about the llvm-commits
mailing list