mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-08-15 06:29:05 +00:00
MCAssembler: Sink fixup list into MCDataFragment.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@96093 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -54,10 +54,6 @@ class MCFragment : public ilist_node<MCFragment> {
|
|||||||
MCFragment(const MCFragment&); // DO NOT IMPLEMENT
|
MCFragment(const MCFragment&); // DO NOT IMPLEMENT
|
||||||
void operator=(const MCFragment&); // DO NOT IMPLEMENT
|
void operator=(const MCFragment&); // DO NOT IMPLEMENT
|
||||||
|
|
||||||
public:
|
|
||||||
typedef std::vector<MCAsmFixup>::const_iterator const_fixup_iterator;
|
|
||||||
typedef std::vector<MCAsmFixup>::iterator fixup_iterator;
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
enum FragmentType {
|
enum FragmentType {
|
||||||
FT_Data,
|
FT_Data,
|
||||||
@@ -85,11 +81,6 @@ private:
|
|||||||
/// FileSize - The file size of this section. This is ~0 until initialized.
|
/// FileSize - The file size of this section. This is ~0 until initialized.
|
||||||
uint64_t FileSize;
|
uint64_t FileSize;
|
||||||
|
|
||||||
/// Fixups - The list of fixups in this fragment.
|
|
||||||
//
|
|
||||||
// FIXME: This should be sunk into MCDataFragment.
|
|
||||||
std::vector<MCAsmFixup> Fixups;
|
|
||||||
|
|
||||||
/// @}
|
/// @}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
@@ -111,36 +102,6 @@ public:
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// @name Fixup Access
|
|
||||||
/// @{
|
|
||||||
|
|
||||||
/// LookupFixup - Look up the fixup for the given \arg Fragment and \arg
|
|
||||||
/// Offset.
|
|
||||||
///
|
|
||||||
/// If multiple fixups exist for the same fragment and offset it is undefined
|
|
||||||
/// which one is returned.
|
|
||||||
//
|
|
||||||
// FIXME: This isn't horribly slow in practice, but there are much nicer
|
|
||||||
// solutions to applying the fixups. This will be fixed by sinking fixups into
|
|
||||||
// data fragments exclusively.
|
|
||||||
const MCAsmFixup *LookupFixup(uint64_t Offset) const {
|
|
||||||
for (unsigned i = 0, e = Fixups.size(); i != e; ++i)
|
|
||||||
if (Fixups[i].Offset == Offset)
|
|
||||||
return &Fixups[i];
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
std::vector<MCAsmFixup> &getFixups() { return Fixups; }
|
|
||||||
const std::vector<MCAsmFixup> &getFixups() const { return Fixups; }
|
|
||||||
|
|
||||||
fixup_iterator fixup_begin() { return Fixups.begin(); }
|
|
||||||
const_fixup_iterator fixup_begin() const { return Fixups.begin(); }
|
|
||||||
|
|
||||||
fixup_iterator fixup_end() {return Fixups.end();}
|
|
||||||
const_fixup_iterator fixup_end() const {return Fixups.end();}
|
|
||||||
|
|
||||||
size_t fixup_size() const { return Fixups.size(); }
|
|
||||||
|
|
||||||
/// @name Assembler Backend Support
|
/// @name Assembler Backend Support
|
||||||
/// @{
|
/// @{
|
||||||
//
|
//
|
||||||
@@ -173,6 +134,13 @@ public:
|
|||||||
class MCDataFragment : public MCFragment {
|
class MCDataFragment : public MCFragment {
|
||||||
SmallString<32> Contents;
|
SmallString<32> Contents;
|
||||||
|
|
||||||
|
/// Fixups - The list of fixups in this fragment.
|
||||||
|
std::vector<MCAsmFixup> Fixups;
|
||||||
|
|
||||||
|
public:
|
||||||
|
typedef std::vector<MCAsmFixup>::const_iterator const_fixup_iterator;
|
||||||
|
typedef std::vector<MCAsmFixup>::iterator fixup_iterator;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
MCDataFragment(MCSectionData *SD = 0) : MCFragment(FT_Data, SD) {}
|
MCDataFragment(MCSectionData *SD = 0) : MCFragment(FT_Data, SD) {}
|
||||||
|
|
||||||
@@ -188,6 +156,22 @@ public:
|
|||||||
|
|
||||||
/// @}
|
/// @}
|
||||||
|
|
||||||
|
/// @name Fixup Access
|
||||||
|
/// @{
|
||||||
|
|
||||||
|
std::vector<MCAsmFixup> &getFixups() { return Fixups; }
|
||||||
|
const std::vector<MCAsmFixup> &getFixups() const { return Fixups; }
|
||||||
|
|
||||||
|
fixup_iterator fixup_begin() { return Fixups.begin(); }
|
||||||
|
const_fixup_iterator fixup_begin() const { return Fixups.begin(); }
|
||||||
|
|
||||||
|
fixup_iterator fixup_end() {return Fixups.end();}
|
||||||
|
const_fixup_iterator fixup_end() const {return Fixups.end();}
|
||||||
|
|
||||||
|
size_t fixup_size() const { return Fixups.size(); }
|
||||||
|
|
||||||
|
/// @}
|
||||||
|
|
||||||
static bool classof(const MCFragment *F) {
|
static bool classof(const MCFragment *F) {
|
||||||
return F->getKind() == MCFragment::FT_Data;
|
return F->getKind() == MCFragment::FT_Data;
|
||||||
}
|
}
|
||||||
|
@@ -455,7 +455,7 @@ public:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ComputeRelocationInfo(MCAssembler &Asm, MCFragment &Fragment,
|
void ComputeRelocationInfo(MCAssembler &Asm, MCDataFragment &Fragment,
|
||||||
MCAsmFixup &Fixup,
|
MCAsmFixup &Fixup,
|
||||||
DenseMap<const MCSymbol*,MCSymbolData*> &SymbolMap,
|
DenseMap<const MCSymbol*,MCSymbolData*> &SymbolMap,
|
||||||
std::vector<MachRelocationEntry> &Relocs) {
|
std::vector<MachRelocationEntry> &Relocs) {
|
||||||
@@ -780,9 +780,10 @@ public:
|
|||||||
unsigned NumRelocsStart = RelocInfos.size();
|
unsigned NumRelocsStart = RelocInfos.size();
|
||||||
for (MCSectionData::reverse_iterator it2 = SD.rbegin(),
|
for (MCSectionData::reverse_iterator it2 = SD.rbegin(),
|
||||||
ie2 = SD.rend(); it2 != ie2; ++it2)
|
ie2 = SD.rend(); it2 != ie2; ++it2)
|
||||||
for (unsigned i = 0, e = it2->fixup_size(); i != e; ++i)
|
if (MCDataFragment *DF = dyn_cast<MCDataFragment>(&*it2))
|
||||||
ComputeRelocationInfo(Asm, *it2, it2->getFixups()[e - i - 1],
|
for (unsigned i = 0, e = DF->fixup_size(); i != e; ++i)
|
||||||
SymbolMap, RelocInfos);
|
ComputeRelocationInfo(Asm, *DF, DF->getFixups()[e - i - 1],
|
||||||
|
SymbolMap, RelocInfos);
|
||||||
|
|
||||||
unsigned NumRelocs = RelocInfos.size() - NumRelocsStart;
|
unsigned NumRelocs = RelocInfos.size() - NumRelocsStart;
|
||||||
uint64_t SectionStart = SectionDataStart + SD.getAddress();
|
uint64_t SectionStart = SectionDataStart + SD.getAddress();
|
||||||
@@ -1198,16 +1199,6 @@ void MCFragment::dump() {
|
|||||||
OS << "<MCFragment " << (void*) this << " Offset:" << Offset
|
OS << "<MCFragment " << (void*) this << " Offset:" << Offset
|
||||||
<< " FileSize:" << FileSize;
|
<< " FileSize:" << FileSize;
|
||||||
|
|
||||||
if (!Fixups.empty()) {
|
|
||||||
OS << "\n";
|
|
||||||
OS << " Fixups:[";
|
|
||||||
for (fixup_iterator it = fixup_begin(), ie = fixup_end(); it != ie; ++it) {
|
|
||||||
if (it != fixup_begin()) OS << ",\n ";
|
|
||||||
OS << *it;
|
|
||||||
}
|
|
||||||
OS << "]";
|
|
||||||
}
|
|
||||||
|
|
||||||
OS << ">";
|
OS << ">";
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1233,7 +1224,19 @@ void MCDataFragment::dump() {
|
|||||||
if (i) OS << ",";
|
if (i) OS << ",";
|
||||||
OS << hexdigit((Contents[i] >> 4) & 0xF) << hexdigit(Contents[i] & 0xF);
|
OS << hexdigit((Contents[i] >> 4) & 0xF) << hexdigit(Contents[i] & 0xF);
|
||||||
}
|
}
|
||||||
OS << "]>";
|
OS << "]";
|
||||||
|
|
||||||
|
if (!getFixups().empty()) {
|
||||||
|
OS << ",\n ";
|
||||||
|
OS << " Fixups:[";
|
||||||
|
for (fixup_iterator it = fixup_begin(), ie = fixup_end(); it != ie; ++it) {
|
||||||
|
if (it != fixup_begin()) OS << ",\n ";
|
||||||
|
OS << *it;
|
||||||
|
}
|
||||||
|
OS << "]";
|
||||||
|
}
|
||||||
|
|
||||||
|
OS << ">";
|
||||||
}
|
}
|
||||||
|
|
||||||
void MCFillFragment::dump() {
|
void MCFillFragment::dump() {
|
||||||
|
Reference in New Issue
Block a user