mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-02-21 06:30:16 +00:00
MC: When running with -mc-relax-all, we can eagerly relax instructions and avoid creating unnecessary MCInstFragments.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@104736 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
2ac0c453b2
commit
83194de76a
@ -845,10 +845,7 @@ bool MCAssembler::LayoutOnce(MCAsmLayout &Layout) {
|
|||||||
for (unsigned i = 0, e = Fixups.size(); i != e; ++i)
|
for (unsigned i = 0, e = Fixups.size(); i != e; ++i)
|
||||||
IF->getFixups().push_back(Fixups[i]);
|
IF->getFixups().push_back(Fixups[i]);
|
||||||
|
|
||||||
// Update the layout, and remember that we relaxed. If we are relaxing
|
// Update the layout, and remember that we relaxed.
|
||||||
// everything, we can skip this step since nothing will depend on updating
|
|
||||||
// the values.
|
|
||||||
if (!getRelaxAll())
|
|
||||||
Layout.UpdateForSlide(IF, SlideAmount);
|
Layout.UpdateForSlide(IF, SlideAmount);
|
||||||
WasRelaxed = true;
|
WasRelaxed = true;
|
||||||
}
|
}
|
||||||
|
@ -463,23 +463,25 @@ void MCMachOStreamer::EmitInstruction(const MCInst &Inst) {
|
|||||||
|
|
||||||
CurSectionData->setHasInstructions(true);
|
CurSectionData->setHasInstructions(true);
|
||||||
|
|
||||||
// See if we might need to relax this instruction, if so it needs its own
|
// If this instruction doesn't need relaxation, just emit it as data.
|
||||||
// fragment.
|
if (!Assembler.getBackend().MayNeedRelaxation(Inst)) {
|
||||||
//
|
|
||||||
// FIXME-PERF: Support target hook to do a fast path that avoids the encoder,
|
|
||||||
// when we can immediately tell that we will get something which might need
|
|
||||||
// relaxation (and compute its size).
|
|
||||||
//
|
|
||||||
// FIXME-PERF: We should also be smart about immediately relaxing instructions
|
|
||||||
// which we can already show will never possibly fit (we can also do a very
|
|
||||||
// good job of this before we do the first relaxation pass, because we have
|
|
||||||
// total knowledge about undefined symbols at that point). Even now, though,
|
|
||||||
// we can do a decent job, especially on Darwin where scattering means that we
|
|
||||||
// are going to often know that we can never fully resolve a fixup.
|
|
||||||
if (Assembler.getBackend().MayNeedRelaxation(Inst))
|
|
||||||
EmitInstToFragment(Inst);
|
|
||||||
else
|
|
||||||
EmitInstToData(Inst);
|
EmitInstToData(Inst);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Otherwise, if we are relaxing everything, relax the instruction as much as
|
||||||
|
// possible and emit it as data.
|
||||||
|
if (Assembler.getRelaxAll()) {
|
||||||
|
MCInst Relaxed;
|
||||||
|
Assembler.getBackend().RelaxInstruction(Inst, Relaxed);
|
||||||
|
while (Assembler.getBackend().MayNeedRelaxation(Relaxed))
|
||||||
|
Assembler.getBackend().RelaxInstruction(Relaxed, Relaxed);
|
||||||
|
EmitInstToData(Relaxed);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Otherwise emit to a separate fragment.
|
||||||
|
EmitInstToFragment(Inst);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MCMachOStreamer::Finish() {
|
void MCMachOStreamer::Finish() {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user