[PATCH] D149839: [RISCV] def cm.jt as an alias inst of cm.jalt
Xinlong Wu via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu May 4 03:45:10 PDT 2023
VincentWu created this revision.
VincentWu added reviewers: kito-cheng, MaskRay, craig.topper, jrtc27, HsiangKai, asb, Jim.
Herald added subscribers: jobnoorman, luke, jeroen.dobbelaere, vkmr, frasercrmck, evandro, luismarques, apazos, sameer.abuasal, s.egerton, benna, psnobl, jocewei, PkmX, the_o, brucehoult, MartinMosbeck, rogfer01, edward-jones, zzheng, shiva0217, niosHD, sabuasal, simoncook, johnrusso, rbar, hiraditya, arichardson.
Herald added a project: All.
VincentWu requested review of this revision.
Herald added subscribers: llvm-commits, pcwang-thead, eopXD.
Herald added a project: LLVM.
This use `InstAlias` to fix the Decoding Conflict between `cm.jt` and `cm.jalt`.
The spec of Zc* defines `cm.jt` and `cm.jalt` has same encoding, the inst will be decode as `cm.jt` if `$index < 32`, it will be decode as `cm.jalt` in other cases.
In previous implemention, it defined two separate instractions with same encoding. But there is no error when compiling.
but it will report Decoding Conflict when we define `cm.mva01s` in https://reviews.llvm.org/D132819 .
After testing, I think it may because decoding conflict between `cm.jt` and `cm.jalt`. Although it dosen't report error promptly. (I think it might be a issue when generating `RISCVGenDisassemblerTables.inc`)
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D149839
Files:
llvm/lib/Target/RISCV/RISCVInstrInfoZc.td
llvm/test/MC/RISCV/rv32zcmt-valid.s
Index: llvm/test/MC/RISCV/rv32zcmt-valid.s
===================================================================
--- llvm/test/MC/RISCV/rv32zcmt-valid.s
+++ llvm/test/MC/RISCV/rv32zcmt-valid.s
@@ -5,7 +5,7 @@
# RUN: -mattr=m < %s \
# RUN: | llvm-objdump --mattr=+experimental-zcmt\
# RUN: -M no-aliases -d -r - \
-# RUN: | FileCheck --check-prefixes=CHECK-OBJ,CHECK-ASM-AND-OBJ %s
+# RUN: | FileCheck --check-prefixes=CHECK-ASM-AND-OBJ %s
# RUN: llvm-mc %s -triple=riscv64 -mattr=+experimental-zcmt\
# RUN: -riscv-no-aliases -show-encoding \
# RUN: | FileCheck -check-prefixes=CHECK-ASM,CHECK-ASM-AND-OBJ %s
@@ -13,7 +13,7 @@
# RUN: -mattr=m < %s \
# RUN: | llvm-objdump --mattr=+experimental-zcmt\
# RUN: -M no-aliases -d -r - \
-# RUN: | FileCheck --check-prefixes=CHECK-OBJ,CHECK-ASM-AND-OBJ %s
+# RUN: | FileCheck --check-prefixes=CHECK-ASM-AND-OBJ %s
#
# RUN: not llvm-mc -triple riscv32 \
# RUN: -riscv-no-aliases -show-encoding < %s 2>&1 \
@@ -22,13 +22,12 @@
# RUN: -riscv-no-aliases -show-encoding < %s 2>&1 \
# RUN: | FileCheck -check-prefixes=CHECK-NO-EXT %s
-# CHECK-ASM-AND-OBJ: cm.jt 1
+# CHECK-ASM-AND-OBJ: cm.jalt 1
# CHECK-ASM: encoding: [0x06,0xa0]
# CHECK-NO-EXT: error: instruction requires the following: 'Zcmt' (table jump instuctions for code-size reduction){{$}}
cm.jt 1
-# CHECK-ASM: cm.jalt 1
-# CHECK-OBJ: cm.jt 1
+# CHECK-ASM-AND-OBJ: cm.jalt 1
# CHECK-ASM: encoding: [0x06,0xa0]
# CHECK-NO-EXT: error: instruction requires the following: 'Zcmt' (table jump instuctions for code-size reduction){{$}}
cm.jalt 1
Index: llvm/lib/Target/RISCV/RISCVInstrInfoZc.td
===================================================================
--- llvm/lib/Target/RISCV/RISCVInstrInfoZc.td
+++ llvm/lib/Target/RISCV/RISCVInstrInfoZc.td
@@ -228,14 +228,7 @@
}
let Predicates = [HasStdExtZcmt],
-hasSideEffects = 0, mayLoad = 0, mayStore = 0 in {
-def CM_JT : RVInst16CJ<0b101, 0b10, (outs), (ins uimm5:$index),
- "cm.jt", "$index">{
- bits<5> index;
-
- let Inst{12-7} = 0b000000;
- let Inst{6-2} = index;
-}
+hasSideEffects = 0, mayLoad = 0, mayStore = 0 in
def CM_JALT : RVInst16CJ<0b101, 0b10, (outs), (ins uimm8:$index),
"cm.jalt", "$index">{
@@ -244,7 +237,6 @@
let Inst{12-10} = 0b000;
let Inst{9-2} = index;
}
-} // Predicates = [HasStdExtZcmt]
let Predicates = [HasStdExtZcb, HasStdExtMOrZmmul] in{
@@ -309,3 +301,6 @@
def : InstAlias<"c.sb $rd, (${rs1})", (C_SB GPRC:$rd, GPRC:$rs1, 0)>;
def : InstAlias<"c.sh $rd, (${rs1})", (C_SH GPRC:$rd, GPRC:$rs1, 0)>;
}
+
+let Predicates = [HasStdExtZcmt] in
+def : InstAlias<"cm.jt $index",(CM_JALT uimm5:$index)>;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D149839.519393.patch
Type: text/x-patch
Size: 2715 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230504/d83d2781/attachment.bin>
More information about the llvm-commits
mailing list