diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/MC/MCAsmInfo.cpp | 3 | ||||
-rw-r--r-- | lib/MC/MCAsmInfoCOFF.cpp | 1 | ||||
-rw-r--r-- | lib/MC/MCAsmInfoDarwin.cpp | 1 | ||||
-rw-r--r-- | lib/MC/MCSectionELF.cpp | 53 | ||||
-rw-r--r-- | lib/Target/MSP430/MCTargetDesc/MSP430MCAsmInfo.cpp | 1 | ||||
-rw-r--r-- | lib/Target/Mangler.cpp | 67 | ||||
-rw-r--r-- | lib/Target/NVPTX/MCTargetDesc/NVPTXMCAsmInfo.cpp | 2 | ||||
-rw-r--r-- | lib/Target/R600/MCTargetDesc/AMDGPUMCAsmInfo.cpp | 3 |
8 files changed, 34 insertions, 97 deletions
diff --git a/lib/MC/MCAsmInfo.cpp b/lib/MC/MCAsmInfo.cpp index fd822b5..28f1c95 100644 --- a/lib/MC/MCAsmInfo.cpp +++ b/lib/MC/MCAsmInfo.cpp @@ -50,9 +50,6 @@ MCAsmInfo::MCAsmInfo() { Code32Directive = ".code32"; Code64Directive = ".code64"; AssemblerDialect = 0; - AllowQuotesInName = false; - AllowNameToStartWithDigit = false; - AllowPeriodsInName = true; AllowAtInName = false; UseDataRegionDirectives = false; ZeroDirective = "\t.zero\t"; diff --git a/lib/MC/MCAsmInfoCOFF.cpp b/lib/MC/MCAsmInfoCOFF.cpp index 33350d9..9d9f98e 100644 --- a/lib/MC/MCAsmInfoCOFF.cpp +++ b/lib/MC/MCAsmInfoCOFF.cpp @@ -43,7 +43,6 @@ MCAsmInfoCOFF::MCAsmInfoCOFF() { void MCAsmInfoMicrosoft::anchor() { } MCAsmInfoMicrosoft::MCAsmInfoMicrosoft() { - AllowQuotesInName = true; } void MCAsmInfoGNUCOFF::anchor() { } diff --git a/lib/MC/MCAsmInfoDarwin.cpp b/lib/MC/MCAsmInfoDarwin.cpp index d362a98..704c816 100644 --- a/lib/MC/MCAsmInfoDarwin.cpp +++ b/lib/MC/MCAsmInfoDarwin.cpp @@ -26,7 +26,6 @@ MCAsmInfoDarwin::MCAsmInfoDarwin() { GlobalPrefix = "_"; PrivateGlobalPrefix = "L"; LinkerPrivateGlobalPrefix = "l"; - AllowQuotesInName = true; HasSingleParameterDotFile = false; HasSubsectionsViaSymbols = true; diff --git a/lib/MC/MCSectionELF.cpp b/lib/MC/MCSectionELF.cpp index ff9c4d3..09eb3e7 100644 --- a/lib/MC/MCSectionELF.cpp +++ b/lib/MC/MCSectionELF.cpp @@ -32,6 +32,29 @@ bool MCSectionELF::ShouldOmitSectionDirective(StringRef Name, return false; } +static void printName(raw_ostream &OS, StringRef Name) { + if (Name.find_first_not_of("0123456789_." + "abcdefghijklmnopqrstuvwxyz" + "ABCDEFGHIJKLMNOPQRSTUVWXYZ") == Name.npos) { + OS << Name; + return; + } + OS << '"'; + for (const char *B = Name.begin(), *E = Name.end(); B < E; ++B) { + if (*B == '"') // Unquoted " + OS << "\\\""; + else if (*B != '\\') // Neither " or backslash + OS << *B; + else if (B + 1 == E) // Trailing backslash + OS << "\\\\"; + else { + OS << B[0] << B[1]; // Quoted character + ++B; + } + } + OS << '"'; +} + void MCSectionELF::PrintSwitchToSection(const MCAsmInfo &MAI, raw_ostream &OS, const MCExpr *Subsection) const { @@ -44,27 +67,8 @@ void MCSectionELF::PrintSwitchToSection(const MCAsmInfo &MAI, return; } - StringRef name = getSectionName(); - if (name.find_first_not_of("0123456789_." - "abcdefghijklmnopqrstuvwxyz" - "ABCDEFGHIJKLMNOPQRSTUVWXYZ") == name.npos) { - OS << "\t.section\t" << name; - } else { - OS << "\t.section\t\""; - for (const char *b = name.begin(), *e = name.end(); b < e; ++b) { - if (*b == '"') // Unquoted " - OS << "\\\""; - else if (*b != '\\') // Neither " or backslash - OS << *b; - else if (b + 1 == e) // Trailing backslash - OS << "\\\\"; - else { - OS << b[0] << b[1]; // Quoted character - ++b; - } - } - OS << '"'; - } + OS << "\t.section\t"; + printName(OS, getSectionName()); // Handle the weird solaris syntax if desired. if (MAI.usesSunStyleELFSectionSwitchSyntax() && @@ -135,8 +139,11 @@ void MCSectionELF::PrintSwitchToSection(const MCAsmInfo &MAI, OS << "," << EntrySize; } - if (Flags & ELF::SHF_GROUP) - OS << "," << Group->getName() << ",comdat"; + if (Flags & ELF::SHF_GROUP) { + OS << ","; + printName(OS, Group->getName()); + OS << ",comdat"; + } OS << '\n'; if (Subsection) diff --git a/lib/Target/MSP430/MCTargetDesc/MSP430MCAsmInfo.cpp b/lib/Target/MSP430/MCTargetDesc/MSP430MCAsmInfo.cpp index 991bf56..acf2ab8 100644 --- a/lib/Target/MSP430/MCTargetDesc/MSP430MCAsmInfo.cpp +++ b/lib/Target/MSP430/MCTargetDesc/MSP430MCAsmInfo.cpp @@ -24,6 +24,5 @@ MSP430MCAsmInfo::MSP430MCAsmInfo(StringRef TT) { CommentString = ";"; AlignmentIsInBytes = false; - AllowNameToStartWithDigit = true; UsesELFSectionDirectiveForBSS = true; } diff --git a/lib/Target/Mangler.cpp b/lib/Target/Mangler.cpp index 20f70a3..0fc1f23 100644 --- a/lib/Target/Mangler.cpp +++ b/lib/Target/Mangler.cpp @@ -23,17 +23,6 @@ #include "llvm/Support/raw_ostream.h" using namespace llvm; -static bool isAcceptableChar(char C, bool AllowPeriod) { - if ((C < 'a' || C > 'z') && - (C < 'A' || C > 'Z') && - (C < '0' || C > '9') && - C != '_' && C != '$' && C != '@' && - !(AllowPeriod && C == '.') && - !(C & 0x80)) - return false; - return true; -} - static char HexDigit(int V) { return V < 10 ? V+'0' : V+'A'-10; } @@ -45,46 +34,6 @@ static void MangleLetter(SmallVectorImpl<char> &OutName, unsigned char C) { OutName.push_back('_'); } -/// NameNeedsEscaping - Return true if the identifier \p Str needs quotes -/// for this assembler. -static bool NameNeedsEscaping(StringRef Str, const MCAsmInfo *MAI) { - assert(!Str.empty() && "Cannot create an empty MCSymbol"); - - // If the first character is a number and the target does not allow this, we - // need quotes. - if (!MAI->doesAllowNameToStartWithDigit() && Str[0] >= '0' && Str[0] <= '9') - return true; - - // If any of the characters in the string is an unacceptable character, force - // quotes. - bool AllowPeriod = MAI->doesAllowPeriodsInName(); - for (unsigned i = 0, e = Str.size(); i != e; ++i) - if (!isAcceptableChar(Str[i], AllowPeriod)) - return true; - return false; -} - -/// appendMangledName - Add the specified string in mangled form if it uses -/// any unusual characters. -static void appendMangledName(SmallVectorImpl<char> &OutName, StringRef Str, - const MCAsmInfo *MAI) { - // The first character is not allowed to be a number unless the target - // explicitly allows it. - if (!MAI->doesAllowNameToStartWithDigit() && Str[0] >= '0' && Str[0] <= '9') { - MangleLetter(OutName, Str[0]); - Str = Str.substr(1); - } - - bool AllowPeriod = MAI->doesAllowPeriodsInName(); - for (unsigned i = 0, e = Str.size(); i != e; ++i) { - if (!isAcceptableChar(Str[i], AllowPeriod)) - MangleLetter(OutName, Str[i]); - else - OutName.push_back(Str[i]); - } -} - - /// appendMangledQuotedName - On systems that support quoted symbols, we still /// have to escape some (obscure) characters like " and \n which would break the /// assembler's lexing. @@ -134,22 +83,14 @@ void Mangler::getNameWithPrefix(SmallVectorImpl<char> &OutName, OutName.append(Prefix, Prefix+strlen(Prefix)); } } - + // If this is a simple string that doesn't need escaping, just append it. - if (!NameNeedsEscaping(Name, MAI) || - // If quotes are supported, they can be used unless the string contains - // a quote or newline. - (MAI->doesAllowQuotesInName() && - Name.find_first_of("\n\"") == StringRef::npos)) { + // Quotes can be used unless the string contains a quote or newline. + if (Name.find_first_of("\n\"") == StringRef::npos) { OutName.append(Name.begin(), Name.end()); return; } - - // On systems that do not allow quoted names, we need to mangle most - // strange characters. - if (!MAI->doesAllowQuotesInName()) - return appendMangledName(OutName, Name, MAI); - + // Okay, the system allows quoted strings. We can quote most anything, the // only characters that need escaping are " and \n. assert(Name.find_first_of("\n\"") != StringRef::npos); diff --git a/lib/Target/NVPTX/MCTargetDesc/NVPTXMCAsmInfo.cpp b/lib/Target/NVPTX/MCTargetDesc/NVPTXMCAsmInfo.cpp index dfa1ff5..f2784b8 100644 --- a/lib/Target/NVPTX/MCTargetDesc/NVPTXMCAsmInfo.cpp +++ b/lib/Target/NVPTX/MCTargetDesc/NVPTXMCAsmInfo.cpp @@ -35,8 +35,6 @@ NVPTXMCAsmInfo::NVPTXMCAsmInfo(const StringRef &TT) { PrivateGlobalPrefix = "$L__"; - AllowPeriodsInName = false; - HasSetDirective = false; HasSingleParameterDotFile = false; diff --git a/lib/Target/R600/MCTargetDesc/AMDGPUMCAsmInfo.cpp b/lib/Target/R600/MCTargetDesc/AMDGPUMCAsmInfo.cpp index 0aeb8d0..4a8e1b0 100644 --- a/lib/Target/R600/MCTargetDesc/AMDGPUMCAsmInfo.cpp +++ b/lib/Target/R600/MCTargetDesc/AMDGPUMCAsmInfo.cpp @@ -31,9 +31,6 @@ AMDGPUMCAsmInfo::AMDGPUMCAsmInfo(StringRef &TT) : MCAsmInfo() { InlineAsmStart = ";#ASMSTART"; InlineAsmEnd = ";#ASMEND"; AssemblerDialect = 0; - AllowQuotesInName = false; - AllowNameToStartWithDigit = false; - AllowPeriodsInName = false; //===--- Data Emission Directives -------------------------------------===// ZeroDirective = ".zero"; |