Skip to content

Commit 29e3c2e

Browse files
committed
MCAsmBackend: Remove unneeded MCAssembler parameter
1 parent d9dfe75 commit 29e3c2e

File tree

4 files changed

+15
-15
lines changed

4 files changed

+15
-15
lines changed

llvm/include/llvm/MC/MCAsmBackend.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@ class LLVM_ABI MCAsmBackend {
200200

201201
// Return true if fragment offsets have been adjusted and an extra layout
202202
// iteration is needed.
203-
virtual bool finishLayout(const MCAssembler &Asm) const { return false; }
203+
virtual bool finishLayout() const { return false; }
204204

205205
/// Generate the compact unwind encoding for the CFI instructions.
206206
virtual uint64_t generateCompactUnwindEncoding(const MCDwarfFrameInfo *FI,

llvm/lib/MC/MCAssembler.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -659,7 +659,7 @@ void MCAssembler::layout() {
659659

660660
// Some targets might want to adjust fragment offsets. If so, perform another
661661
// layout iteration.
662-
if (getBackend().finishLayout(*this))
662+
if (getBackend().finishLayout())
663663
for (MCSection &Sec : *this)
664664
layoutSection(Sec);
665665

llvm/lib/Target/Hexagon/MCTargetDesc/HexagonAsmBackend.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -569,9 +569,9 @@ class HexagonAsmBackend : public MCAsmBackend {
569569
return true;
570570
}
571571

572-
bool finishLayout(const MCAssembler &Asm) const override {
572+
bool finishLayout() const override {
573573
SmallVector<MCFragment *> Frags;
574-
for (MCSection &Sec : Asm) {
574+
for (MCSection &Sec : *Asm) {
575575
Frags.clear();
576576
for (MCFragment &F : Sec)
577577
Frags.push_back(&F);
@@ -580,7 +580,7 @@ class HexagonAsmBackend : public MCAsmBackend {
580580
default:
581581
break;
582582
case MCFragment::FT_Align: {
583-
auto Size = Asm.computeFragmentSize(*Frags[J]);
583+
auto Size = Asm->computeFragmentSize(*Frags[J]);
584584
for (auto K = J; K != 0 && Size >= HEXAGON_PACKET_SIZE;) {
585585
--K;
586586
switch (Frags[K]->getKind()) {
@@ -597,14 +597,14 @@ class HexagonAsmBackend : public MCAsmBackend {
597597
MCInst Inst = RF.getInst();
598598

599599
const bool WouldTraverseLabel = llvm::any_of(
600-
Asm.symbols(), [&Asm, &RF, &Inst](MCSymbol const &sym) {
600+
Asm->symbols(), [&RF, &Inst, Asm = Asm](MCSymbol const &sym) {
601601
uint64_t Offset = 0;
602-
const bool HasOffset = Asm.getSymbolOffset(sym, Offset);
602+
const bool HasOffset = Asm->getSymbolOffset(sym, Offset);
603603
const unsigned PacketSizeBytes =
604604
HexagonMCInstrInfo::bundleSize(Inst) *
605605
HEXAGON_INSTR_SIZE;
606606
const bool OffsetPastSym =
607-
Offset <= (Asm.getFragmentOffset(RF) + PacketSizeBytes);
607+
Offset <= Asm->getFragmentOffset(RF) + PacketSizeBytes;
608608
return !sym.isVariable() && Offset != 0 && HasOffset &&
609609
OffsetPastSym;
610610
});
@@ -631,7 +631,7 @@ class HexagonAsmBackend : public MCAsmBackend {
631631
*RF.getSubtargetInfo(), Inst);
632632
//assert(!Error);
633633
(void)Error;
634-
ReplaceInstruction(Asm.getEmitter(), RF, Inst);
634+
ReplaceInstruction(Asm->getEmitter(), RF, Inst);
635635
Size = 0; // Only look back one instruction
636636
break;
637637
}

llvm/lib/Target/X86/MCTargetDesc/X86AsmBackend.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@ class X86AsmBackend : public MCAsmBackend {
195195
bool padInstructionEncoding(MCFragment &RF, MCCodeEmitter &Emitter,
196196
unsigned &RemainingSize) const;
197197

198-
bool finishLayout(const MCAssembler &Asm) const override;
198+
bool finishLayout() const override;
199199

200200
unsigned getMaximumNopSize(const MCSubtargetInfo &STI) const override;
201201

@@ -850,7 +850,7 @@ bool X86AsmBackend::padInstructionEncoding(MCFragment &RF,
850850
return Changed;
851851
}
852852

853-
bool X86AsmBackend::finishLayout(const MCAssembler &Asm) const {
853+
bool X86AsmBackend::finishLayout() const {
854854
// See if we can further relax some instructions to cut down on the number of
855855
// nop bytes required for code alignment. The actual win is in reducing
856856
// instruction count, not number of bytes. Modern X86-64 can easily end up
@@ -864,11 +864,11 @@ bool X86AsmBackend::finishLayout(const MCAssembler &Asm) const {
864864
// MCSymbols and therefore different relaxation results. X86PadForAlign is
865865
// disabled by default to eliminate the -g vs non -g difference.
866866
DenseSet<MCFragment *> LabeledFragments;
867-
for (const MCSymbol &S : Asm.symbols())
867+
for (const MCSymbol &S : Asm->symbols())
868868
LabeledFragments.insert(S.getFragment());
869869

870870
bool Changed = false;
871-
for (MCSection &Sec : Asm) {
871+
for (MCSection &Sec : *Asm) {
872872
if (!Sec.isText())
873873
continue;
874874

@@ -908,13 +908,13 @@ bool X86AsmBackend::finishLayout(const MCAssembler &Asm) const {
908908
// the align directive. This is purely about human understandability
909909
// of the resulting code. If we later find a reason to expand
910910
// particular instructions over others, we can adjust.
911-
unsigned RemainingSize = Asm.computeFragmentSize(F) - F.getFixedSize();
911+
unsigned RemainingSize = Asm->computeFragmentSize(F) - F.getFixedSize();
912912
while (!Relaxable.empty() && RemainingSize != 0) {
913913
auto &RF = *Relaxable.pop_back_val();
914914
// Give the backend a chance to play any tricks it wishes to increase
915915
// the encoding size of the given instruction. Target independent code
916916
// will try further relaxation, but target's may play further tricks.
917-
Changed |= padInstructionEncoding(RF, Asm.getEmitter(), RemainingSize);
917+
Changed |= padInstructionEncoding(RF, Asm->getEmitter(), RemainingSize);
918918

919919
// If we have an instruction which hasn't been fully relaxed, we can't
920920
// skip past it and insert bytes before it. Changing its starting

0 commit comments

Comments
 (0)