MC: Add TargetAsmBackend::MayNeedRelaxation, for checking whether a particular instruction + fixups might need relaxation.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@99249 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Daniel Dunbar
2010-03-23 03:13:05 +00:00
parent 8f9b80e5df
commit 337055e62f
5 changed files with 45 additions and 5 deletions

View File

@@ -715,7 +715,7 @@ void MCAssembler::FinishLayout(MCAsmLayout &Layout) {
// Create a new data fragment for the instruction.
//
// FIXME: Reuse previous data fragment if possible.
// FIXME-PERF: Reuse previous data fragment if possible.
MCDataFragment *DF = new MCDataFragment();
SD.getFragmentList().insert(it2, DF);

View File

@@ -383,12 +383,19 @@ void MCMachOStreamer::EmitInstruction(const MCInst &Inst) {
Assembler.getEmitter().EncodeInstruction(Inst, VecOS, Fixups);
VecOS.flush();
// Add the fixups and data.
MCDataFragment *DF = getOrCreateDataFragment();
// FIXME: Eliminate this copy.
SmallVector<MCAsmFixup, 4> AsmFixups;
for (unsigned i = 0, e = Fixups.size(); i != e; ++i) {
MCFixup &F = Fixups[i];
DF->addFixup(MCAsmFixup(DF->getContents().size()+F.getOffset(),
*F.getValue(), F.getKind()));
AsmFixups.push_back(MCAsmFixup(F.getOffset(), *F.getValue(),
F.getKind()));
}
// Add the fixups and data.
MCDataFragment *DF = getOrCreateDataFragment();
for (unsigned i = 0, e = AsmFixups.size(); i != e; ++i) {
AsmFixups[i].Offset += DF->getContents().size();
DF->addFixup(AsmFixups[i]);
}
DF->getContents().append(Code.begin(), Code.end());
}