[llvm] 3c5d03a - SystemZMCCodeEmitter: Standardize how fixups are appended
Fangrui Song via llvm-commits
llvm-commits at lists.llvm.org
Fri Jul 4 17:29:02 PDT 2025
Author: Fangrui Song
Date: 2025-07-04T17:28:58-07:00
New Revision: 3c5d03a86a04bf2f7cc35c2a9c0375f73c47dae8
URL: https://github.com/llvm/llvm-project/commit/3c5d03a86a04bf2f7cc35c2a9c0375f73c47dae8
DIFF: https://github.com/llvm/llvm-project/commit/3c5d03a86a04bf2f7cc35c2a9c0375f73c47dae8.diff
LOG: SystemZMCCodeEmitter: Standardize how fixups are appended
This helper will facilitate future fixup data structure optimizations.
Added:
Modified:
llvm/lib/Target/SystemZ/MCTargetDesc/SystemZMCCodeEmitter.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Target/SystemZ/MCTargetDesc/SystemZMCCodeEmitter.cpp b/llvm/lib/Target/SystemZ/MCTargetDesc/SystemZMCCodeEmitter.cpp
index 8db4f716c123e..59d1db784c688 100644
--- a/llvm/lib/Target/SystemZ/MCTargetDesc/SystemZMCCodeEmitter.cpp
+++ b/llvm/lib/Target/SystemZ/MCTargetDesc/SystemZMCCodeEmitter.cpp
@@ -129,6 +129,11 @@ class SystemZMCCodeEmitter : public MCCodeEmitter {
};
} // end anonymous namespace
+ //
+static void addFixup(SmallVectorImpl<MCFixup> &Fixups, uint32_t Offset,
+ const MCExpr *Value, uint16_t Kind, bool PCRel = false) {
+ Fixups.push_back(MCFixup::create(Offset, Value, Kind, PCRel));
+}
void SystemZMCCodeEmitter::encodeInstruction(const MCInst &MI,
SmallVectorImpl<char> &CB,
@@ -170,8 +175,7 @@ uint64_t SystemZMCCodeEmitter::getImmOpValue(const MCInst &MI, unsigned OpNum,
unsigned OpBitSize =
SystemZ::MCFixupKindInfos[Kind - FirstTargetFixupKind].TargetSize;
uint32_t BitOffset = MIBitSize - RawBitOffset - OpBitSize;
- Fixups.push_back(
- MCFixup::create(BitOffset >> 3, MO.getExpr(), (MCFixupKind)Kind));
+ addFixup(Fixups, BitOffset >> 3, MO.getExpr(), Kind);
return 0;
}
llvm_unreachable("Unexpected operand type!");
@@ -206,13 +210,12 @@ SystemZMCCodeEmitter::getPCRelEncoding(const MCInst &MI, unsigned OpNum,
Expr = MCBinaryExpr::createAdd(Expr, OffsetExpr, Ctx, Loc);
}
}
- Fixups.push_back(MCFixup::create(Offset, Expr, Kind, true));
+ addFixup(Fixups, Offset, Expr, Kind, true);
// Output the fixup for the TLS marker if present.
if (AllowTLS && OpNum + 1 < MI.getNumOperands()) {
const MCOperand &MOTLS = MI.getOperand(OpNum + 1);
- Fixups.push_back(MCFixup::create(0, MOTLS.getExpr(),
- (MCFixupKind)SystemZ::FK_390_TLS_CALL));
+ addFixup(Fixups, 0, MOTLS.getExpr(), SystemZ::FK_390_TLS_CALL);
}
return 0;
}
More information about the llvm-commits
mailing list