mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2025-02-04 03:06:28 +00:00
Implement MASM sections correctly, without a "has masm sections flag" and a bunch of special case code.
llvm-svn: 28194
This commit is contained in:
parent
9669e5ece6
commit
b7152b0b42
@ -47,7 +47,9 @@ AsmPrinter::AsmPrinter(std::ostream &o, TargetMachine &tm)
|
|||||||
AlignDirective("\t.align\t"),
|
AlignDirective("\t.align\t"),
|
||||||
AlignmentIsInBytes(true),
|
AlignmentIsInBytes(true),
|
||||||
SwitchToSectionDirective("\t.section\t"),
|
SwitchToSectionDirective("\t.section\t"),
|
||||||
MLSections(false),
|
TextSectionStartSuffix(""),
|
||||||
|
DataSectionStartSuffix(""),
|
||||||
|
SectionEndDirectiveSuffix(0),
|
||||||
ConstantPoolSection("\t.section .rodata\n"),
|
ConstantPoolSection("\t.section .rodata\n"),
|
||||||
JumpTableSection("\t.section .rodata\n"),
|
JumpTableSection("\t.section .rodata\n"),
|
||||||
StaticCtorsSection("\t.section .ctors,\"aw\",@progbits"),
|
StaticCtorsSection("\t.section .ctors,\"aw\",@progbits"),
|
||||||
@ -73,20 +75,14 @@ void AsmPrinter::SwitchToTextSection(const char *NewSection,
|
|||||||
// If we're already in this section, we're done.
|
// If we're already in this section, we're done.
|
||||||
if (CurrentSection == NS) return;
|
if (CurrentSection == NS) return;
|
||||||
|
|
||||||
// Microsoft ML/MASM has a fundamentally different approach to handling
|
// Close the current section, if applicable.
|
||||||
// sections.
|
if (SectionEndDirectiveSuffix && !CurrentSection.empty())
|
||||||
|
O << CurrentSection << SectionEndDirectiveSuffix << "\n";
|
||||||
|
|
||||||
if (MLSections) {
|
CurrentSection = NS;
|
||||||
if (!CurrentSection.empty())
|
|
||||||
O << CurrentSection << "\tends\n\n";
|
if (!CurrentSection.empty())
|
||||||
CurrentSection = NS;
|
O << CurrentSection << TextSectionStartSuffix << '\n';
|
||||||
if (!CurrentSection.empty())
|
|
||||||
O << CurrentSection << "\tsegment 'CODE'\n";
|
|
||||||
} else {
|
|
||||||
CurrentSection = NS;
|
|
||||||
if (!CurrentSection.empty())
|
|
||||||
O << CurrentSection << '\n';
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// SwitchToTextSection - Switch to the specified text section of the executable
|
/// SwitchToTextSection - Switch to the specified text section of the executable
|
||||||
@ -103,20 +99,14 @@ void AsmPrinter::SwitchToDataSection(const char *NewSection,
|
|||||||
// If we're already in this section, we're done.
|
// If we're already in this section, we're done.
|
||||||
if (CurrentSection == NS) return;
|
if (CurrentSection == NS) return;
|
||||||
|
|
||||||
// Microsoft ML/MASM has a fundamentally different approach to handling
|
// Close the current section, if applicable.
|
||||||
// sections.
|
if (SectionEndDirectiveSuffix && !CurrentSection.empty())
|
||||||
|
O << CurrentSection << SectionEndDirectiveSuffix << "\n";
|
||||||
|
|
||||||
|
CurrentSection = NS;
|
||||||
|
|
||||||
if (MLSections) {
|
if (!CurrentSection.empty())
|
||||||
if (!CurrentSection.empty())
|
O << CurrentSection << DataSectionStartSuffix << '\n';
|
||||||
O << CurrentSection << "\tends\n\n";
|
|
||||||
CurrentSection = NS;
|
|
||||||
if (!CurrentSection.empty())
|
|
||||||
O << CurrentSection << "\tsegment 'DATA'\n";
|
|
||||||
} else {
|
|
||||||
CurrentSection = NS;
|
|
||||||
if (!CurrentSection.empty())
|
|
||||||
O << CurrentSection << '\n';
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -284,7 +284,6 @@ void X86IntelAsmPrinter::printMachineInstruction(const MachineInstr *MI) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool X86IntelAsmPrinter::doInitialization(Module &M) {
|
bool X86IntelAsmPrinter::doInitialization(Module &M) {
|
||||||
MLSections = true;
|
|
||||||
GlobalPrefix = "_";
|
GlobalPrefix = "_";
|
||||||
CommentString = ";";
|
CommentString = ";";
|
||||||
|
|
||||||
@ -306,6 +305,9 @@ bool X86IntelAsmPrinter::doInitialization(Module &M) {
|
|||||||
DefaultTextSection = "_text";
|
DefaultTextSection = "_text";
|
||||||
DefaultDataSection = "_data";
|
DefaultDataSection = "_data";
|
||||||
SwitchToSectionDirective = "";
|
SwitchToSectionDirective = "";
|
||||||
|
TextSectionStartSuffix = "\tsegment 'CODE'";
|
||||||
|
DataSectionStartSuffix = "\tsegment 'DATA'";
|
||||||
|
SectionEndDirectiveSuffix = "\tends\n";
|
||||||
|
|
||||||
O << "\t.686\n\t.model flat\n\n";
|
O << "\t.686\n\t.model flat\n\n";
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user