[llvm] fix isCall flag for JAL and JALR, and the isBranch flag for C_JR (PR #161105)
مصطفي محمود كمال الدين via llvm-commits
llvm-commits at lists.llvm.org
Sun Sep 28 16:22:10 PDT 2025
https://github.com/moste00 created https://github.com/llvm/llvm-project/pull/161105
Fixes https://github.com/llvm/llvm-project/issues/161104
>From 7152a74035a1f969f5742e8ea0be1e892fe13fb2 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=D9=85=D8=B5=D8=B7=D9=81=D9=8A=20=D9=85=D8=AD=D9=85=D9=88?=
=?UTF-8?q?=D8=AF=20=D9=83=D9=85=D8=A7=D9=84=20=D8=A7=D9=84=D8=AF=D9=8A?=
=?UTF-8?q?=D9=86?= <48567303+moste00 at users.noreply.github.com>
Date: Mon, 29 Sep 2025 02:05:57 +0300
Subject: [PATCH] fix isCall flag for JAL and JALR, and the isBranch flag for
C_JR
---
llvm/lib/Target/RISCV/RISCVInstrInfo.td | 14 ++++++++------
llvm/lib/Target/RISCV/RISCVInstrInfoC.td | 1 +
2 files changed, 9 insertions(+), 6 deletions(-)
diff --git a/llvm/lib/Target/RISCV/RISCVInstrInfo.td b/llvm/lib/Target/RISCV/RISCVInstrInfo.td
index 9855c47a63392..3aa65cfb4c556 100644
--- a/llvm/lib/Target/RISCV/RISCVInstrInfo.td
+++ b/llvm/lib/Target/RISCV/RISCVInstrInfo.td
@@ -752,13 +752,15 @@ def LUI : RVInstU<OPC_LUI, (outs GPR:$rd), (ins uimm20_lui:$imm20),
def AUIPC : RVInstU<OPC_AUIPC, (outs GPR:$rd), (ins uimm20_auipc:$imm20),
"auipc", "$rd, $imm20">, Sched<[WriteIALU]>;
-def JAL : RVInstJ<OPC_JAL, (outs GPR:$rd), (ins simm21_lsb0_jal:$imm20),
- "jal", "$rd, $imm20">, Sched<[WriteJal]>;
+ let isCall = 1 in {
+ def JAL : RVInstJ<OPC_JAL, (outs GPR:$rd), (ins simm21_lsb0_jal:$imm20),
+ "jal", "$rd, $imm20">, Sched<[WriteJal]>;
-def JALR : RVInstI<0b000, OPC_JALR, (outs GPR:$rd),
- (ins GPR:$rs1, simm12_lo:$imm12),
- "jalr", "$rd, ${imm12}(${rs1})">,
- Sched<[WriteJalr, ReadJalr]>;
+ def JALR : RVInstI<0b000, OPC_JALR, (outs GPR:$rd),
+ (ins GPR:$rs1, simm12_lo:$imm12),
+ "jalr", "$rd, ${imm12}(${rs1})">,
+ Sched<[WriteJalr, ReadJalr]>;
+ }
} // hasSideEffects = 0, mayLoad = 0, mayStore = 0
def BEQ : BranchCC_rri<0b000, "beq">;
diff --git a/llvm/lib/Target/RISCV/RISCVInstrInfoC.td b/llvm/lib/Target/RISCV/RISCVInstrInfoC.td
index 24e7a0ee5a79f..fadea31075d37 100644
--- a/llvm/lib/Target/RISCV/RISCVInstrInfoC.td
+++ b/llvm/lib/Target/RISCV/RISCVInstrInfoC.td
@@ -488,6 +488,7 @@ def C_LDSP : CStackLoad<0b011, "c.ldsp", GPRNoX0, uimm9_lsb000>,
let hasSideEffects = 0, mayLoad = 0, mayStore = 0 in
def C_JR : RVInst16CR<0b1000, 0b10, (outs), (ins GPRNoX0:$rs1),
"c.jr", "$rs1">, Sched<[WriteJalr, ReadJalr]> {
+ let isBranch = 1;
let isBarrier = 1;
let isTerminator = 1;
let rs2 = 0;
More information about the llvm-commits
mailing list