move mangler quote handling from asm printers to TargetAsmInfo.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@73738 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Chris Lattner
2009-06-18 23:41:35 +00:00
parent 7e816dc175
commit a93ca92379
9 changed files with 39 additions and 38 deletions

View File

@@ -278,6 +278,10 @@ namespace llvm {
/// use '\1' as the first character. /// use '\1' as the first character.
const char *StringConstantPrefix; // Defaults to ".str" const char *StringConstantPrefix; // Defaults to ".str"
/// AllowQuotesInName - This is true if the assembler allows for complex
/// symbol names to be surrounded in quotes. This defaults to false.
bool AllowQuotesInName;
//===--- Data Emission Directives -------------------------------------===// //===--- Data Emission Directives -------------------------------------===//
/// ZeroDirective - this should be set to the directive used to get some /// ZeroDirective - this should be set to the directive used to get some
@@ -745,6 +749,9 @@ namespace llvm {
const char *getStringConstantPrefix() const { const char *getStringConstantPrefix() const {
return StringConstantPrefix; return StringConstantPrefix;
} }
bool doesAllowQuotesInName() const {
return AllowQuotesInName;
}
const char *getZeroDirective() const { const char *getZeroDirective() const {
return ZeroDirective; return ZeroDirective;
} }

View File

@@ -152,6 +152,9 @@ void AsmPrinter::getAnalysisUsage(AnalysisUsage &AU) const {
bool AsmPrinter::doInitialization(Module &M) { bool AsmPrinter::doInitialization(Module &M) {
Mang = new Mangler(M, TAI->getGlobalPrefix(), TAI->getPrivateGlobalPrefix()); Mang = new Mangler(M, TAI->getGlobalPrefix(), TAI->getPrivateGlobalPrefix());
if (TAI->doesAllowQuotesInName())
Mang->setUseQuotes(true);
GCModuleInfo *MI = getAnalysisIfAvailable<GCModuleInfo>(); GCModuleInfo *MI = getAnalysisIfAvailable<GCModuleInfo>();
assert(MI && "AsmPrinter didn't require GCModuleInfo?"); assert(MI && "AsmPrinter didn't require GCModuleInfo?");

View File

@@ -17,31 +17,31 @@
#include <cctype> #include <cctype>
using namespace llvm; using namespace llvm;
const char *const llvm::arm_asm_table[] = { const char *const llvm::arm_asm_table[] = {
"{r0}", "r0", "{r0}", "r0",
"{r1}", "r1", "{r1}", "r1",
"{r2}", "r2", "{r2}", "r2",
"{r3}", "r3", "{r3}", "r3",
"{r4}", "r4", "{r4}", "r4",
"{r5}", "r5", "{r5}", "r5",
"{r6}", "r6", "{r6}", "r6",
"{r7}", "r7", "{r7}", "r7",
"{r8}", "r8", "{r8}", "r8",
"{r9}", "r9", "{r9}", "r9",
"{r10}", "r10", "{r10}", "r10",
"{r11}", "r11", "{r11}", "r11",
"{r12}", "r12", "{r12}", "r12",
"{r13}", "r13", "{r13}", "r13",
"{r14}", "r14", "{r14}", "r14",
"{lr}", "lr", "{lr}", "lr",
"{sp}", "sp", "{sp}", "sp",
"{ip}", "ip", "{ip}", "ip",
"{fp}", "fp", "{fp}", "fp",
"{sl}", "sl", "{sl}", "sl",
"{memory}", "memory", "{memory}", "memory",
"{cc}", "cc", "{cc}", "cc",
0,0}; 0,0
};
ARMDarwinTargetAsmInfo::ARMDarwinTargetAsmInfo(const ARMTargetMachine &TM): ARMDarwinTargetAsmInfo::ARMDarwinTargetAsmInfo(const ARMTargetMachine &TM):
ARMTargetAsmInfo<DarwinTargetAsmInfo>(TM) { ARMTargetAsmInfo<DarwinTargetAsmInfo>(TM) {
@@ -64,6 +64,8 @@ ARMDarwinTargetAsmInfo::ARMDarwinTargetAsmInfo(const ARMTargetMachine &TM):
HasDotTypeDotSizeDirective = false; HasDotTypeDotSizeDirective = false;
HasSingleParameterDotFile = false; HasSingleParameterDotFile = false;
NeedsIndirectEncoding = true; NeedsIndirectEncoding = true;
AllowQuotesInName = true;
if (TM.getRelocationModel() == Reloc::Static) { if (TM.getRelocationModel() == Reloc::Static) {
StaticCtorsSection = ".constructor"; StaticCtorsSection = ".constructor";
StaticDtorsSection = ".destructor"; StaticDtorsSection = ".destructor";

View File

@@ -836,10 +836,6 @@ bool ARMAsmPrinter::doInitialization(Module &M) {
assert(DW && "Dwarf Writer is not available"); assert(DW && "Dwarf Writer is not available");
DW->BeginModule(&M, MMI, O, this, TAI); DW->BeginModule(&M, MMI, O, this, TAI);
// Darwin wants symbols to be quoted if they have complex names.
if (Subtarget->isTargetDarwin())
Mang->setUseQuotes(true);
// Thumb-2 instructions are supported only in unified assembler syntax mode. // Thumb-2 instructions are supported only in unified assembler syntax mode.
if (Subtarget->hasThumb2()) if (Subtarget->hasThumb2())
O << "\t.syntax unified\n"; O << "\t.syntax unified\n";

View File

@@ -654,9 +654,6 @@ bool PPCLinuxAsmPrinter::doInitialization(Module &M) {
assert(DW && "DwarfWriter is not available"); assert(DW && "DwarfWriter is not available");
DW->BeginModule(&M, MMI, O, this, TAI); DW->BeginModule(&M, MMI, O, this, TAI);
// GNU as handles section names wrapped in quotes
Mang->setUseQuotes(true);
SwitchToSection(TAI->getTextSection()); SwitchToSection(TAI->getTextSection());
return Result; return Result;
@@ -885,9 +882,6 @@ bool PPCDarwinAsmPrinter::doInitialization(Module &M) {
assert(DW && "DwarfWriter is not available"); assert(DW && "DwarfWriter is not available");
DW->BeginModule(&M, MMI, O, this, TAI); DW->BeginModule(&M, MMI, O, this, TAI);
// Darwin wants symbols to be quoted if they have complex names.
Mang->setUseQuotes(true);
// Prime text sections so they are adjacent. This reduces the likelihood a // Prime text sections so they are adjacent. This reduces the likelihood a
// large data or debug section causes a branch to exceed 16M limit. // large data or debug section causes a branch to exceed 16M limit.
SwitchToTextSection("\t.section __TEXT,__textcoal_nt,coalesced," SwitchToTextSection("\t.section __TEXT,__textcoal_nt,coalesced,"

View File

@@ -45,6 +45,7 @@ PPCDarwinTargetAsmInfo::PPCDarwinTargetAsmInfo(const PPCTargetMachine &TM):
HiddenDirective = "\t.private_extern "; HiddenDirective = "\t.private_extern ";
SupportsExceptionHandling = true; SupportsExceptionHandling = true;
NeedsIndirectEncoding = true; NeedsIndirectEncoding = true;
AllowQuotesInName = true;
NeedsSet = true; NeedsSet = true;
BSSSection = 0; BSSSection = 0;

View File

@@ -58,6 +58,7 @@ void TargetAsmInfo::fillDefaultValues() {
InlineAsmEnd = "#NO_APP"; InlineAsmEnd = "#NO_APP";
AssemblerDialect = 0; AssemblerDialect = 0;
StringConstantPrefix = ".str"; StringConstantPrefix = ".str";
AllowQuotesInName = false;
ZeroDirective = "\t.zero\t"; ZeroDirective = "\t.zero\t";
ZeroDirectiveSuffix = 0; ZeroDirectiveSuffix = 0;
AsciiDirective = "\t.ascii\t"; AsciiDirective = "\t.ascii\t";

View File

@@ -781,10 +781,6 @@ bool X86ATTAsmPrinter::doInitialization(Module &M) {
DW->BeginModule(&M, MMI, O, this, TAI); DW->BeginModule(&M, MMI, O, this, TAI);
} }
// Darwin wants symbols to be quoted if they have complex names.
if (Subtarget->isTargetDarwin())
Mang->setUseQuotes(true);
return Result; return Result;
} }

View File

@@ -86,6 +86,7 @@ X86DarwinTargetAsmInfo::X86DarwinTargetAsmInfo(const X86TargetMachine &TM):
PersonalitySuffix = "$non_lazy_ptr"; PersonalitySuffix = "$non_lazy_ptr";
} }
NeedsIndirectEncoding = true; NeedsIndirectEncoding = true;
AllowQuotesInName = true;
InlineAsmStart = "## InlineAsm Start"; InlineAsmStart = "## InlineAsm Start";
InlineAsmEnd = "## InlineAsm End"; InlineAsmEnd = "## InlineAsm End";
CommentString = "##"; CommentString = "##";