Skip to content

Commit cc40a46

Browse files
committed
[RISCV] Increase EmitPriority on some InstAliases. NFC
Use EmitPriority instead of relying on file ordering when there are multiple InstAliases for the same instruction. Enhance tests to check that we are printing the alias correctly by checking to end of line. Remove -no-aliases from some RUN lines that expect to check alias. Remove encoding checks from alias test.
1 parent e323b40 commit cc40a46

File tree

3 files changed

+19
-33
lines changed

3 files changed

+19
-33
lines changed

llvm/lib/Target/RISCV/RISCVInstrInfo.td

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -961,14 +961,14 @@ def : InstAlias<"fence", (FENCE 0xF, 0xF)>; // 0xF == iorw
961961
let Predicates = [HasStdExtZihintpause] in
962962
def : InstAlias<"pause", (FENCE 0x1, 0x0)>; // 0x1 == w
963963

964-
def : InstAlias<"rdinstret $rd", (CSRRS GPR:$rd, INSTRET.Encoding, X0)>;
965-
def : InstAlias<"rdcycle $rd", (CSRRS GPR:$rd, CYCLE.Encoding, X0)>;
966-
def : InstAlias<"rdtime $rd", (CSRRS GPR:$rd, TIME.Encoding, X0)>;
964+
def : InstAlias<"rdinstret $rd", (CSRRS GPR:$rd, INSTRET.Encoding, X0), 2>;
965+
def : InstAlias<"rdcycle $rd", (CSRRS GPR:$rd, CYCLE.Encoding, X0), 2>;
966+
def : InstAlias<"rdtime $rd", (CSRRS GPR:$rd, TIME.Encoding, X0), 2>;
967967

968968
let Predicates = [IsRV32] in {
969-
def : InstAlias<"rdinstreth $rd", (CSRRS GPR:$rd, INSTRETH.Encoding, X0)>;
970-
def : InstAlias<"rdcycleh $rd", (CSRRS GPR:$rd, CYCLEH.Encoding, X0)>;
971-
def : InstAlias<"rdtimeh $rd", (CSRRS GPR:$rd, TIMEH.Encoding, X0)>;
969+
def : InstAlias<"rdinstreth $rd", (CSRRS GPR:$rd, INSTRETH.Encoding, X0), 2>;
970+
def : InstAlias<"rdcycleh $rd", (CSRRS GPR:$rd, CYCLEH.Encoding, X0), 2>;
971+
def : InstAlias<"rdtimeh $rd", (CSRRS GPR:$rd, TIMEH.Encoding, X0), 2>;
972972
} // Predicates = [IsRV32]
973973

974974
def : InstAlias<"csrr $rd, $csr", (CSRRS GPR:$rd, csr_sysreg:$csr, X0)>;
@@ -990,13 +990,13 @@ def : InstAlias<"csrrs $rd, $csr, $imm", (CSRRSI GPR:$rd, csr_sysreg:$csr, uimm5
990990
def : InstAlias<"csrrc $rd, $csr, $imm", (CSRRCI GPR:$rd, csr_sysreg:$csr, uimm5:$imm)>;
991991
}
992992

993-
def : InstAlias<"sfence.vma", (SFENCE_VMA X0, X0)>;
993+
def : InstAlias<"sfence.vma", (SFENCE_VMA X0, X0), 2>;
994994
def : InstAlias<"sfence.vma $rs", (SFENCE_VMA GPR:$rs, X0)>;
995995

996-
def : InstAlias<"hfence.gvma", (HFENCE_GVMA X0, X0)>;
996+
def : InstAlias<"hfence.gvma", (HFENCE_GVMA X0, X0), 2>;
997997
def : InstAlias<"hfence.gvma $rs", (HFENCE_GVMA GPR:$rs, X0)>;
998998

999-
def : InstAlias<"hfence.vvma", (HFENCE_VVMA X0, X0)>;
999+
def : InstAlias<"hfence.vvma", (HFENCE_VVMA X0, X0), 2>;
10001000
def : InstAlias<"hfence.vvma $rs", (HFENCE_VVMA GPR:$rs, X0)>;
10011001

