mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-07-23 14:25:07 +00:00
Fix the MASM asmprinter's lies. It does not want to emit code to .text/.data
it wants it emitted to _text/_data. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@28185 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -46,11 +46,11 @@ bool X86ATTAsmPrinter::runOnMachineFunction(MachineFunction &MF) {
|
|||||||
switch (F->getLinkage()) {
|
switch (F->getLinkage()) {
|
||||||
default: assert(0 && "Unknown linkage type!");
|
default: assert(0 && "Unknown linkage type!");
|
||||||
case Function::InternalLinkage: // Symbols default to internal.
|
case Function::InternalLinkage: // Symbols default to internal.
|
||||||
SwitchToTextSection(".text", F);
|
SwitchToTextSection(DefaultTextSection, F);
|
||||||
EmitAlignment(4, F); // FIXME: This should be parameterized somewhere.
|
EmitAlignment(4, F); // FIXME: This should be parameterized somewhere.
|
||||||
break;
|
break;
|
||||||
case Function::ExternalLinkage:
|
case Function::ExternalLinkage:
|
||||||
SwitchToTextSection(".text", F);
|
SwitchToTextSection(DefaultTextSection, F);
|
||||||
EmitAlignment(4, F); // FIXME: This should be parameterized somewhere.
|
EmitAlignment(4, F); // FIXME: This should be parameterized somewhere.
|
||||||
O << "\t.globl\t" << CurrentFnName << "\n";
|
O << "\t.globl\t" << CurrentFnName << "\n";
|
||||||
break;
|
break;
|
||||||
|
@@ -50,6 +50,8 @@ bool X86SharedAsmPrinter::doInitialization(Module &M) {
|
|||||||
|
|
||||||
forDarwin = false;
|
forDarwin = false;
|
||||||
PrivateGlobalPrefix = ".L";
|
PrivateGlobalPrefix = ".L";
|
||||||
|
DefaultTextSection = ".text";
|
||||||
|
DefaultDataSection = ".data";
|
||||||
|
|
||||||
switch (Subtarget->TargetType) {
|
switch (Subtarget->TargetType) {
|
||||||
case X86Subtarget::isDarwin:
|
case X86Subtarget::isDarwin:
|
||||||
@@ -119,7 +121,7 @@ bool X86SharedAsmPrinter::doFinalization(Module &M) {
|
|||||||
O << "\t.zerofill __DATA__, __common, " << name << ", "
|
O << "\t.zerofill __DATA__, __common, " << name << ", "
|
||||||
<< Size << ", " << Align;
|
<< Size << ", " << Align;
|
||||||
} else {
|
} else {
|
||||||
SwitchToDataSection(".data", I);
|
SwitchToDataSection(DefaultDataSection, I);
|
||||||
if (LCOMMDirective != NULL) {
|
if (LCOMMDirective != NULL) {
|
||||||
if (I->hasInternalLinkage()) {
|
if (I->hasInternalLinkage()) {
|
||||||
O << LCOMMDirective << name << "," << Size;
|
O << LCOMMDirective << name << "," << Size;
|
||||||
@@ -157,7 +159,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:
|
||||||
SwitchToDataSection(".data", I);
|
SwitchToDataSection(DefaultDataSection, I);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
assert(0 && "Unknown linkage type!");
|
assert(0 && "Unknown linkage type!");
|
||||||
|
@@ -70,6 +70,10 @@ struct X86SharedAsmPrinter : public AsmPrinter {
|
|||||||
|
|
||||||
bool forDarwin; // FIXME: eliminate.
|
bool forDarwin; // FIXME: eliminate.
|
||||||
|
|
||||||
|
const char *DefaultTextSection; // "_text" for MASM, ".text" for others.
|
||||||
|
const char *DefaultDataSection; // "_data" for MASM, ".data" for others.
|
||||||
|
|
||||||
|
|
||||||
// Necessary for Darwin to print out the apprioriate types of linker stubs
|
// Necessary for Darwin to print out the apprioriate types of linker stubs
|
||||||
std::set<std::string> FnStubs, GVStubs, LinkOnceStubs;
|
std::set<std::string> FnStubs, GVStubs, LinkOnceStubs;
|
||||||
|
|
||||||
|
@@ -37,7 +37,7 @@ bool X86IntelAsmPrinter::runOnMachineFunction(MachineFunction &MF) {
|
|||||||
EmitConstantPool(MF.getConstantPool());
|
EmitConstantPool(MF.getConstantPool());
|
||||||
|
|
||||||
// Print out labels for the function.
|
// Print out labels for the function.
|
||||||
SwitchToTextSection(".code", MF.getFunction());
|
SwitchToTextSection("_text", MF.getFunction());
|
||||||
EmitAlignment(4);
|
EmitAlignment(4);
|
||||||
if (MF.getFunction()->getLinkage() == GlobalValue::ExternalLinkage)
|
if (MF.getFunction()->getLinkage() == GlobalValue::ExternalLinkage)
|
||||||
O << "\tpublic " << CurrentFnName << "\n";
|
O << "\tpublic " << CurrentFnName << "\n";
|
||||||
@@ -303,6 +303,9 @@ bool X86IntelAsmPrinter::doInitialization(Module &M) {
|
|||||||
HasDotTypeDotSizeDirective = false;
|
HasDotTypeDotSizeDirective = false;
|
||||||
Mang->markCharUnacceptable('.');
|
Mang->markCharUnacceptable('.');
|
||||||
|
|
||||||
|
DefaultTextSection = "_text";
|
||||||
|
DefaultDataSection = "_data";
|
||||||
|
|
||||||
O << "\t.686\n\t.model flat\n\n";
|
O << "\t.686\n\t.model flat\n\n";
|
||||||
|
|
||||||
// Emit declarations for external functions.
|
// Emit declarations for external functions.
|
||||||
@@ -359,7 +362,7 @@ bool X86IntelAsmPrinter::doFinalization(Module &M) {
|
|||||||
O << "\tpublic " << name << "\n";
|
O << "\tpublic " << name << "\n";
|
||||||
// FALL THROUGH
|
// FALL THROUGH
|
||||||
case GlobalValue::InternalLinkage:
|
case GlobalValue::InternalLinkage:
|
||||||
SwitchToDataSection(".data", I);
|
SwitchToDataSection(DefaultDataSection, I);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
assert(0 && "Unknown linkage type!");
|
assert(0 && "Unknown linkage type!");
|
||||||
@@ -378,7 +381,8 @@ bool X86IntelAsmPrinter::doFinalization(Module &M) {
|
|||||||
|
|
||||||
// Bypass X86SharedAsmPrinter::doFinalization().
|
// Bypass X86SharedAsmPrinter::doFinalization().
|
||||||
AsmPrinter::doFinalization(M);
|
AsmPrinter::doFinalization(M);
|
||||||
SwitchToDataSection("", 0);
|
SwitchToDataSection("_data", 0);
|
||||||
|
O << "_data\tends\n";
|
||||||
O << "\tend\n";
|
O << "\tend\n";
|
||||||
return false; // success
|
return false; // success
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user