mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-07-27 12:26:08 +00:00
Start using the AsmPrinter shared SwitchSection code. This allows the X86
backend to implement global variables in sections. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@24447 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -105,7 +105,6 @@ void X86SharedAsmPrinter::printConstantPool(MachineConstantPool *MCP) {
|
|||||||
|
|
||||||
bool X86SharedAsmPrinter::doFinalization(Module &M) {
|
bool X86SharedAsmPrinter::doFinalization(Module &M) {
|
||||||
const TargetData &TD = TM.getTargetData();
|
const TargetData &TD = TM.getTargetData();
|
||||||
std::string CurSection;
|
|
||||||
|
|
||||||
// Print out module-level global variables here.
|
// Print out module-level global variables here.
|
||||||
for (Module::const_global_iterator I = M.global_begin(),
|
for (Module::const_global_iterator I = M.global_begin(),
|
||||||
@@ -120,7 +119,7 @@ bool X86SharedAsmPrinter::doFinalization(Module &M) {
|
|||||||
if (C->isNullValue() &&
|
if (C->isNullValue() &&
|
||||||
(I->hasLinkOnceLinkage() || I->hasInternalLinkage() ||
|
(I->hasLinkOnceLinkage() || I->hasInternalLinkage() ||
|
||||||
I->hasWeakLinkage() /* FIXME: Verify correct */)) {
|
I->hasWeakLinkage() /* FIXME: Verify correct */)) {
|
||||||
switchSection(O, CurSection, ".data");
|
SwitchSection(".data", I);
|
||||||
if (!forCygwin && !forDarwin && I->hasInternalLinkage())
|
if (!forCygwin && !forDarwin && I->hasInternalLinkage())
|
||||||
O << "\t.local " << name << "\n";
|
O << "\t.local " << name << "\n";
|
||||||
if (forDarwin && I->hasInternalLinkage())
|
if (forDarwin && I->hasInternalLinkage())
|
||||||
@@ -139,8 +138,8 @@ bool X86SharedAsmPrinter::doFinalization(Module &M) {
|
|||||||
case GlobalValue::WeakLinkage: // FIXME: Verify correct for weak.
|
case GlobalValue::WeakLinkage: // FIXME: Verify correct for weak.
|
||||||
// Nonnull linkonce -> weak
|
// Nonnull linkonce -> weak
|
||||||
O << "\t.weak " << name << "\n";
|
O << "\t.weak " << name << "\n";
|
||||||
switchSection(O, CurSection, "");
|
|
||||||
O << "\t.section\t.llvm.linkonce.d." << name << ",\"aw\",@progbits\n";
|
O << "\t.section\t.llvm.linkonce.d." << name << ",\"aw\",@progbits\n";
|
||||||
|
SwitchSection("", I);
|
||||||
break;
|
break;
|
||||||
case GlobalValue::AppendingLinkage:
|
case GlobalValue::AppendingLinkage:
|
||||||
// FIXME: appending linkage variables should go into a section of
|
// FIXME: appending linkage variables should go into a section of
|
||||||
@@ -150,10 +149,7 @@ bool X86SharedAsmPrinter::doFinalization(Module &M) {
|
|||||||
O << "\t.globl " << name << "\n";
|
O << "\t.globl " << name << "\n";
|
||||||
// FALL THROUGH
|
// FALL THROUGH
|
||||||
case GlobalValue::InternalLinkage:
|
case GlobalValue::InternalLinkage:
|
||||||
if (C->isNullValue())
|
SwitchSection(C->isNullValue() ? ".bss" : ".data", I);
|
||||||
switchSection(O, CurSection, ".bss");
|
|
||||||
else
|
|
||||||
switchSection(O, CurSection, ".data");
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -55,17 +55,6 @@ struct X86SharedAsmPrinter : public AsmPrinter {
|
|||||||
MI->getOperand(Op+2).isRegister() && (MI->getOperand(Op+3).isImmediate()||
|
MI->getOperand(Op+2).isRegister() && (MI->getOperand(Op+3).isImmediate()||
|
||||||
MI->getOperand(Op+3).isGlobalAddress());
|
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
|
} // end namespace x86
|
||||||
|
Reference in New Issue
Block a user