Skip to content

Commit 372752c

Browse files
committed
MCFixup: Remove unused Loc argument
MCFixup::Loc has been removed in favor of MCExpr::Loc through `const MCExpr *Value` (commit 777391a). While here, change Kind to uint16_t from MCFixupKind. Most fixup kinds are target-specific.
1 parent 20b3ab5 commit 372752c

File tree

7 files changed

+24
-31
lines changed

7 files changed

+24
-31
lines changed

llvm/include/llvm/MC/MCFixup.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ class MCFixup {
7171

7272
/// The target dependent kind of fixup item this is. The kind is used to
7373
/// determine how the operand value should be encoded into the instruction.
74-
MCFixupKind Kind = FK_NONE;
74+
uint16_t Kind = FK_NONE;
7575

7676
bool PCRel = false;
7777

@@ -82,19 +82,19 @@ class MCFixup {
8282
/// Consider bit fields if we need more flags.
8383

8484
public:
85-
static MCFixup create(uint32_t Offset, const MCExpr *Value,
86-
MCFixupKind Kind, SMLoc Loc = SMLoc()) {
85+
static MCFixup create(uint32_t Offset, const MCExpr *Value, uint16_t Kind) {
8786
MCFixup FI;
8887
FI.Value = Value;
8988
FI.Offset = Offset;
9089
FI.Kind = Kind;
9190
return FI;
9291
}
93-
static MCFixup create(uint32_t Offset, const MCExpr *Value, unsigned Kind) {
94-
return create(Offset, Value, MCFixupKind(Kind));
92+
static MCFixup create(uint32_t Offset, const MCExpr *Value,
93+
MCFixupKind Kind) {
94+
return create(Offset, Value, unsigned(Kind));
9595
}
9696

97-
MCFixupKind getKind() const { return Kind; }
97+
MCFixupKind getKind() const { return MCFixupKind(Kind); }
9898

9999
unsigned getTargetKind() const { return Kind; }
100100

llvm/lib/Target/LoongArch/MCTargetDesc/LoongArchAsmBackend.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -290,7 +290,7 @@ std::pair<bool, bool> LoongArchAsmBackend::relaxLEB128(MCLEBFragment &LF,
290290
const MCExpr &Expr = LF.getValue();
291291
if (LF.isSigned() || !Expr.evaluateKnownAbsolute(Value, *Asm))
292292
return std::make_pair(false, false);
293-
LF.addFixup(MCFixup::create(0, &Expr, FK_Data_leb128, Expr.getLoc()));
293+
LF.addFixup(MCFixup::create(0, &Expr, FK_Data_leb128));
294294
return std::make_pair(true, true);
295295
}
296296

llvm/lib/Target/M68k/MCTargetDesc/M68kMCCodeEmitter.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -140,8 +140,7 @@ void M68kMCCodeEmitter::encodeRelocImm(const MCInst &MI, unsigned OpIdx,
140140
// Relocatable address
141141
unsigned InsertByte = getBytePosition<Size>(InsertPos);
142142
Fixups.push_back(MCFixup::create(InsertByte, Expr,
143-
getFixupForSize(Size, /*IsPCRel=*/false),
144-
MI.getLoc()));
143+
getFixupForSize(Size, /*IsPCRel=*/false)));
145144
}
146145
}
147146

@@ -176,8 +175,7 @@ void M68kMCCodeEmitter::encodePCRelImm(const MCInst &MI, unsigned OpIdx,
176175
}
177176

178177
Fixups.push_back(MCFixup::create(InsertByte, Expr,
179-
getFixupForSize(Size, /*IsPCRel=*/true),
180-
MI.getLoc()));
178+
getFixupForSize(Size, /*IsPCRel=*/true)));
181179
}
182180
}
183181

llvm/lib/Target/Mips/MCTargetDesc/MipsMCCodeEmitter.cpp

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -367,9 +367,7 @@ getBranchTargetOpValueMM(const MCInst &MI, unsigned OpNo,
367367
"getBranchTargetOpValueMM expects only expressions or immediates");
368368

369369
const MCExpr *Expr = MO.getExpr();
370-
Fixups.push_back(MCFixup::create(0, Expr,
371-
MCFixupKind(Mips::
372-
fixup_MICROMIPS_PC16_S1)));
370+
Fixups.push_back(MCFixup::create(0, Expr, Mips::fixup_MICROMIPS_PC16_S1));
373371
return 0;
374372
}
375373

@@ -390,8 +388,8 @@ getBranchTarget21OpValue(const MCInst &MI, unsigned OpNo,
390388

391389
const MCExpr *FixupExpression = MCBinaryExpr::createAdd(
392390
MO.getExpr(), MCConstantExpr::create(-4, Ctx), Ctx);
393-
Fixups.push_back(MCFixup::create(0, FixupExpression,
394-
MCFixupKind(Mips::fixup_MIPS_PC21_S2)));
391+
Fixups.push_back(
392+
MCFixup::create(0, FixupExpression, Mips::fixup_MIPS_PC21_S2));
395393
return 0;
396394
}
397395

