bool X86SharedAsmPrinter::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(),
if (C->isNullValue() &&
(I->hasLinkOnceLinkage() || I->hasInternalLinkage() ||
I->hasWeakLinkage() /* FIXME: Verify correct */)) {
- switchSection(O, CurSection, ".data");
+ SwitchSection(".data", I);
if (!forCygwin && !forDarwin && I->hasInternalLinkage())
O << "\t.local " << name << "\n";
if (forDarwin && I->hasInternalLinkage())
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
O << "\t.globl " << 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;
}
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!
- inline static void switchSection(std::ostream &OS, std::string &CurSection,
- const char *NewSection) {
- if (CurSection != NewSection) {
- CurSection = NewSection;
- if (!CurSection.empty())
- OS << "\t" << NewSection << "\n";
- }
- }
};
} // end namespace x86