summaryrefslogtreecommitdiffstats
path: root/llvm/lib
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2005-11-21 07:26:04 +0000
committerChris Lattner <sabre@nondot.org>2005-11-21 07:26:04 +0000
commit2bccd73dbb1b1c82894b17e1e8c2f4c993b05215 (patch)
tree21f00c2abcaa10d472b9f006b8719a131c5f8b79 /llvm/lib
parent050bf2faf8d838d74562825c1b9266cd5c6f953d (diff)
downloadbcm5719-llvm-2bccd73dbb1b1c82894b17e1e8c2f4c993b05215.tar.gz
bcm5719-llvm-2bccd73dbb1b1c82894b17e1e8c2f4c993b05215.zip
Start using SwitchSection, allowing globals and functions to be emitted
to specific sections. Delete some dead functions copied from the X86 backend. llvm-svn: 24449
Diffstat (limited to 'llvm/lib')
-rw-r--r--llvm/lib/Target/IA64/IA64AsmPrinter.cpp46
1 files changed, 7 insertions, 39 deletions
diff --git a/llvm/lib/Target/IA64/IA64AsmPrinter.cpp b/llvm/lib/Target/IA64/IA64AsmPrinter.cpp
index 8f3c2581c3d..9d5f647539a 100644
--- a/llvm/lib/Target/IA64/IA64AsmPrinter.cpp
+++ b/llvm/lib/Target/IA64/IA64AsmPrinter.cpp
@@ -46,33 +46,6 @@ namespace {
};
}
-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 @@ void IA64SharedAsmPrinter::printConstantPool(MachineConstantPool *MCP) {
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 @@ void IA64SharedAsmPrinter::printConstantPool(MachineConstantPool *MCP) {
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 @@ bool IA64SharedAsmPrinter::doFinalization(Module &M) {
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 @@ bool IA64SharedAsmPrinter::doFinalization(Module &M) {
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 @@ bool IA64SharedAsmPrinter::doFinalization(Module &M) {
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 @@ bool IA64AsmPrinter::runOnMachineFunction(MachineFunction &MF) {
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 @@ void IA64AsmPrinter::printOp(const MachineOperand &MO,
/// MI to the current output stream.
///
void IA64AsmPrinter::printMachineInstruction(const MachineInstr *MI) {
-
++EmittedInsts;
// Call the autogenerated instruction printer routines.
OpenPOWER on IntegriCloud