[llvm-commits] CVS: llvm/lib/Target/IA64/IA64AsmPrinter.cpp
Chris Lattner
lattner at cs.uiuc.edu
Sun Nov 20 23:26:16 PST 2005
Changes in directory llvm/lib/Target/IA64:
IA64AsmPrinter.cpp updated: 1.15 -> 1.16
---
Log message:
Start using SwitchSection, allowing globals and functions to be emitted
to specific sections. Delete some dead functions copied from the X86 backend.
---
Diffs of the changes: (+7 -39)
IA64AsmPrinter.cpp | 46 +++++++---------------------------------------
1 files changed, 7 insertions(+), 39 deletions(-)
Index: llvm/lib/Target/IA64/IA64AsmPrinter.cpp
diff -u llvm/lib/Target/IA64/IA64AsmPrinter.cpp:1.15 llvm/lib/Target/IA64/IA64AsmPrinter.cpp:1.16
--- llvm/lib/Target/IA64/IA64AsmPrinter.cpp:1.15 Mon Nov 21 00:55:27 2005
+++ llvm/lib/Target/IA64/IA64AsmPrinter.cpp Mon Nov 21 01:26:04 2005
@@ -46,33 +46,6 @@
};
}
-static bool isScale(const MachineOperand &MO) {
- return MO.isImmediate() &&
- (MO.getImmedValue() == 1 || MO.getImmedValue() == 2 ||
- MO.getImmedValue() == 4 || MO.getImmedValue() == 8);
-}
-
-static bool isMem(const MachineInstr *MI, unsigned Op) {
- if (MI->getOperand(Op).isFrameIndex()) return true;
- if (MI->getOperand(Op).isConstantPoolIndex()) return true;
- return Op+4 <= MI->getNumOperands() &&
- MI->getOperand(Op ).isRegister() && isScale(MI->getOperand(Op+1)) &&
- MI->getOperand(Op+2).isRegister() && (MI->getOperand(Op+3).isImmediate() ||
- MI->getOperand(Op+3).isGlobalAddress());
-}
-
-// switchSection - Switch to the specified section of the executable if we are
-// not already in it!
-//
-static void switchSection(std::ostream &OS, std::string &CurSection,
- const char *NewSection) {
- if (CurSection != NewSection) {
- CurSection = NewSection;
- if (!CurSection.empty())
- OS << "\t" << NewSection << "\n";
- }
-}
-
/// printConstantPool - Print to the current output stream assembly
/// representations of the constants in the constant pool MCP. This is
/// used to print out constants which have been "spilled to memory" by
@@ -84,8 +57,8 @@
if (CP.empty()) return;
- O << "\n\t.section .data, \"aw\", \"progbits\"\n";
- // FIXME: would be nice to have rodata (no 'w') when appropriate?
+ // FIXME: would be nice to have rodata (no 'w') when appropriate?
+ SwitchSection("\n\t.section .data, \"aw\", \"progbits\"\n", 0);
for (unsigned i = 0, e = CP.size(); i != e; ++i) {
emitAlignment(TD.getTypeAlignmentShift(CP[i]->getType()));
O << PrivateGlobalPrefix << "CPI" << CurrentFnName << "_" << i
@@ -96,7 +69,6 @@
bool IA64SharedAsmPrinter::doFinalization(Module &M) {
const TargetData &TD = TM.getTargetData();
- std::string CurSection;
// Print out module-level global variables here.
for (Module::const_global_iterator I = M.global_begin(), E = M.global_end();
@@ -111,7 +83,7 @@
if (C->isNullValue() &&
(I->hasLinkOnceLinkage() || I->hasInternalLinkage() ||
I->hasWeakLinkage() /* FIXME: Verify correct */)) {
- switchSection(O, CurSection, ".data");
+ SwitchSection(".data", I);
if (I->hasInternalLinkage()) {
O << "\t.lcomm " << name << "," << TD.getTypeSize(C->getType())
<< "," << (1 << Align);
@@ -129,9 +101,9 @@
case GlobalValue::WeakLinkage: // FIXME: Verify correct for weak.
// Nonnull linkonce -> weak
O << "\t.weak " << name << "\n";
- switchSection(O, CurSection, "");
O << "\t.section\t.llvm.linkonce.d." << name
<< ", \"aw\", \"progbits\"\n";
+ SwitchSection("", I);
break;
case GlobalValue::AppendingLinkage:
// FIXME: appending linkage variables should go into a section of
@@ -141,10 +113,7 @@
O << "\t.global " << name << "\n";
// FALL THROUGH
case GlobalValue::InternalLinkage:
- if (C->isNullValue())
- switchSection(O, CurSection, ".bss");
- else
- switchSection(O, CurSection, ".data");
+ SwitchSection(C->isNullValue() ? ".bss" : ".data", I);
break;
case GlobalValue::GhostLinkage:
std::cerr << "GhostLinkage cannot appear in IA64AsmPrinter!\n";
@@ -298,8 +267,8 @@
printConstantPool(MF.getConstantPool());
// Print out labels for the function.
- O << "\n\t.section .text, \"ax\", \"progbits\"\n";
- // ^^ means "Allocated instruXions in mem, initialized"
+ SwitchSection("\n\t.section .text, \"ax\", \"progbits\"\n", MF.getFunction());
+ // ^^ means "Allocated instruXions in mem, initialized"
emitAlignment(5);
O << "\t.global\t" << CurrentFnName << "\n";
O << "\t.type\t" << CurrentFnName << ", @function\n";
@@ -413,7 +382,6 @@
/// MI to the current output stream.
///
void IA64AsmPrinter::printMachineInstruction(const MachineInstr *MI) {
-
++EmittedInsts;
// Call the autogenerated instruction printer routines.
More information about the llvm-commits
mailing list