mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-12-15 07:39:31 +00:00
Move MCContext and friends to StringRef based APIs.
llvm-svn: 77251
This commit is contained in:
parent
923a453dea
commit
6de68a2544
@ -18,6 +18,7 @@ namespace llvm {
|
||||
class MCValue;
|
||||
class MCSection;
|
||||
class MCSymbol;
|
||||
class StringRef;
|
||||
|
||||
/// MCContext - Context object for machine code objects.
|
||||
class MCContext {
|
||||
@ -46,19 +47,19 @@ namespace llvm {
|
||||
~MCContext();
|
||||
|
||||
/// GetSection - Get or create a new section with the given @param Name.
|
||||
MCSection *GetSection(const char *Name);
|
||||
MCSection *GetSection(const StringRef &Name);
|
||||
|
||||
/// CreateSymbol - Create a new symbol with the specified @param Name.
|
||||
///
|
||||
/// @param Name - The symbol name, which must be unique across all symbols.
|
||||
MCSymbol *CreateSymbol(const char *Name);
|
||||
MCSymbol *CreateSymbol(const StringRef &Name);
|
||||
|
||||
/// GetOrCreateSymbol - Lookup the symbol inside with the specified
|
||||
/// @param Name. If it exists, return it. If not, create a forward
|
||||
/// reference and return it.
|
||||
///
|
||||
/// @param Name - The symbol name, which must be unique across all symbols.
|
||||
MCSymbol *GetOrCreateSymbol(const char *Name);
|
||||
MCSymbol *GetOrCreateSymbol(const StringRef &Name);
|
||||
|
||||
/// CreateTemporarySymbol - Create a new temporary symbol with the specified
|
||||
/// @param Name.
|
||||
@ -66,10 +67,10 @@ namespace llvm {
|
||||
/// @param Name - The symbol name, for debugging purposes only, temporary
|
||||
/// symbols do not surive assembly. If non-empty the name must be unique
|
||||
/// across all symbols.
|
||||
MCSymbol *CreateTemporarySymbol(const char *Name = "");
|
||||
MCSymbol *CreateTemporarySymbol(const StringRef &Name = "");
|
||||
|
||||
/// LookupSymbol - Get the symbol for @param Name, or null.
|
||||
MCSymbol *LookupSymbol(const char *Name) const;
|
||||
MCSymbol *LookupSymbol(const StringRef &Name) const;
|
||||
|
||||
/// ClearSymbolValue - Erase a value binding for @param Symbol, if one
|
||||
/// exists.
|
||||
|
@ -15,6 +15,7 @@
|
||||
#define LLVM_MC_MCSECTION_H
|
||||
|
||||
#include <string>
|
||||
#include "llvm/ADT/StringRef.h"
|
||||
|
||||
namespace llvm {
|
||||
|
||||
@ -25,7 +26,7 @@ namespace llvm {
|
||||
std::string Name;
|
||||
private:
|
||||
friend class MCContext;
|
||||
MCSection(const char *_Name) : Name(_Name) {}
|
||||
MCSection(const StringRef &_Name) : Name(_Name) {}
|
||||
|
||||
MCSection(const MCSection&); // DO NOT IMPLEMENT
|
||||
void operator=(const MCSection&); // DO NOT IMPLEMENT
|
||||
|
@ -15,6 +15,7 @@
|
||||
#define LLVM_MC_MCSYMBOL_H
|
||||
|
||||
#include <string>
|
||||
#include "llvm/ADT/StringRef.h"
|
||||
|
||||
namespace llvm {
|
||||
class MCSection;
|
||||
@ -46,7 +47,7 @@ namespace llvm {
|
||||
|
||||
private: // MCContext creates and uniques these.
|
||||
friend class MCContext;
|
||||
MCSymbol(const char *_Name, bool _IsTemporary)
|
||||
MCSymbol(const StringRef &_Name, bool _IsTemporary)
|
||||
: Name(_Name), Section(0), IsTemporary(_IsTemporary), IsExternal(false) {}
|
||||
|
||||
MCSymbol(const MCSymbol&); // DO NOT IMPLEMENT
|
||||
|
@ -21,7 +21,7 @@ MCContext::MCContext()
|
||||
MCContext::~MCContext() {
|
||||
}
|
||||
|
||||
MCSection *MCContext::GetSection(const char *Name) {
|
||||
MCSection *MCContext::GetSection(const StringRef &Name) {
|
||||
MCSection *&Entry = Sections[Name];
|
||||
|
||||
if (!Entry)
|
||||
@ -30,7 +30,7 @@ MCSection *MCContext::GetSection(const char *Name) {
|
||||
return Entry;
|
||||
}
|
||||
|
||||
MCSymbol *MCContext::CreateSymbol(const char *Name) {
|
||||
MCSymbol *MCContext::CreateSymbol(const StringRef &Name) {
|
||||
assert(Name[0] != '\0' && "Normal symbols cannot be unnamed!");
|
||||
|
||||
// Create and bind the symbol, and ensure that names are unique.
|
||||
@ -39,7 +39,7 @@ MCSymbol *MCContext::CreateSymbol(const char *Name) {
|
||||
return Entry = new (*this) MCSymbol(Name, false);
|
||||
}
|
||||
|
||||
MCSymbol *MCContext::GetOrCreateSymbol(const char *Name) {
|
||||
MCSymbol *MCContext::GetOrCreateSymbol(const StringRef &Name) {
|
||||
MCSymbol *&Entry = Symbols[Name];
|
||||
if (Entry) return Entry;
|
||||
|
||||
@ -47,9 +47,9 @@ MCSymbol *MCContext::GetOrCreateSymbol(const char *Name) {
|
||||
}
|
||||
|
||||
|
||||
MCSymbol *MCContext::CreateTemporarySymbol(const char *Name) {
|
||||
MCSymbol *MCContext::CreateTemporarySymbol(const StringRef &Name) {
|
||||
// If unnamed, just create a symbol.
|
||||
if (Name[0] == '\0')
|
||||
if (Name.empty())
|
||||
new (*this) MCSymbol("", true);
|
||||
|
||||
// Otherwise create as usual.
|
||||
@ -58,7 +58,7 @@ MCSymbol *MCContext::CreateTemporarySymbol(const char *Name) {
|
||||
return Entry = new (*this) MCSymbol(Name, true);
|
||||
}
|
||||
|
||||
MCSymbol *MCContext::LookupSymbol(const char *Name) const {
|
||||
MCSymbol *MCContext::LookupSymbol(const StringRef &Name) const {
|
||||
return Symbols.lookup(Name);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user