forked from OSchip/llvm-project
MC: Share the MCAsmLayout object, although its still not used for anything important.
llvm-svn: 99202
This commit is contained in:
parent
e60e3ab624
commit
32ffc58ca9
|
@ -642,16 +642,17 @@ private:
|
||||||
|
|
||||||
/// Check whether a fixup can be satisfied, or whether it needs to be relaxed
|
/// Check whether a fixup can be satisfied, or whether it needs to be relaxed
|
||||||
/// (increased in size, in order to hold its value correctly).
|
/// (increased in size, in order to hold its value correctly).
|
||||||
bool FixupNeedsRelaxation(MCAsmFixup &Fixup, MCDataFragment *DF);
|
bool FixupNeedsRelaxation(MCAsmFixup &Fixup, MCDataFragment *DF,
|
||||||
|
const MCAsmLayout &Layout) const;
|
||||||
|
|
||||||
/// LayoutSection - Assign offsets and sizes to the fragments in the section
|
/// LayoutSection - Assign offsets and sizes to the fragments in the section
|
||||||
/// \arg SD, and update the section size. The section file offset should
|
/// \arg SD, and update the section size. The section file offset should
|
||||||
/// already have been computed.
|
/// already have been computed.
|
||||||
void LayoutSection(MCSectionData &SD);
|
void LayoutSection(MCSectionData &SD, MCAsmLayout &Layout);
|
||||||
|
|
||||||
/// LayoutOnce - Perform one layout iteration and return true if any offsets
|
/// LayoutOnce - Perform one layout iteration and return true if any offsets
|
||||||
/// were adjusted.
|
/// were adjusted.
|
||||||
bool LayoutOnce();
|
bool LayoutOnce(MCAsmLayout &Layout);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
/// Find the symbol which defines the atom containing given address, inside
|
/// Find the symbol which defines the atom containing given address, inside
|
||||||
|
|
|
@ -297,8 +297,8 @@ bool MCAssembler::EvaluateFixup(const MCAsmLayout &Layout, MCAsmFixup &Fixup,
|
||||||
return IsResolved;
|
return IsResolved;
|
||||||
}
|
}
|
||||||
|
|
||||||
void MCAssembler::LayoutSection(MCSectionData &SD) {
|
void MCAssembler::LayoutSection(MCSectionData &SD,
|
||||||
MCAsmLayout Layout(*this);
|
MCAsmLayout &Layout) {
|
||||||
uint64_t Address = SD.getAddress();
|
uint64_t Address = SD.getAddress();
|
||||||
|
|
||||||
for (MCSectionData::iterator it = SD.begin(), ie = SD.end(); it != ie; ++it) {
|
for (MCSectionData::iterator it = SD.begin(), ie = SD.end(); it != ie; ++it) {
|
||||||
|
@ -533,14 +533,14 @@ void MCAssembler::Finish() {
|
||||||
dump(); });
|
dump(); });
|
||||||
|
|
||||||
// Layout until everything fits.
|
// Layout until everything fits.
|
||||||
while (LayoutOnce())
|
MCAsmLayout Layout(*this);
|
||||||
|
while (LayoutOnce(Layout))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
DEBUG_WITH_TYPE("mc-dump", {
|
DEBUG_WITH_TYPE("mc-dump", {
|
||||||
llvm::errs() << "assembler backend - post-layout\n--\n";
|
llvm::errs() << "assembler backend - post-layout\n--\n";
|
||||||
dump(); });
|
dump(); });
|
||||||
|
|
||||||
// FIXME: Factor out MCObjectWriter.
|
|
||||||
llvm::OwningPtr<MCObjectWriter> Writer(getBackend().createObjectWriter(OS));
|
llvm::OwningPtr<MCObjectWriter> Writer(getBackend().createObjectWriter(OS));
|
||||||
if (!Writer)
|
if (!Writer)
|
||||||
llvm_report_error("unable to create object writer!");
|
llvm_report_error("unable to create object writer!");
|
||||||
|
@ -550,9 +550,6 @@ void MCAssembler::Finish() {
|
||||||
Writer->ExecutePostLayoutBinding(*this);
|
Writer->ExecutePostLayoutBinding(*this);
|
||||||
|
|
||||||
// Evaluate and apply the fixups, generating relocation entries as necessary.
|
// Evaluate and apply the fixups, generating relocation entries as necessary.
|
||||||
//
|
|
||||||
// FIXME: Share layout object.
|
|
||||||
MCAsmLayout Layout(*this);
|
|
||||||
for (MCAssembler::iterator it = begin(), ie = end(); it != ie; ++it) {
|
for (MCAssembler::iterator it = begin(), ie = end(); it != ie; ++it) {
|
||||||
for (MCSectionData::iterator it2 = it->begin(),
|
for (MCSectionData::iterator it2 = it->begin(),
|
||||||
ie2 = it->end(); it2 != ie2; ++it2) {
|
ie2 = it->end(); it2 != ie2; ++it2) {
|
||||||
|
@ -584,10 +581,8 @@ void MCAssembler::Finish() {
|
||||||
OS.flush();
|
OS.flush();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool MCAssembler::FixupNeedsRelaxation(MCAsmFixup &Fixup, MCDataFragment *DF) {
|
bool MCAssembler::FixupNeedsRelaxation(MCAsmFixup &Fixup, MCDataFragment *DF,
|
||||||
// FIXME: Share layout object.
|
const MCAsmLayout &Layout) const {
|
||||||
MCAsmLayout Layout(*this);
|
|
||||||
|
|
||||||
// Currently we only need to relax X86::reloc_pcrel_1byte.
|
// Currently we only need to relax X86::reloc_pcrel_1byte.
|
||||||
if (unsigned(Fixup.Kind) != X86::reloc_pcrel_1byte)
|
if (unsigned(Fixup.Kind) != X86::reloc_pcrel_1byte)
|
||||||
return false;
|
return false;
|
||||||
|
@ -602,7 +597,7 @@ bool MCAssembler::FixupNeedsRelaxation(MCAsmFixup &Fixup, MCDataFragment *DF) {
|
||||||
return int64_t(Value) != int64_t(int8_t(Value));
|
return int64_t(Value) != int64_t(int8_t(Value));
|
||||||
}
|
}
|
||||||
|
|
||||||
bool MCAssembler::LayoutOnce() {
|
bool MCAssembler::LayoutOnce(MCAsmLayout &Layout) {
|
||||||
// Layout the concrete sections and fragments.
|
// Layout the concrete sections and fragments.
|
||||||
uint64_t Address = 0;
|
uint64_t Address = 0;
|
||||||
MCSectionData *Prev = 0;
|
MCSectionData *Prev = 0;
|
||||||
|
@ -623,7 +618,7 @@ bool MCAssembler::LayoutOnce() {
|
||||||
|
|
||||||
// Layout the section fragments and its size.
|
// Layout the section fragments and its size.
|
||||||
SD.setAddress(Address);
|
SD.setAddress(Address);
|
||||||
LayoutSection(SD);
|
LayoutSection(SD, Layout);
|
||||||
Address += SD.getFileSize();
|
Address += SD.getFileSize();
|
||||||
|
|
||||||
Prev = &SD;
|
Prev = &SD;
|
||||||
|
@ -642,7 +637,7 @@ bool MCAssembler::LayoutOnce() {
|
||||||
Address += Pad;
|
Address += Pad;
|
||||||
|
|
||||||
SD.setAddress(Address);
|
SD.setAddress(Address);
|
||||||
LayoutSection(SD);
|
LayoutSection(SD, Layout);
|
||||||
Address += SD.getSize();
|
Address += SD.getSize();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -661,7 +656,7 @@ bool MCAssembler::LayoutOnce() {
|
||||||
MCAsmFixup &Fixup = *it3;
|
MCAsmFixup &Fixup = *it3;
|
||||||
|
|
||||||
// Check whether we need to relax this fixup.
|
// Check whether we need to relax this fixup.
|
||||||
if (!FixupNeedsRelaxation(Fixup, DF))
|
if (!FixupNeedsRelaxation(Fixup, DF, Layout))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
// Relax the instruction.
|
// Relax the instruction.
|
||||||
|
|
Loading…
Reference in New Issue