summaryrefslogtreecommitdiffstats
path: root/llvm
diff options
context:
space:
mode:
authorPete Cooper <peter_cooper@apple.com>2015-06-08 17:17:09 +0000
committerPete Cooper <peter_cooper@apple.com>2015-06-08 17:17:09 +0000
commita3ab3841c0cce9c4747fae96ef25e5695fc1f856 (patch)
tree9d43f92785e894089e3e896e08db1279a9c4a92a /llvm
parent37ff6c4207494dcc0475750d16b3fbd7b890403f (diff)
downloadbcm5719-llvm-a3ab3841c0cce9c4747fae96ef25e5695fc1f856.tar.gz
bcm5719-llvm-a3ab3841c0cce9c4747fae96ef25e5695fc1f856.zip
Change MCSymbol IsELF to an enum to support future MCSymbolCOFF and MCSymbolMachO.
Reviewed by Rafael EspĂ­ndola. llvm-svn: 239311
Diffstat (limited to 'llvm')
-rw-r--r--llvm/include/llvm/MC/MCSymbol.h22
-rw-r--r--llvm/include/llvm/MC/MCSymbolELF.h2
-rw-r--r--llvm/lib/MC/MCContext.cpp2
3 files changed, 20 insertions, 6 deletions
diff --git a/llvm/include/llvm/MC/MCSymbol.h b/llvm/include/llvm/MC/MCSymbol.h
index 7f74f378d46..5710051840e 100644
--- a/llvm/include/llvm/MC/MCSymbol.h
+++ b/llvm/include/llvm/MC/MCSymbol.h
@@ -35,6 +35,16 @@ class raw_ostream;
/// Section member is set to indicate what section it lives in. Otherwise, if
/// it is a reference to an external entity, it has a null section.
class MCSymbol {
+protected:
+ /// The kind of the symbol. If it is any value other than unset then this
+ /// class is actually one of the appropriate subclasses of MCSymbol.
+ enum SymbolKind {
+ SymbolKindUnset,
+ SymbolKindCOFF,
+ SymbolKindELF,
+ SymbolKindMachO,
+ };
+
// Special sentinal value for the absolute pseudo section.
//
// FIXME: Use a PointerInt wrapper for this?
@@ -83,7 +93,7 @@ class MCSymbol {
mutable unsigned HasFragment : 1;
- unsigned IsELF : 1;
+ SymbolKind Kind : 2;
/// Index field, for use by the object file implementation.
mutable uint32_t Index = 0;
@@ -108,11 +118,11 @@ class MCSymbol {
protected: // MCContext creates and uniques these.
friend class MCExpr;
friend class MCContext;
- MCSymbol(bool IsELF, const StringMapEntry<bool> *Name, bool isTemporary)
+ MCSymbol(SymbolKind Kind, const StringMapEntry<bool> *Name, bool isTemporary)
: Name(Name), Section(nullptr), Value(nullptr), IsTemporary(isTemporary),
IsRedefinable(false), IsUsed(false), IsRegistered(false),
IsExternal(false), IsPrivateExtern(false), HasFragment(false),
- IsELF(IsELF) {
+ Kind(Kind) {
Offset = 0;
}
@@ -197,7 +207,11 @@ public:
Section = nullptr;
}
- bool isELF() const { return IsELF; }
+ bool isELF() const { return Kind == SymbolKindELF; }
+
+ bool isCOFF() const { return Kind == SymbolKindCOFF; }
+
+ bool isMachO() const { return Kind == SymbolKindMachO; }
/// @}
/// \name Variable Symbols
diff --git a/llvm/include/llvm/MC/MCSymbolELF.h b/llvm/include/llvm/MC/MCSymbolELF.h
index c943054a4fd..0cc11156b5c 100644
--- a/llvm/include/llvm/MC/MCSymbolELF.h
+++ b/llvm/include/llvm/MC/MCSymbolELF.h
@@ -19,7 +19,7 @@ class MCSymbolELF : public MCSymbol {
public:
MCSymbolELF(const StringMapEntry<bool> *Name, bool isTemporary)
- : MCSymbol(true, Name, isTemporary) {}
+ : MCSymbol(SymbolKindELF, Name, isTemporary) {}
void setSize(const MCExpr *SS) { SymbolSize = SS; }
const MCExpr *getSize() const { return SymbolSize; }
diff --git a/llvm/lib/MC/MCContext.cpp b/llvm/lib/MC/MCContext.cpp
index 79f9bdae463..b44cbc0f85b 100644
--- a/llvm/lib/MC/MCContext.cpp
+++ b/llvm/lib/MC/MCContext.cpp
@@ -162,7 +162,7 @@ MCSymbol *MCContext::createSymbolImpl(const StringMapEntry<bool> *Name,
bool IsELF = MOFI && MOFI->getObjectFileType() == MCObjectFileInfo::IsELF;
if (IsELF)
return new (*this) MCSymbolELF(Name, IsTemporary);
- return new (*this) MCSymbol(false, Name, IsTemporary);
+ return new (*this) MCSymbol(MCSymbol::SymbolKindUnset, Name, IsTemporary);
}
MCSymbol *MCContext::createSymbol(StringRef Name, bool AlwaysAddSuffix,
OpenPOWER on IntegriCloud