Skip to content

Commit d7e6e72

Browse files
authored
[RISCV] Correct the predicate for the ror and rorw with immediate InstAliases. (#157921)
1 parent f0b8069 commit d7e6e72

File tree

3 files changed

+50
-6
lines changed

3 files changed

+50
-6
lines changed

llvm/lib/Target/RISCV/RISCVInstrInfoZb.td

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -459,15 +459,15 @@ let Predicates = [HasStdExtZba, IsRV64] in {
459459
def : InstAlias<"zext.w $rd, $rs", (ADD_UW GPR:$rd, GPR:$rs, X0)>;
460460
} // Predicates = [HasStdExtZba, IsRV64]
461461

462-
let Predicates = [HasStdExtZbb] in {
462+
let Predicates = [HasStdExtZbbOrZbkb] in {
463463
def : InstAlias<"ror $rd, $rs1, $shamt",
464-
(RORI GPR:$rd, GPR:$rs1, uimmlog2xlen:$shamt), 0>;
465-
} // Predicates = [HasStdExtZbb]
464+
(RORI GPR:$rd, GPR:$rs1, uimmlog2xlen:$shamt), 0>;
465+
} // Predicates = [HasStdExtZbbOrZbkb]
466466

467-
let Predicates = [HasStdExtZbb, IsRV64] in {
467+
let Predicates = [HasStdExtZbbOrZbkb, IsRV64] in {
468468
def : InstAlias<"rorw $rd, $rs1, $shamt",
469-
(RORIW GPR:$rd, GPR:$rs1, uimm5:$shamt), 0>;
470-
} // Predicates = [HasStdExtZbb, IsRV64]
469+
(RORIW GPR:$rd, GPR:$rs1, uimm5:$shamt), 0>;
470+
} // Predicates = [HasStdExtZbbOrZbkb, IsRV64]
471471

472472
let Predicates = [HasStdExtZbs] in {
473473
def : InstAlias<"bset $rd, $rs1, $shamt",
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# RUN: llvm-mc %s -triple=riscv32 -mattr=+zbkb -M no-aliases \
2+
# RUN: | FileCheck -check-prefixes=CHECK-S-OBJ-NOALIAS %s
3+
# RUN: llvm-mc %s -triple=riscv32 -mattr=+zbkb \
4+
# RUN: | FileCheck -check-prefixes=CHECK-S-OBJ %s
5+
# RUN: llvm-mc -filetype=obj -triple riscv32 -mattr=+zbkb < %s \
6+
# RUN: | llvm-objdump --no-print-imm-hex -d -r -M no-aliases --mattr=+zbkb - \
7+
# RUN: | FileCheck -check-prefixes=CHECK-S-OBJ-NOALIAS %s
8+
# RUN: llvm-mc -filetype=obj -triple riscv32 -mattr=+zbkb < %s \
9+
# RUN: | llvm-objdump --no-print-imm-hex -d -r --mattr=+zbkb - \
10+
# RUN: | FileCheck -check-prefixes=CHECK-S-OBJ %s
11+
12+
# The following check prefixes are used in this test:
13+
# CHECK-S-OBJ Match both the .s and objdumped object output with
14+
# aliases enabled
15+
# CHECK-S-OBJ-NOALIAS Match both the .s and objdumped object output with
16+
# aliases disabled
17+
18+
# CHECK-S-OBJ-NOALIAS: rori t0, t1, 8
19+
# CHECK-S-OBJ: rori t0, t1, 8
20+
ror x5, x6, 8
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# RUN: llvm-mc %s -triple=riscv64 -mattr=+zbkb -M no-aliases \
2+
# RUN: | FileCheck -check-prefixes=CHECK-S-OBJ-NOALIAS %s
3+
# RUN: llvm-mc %s -triple=riscv64 -mattr=+zbkb \
4+
# RUN: | FileCheck -check-prefixes=CHECK-S-OBJ %s
5+
# RUN: llvm-mc -filetype=obj -triple riscv64 -mattr=+zbkb < %s \
6+
# RUN: | llvm-objdump --no-print-imm-hex -d -r -M no-aliases --mattr=+zbkb - \
7+
# RUN: | FileCheck -check-prefixes=CHECK-S-OBJ-NOALIAS %s
8+
# RUN: llvm-mc -filetype=obj -triple riscv64 -mattr=+zbkb < %s \
9+
# RUN: | llvm-objdump --no-print-imm-hex -d -r --mattr=+zbkb - \
10+
# RUN: | FileCheck -check-prefixes=CHECK-S-OBJ %s
11+
12+
# The following check prefixes are used in this test:
13+
# CHECK-S-OBJ Match both the .s and objdumped object output with
14+
# aliases enabled
15+
# CHECK-S-OBJ-NOALIAS Match both the .s and objdumped object output with
16+
# aliases disabled
17+
18+
# CHECK-S-OBJ-NOALIAS: rori t0, t1, 8
19+
# CHECK-S-OBJ: rori t0, t1, 8
20+
ror x5, x6, 8
21+
22+
# CHECK-S-OBJ-NOALIAS: roriw t0, t1, 8
23+
# CHECK-S-OBJ: roriw t0, t1, 8
24+
rorw x5, x6, 8

0 commit comments

Comments
 (0)