mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-11-03 14:21:30 +00:00
MC: Allow targets to stop symbol name quoting
Currently symbol names are printed in quotes if it contains something outside of the arbitrary set of characters that isAcceptableChar tests for. On somem targets, it is never OK to print a symbol name in quotes so allow targets to opt out of this behavior. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@235670 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -155,6 +155,9 @@ protected:
|
|||||||
/// Defaults to false.
|
/// Defaults to false.
|
||||||
bool AllowAtInName;
|
bool AllowAtInName;
|
||||||
|
|
||||||
|
/// If this is true, symbol names will not attempt to be quoted when printed.
|
||||||
|
bool NoSymbolNameQuoting;
|
||||||
|
|
||||||
/// This is true if data region markers should be printed as
|
/// This is true if data region markers should be printed as
|
||||||
/// ".data_region/.end_data_region" directives. If false, use "$d/$a" labels
|
/// ".data_region/.end_data_region" directives. If false, use "$d/$a" labels
|
||||||
/// instead.
|
/// instead.
|
||||||
@@ -452,6 +455,7 @@ public:
|
|||||||
const char *getCode64Directive() const { return Code64Directive; }
|
const char *getCode64Directive() const { return Code64Directive; }
|
||||||
unsigned getAssemblerDialect() const { return AssemblerDialect; }
|
unsigned getAssemblerDialect() const { return AssemblerDialect; }
|
||||||
bool doesAllowAtInName() const { return AllowAtInName; }
|
bool doesAllowAtInName() const { return AllowAtInName; }
|
||||||
|
bool noSymbolNameQuoting() const { return NoSymbolNameQuoting; }
|
||||||
bool doesSupportDataRegionDirectives() const {
|
bool doesSupportDataRegionDirectives() const {
|
||||||
return UseDataRegionDirectives;
|
return UseDataRegionDirectives;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -55,6 +55,10 @@ namespace llvm {
|
|||||||
/// "Lfoo" or ".foo".
|
/// "Lfoo" or ".foo".
|
||||||
unsigned IsTemporary : 1;
|
unsigned IsTemporary : 1;
|
||||||
|
|
||||||
|
/// True if the name should be quoted if "unacceptable" characters are used
|
||||||
|
/// in the name.
|
||||||
|
unsigned NoQuoting : 1;
|
||||||
|
|
||||||
/// \brief True if this symbol can be redefined.
|
/// \brief True if this symbol can be redefined.
|
||||||
unsigned IsRedefinable : 1;
|
unsigned IsRedefinable : 1;
|
||||||
|
|
||||||
@@ -64,9 +68,10 @@ namespace llvm {
|
|||||||
private: // MCContext creates and uniques these.
|
private: // MCContext creates and uniques these.
|
||||||
friend class MCExpr;
|
friend class MCExpr;
|
||||||
friend class MCContext;
|
friend class MCContext;
|
||||||
MCSymbol(StringRef name, bool isTemporary)
|
MCSymbol(StringRef name, bool isTemporary, bool noQuoting)
|
||||||
: Name(name), Section(nullptr), Value(nullptr),
|
: Name(name), Section(nullptr), Value(nullptr),
|
||||||
IsTemporary(isTemporary), IsRedefinable(false), IsUsed(false) {}
|
IsTemporary(isTemporary), NoQuoting(noQuoting),
|
||||||
|
IsRedefinable(false), IsUsed(false) {}
|
||||||
|
|
||||||
MCSymbol(const MCSymbol&) = delete;
|
MCSymbol(const MCSymbol&) = delete;
|
||||||
void operator=(const MCSymbol&) = delete;
|
void operator=(const MCSymbol&) = delete;
|
||||||
|
|||||||
@@ -50,6 +50,7 @@ MCAsmInfo::MCAsmInfo() {
|
|||||||
Code64Directive = ".code64";
|
Code64Directive = ".code64";
|
||||||
AssemblerDialect = 0;
|
AssemblerDialect = 0;
|
||||||
AllowAtInName = false;
|
AllowAtInName = false;
|
||||||
|
NoSymbolNameQuoting = false;
|
||||||
UseDataRegionDirectives = false;
|
UseDataRegionDirectives = false;
|
||||||
ZeroDirective = "\t.zero\t";
|
ZeroDirective = "\t.zero\t";
|
||||||
AsciiDirective = "\t.ascii\t";
|
AsciiDirective = "\t.ascii\t";
|
||||||
|
|||||||
@@ -125,7 +125,8 @@ MCSymbol *MCContext::getOrCreateSectionSymbol(const MCSectionELF &Section) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
auto NameIter = UsedNames.insert(std::make_pair(Name, true)).first;
|
auto NameIter = UsedNames.insert(std::make_pair(Name, true)).first;
|
||||||
Sym = new (*this) MCSymbol(NameIter->getKey(), /*isTemporary*/ false);
|
Sym = new (*this) MCSymbol(NameIter->getKey(), /*isTemporary*/ false,
|
||||||
|
MAI->noSymbolNameQuoting());
|
||||||
|
|
||||||
if (!OldSym)
|
if (!OldSym)
|
||||||
OldSym = Sym;
|
OldSym = Sym;
|
||||||
@@ -163,7 +164,8 @@ MCSymbol *MCContext::CreateSymbol(StringRef Name, bool AlwaysAddSuffix) {
|
|||||||
// Ok, we found a name. Have the MCSymbol object itself refer to the copy
|
// Ok, we found a name. Have the MCSymbol object itself refer to the copy
|
||||||
// of the string that is embedded in the UsedNames entry.
|
// of the string that is embedded in the UsedNames entry.
|
||||||
MCSymbol *Result =
|
MCSymbol *Result =
|
||||||
new (*this) MCSymbol(NameEntry.first->getKey(), IsTemporary);
|
new (*this) MCSymbol(NameEntry.first->getKey(), IsTemporary,
|
||||||
|
MAI->noSymbolNameQuoting());
|
||||||
return Result;
|
return Result;
|
||||||
}
|
}
|
||||||
assert(IsTemporary && "Cannot rename non-temporary symbols");
|
assert(IsTemporary && "Cannot rename non-temporary symbols");
|
||||||
|
|||||||
@@ -51,7 +51,7 @@ void MCSymbol::print(raw_ostream &OS) const {
|
|||||||
// some targets support quoting names with funny characters. If the name
|
// some targets support quoting names with funny characters. If the name
|
||||||
// contains a funny character, then print it quoted.
|
// contains a funny character, then print it quoted.
|
||||||
StringRef Name = getName();
|
StringRef Name = getName();
|
||||||
if (!NameNeedsQuoting(Name)) {
|
if (NoQuoting || !NameNeedsQuoting(Name)) {
|
||||||
OS << Name;
|
OS << Name;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user