Changeset View
Changeset View
Standalone View
Standalone View
llvm/lib/MC/MCObjectStreamer.cpp
Show First 20 Lines • Show All 182 Lines • ▼ Show 20 Lines | MCFragment *MCObjectStreamer::getCurrentFragment() const { | ||||
assert(getCurrentSectionOnly() && "No current section!"); | assert(getCurrentSectionOnly() && "No current section!"); | ||||
if (CurInsertionPoint != getCurrentSectionOnly()->getFragmentList().begin()) | if (CurInsertionPoint != getCurrentSectionOnly()->getFragmentList().begin()) | ||||
return &*std::prev(CurInsertionPoint); | return &*std::prev(CurInsertionPoint); | ||||
return nullptr; | return nullptr; | ||||
} | } | ||||
static bool CanReuseDataFragment(const MCDataFragment &F, | static bool CanReuseDataFragment(const MCDataFragment &F, MCObjectStreamer &OS, | ||||
const MCAssembler &Assembler, | |||||
const MCSubtargetInfo *STI) { | const MCSubtargetInfo *STI) { | ||||
if (!F.hasInstructions()) | if (!F.hasInstructions()) | ||||
return true; | return true; | ||||
MCAssembler &Assembler = OS.getAssembler(); | |||||
// When the target need align instructions, we need to determine the size | |||||
// of some instructions during the relaxation, the easiest way to do it is | |||||
// to emit each instruction into fragment of its own. | |||||
if (Assembler.getBackend().needAlign(OS)) | |||||
return !F.hasInstructions(); | |||||
// When bundling is enabled, we don't want to add data to a fragment that | // When bundling is enabled, we don't want to add data to a fragment that | ||||
// already has instructions (see MCELFStreamer::EmitInstToData for details) | // already has instructions (see MCELFStreamer::EmitInstToData for details) | ||||
if (Assembler.isBundlingEnabled()) | if (Assembler.isBundlingEnabled()) | ||||
return Assembler.getRelaxAll(); | return Assembler.getRelaxAll(); | ||||
// If the subtarget is changed mid fragment we start a new fragment to record | // If the subtarget is changed mid fragment we start a new fragment to record | ||||
// the new STI. | // the new STI. | ||||
return !STI || F.getSubtargetInfo() == STI; | return !STI || F.getSubtargetInfo() == STI; | ||||
} | } | ||||
MCDataFragment * | MCDataFragment * | ||||
MCObjectStreamer::getOrCreateDataFragment(const MCSubtargetInfo *STI) { | MCObjectStreamer::getOrCreateDataFragment(const MCSubtargetInfo *STI) { | ||||
MCDataFragment *F = dyn_cast_or_null<MCDataFragment>(getCurrentFragment()); | MCDataFragment *F = dyn_cast_or_null<MCDataFragment>(getCurrentFragment()); | ||||
if (!F || !CanReuseDataFragment(*F, *Assembler, STI)) { | if (!F || !CanReuseDataFragment(*F, *this, STI)) { | ||||
F = new MCDataFragment(); | F = new MCDataFragment(); | ||||
insert(F); | insert(F); | ||||
} | } | ||||
return F; | return F; | ||||
} | } | ||||
MCBoundaryAlignFragment *MCObjectStreamer::getOrCreateBoundaryAlignFragment() { | |||||
auto *F = dyn_cast_or_null<MCBoundaryAlignFragment>(getCurrentFragment()); | |||||
if (!F || F->hasEmit()) { | |||||
F = new MCBoundaryAlignFragment(); | |||||
insert(F); | |||||
} | |||||
return F; | |||||
} | |||||
void MCObjectStreamer::visitUsedSymbol(const MCSymbol &Sym) { | void MCObjectStreamer::visitUsedSymbol(const MCSymbol &Sym) { | ||||
Assembler->registerSymbol(Sym); | Assembler->registerSymbol(Sym); | ||||
} | } | ||||
void MCObjectStreamer::EmitCFISections(bool EH, bool Debug) { | void MCObjectStreamer::EmitCFISections(bool EH, bool Debug) { | ||||
MCStreamer::EmitCFISections(EH, Debug); | MCStreamer::EmitCFISections(EH, Debug); | ||||
EmitEHFrame = EH; | EmitEHFrame = EH; | ||||
EmitDebugFrame = Debug; | EmitDebugFrame = Debug; | ||||
▲ Show 20 Lines • Show All 544 Lines • Show Last 20 Lines |