@@ -412,8 +410,8 @@ getBranchTarget21OpValueMM(const MCInst &MI, unsigned OpNo,
412410

413411
const MCExpr *FixupExpression = MCBinaryExpr::createAdd(
414412
MO.getExpr(), MCConstantExpr::create(-4, Ctx), Ctx);
415-
Fixups.push_back(MCFixup::create(0, FixupExpression,
416-
MCFixupKind(Mips::fixup_MICROMIPS_PC21_S1)));
413+
Fixups.push_back(
414+
MCFixup::create(0, FixupExpression, Mips::fixup_MICROMIPS_PC21_S1));
417415
return 0;
418416
}
419417

@@ -434,8 +432,8 @@ getBranchTarget26OpValue(const MCInst &MI, unsigned OpNo,
434432

435433
const MCExpr *FixupExpression = MCBinaryExpr::createAdd(
436434
MO.getExpr(), MCConstantExpr::create(-4, Ctx), Ctx);
437-
Fixups.push_back(MCFixup::create(0, FixupExpression,
438-
MCFixupKind(Mips::fixup_MIPS_PC26_S2)));
435+
Fixups.push_back(
436+
MCFixup::create(0, FixupExpression, Mips::fixup_MIPS_PC26_S2));
439437
return 0;
440438
}
441439

@@ -734,8 +732,8 @@ unsigned MipsMCCodeEmitter::getImmOpValue(const MCInst &MI, const MCOperand &MO,
734732
return Res;
735733
unsigned MIFrm = MipsII::getFormat(MCII.get(MI.getOpcode()).TSFlags);
736734
if (!isa<MCSpecifierExpr>(Expr) && MIFrm == MipsII::FrmI) {
737-
Fixups.push_back(MCFixup::create(
738-
0, Expr, MCFixupKind(Mips::fixup_Mips_AnyImm16), Expr->getLoc()));
735+
Fixups.push_back(
736+
MCFixup::create(0, Expr, MCFixupKind(Mips::fixup_Mips_AnyImm16)));
739737
return 0;
740738
}
741739
return getExprOpValue(Expr, Fixups, STI);

llvm/lib/Target/PowerPC/MCTargetDesc/PPCELFStreamer.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -159,8 +159,7 @@ void PPCELFStreamer::emitGOTToPCRelReloc(const MCInst &Inst) {
159159
assert(DF && "Expecting a valid data fragment.");
160160
MCFixupKind FixupKind = static_cast<MCFixupKind>(FirstLiteralRelocationKind +
161161
ELF::R_PPC64_PCREL_OPT);
162-
DF->addFixup(MCFixup::create(LabelSym->getOffset() - 8, SubExpr2, FixupKind,
163-
Inst.getLoc()));
162+
DF->addFixup(MCFixup::create(LabelSym->getOffset() - 8, SubExpr2, FixupKind));
164163
emitLabel(CurrentLocation, Inst.getLoc());
165164
}
166165

llvm/lib/Target/RISCV/MCTargetDesc/RISCVAsmBackend.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -396,7 +396,7 @@ std::pair<bool, bool> RISCVAsmBackend::relaxLEB128(MCLEBFragment &LF,
396396
return std::make_pair(false, false);
397397
const MCExpr &Expr = LF.getValue();
398398
if (ULEB128Reloc) {
399-
LF.addFixup(MCFixup::create(0, &Expr, FK_Data_leb128, Expr.getLoc()));
399+
LF.addFixup(MCFixup::create(0, &Expr, FK_Data_leb128));
400400
}
401401
return std::make_pair(Expr.evaluateKnownAbsolute(Value, *Asm), false);
402402
}

llvm/lib/Target/RISCV/MCTargetDesc/RISCVMCCodeEmitter.cpp

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -319,9 +319,8 @@ void RISCVMCCodeEmitter::expandLongCondBr(const MCInst &MI,
319319
Fixups.resize(FixupStartIndex);
320320

321321
if (SrcSymbol.isExpr()) {
322-
Fixups.push_back(MCFixup::create(Offset, SrcSymbol.getExpr(),
323-
MCFixupKind(RISCV::fixup_riscv_jal),
324-
MI.getLoc()));
322+
Fixups.push_back(
323+
MCFixup::create(Offset, SrcSymbol.getExpr(), RISCV::fixup_riscv_jal));
325324
}
326325
}
327326

@@ -370,9 +369,8 @@ void RISCVMCCodeEmitter::expandQCLongCondBrImm(const MCInst &MI,
370369
// Drop any fixup added so we can add the correct one.
371370
Fixups.resize(FixupStartIndex);
372371
if (SrcSymbol.isExpr()) {
373-
Fixups.push_back(MCFixup::create(Offset, SrcSymbol.getExpr(),
374-
MCFixupKind(RISCV::fixup_riscv_jal),
375-
MI.getLoc()));
372+
Fixups.push_back(
373+
MCFixup::create(Offset, SrcSymbol.getExpr(), RISCV::fixup_riscv_jal));
376374
}
377375
}
378376

0 commit comments

Comments
 (0)