mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-10-05 11:17:53 +00:00
Merge MCSymbol and MCSymbolData.
As a transition hack leave MCSymbolData as a typedef of MCSymbol. I will be removing that in a second. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@238609 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -18,7 +18,6 @@ class MCAssembler;
|
|||||||
class MCFragment;
|
class MCFragment;
|
||||||
class MCSection;
|
class MCSection;
|
||||||
class MCSymbol;
|
class MCSymbol;
|
||||||
class MCSymbolData;
|
|
||||||
|
|
||||||
/// Encapsulates the layout of an assembly file at a particular point in time.
|
/// Encapsulates the layout of an assembly file at a particular point in time.
|
||||||
///
|
///
|
||||||
|
@@ -21,7 +21,6 @@ class MCFixup;
|
|||||||
class MCFragment;
|
class MCFragment;
|
||||||
class MCObjectWriter;
|
class MCObjectWriter;
|
||||||
class MCSymbol;
|
class MCSymbol;
|
||||||
class MCSymbolData;
|
|
||||||
class MCValue;
|
class MCValue;
|
||||||
class raw_pwrite_stream;
|
class raw_pwrite_stream;
|
||||||
|
|
||||||
|
@@ -24,7 +24,6 @@ class MCCodeEmitter;
|
|||||||
class MCExpr;
|
class MCExpr;
|
||||||
class MCInst;
|
class MCInst;
|
||||||
class MCSymbol;
|
class MCSymbol;
|
||||||
class MCSymbolData;
|
|
||||||
class raw_ostream;
|
class raw_ostream;
|
||||||
|
|
||||||
class MCELFStreamer : public MCObjectStreamer {
|
class MCELFStreamer : public MCObjectStreamer {
|
||||||
|
@@ -22,7 +22,6 @@ class MCAsmLayout;
|
|||||||
class MCAssembler;
|
class MCAssembler;
|
||||||
class MCFixup;
|
class MCFixup;
|
||||||
class MCFragment;
|
class MCFragment;
|
||||||
class MCSymbolData;
|
|
||||||
class MCSymbolRefExpr;
|
class MCSymbolRefExpr;
|
||||||
class MCValue;
|
class MCValue;
|
||||||
|
|
||||||
|
@@ -27,39 +27,6 @@ class MCSection;
|
|||||||
class MCContext;
|
class MCContext;
|
||||||
class raw_ostream;
|
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,
|
/// MCSymbol - Instances of this class represent a symbol name in the MC file,
|
||||||
/// and MCSymbols are created and uniqued by the MCContext class. MCSymbols
|
/// and MCSymbols are created and uniqued by the MCContext class. MCSymbols
|
||||||
/// should only be constructed with valid names for the object file.
|
/// 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.
|
/// additional per symbol information which is not easily classified.
|
||||||
mutable uint32_t Flags = 0;
|
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.
|
private: // MCContext creates and uniques these.
|
||||||
friend class MCExpr;
|
friend class MCExpr;
|
||||||
@@ -147,11 +117,7 @@ public:
|
|||||||
|
|
||||||
bool hasData() const { return HasData; }
|
bool hasData() const { return HasData; }
|
||||||
|
|
||||||
/// Get associated symbol data.
|
MCSymbol &getData() const { return *const_cast<MCSymbol *>(this); }
|
||||||
MCSymbolData &getData() const {
|
|
||||||
assert(HasData && "Missing symbol data!");
|
|
||||||
return Data;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Initialize symbol data.
|
/// Initialize symbol data.
|
||||||
///
|
///
|
||||||
@@ -297,6 +263,19 @@ public:
|
|||||||
Flags = (Flags & ~Mask) | Value;
|
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.
|
/// print - Print the value to the stream \p OS.
|
||||||
void print(raw_ostream &OS) const;
|
void print(raw_ostream &OS) const;
|
||||||
|
|
||||||
@@ -304,6 +283,8 @@ public:
|
|||||||
void dump() const;
|
void dump() const;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
typedef MCSymbol MCSymbolData;
|
||||||
|
|
||||||
inline raw_ostream &operator<<(raw_ostream &OS, const MCSymbol &Sym) {
|
inline raw_ostream &operator<<(raw_ostream &OS, const MCSymbol &Sym) {
|
||||||
Sym.print(OS);
|
Sym.print(OS);
|
||||||
return OS;
|
return OS;
|
||||||
|
@@ -1183,18 +1183,6 @@ void MCFragment::dump() {
|
|||||||
OS << ">";
|
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() {
|
void MCAssembler::dump() {
|
||||||
raw_ostream &OS = llvm::errs();
|
raw_ostream &OS = llvm::errs();
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user