10021002
let Predicates = [HasStdExtZihintntl] in {
Lines changed: 8 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,70 +1,56 @@
1-
# RUN: llvm-mc %s -triple=riscv32 -mattr=+h -riscv-no-aliases -show-encoding \
2-
# RUN: | FileCheck -check-prefixes=CHECK,CHECK-INST,CHECK-ALIAS-INST %s
3-
# RUN: llvm-mc %s -triple=riscv64 -mattr=+h -riscv-no-aliases -show-encoding \
4-
# RUN: | FileCheck -check-prefixes=CHECK,CHECK-INST,CHECK-ALIAS-INST %s
1+
# RUN: llvm-mc %s -triple=riscv32 -mattr=+h \
2+
# RUN: | FileCheck -check-prefixes=CHECK-INST,CHECK-ALIAS-INST %s
3+
# RUN: llvm-mc %s -triple=riscv64 -mattr=+h \
4+
# RUN: | FileCheck -check-prefixes=CHECK-INST,CHECK-ALIAS-INST %s
55
# RUN: llvm-mc -filetype=obj -mattr=+h -triple riscv32 < %s \
66
# RUN: | llvm-objdump --mattr=+h -M no-aliases -d - \
77
# RUN: | FileCheck -check-prefixes=CHECK-INST,CHECK-NOALIAS-INST %s
88
# RUN: llvm-mc -filetype=obj -mattr=+h -triple riscv64 < %s \
99
# RUN: | llvm-objdump --mattr=+h -M no-aliases -d - \
1010
# RUN: | FileCheck -check-prefixes=CHECK-INST,CHECK-NOALIAS-INST %s
1111

12-
# CHECK-ALIAS-INST: hfence.gvma
12+
# CHECK-ALIAS-INST: hfence.gvma{{$}}
1313
# CHECK-NOALIAS-INST: hfence.gvma zero, zero
14-
# CHECK: encoding: [0x73,0x00,0x00,0x62]
1514
hfence.gvma
1615

17-
# CHECK-ALIAS-INST: hfence.gvma a0
16+
# CHECK-ALIAS-INST: hfence.gvma a0{{$}}
1817
# CHECK-NOALIAS-INST: hfence.gvma a0, zero
19-
# CHECK: encoding: [0x73,0x00,0x05,0x62]
2018
hfence.gvma a0
2119

22-
# CHECK-ALIAS-INST: hfence.vvma
20+
# CHECK-ALIAS-INST: hfence.vvma{{$}}
2321
# CHECK-NOALIAS-INST: hfence.vvma zero, zero
24-
# CHECK: encoding: [0x73,0x00,0x00,0x22]
2522
hfence.vvma
2623

27-
# CHECK-ALIAS-INST: hfence.vvma a0
24+
# CHECK-ALIAS-INST: hfence.vvma a0{{$}}
2825
# CHECK-NOALIAS-INST: hfence.vvma a0, zero
29-
# CHECK: encoding: [0x73,0x00,0x05,0x22]
3026
hfence.vvma a0
3127

3228
# CHECK-INST: hlv.b a0, (a1)
33-
# CHECK: encoding: [0x73,0xc5,0x05,0x60]
3429
hlv.b a0, 0(a1)
3530

3631
# CHECK-INST: hlv.bu a0, (a1)
37-
# CHECK: encoding: [0x73,0xc5,0x15,0x60]
3832
hlv.bu a0, 0(a1)
3933

4034
# CHECK-INST: hlv.h a1, (a2)
41-
# CHECK: encoding: [0xf3,0x45,0x06,0x64]
4235
hlv.h a1, 0(a2)
4336

4437
# CHECK-INST: hlv.hu a1, (a1)
45-
# CHECK: encoding: [0xf3,0xc5,0x15,0x64]
4638
hlv.hu a1, 0(a1)
4739

4840
# CHECK-INST: hlvx.hu a1, (a2)
49-
# CHECK: encoding: [0xf3,0x45,0x36,0x64]
5041
hlvx.hu a1, 0(a2)
5142

5243
# CHECK-INST: hlv.w a2, (a2)
53-
# CHECK: encoding: [0x73,0x46,0x06,0x68]
5444
hlv.w a2, 0(a2)
5545

5646
# CHECK-INST: hlvx.wu a2, (a3)
57-
# CHECK: encoding: [0x73,0xc6,0x36,0x68]
5847
hlvx.wu a2, 0(a3)
5948

6049
# CHECK-INST: hsv.b a0, (a1)
61-
# CHECK: encoding: [0x73,0xc0,0xa5,0x62]
6250
hsv.b a0, 0(a1)
6351

6452
# CHECK-INST: hsv.h a0, (a1)
65-
# CHECK: encoding: [0x73,0xc0,0xa5,0x66]
6653
hsv.h a0, 0(a1)
6754

6855
# CHECK-INST: hsv.w a0, (a1)
69-
# CHECK: encoding: [0x73,0xc0,0xa5,0x6a]
7056
hsv.w a0, 0(a1)

llvm/test/MC/RISCV/rvi-aliases-valid.s

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -261,10 +261,10 @@ csrrs t0, 0xfff, 0x10
261261
csrrc t0, 0x140, 0x11
262262

263263
# CHECK-S-OBJ-NOALIAS: sfence.vma zero, zero
264-
# CHECK-S-OBJ: sfence.vma
264+
# CHECK-S-OBJ: sfence.vma{{$}}
265265
sfence.vma
266266
# CHECK-S-OBJ-NOALIAS: sfence.vma a0, zero
267-
# CHECK-S-OBJ: sfence.vma a0
267+
# CHECK-S-OBJ: sfence.vma a0{{$}}
268268
sfence.vma a0
269269

270270
# The following aliases are accepted as input but the canonical form

0 commit comments

Comments
 (0)