[llvm] 372752c - MCFixup: Remove unused Loc argument
Fangrui Song via llvm-commits
llvm-commits at lists.llvm.org
Fri Jul 4 12:51:43 PDT 2025
Author: Fangrui Song
Date: 2025-07-04T12:51:39-07:00
New Revision: 372752c2ddd0919a305d6019e30077829dea2858
URL: https://github.com/llvm/llvm-project/commit/372752c2ddd0919a305d6019e30077829dea2858
DIFF: https://github.com/llvm/llvm-project/commit/372752c2ddd0919a305d6019e30077829dea2858.diff
LOG: MCFixup: Remove unused Loc argument
MCFixup::Loc has been removed in favor of MCExpr::Loc through
`const MCExpr *Value` (commit 777391a2164b89d2030ca013562151ca3c3676d1).
While here, change Kind to uint16_t from MCFixupKind. Most fixup kinds
are target-specific.
Added:
Modified:
llvm/include/llvm/MC/MCFixup.h
llvm/lib/Target/LoongArch/MCTargetDesc/LoongArchAsmBackend.cpp
llvm/lib/Target/M68k/MCTargetDesc/M68kMCCodeEmitter.cpp
llvm/lib/Target/Mips/MCTargetDesc/MipsMCCodeEmitter.cpp
llvm/lib/Target/PowerPC/MCTargetDesc/PPCELFStreamer.cpp
llvm/lib/Target/RISCV/MCTargetDesc/RISCVAsmBackend.cpp
llvm/lib/Target/RISCV/MCTargetDesc/RISCVMCCodeEmitter.cpp
Removed:
################################################################################
diff --git a/llvm/include/llvm/MC/MCFixup.h b/llvm/include/llvm/MC/MCFixup.h
index bf33d66cc1113..ac8e0865e4af1 100644
--- a/llvm/include/llvm/MC/MCFixup.h
+++ b/llvm/include/llvm/MC/MCFixup.h
@@ -71,7 +71,7 @@ class MCFixup {
/// The target dependent kind of fixup item this is. The kind is used to
/// determine how the operand value should be encoded into the instruction.
- MCFixupKind Kind = FK_NONE;
+ uint16_t Kind = FK_NONE;
bool PCRel = false;
@@ -82,19 +82,19 @@ class MCFixup {
/// Consider bit fields if we need more flags.
public:
- static MCFixup create(uint32_t Offset, const MCExpr *Value,
- MCFixupKind Kind, SMLoc Loc = SMLoc()) {
+ static MCFixup create(uint32_t Offset, const MCExpr *Value, uint16_t Kind) {
MCFixup FI;
FI.Value = Value;
FI.Offset = Offset;
FI.Kind = Kind;
return FI;
}
- static MCFixup create(uint32_t Offset, const MCExpr *Value, unsigned Kind) {
- return create(Offset, Value, MCFixupKind(Kind));
+ static MCFixup create(uint32_t Offset, const MCExpr *Value,
+ MCFixupKind Kind) {
+ return create(Offset, Value, unsigned(Kind));
}
- MCFixupKind getKind() const { return Kind; }
+ MCFixupKind getKind() const { return MCFixupKind(Kind); }
unsigned getTargetKind() const { return Kind; }
diff --git a/llvm/lib/Target/LoongArch/MCTargetDesc/LoongArchAsmBackend.cpp b/llvm/lib/Target/LoongArch/MCTargetDesc/LoongArchAsmBackend.cpp
index 18b59b436657e..4a9d56160b812 100644
--- a/llvm/lib/Target/LoongArch/MCTargetDesc/LoongArchAsmBackend.cpp
+++ b/llvm/lib/Target/LoongArch/MCTargetDesc/LoongArchAsmBackend.cpp
@@ -290,7 +290,7 @@ std::pair<bool, bool> LoongArchAsmBackend::relaxLEB128(MCLEBFragment &LF,
const MCExpr &Expr = LF.getValue();
if (LF.isSigned() || !Expr.evaluateKnownAbsolute(Value, *Asm))
return std::make_pair(false, false);
- LF.addFixup(MCFixup::create(0, &Expr, FK_Data_leb128, Expr.getLoc()));
+ LF.addFixup(MCFixup::create(0, &Expr, FK_Data_leb128));
return std::make_pair(true, true);
}
diff --git a/llvm/lib/Target/M68k/MCTargetDesc/M68kMCCodeEmitter.cpp b/llvm/lib/Target/M68k/MCTargetDesc/M68kMCCodeEmitter.cpp
index 3bd1d0d7dcaeb..abc7a9af6c555 100644
--- a/llvm/lib/Target/M68k/MCTargetDesc/M68kMCCodeEmitter.cpp
+++ b/llvm/lib/Target/M68k/MCTargetDesc/M68kMCCodeEmitter.cpp
@@ -140,8 +140,7 @@ void M68kMCCodeEmitter::encodeRelocImm(const MCInst &MI, unsigned OpIdx,
// Relocatable address
unsigned InsertByte = getBytePosition<Size>(InsertPos);
Fixups.push_back(MCFixup::create(InsertByte, Expr,
- getFixupForSize(Size, /*IsPCRel=*/false),
- MI.getLoc()));
+ getFixupForSize(Size, /*IsPCRel=*/false)));
}
}
@@ -176,8 +175,7 @@ void M68kMCCodeEmitter::encodePCRelImm(const MCInst &MI, unsigned OpIdx,
}
Fixups.push_back(MCFixup::create(InsertByte, Expr,
- getFixupForSize(Size, /*IsPCRel=*/true),
- MI.getLoc()));
+ getFixupForSize(Size, /*IsPCRel=*/true)));
}
}
diff --git a/llvm/lib/Target/Mips/MCTargetDesc/MipsMCCodeEmitter.cpp b/llvm/lib/Target/Mips/MCTargetDesc/MipsMCCodeEmitter.cpp
index 35d4e0db35c31..2fd2b16560d4d 100644
--- a/llvm/lib/Target/Mips/MCTargetDesc/MipsMCCodeEmitter.cpp
+++ b/llvm/lib/Target/Mips/MCTargetDesc/MipsMCCodeEmitter.cpp
@@ -367,9 +367,7 @@ getBranchTargetOpValueMM(const MCInst &MI, unsigned OpNo,
"getBranchTargetOpValueMM expects only expressions or immediates");
const MCExpr *Expr = MO.getExpr();
- Fixups.push_back(MCFixup::create(0, Expr,
- MCFixupKind(Mips::
- fixup_MICROMIPS_PC16_S1)));
+ Fixups.push_back(MCFixup::create(0, Expr, Mips::fixup_MICROMIPS_PC16_S1));
return 0;
}
@@ -390,8 +388,8 @@ getBranchTarget21OpValue(const MCInst &MI, unsigned OpNo,
const MCExpr *FixupExpression = MCBinaryExpr::createAdd(
MO.getExpr(), MCConstantExpr::create(-4, Ctx), Ctx);
- Fixups.push_back(MCFixup::create(0, FixupExpression,
- MCFixupKind(Mips::fixup_MIPS_PC21_S2)));
+ Fixups.push_back(
+ MCFixup::create(0, FixupExpression, Mips::fixup_MIPS_PC21_S2));
return 0;
}
@@ -412,8 +410,8 @@ getBranchTarget21OpValueMM(const MCInst &MI, unsigned OpNo,
const MCExpr *FixupExpression = MCBinaryExpr::createAdd(
MO.getExpr(), MCConstantExpr::create(-4, Ctx), Ctx);
- Fixups.push_back(MCFixup::create(0, FixupExpression,
- MCFixupKind(Mips::fixup_MICROMIPS_PC21_S1)));
+ Fixups.push_back(
+ MCFixup::create(0, FixupExpression, Mips::fixup_MICROMIPS_PC21_S1));
return 0;
}
@@ -434,8 +432,8 @@ getBranchTarget26OpValue(const MCInst &MI, unsigned OpNo,
const MCExpr *FixupExpression = MCBinaryExpr::createAdd(
MO.getExpr(), MCConstantExpr::create(-4, Ctx), Ctx);
- Fixups.push_back(MCFixup::create(0, FixupExpression,
- MCFixupKind(Mips::fixup_MIPS_PC26_S2)));
+ Fixups.push_back(
+ MCFixup::create(0, FixupExpression, Mips::fixup_MIPS_PC26_S2));
return 0;
}
@@ -734,8 +732,8 @@ unsigned MipsMCCodeEmitter::getImmOpValue(const MCInst &MI, const MCOperand &MO,
return Res;
unsigned MIFrm = MipsII::getFormat(MCII.get(MI.getOpcode()).TSFlags);
if (!isa<MCSpecifierExpr>(Expr) && MIFrm == MipsII::FrmI) {
- Fixups.push_back(MCFixup::create(
- 0, Expr, MCFixupKind(Mips::fixup_Mips_AnyImm16), Expr->getLoc()));
+ Fixups.push_back(
+ MCFixup::create(0, Expr, MCFixupKind(Mips::fixup_Mips_AnyImm16)));
return 0;
}
return getExprOpValue(Expr, Fixups, STI);
diff --git a/llvm/lib/Target/PowerPC/MCTargetDesc/PPCELFStreamer.cpp b/llvm/lib/Target/PowerPC/MCTargetDesc/PPCELFStreamer.cpp
index 3c97205df1656..ee99cfc7d655d 100644
--- a/llvm/lib/Target/PowerPC/MCTargetDesc/PPCELFStreamer.cpp
+++ b/llvm/lib/Target/PowerPC/MCTargetDesc/PPCELFStreamer.cpp
@@ -159,8 +159,7 @@ void PPCELFStreamer::emitGOTToPCRelReloc(const MCInst &Inst) {
assert(DF && "Expecting a valid data fragment.");
MCFixupKind FixupKind = static_cast<MCFixupKind>(FirstLiteralRelocationKind +
ELF::R_PPC64_PCREL_OPT);
- DF->addFixup(MCFixup::create(LabelSym->getOffset() - 8, SubExpr2, FixupKind,
- Inst.getLoc()));
+ DF->addFixup(MCFixup::create(LabelSym->getOffset() - 8, SubExpr2, FixupKind));
emitLabel(CurrentLocation, Inst.getLoc());
}
diff --git a/llvm/lib/Target/RISCV/MCTargetDesc/RISCVAsmBackend.cpp b/llvm/lib/Target/RISCV/MCTargetDesc/RISCVAsmBackend.cpp
index 592af18a969a1..d298ce769c1dc 100644
--- a/llvm/lib/Target/RISCV/MCTargetDesc/RISCVAsmBackend.cpp
+++ b/llvm/lib/Target/RISCV/MCTargetDesc/RISCVAsmBackend.cpp
@@ -396,7 +396,7 @@ std::pair<bool, bool> RISCVAsmBackend::relaxLEB128(MCLEBFragment &LF,
return std::make_pair(false, false);
const MCExpr &Expr = LF.getValue();
if (ULEB128Reloc) {
- LF.addFixup(MCFixup::create(0, &Expr, FK_Data_leb128, Expr.getLoc()));
+ LF.addFixup(MCFixup::create(0, &Expr, FK_Data_leb128));
}
return std::make_pair(Expr.evaluateKnownAbsolute(Value, *Asm), false);
}
diff --git a/llvm/lib/Target/RISCV/MCTargetDesc/RISCVMCCodeEmitter.cpp b/llvm/lib/Target/RISCV/MCTargetDesc/RISCVMCCodeEmitter.cpp
index 421da06aa4993..e13b201369c71 100644
--- a/llvm/lib/Target/RISCV/MCTargetDesc/RISCVMCCodeEmitter.cpp
+++ b/llvm/lib/Target/RISCV/MCTargetDesc/RISCVMCCodeEmitter.cpp
@@ -319,9 +319,8 @@ void RISCVMCCodeEmitter::expandLongCondBr(const MCInst &MI,
Fixups.resize(FixupStartIndex);
if (SrcSymbol.isExpr()) {
- Fixups.push_back(MCFixup::create(Offset, SrcSymbol.getExpr(),
- MCFixupKind(RISCV::fixup_riscv_jal),
- MI.getLoc()));
+ Fixups.push_back(
+ MCFixup::create(Offset, SrcSymbol.getExpr(), RISCV::fixup_riscv_jal));
}
}
@@ -370,9 +369,8 @@ void RISCVMCCodeEmitter::expandQCLongCondBrImm(const MCInst &MI,
// Drop any fixup added so we can add the correct one.
Fixups.resize(FixupStartIndex);
if (SrcSymbol.isExpr()) {
- Fixups.push_back(MCFixup::create(Offset, SrcSymbol.getExpr(),
- MCFixupKind(RISCV::fixup_riscv_jal),
- MI.getLoc()));
+ Fixups.push_back(
+ MCFixup::create(Offset, SrcSymbol.getExpr(), RISCV::fixup_riscv_jal));
}
}
More information about the llvm-commits
mailing list