Skip to content

Commit b418e73

Browse files
committed
AMDGPUMCCodeEmitter: Set PCRel at fixup creation
Avoid reliance on the MCAssembler::evaluateFixup workaround that checks MCFixupKindInfo::FKF_IsPCRel. Additionally, standardize how fixups are appended. This helper will facilitate future fixup data structure optimizations.
1 parent 21cf7bd commit b418e73

File tree

2 files changed

+9
-6
lines changed

2 files changed

+9
-6
lines changed

llvm/lib/Target/AMDGPU/MCTargetDesc/AMDGPUAsmBackend.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -175,8 +175,8 @@ AMDGPUAsmBackend::getFixupKind(StringRef Name) const {
175175

176176
MCFixupKindInfo AMDGPUAsmBackend::getFixupKindInfo(MCFixupKind Kind) const {
177177
const static MCFixupKindInfo Infos[AMDGPU::NumTargetFixupKinds] = {
178-
// name offset bits flags
179-
{ "fixup_si_sopp_br", 0, 16, MCFixupKindInfo::FKF_IsPCRel },
178+
// name offset bits flags
179+
{"fixup_si_sopp_br", 0, 16, 0},
180180
};
181181

182182
if (mc::isRelocation(Kind))

llvm/lib/Target/AMDGPU/MCTargetDesc/AMDGPUMCCodeEmitter.cpp

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,11 @@ MCCodeEmitter *llvm::createAMDGPUMCCodeEmitter(const MCInstrInfo &MCII,
103103
return new AMDGPUMCCodeEmitter(MCII, *Ctx.getRegisterInfo());
104104
}
105105

106+
static void addFixup(SmallVectorImpl<MCFixup> &Fixups, uint32_t Offset,
107+
const MCExpr *Value, uint16_t Kind, bool PCRel = false) {
108+
Fixups.push_back(MCFixup::create(Offset, Value, Kind, PCRel));
109+
}
110+
106111
// Returns the encoding value to use if the given integer is an integer inline
107112
// immediate value, or 0 if it is not.
108113
template <typename IntTy>
@@ -445,8 +450,7 @@ void AMDGPUMCCodeEmitter::getSOPPBrEncoding(const MCInst &MI, unsigned OpNo,
445450

446451
if (MO.isExpr()) {
447452
const MCExpr *Expr = MO.getExpr();
448-
MCFixupKind Kind = (MCFixupKind)AMDGPU::fixup_si_sopp_br;
449-
Fixups.push_back(MCFixup::create(0, Expr, Kind));
453+
addFixup(Fixups, 0, Expr, AMDGPU::fixup_si_sopp_br, true);
450454
Op = APInt::getZero(96);
451455
} else {
452456
getMachineOpValue(MI, MO, Op, Fixups, STI);
@@ -661,8 +665,7 @@ void AMDGPUMCCodeEmitter::getMachineOpValueCommon(
661665
const MCInstrDesc &Desc = MCII.get(MI.getOpcode());
662666
uint32_t Offset = Desc.getSize();
663667
assert(Offset == 4 || Offset == 8);
664-
665-
Fixups.push_back(MCFixup::create(Offset, MO.getExpr(), Kind));
668+
addFixup(Fixups, Offset, MO.getExpr(), Kind, Kind == FK_PCRel_4);
666669
}
667670

668671
const MCInstrDesc &Desc = MCII.get(MI.getOpcode());

0 commit comments

Comments
 (0)