[llvm] r238609 - Merge MCSymbol and MCSymbolData.
Rafael Espindola
rafael.espindola at gmail.com
Fri May 29 13:31:23 PDT 2015
Author: rafael
Date: Fri May 29 15:31:23 2015
New Revision: 238609
URL: http://llvm.org/viewvc/llvm-project?rev=238609&view=rev
Log:
Merge MCSymbol and MCSymbolData.
As a transition hack leave MCSymbolData as a typedef of MCSymbol. I will be
removing that in a second.
Modified:
llvm/trunk/include/llvm/MC/MCAsmLayout.h
llvm/trunk/include/llvm/MC/MCELFObjectWriter.h
llvm/trunk/include/llvm/MC/MCELFStreamer.h
llvm/trunk/include/llvm/MC/MCObjectWriter.h
llvm/trunk/include/llvm/MC/MCSymbol.h
llvm/trunk/lib/MC/MCAssembler.cpp
Modified: llvm/trunk/include/llvm/MC/MCAsmLayout.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/MC/MCAsmLayout.h?rev=238609&r1=238608&r2=238609&view=diff
==============================================================================
--- llvm/trunk/include/llvm/MC/MCAsmLayout.h (original)
+++ llvm/trunk/include/llvm/MC/MCAsmLayout.h Fri May 29 15:31:23 2015
@@ -18,7 +18,6 @@ class MCAssembler;
class MCFragment;
class MCSection;
class MCSymbol;
-class MCSymbolData;
/// Encapsulates the layout of an assembly file at a particular point in time.
///
Modified: llvm/trunk/include/llvm/MC/MCELFObjectWriter.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/MC/MCELFObjectWriter.h?rev=238609&r1=238608&r2=238609&view=diff
==============================================================================
--- llvm/trunk/include/llvm/MC/MCELFObjectWriter.h (original)
+++ llvm/trunk/include/llvm/MC/MCELFObjectWriter.h Fri May 29 15:31:23 2015
@@ -21,7 +21,6 @@ class MCFixup;
class MCFragment;
class MCObjectWriter;
class MCSymbol;
-class MCSymbolData;
class MCValue;
class raw_pwrite_stream;
Modified: llvm/trunk/include/llvm/MC/MCELFStreamer.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/MC/MCELFStreamer.h?rev=238609&r1=238608&r2=238609&view=diff
==============================================================================
--- llvm/trunk/include/llvm/MC/MCELFStreamer.h (original)
+++ llvm/trunk/include/llvm/MC/MCELFStreamer.h Fri May 29 15:31:23 2015
@@ -24,7 +24,6 @@ class MCCodeEmitter;
class MCExpr;
class MCInst;
class MCSymbol;
-class MCSymbolData;
class raw_ostream;
class MCELFStreamer : public MCObjectStreamer {
Modified: llvm/trunk/include/llvm/MC/MCObjectWriter.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/MC/MCObjectWriter.h?rev=238609&r1=238608&r2=238609&view=diff
==============================================================================
--- llvm/trunk/include/llvm/MC/MCObjectWriter.h (original)
+++ llvm/trunk/include/llvm/MC/MCObjectWriter.h Fri May 29 15:31:23 2015
@@ -22,7 +22,6 @@ class MCAsmLayout;
class MCAssembler;
class MCFixup;
class MCFragment;
-class MCSymbolData;
class MCSymbolRefExpr;
class MCValue;
Modified: llvm/trunk/include/llvm/MC/MCSymbol.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/MC/MCSymbol.h?rev=238609&r1=238608&r2=238609&view=diff
==============================================================================
--- llvm/trunk/include/llvm/MC/MCSymbol.h (original)
+++ llvm/trunk/include/llvm/MC/MCSymbol.h Fri May 29 15:31:23 2015
@@ -27,39 +27,6 @@ class MCSection;
class MCContext;
class raw_ostream;
-// TODO: Merge completely with MCSymbol.
-class MCSymbolData {
- /// Fragment - The fragment this symbol's value is relative to, if any. Also
- /// stores if this symbol is visible outside this translation unit (bit 0) or
- /// if it is private extern (bit 1).
- PointerIntPair<MCFragment *, 2> Fragment;
-
-
-public:
- MCSymbolData() = default;
-
- MCFragment *getFragment() const { return Fragment.getPointer(); }
- void setFragment(MCFragment *Value) { Fragment.setPointer(Value); }
-
- /// @}
- /// \name Symbol Attributes
- /// @{
-
- bool isExternal() const { return Fragment.getInt() & 1; }
- void setExternal(bool Value) {
- Fragment.setInt((Fragment.getInt() & ~1) | unsigned(Value));
- }
-
- bool isPrivateExtern() const { return Fragment.getInt() & 2; }
- void setPrivateExtern(bool Value) {
- Fragment.setInt((Fragment.getInt() & ~2) | (unsigned(Value) << 1));
- }
-
- /// @}
-
- void dump() const;
-};
-
/// MCSymbol - Instances of this class represent a symbol name in the MC file,
/// and MCSymbols are created and uniqued by the MCContext class. MCSymbols
/// should only be constructed with valid names for the object file.
@@ -122,7 +89,10 @@ class MCSymbol {
/// additional per symbol information which is not easily classified.
mutable uint32_t Flags = 0;
- mutable MCSymbolData Data;
+ /// The fragment this symbol's value is relative to, if any. Also stores if
+ /// this symbol is visible outside this translation unit (bit 0) or if it is
+ /// private extern (bit 1).
+ mutable PointerIntPair<MCFragment *, 2> Fragment;
private: // MCContext creates and uniques these.
friend class MCExpr;
@@ -147,11 +117,7 @@ public:
bool hasData() const { return HasData; }
- /// Get associated symbol data.
- MCSymbolData &getData() const {
- assert(HasData && "Missing symbol data!");
- return Data;
- }
+ MCSymbol &getData() const { return *const_cast<MCSymbol *>(this); }
/// Initialize symbol data.
///
@@ -297,6 +263,19 @@ public:
Flags = (Flags & ~Mask) | Value;
}
+ MCFragment *getFragment() const { return Fragment.getPointer(); }
+ void setFragment(MCFragment *Value) const { Fragment.setPointer(Value); }
+
+ bool isExternal() const { return Fragment.getInt() & 1; }
+ void setExternal(bool Value) const {
+ Fragment.setInt((Fragment.getInt() & ~1) | unsigned(Value));
+ }
+
+ bool isPrivateExtern() const { return Fragment.getInt() & 2; }
+ void setPrivateExtern(bool Value) {
+ Fragment.setInt((Fragment.getInt() & ~2) | (unsigned(Value) << 1));
+ }
+
/// print - Print the value to the stream \p OS.
void print(raw_ostream &OS) const;
@@ -304,6 +283,8 @@ public:
void dump() const;
};
+typedef MCSymbol MCSymbolData;
+
inline raw_ostream &operator<<(raw_ostream &OS, const MCSymbol &Sym) {
Sym.print(OS);
return OS;
Modified: llvm/trunk/lib/MC/MCAssembler.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCAssembler.cpp?rev=238609&r1=238608&r2=238609&view=diff
==============================================================================
--- llvm/trunk/lib/MC/MCAssembler.cpp (original)
+++ llvm/trunk/lib/MC/MCAssembler.cpp Fri May 29 15:31:23 2015
@@ -1183,18 +1183,6 @@ void MCFragment::dump() {
OS << ">";
}
-void MCSymbolData::dump() const {
- raw_ostream &OS = llvm::errs();
-
- OS << "<MCSymbolData"
- << " Fragment:" << getFragment();
- if (isExternal())
- OS << " (external)";
- if (isPrivateExtern())
- OS << " (private extern)";
- OS << ">";
-}
-
void MCAssembler::dump() {
raw_ostream &OS = llvm::errs();
More information about the llvm-commits
mailing list