[llvm] [BOLT][RISCV] Fix AUIPC/JALR call rewriting (PR #216882)
Craig Topper via llvm-commits
llvm-commits at lists.llvm.org
Thu Aug 20 12:01:03 PDT 2026
================
@@ -27,6 +29,33 @@ using namespace bolt;
namespace {
+bool isValidUnsymbolizedCallAUIPC(const MCInst &Inst) {
+ if (Inst.getOpcode() != RISCV::AUIPC ||
+ MCPlus::getNumPrimeOperands(Inst) != 2)
+ return false;
+
+ const MCOperand &Destination = Inst.getOperand(0);
+ return Destination.isReg() && Destination.getReg() != RISCV::X0 &&
+ Inst.getOperand(1).isImm();
+}
+
+bool isValidUnsymbolizedCallJALR(const MCInst &Inst) {
+ if (Inst.getOpcode() != RISCV::JALR || MCPlus::getNumPrimeOperands(Inst) != 3)
+ return false;
+
+ return Inst.getOperand(0).isReg() && Inst.getOperand(1).isReg() &&
+ Inst.getOperand(2).isImm();
+}
+
+bool hasSupportedCallRegisters(const MCInst &First, const MCInst &Second) {
+ const MCPhysReg Base = First.getOperand(0).getReg();
----------------
topperc wrote:
Use MCRegister here. I'm trying to migrate bolt off of MCPhysReg here https://github.com/llvm/llvm-project/pull/216525 and getReg() does return MCRegister.
https://github.com/llvm/llvm-project/pull/216882
More information about the llvm-commits
mailing list