mirror of
https://github.com/RPCS3/llvm.git
synced 2025-01-10 22:46:25 +00:00
eliminate MCContext::CreateSymbol and CreateTemporarySymbol.
Add a new GetOrCreateTemporarySymbol method and a version that takes a twine. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@98118 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
d85fc6e0b1
commit
00685bb5cf
@ -46,11 +46,6 @@ namespace llvm {
|
|||||||
/// @name Symbol Managment
|
/// @name Symbol Managment
|
||||||
/// @{
|
/// @{
|
||||||
|
|
||||||
/// CreateSymbol - Create a new symbol with the specified @p Name.
|
|
||||||
///
|
|
||||||
/// @param Name - The symbol name, which must be unique across all symbols.
|
|
||||||
MCSymbol *CreateSymbol(StringRef Name);
|
|
||||||
|
|
||||||
/// GetOrCreateSymbol - Lookup the symbol inside with the specified
|
/// GetOrCreateSymbol - Lookup the symbol inside with the specified
|
||||||
/// @p Name. If it exists, return it. If not, create a forward
|
/// @p Name. If it exists, return it. If not, create a forward
|
||||||
/// reference and return it.
|
/// reference and return it.
|
||||||
@ -59,13 +54,15 @@ namespace llvm {
|
|||||||
MCSymbol *GetOrCreateSymbol(StringRef Name);
|
MCSymbol *GetOrCreateSymbol(StringRef Name);
|
||||||
MCSymbol *GetOrCreateSymbol(const Twine &Name);
|
MCSymbol *GetOrCreateSymbol(const Twine &Name);
|
||||||
|
|
||||||
/// CreateTemporarySymbol - Create a new temporary symbol with the specified
|
/// GetOrCreateTemporarySymbol - Create a new assembler temporary symbol
|
||||||
/// @p Name.
|
/// with the specified @p Name if it doesn't exist or return the existing
|
||||||
|
/// one if it does.
|
||||||
///
|
///
|
||||||
/// @param Name - The symbol name, for debugging purposes only, temporary
|
/// @param Name - The symbol name, for debugging purposes only, temporary
|
||||||
/// symbols do not surive assembly. If non-empty the name must be unique
|
/// symbols do not surive assembly. If non-empty the name must be unique
|
||||||
/// across all symbols.
|
/// across all symbols.
|
||||||
MCSymbol *CreateTemporarySymbol(StringRef Name = "");
|
MCSymbol *GetOrCreateTemporarySymbol(StringRef Name = "");
|
||||||
|
MCSymbol *GetOrCreateTemporarySymbol(const Twine &Name);
|
||||||
|
|
||||||
/// LookupSymbol - Get the symbol for \p Name, or null.
|
/// LookupSymbol - Get the symbol for \p Name, or null.
|
||||||
MCSymbol *LookupSymbol(StringRef Name) const;
|
MCSymbol *LookupSymbol(StringRef Name) const;
|
||||||
|
@ -23,16 +23,8 @@ MCContext::~MCContext() {
|
|||||||
// we don't need to free them here.
|
// we don't need to free them here.
|
||||||
}
|
}
|
||||||
|
|
||||||
MCSymbol *MCContext::CreateSymbol(StringRef Name) {
|
|
||||||
assert(Name[0] != '\0' && "Normal symbols cannot be unnamed!");
|
|
||||||
|
|
||||||
// Create and bind the symbol, and ensure that names are unique.
|
|
||||||
MCSymbol *&Entry = Symbols[Name];
|
|
||||||
assert(!Entry && "Duplicate symbol definition!");
|
|
||||||
return Entry = new (*this) MCSymbol(Name, false);
|
|
||||||
}
|
|
||||||
|
|
||||||
MCSymbol *MCContext::GetOrCreateSymbol(StringRef Name) {
|
MCSymbol *MCContext::GetOrCreateSymbol(StringRef Name) {
|
||||||
|
assert(!Name.empty() && "Normal symbols cannot be unnamed!");
|
||||||
MCSymbol *&Entry = Symbols[Name];
|
MCSymbol *&Entry = Symbols[Name];
|
||||||
if (Entry) return Entry;
|
if (Entry) return Entry;
|
||||||
|
|
||||||
@ -46,17 +38,24 @@ MCSymbol *MCContext::GetOrCreateSymbol(const Twine &Name) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
MCSymbol *MCContext::CreateTemporarySymbol(StringRef Name) {
|
MCSymbol *MCContext::GetOrCreateTemporarySymbol(StringRef Name) {
|
||||||
// If unnamed, just create a symbol.
|
// If unnamed, just create a symbol.
|
||||||
if (Name.empty())
|
if (Name.empty())
|
||||||
new (*this) MCSymbol("", true);
|
new (*this) MCSymbol("", true);
|
||||||
|
|
||||||
// Otherwise create as usual.
|
// Otherwise create as usual.
|
||||||
MCSymbol *&Entry = Symbols[Name];
|
MCSymbol *&Entry = Symbols[Name];
|
||||||
assert(!Entry && "Duplicate symbol definition!");
|
if (Entry) return Entry;
|
||||||
return Entry = new (*this) MCSymbol(Name, true);
|
return Entry = new (*this) MCSymbol(Name, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
MCSymbol *MCContext::GetOrCreateTemporarySymbol(const Twine &Name) {
|
||||||
|
SmallString<128> NameSV;
|
||||||
|
Name.toVector(NameSV);
|
||||||
|
return GetOrCreateTemporarySymbol(NameSV.str());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
MCSymbol *MCContext::LookupSymbol(StringRef Name) const {
|
MCSymbol *MCContext::LookupSymbol(StringRef Name) const {
|
||||||
return Symbols.lookup(Name);
|
return Symbols.lookup(Name);
|
||||||
}
|
}
|
||||||
|
@ -240,14 +240,10 @@ bool AsmParser::ParseParenExpr(const MCExpr *&Res, SMLoc &EndLoc) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
MCSymbol *AsmParser::CreateSymbol(StringRef Name) {
|
MCSymbol *AsmParser::CreateSymbol(StringRef Name) {
|
||||||
if (MCSymbol *S = Ctx.LookupSymbol(Name))
|
|
||||||
return S;
|
|
||||||
|
|
||||||
// If the label starts with L it is an assembler temporary label.
|
// If the label starts with L it is an assembler temporary label.
|
||||||
if (Name.startswith("L"))
|
if (Name.startswith("L"))
|
||||||
return Ctx.CreateTemporarySymbol(Name);
|
return Ctx.GetOrCreateTemporarySymbol(Name);
|
||||||
|
return Ctx.GetOrCreateSymbol(Name);
|
||||||
return Ctx.CreateSymbol(Name);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// ParsePrimaryExpr - Parse a primary expression and return it.
|
/// ParsePrimaryExpr - Parse a primary expression and return it.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user