mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-02-25 03:30:37 +00:00
MC: Lift MCSymbolData::Index up to MCSymbol::Index, NFC
Lift `MCSymbolData::Index` up a level to `MCSymbol`, as preparation for packing it into the bitfield in `MCSymbol`. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@238001 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
117f3a66e8
commit
6c3a7cbe54
@ -56,9 +56,6 @@ class MCSymbolData {
|
|||||||
/// additional per symbol information which is not easily classified.
|
/// additional per symbol information which is not easily classified.
|
||||||
uint32_t Flags = 0;
|
uint32_t Flags = 0;
|
||||||
|
|
||||||
/// Index - Index field, for use by the object file implementation.
|
|
||||||
uint64_t Index = 0;
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
MCSymbolData() { Offset = 0; }
|
MCSymbolData() { Offset = 0; }
|
||||||
|
|
||||||
@ -128,12 +125,6 @@ public:
|
|||||||
Flags = (Flags & ~Mask) | Value;
|
Flags = (Flags & ~Mask) | Value;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// getIndex - Get the (implementation defined) index.
|
|
||||||
uint64_t getIndex() const { return Index; }
|
|
||||||
|
|
||||||
/// setIndex - Set the (implementation defined) index.
|
|
||||||
void setIndex(uint64_t Value) { Index = Value; }
|
|
||||||
|
|
||||||
/// @}
|
/// @}
|
||||||
|
|
||||||
void dump() const;
|
void dump() const;
|
||||||
@ -178,6 +169,9 @@ class MCSymbol {
|
|||||||
mutable bool HasData : 1;
|
mutable bool HasData : 1;
|
||||||
mutable MCSymbolData Data;
|
mutable MCSymbolData Data;
|
||||||
|
|
||||||
|
/// Index field, for use by the object file implementation.
|
||||||
|
mutable uint64_t Index = 0;
|
||||||
|
|
||||||
private: // MCContext creates and uniques these.
|
private: // MCContext creates and uniques these.
|
||||||
friend class MCExpr;
|
friend class MCExpr;
|
||||||
friend class MCContext;
|
friend class MCContext;
|
||||||
@ -287,6 +281,18 @@ public:
|
|||||||
|
|
||||||
/// @}
|
/// @}
|
||||||
|
|
||||||
|
/// Get the (implementation defined) index.
|
||||||
|
uint64_t getIndex() const {
|
||||||
|
assert(HasData && "Uninitialized symbol data");
|
||||||
|
return Index;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Set the (implementation defined) index.
|
||||||
|
void setIndex(uint64_t Value) const {
|
||||||
|
assert(HasData && "Uninitialized symbol data");
|
||||||
|
Index = Value;
|
||||||
|
}
|
||||||
|
|
||||||
/// 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;
|
||||||
|
|
||||||
|
@ -858,8 +858,8 @@ void ELFObjectWriter::RecordRelocation(MCAssembler &Asm,
|
|||||||
uint64_t
|
uint64_t
|
||||||
ELFObjectWriter::getSymbolIndexInSymbolTable(const MCAssembler &Asm,
|
ELFObjectWriter::getSymbolIndexInSymbolTable(const MCAssembler &Asm,
|
||||||
const MCSymbol *S) {
|
const MCSymbol *S) {
|
||||||
const MCSymbolData &SD = Asm.getSymbolData(*S);
|
assert(S->hasData());
|
||||||
return SD.getIndex();
|
return S->getIndex();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ELFObjectWriter::isInSymtab(const MCAsmLayout &Layout,
|
bool ELFObjectWriter::isInSymtab(const MCAsmLayout &Layout,
|
||||||
@ -1049,12 +1049,12 @@ void ELFObjectWriter::computeSymbolTable(
|
|||||||
// symbols with non-local bindings.
|
// symbols with non-local bindings.
|
||||||
unsigned Index = FileSymbolData.size() + 1;
|
unsigned Index = FileSymbolData.size() + 1;
|
||||||
for (unsigned i = 0, e = LocalSymbolData.size(); i != e; ++i)
|
for (unsigned i = 0, e = LocalSymbolData.size(); i != e; ++i)
|
||||||
LocalSymbolData[i].Symbol->getData().setIndex(Index++);
|
LocalSymbolData[i].Symbol->setIndex(Index++);
|
||||||
|
|
||||||
for (unsigned i = 0, e = ExternalSymbolData.size(); i != e; ++i)
|
for (unsigned i = 0, e = ExternalSymbolData.size(); i != e; ++i)
|
||||||
ExternalSymbolData[i].Symbol->getData().setIndex(Index++);
|
ExternalSymbolData[i].Symbol->setIndex(Index++);
|
||||||
for (unsigned i = 0, e = UndefinedSymbolData.size(); i != e; ++i)
|
for (unsigned i = 0, e = UndefinedSymbolData.size(); i != e; ++i)
|
||||||
UndefinedSymbolData[i].Symbol->getData().setIndex(Index++);
|
UndefinedSymbolData[i].Symbol->setIndex(Index++);
|
||||||
}
|
}
|
||||||
|
|
||||||
MCSectionELF *
|
MCSectionELF *
|
||||||
|
@ -1268,7 +1268,7 @@ void MCSymbolData::dump() const {
|
|||||||
<< " Fragment:" << getFragment();
|
<< " Fragment:" << getFragment();
|
||||||
if (!isCommon())
|
if (!isCommon())
|
||||||
OS << " Offset:" << getOffset();
|
OS << " Offset:" << getOffset();
|
||||||
OS << " Flags:" << getFlags() << " Index:" << getIndex();
|
OS << " Flags:" << getFlags();
|
||||||
if (isCommon())
|
if (isCommon())
|
||||||
OS << " (common, size:" << getCommonSize()
|
OS << " (common, size:" << getCommonSize()
|
||||||
<< " align: " << getCommonAlignment() << ")";
|
<< " align: " << getCommonAlignment() << ")";
|
||||||
@ -1295,7 +1295,7 @@ void MCAssembler::dump() {
|
|||||||
if (it != symbol_begin()) OS << ",\n ";
|
if (it != symbol_begin()) OS << ",\n ";
|
||||||
OS << "(";
|
OS << "(";
|
||||||
it->dump();
|
it->dump();
|
||||||
OS << ",";
|
OS << ", Index:" << it->getIndex() << ", ";
|
||||||
it->getData().dump();
|
it->getData().dump();
|
||||||
OS << ")";
|
OS << ")";
|
||||||
}
|
}
|
||||||
|
@ -616,11 +616,11 @@ void MachObjectWriter::ComputeSymbolTable(
|
|||||||
// Set the symbol indices.
|
// Set the symbol indices.
|
||||||
Index = 0;
|
Index = 0;
|
||||||
for (unsigned i = 0, e = LocalSymbolData.size(); i != e; ++i)
|
for (unsigned i = 0, e = LocalSymbolData.size(); i != e; ++i)
|
||||||
LocalSymbolData[i].Symbol->getData().setIndex(Index++);
|
LocalSymbolData[i].Symbol->setIndex(Index++);
|
||||||
for (unsigned i = 0, e = ExternalSymbolData.size(); i != e; ++i)
|
for (unsigned i = 0, e = ExternalSymbolData.size(); i != e; ++i)
|
||||||
ExternalSymbolData[i].Symbol->getData().setIndex(Index++);
|
ExternalSymbolData[i].Symbol->setIndex(Index++);
|
||||||
for (unsigned i = 0, e = UndefinedSymbolData.size(); i != e; ++i)
|
for (unsigned i = 0, e = UndefinedSymbolData.size(); i != e; ++i)
|
||||||
UndefinedSymbolData[i].Symbol->getData().setIndex(Index++);
|
UndefinedSymbolData[i].Symbol->setIndex(Index++);
|
||||||
|
|
||||||
for (const MCSectionData &SD : Asm) {
|
for (const MCSectionData &SD : Asm) {
|
||||||
std::vector<RelAndSymbol> &Relocs = Relocations[&SD];
|
std::vector<RelAndSymbol> &Relocs = Relocations[&SD];
|
||||||
@ -629,7 +629,7 @@ void MachObjectWriter::ComputeSymbolTable(
|
|||||||
continue;
|
continue;
|
||||||
|
|
||||||
// Set the Index and the IsExtern bit.
|
// Set the Index and the IsExtern bit.
|
||||||
unsigned Index = Rel.Sym->getData().getIndex();
|
unsigned Index = Rel.Sym->getIndex();
|
||||||
assert(isInt<24>(Index));
|
assert(isInt<24>(Index));
|
||||||
if (IsLittleEndian)
|
if (IsLittleEndian)
|
||||||
Rel.MRE.r_word1 = (Rel.MRE.r_word1 & (~0U << 24)) | Index | (1 << 27);
|
Rel.MRE.r_word1 = (Rel.MRE.r_word1 & (~0U << 24)) | Index | (1 << 27);
|
||||||
@ -982,7 +982,7 @@ void MachObjectWriter::WriteObject(MCAssembler &Asm,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Write32(Asm.getSymbolData(*it->Symbol).getIndex());
|
Write32(it->Symbol->getIndex());
|
||||||
}
|
}
|
||||||
|
|
||||||
// FIXME: Check that offsets match computed ones.
|
// FIXME: Check that offsets match computed ones.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user