Skip to content

Commit 9f16659

Browse files
committed
Address Review Feedback; Add Tests
1 parent 9e687ae commit 9f16659

File tree

6 files changed

+52
-7
lines changed

6 files changed

+52
-7
lines changed

llvm/test/MC/RISCV/rv64c-invalid.s

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,17 +13,25 @@ c.ldsp zero, 4(sp) # CHECK: :[[@LINE]]:9: error: register must be a GPR excludi
1313

1414
# Out of range immediates
1515

16+
reldef:
17+
.global undef
18+
1619
## uimmlog2xlennonzero
1720
c.slli t0, 64 # CHECK: :[[@LINE]]:12: error: immediate must be an integer in the range [1, 63]
1821
c.srli a0, -1 # CHECK: :[[@LINE]]:12: error: immediate must be an integer in the range [1, 63]
1922
c.srai a0, 0 # CHECK: :[[@LINE]]:12: error: immediate must be an integer in the range [1, 63]
23+
c.slli t0, reldef # CHECK: :[[@LINE]]:12: error: immediate must be an integer in the range [1, 63]
24+
c.srli a0, reldef-. # CHECK: :[[@LINE]]:12: error: immediate must be an integer in the range [1, 63]
25+
c.srai a0, undef # CHECK: :[[@LINE]]:12: error: immediate must be an integer in the range [1, 63]
2026

2127
## simm6
2228
c.addiw t0, -33 # CHECK: :[[@LINE]]:13: error: immediate must be an integer in the range [-32, 31]
2329
c.addiw t0, 32 # CHECK: :[[@LINE]]:13: error: immediate must be an integer in the range [-32, 31]
24-
c.addiw t0, foo # CHECK: :[[@LINE]]:13: error: immediate must be an integer in the range [-32, 31]
2530
c.addiw t0, %lo(foo) # CHECK: :[[@LINE]]:13: error: immediate must be an integer in the range [-32, 31]
2631
c.addiw t0, %hi(foo) # CHECK: :[[@LINE]]:13: error: immediate must be an integer in the range [-32, 31]
32+
c.addiw t0, reldef # CHECK: :[[@LINE]]:13: error: immediate must be an integer in the range [-32, 31]
33+
c.addiw t0, reldef-. # CHECK: :[[@LINE]]:13: error: immediate must be an integer in the range [-32, 31]
34+
c.addiw t0, undef # CHECK: :[[@LINE]]:13: error: immediate must be an integer in the range [-32, 31]
2735

2836
## uimm9_lsb000
2937
c.ldsp ra, 512(sp) # CHECK: :[[@LINE]]:13: error: immediate must be a multiple of 8 bytes in the range [0, 504]

llvm/test/MC/RISCV/rv64c-valid.s

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,3 +72,10 @@ c.srli a3, 63
7272
# CHECK-ASM: encoding: [0x7d,0x96]
7373
# CHECK-NO-EXT: error: instruction requires the following: 'C' (Compressed Instructions) or 'Zca' (part of the C extension, excluding compressed floating point loads/stores){{$}}
7474
c.srai a2, 63
75+
76+
.set absdef, 1
77+
78+
# CHECK-ASM-AND-OBJ: c.addiw a0, 1
79+
# CHECK-ASM: encoding: [0x05,0x25]
80+
# CHECK-NO-EXT: error: instruction requires the following: 'C' (Compressed Instructions) or 'Zca' (part of the C extension, excluding compressed floating point loads/stores){{$}}
81+
c.addiw a0, absdef

llvm/test/MC/RISCV/rvc-invalid.s

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# RUN: not llvm-mc %s -triple=riscv32 2>&1 | FileCheck %s
2+
# RUN: not llvm-mc %s -triple=riscv64 2>&1 | FileCheck %s
3+
4+
reldef:
5+
6+
.global undef
7+
8+
c.addi a0, reldef # CHECK: :[[@LINE]]:12: error: invalid operand for instruction
9+
c.addi a0, reldef-. # CHECK: :[[@LINE]]:12: error: invalid operand for instruction
10+
c.addi a0, undef # CHECK: :[[@LINE]]:12: error: invalid operand for instruction
11+
12+
c.li a0, reldef # CHECK: :[[@LINE]]:10: error: invalid operand for instruction
13+
c.li a0, reldef-. # CHECK: :[[@LINE]]:10: error: invalid operand for instruction
14+
c.li a0, undef # CHECK: :[[@LINE]]:10: error: invalid operand for instruction
15+
16+
c.andi a0, reldef # CHECK: :[[@LINE]]:12: error: invalid operand for instruction
17+
c.andi a0, reldef-. # CHECK: :[[@LINE]]:12: error: invalid operand for instruction
18+
c.andi a0, undef # CHECK: :[[@LINE]]:12: error: invalid operand for instruction

llvm/test/MC/RISCV/rvc-valid.s

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,3 +175,21 @@ c.lui s0, 0xfffff
175175
# CHECK-ASM: encoding: [0x00,0x00]
176176
# CHECK-NO-EXT: error: instruction requires the following: 'C' (Compressed Instructions) or 'Zca' (part of the C extension, excluding compressed floating point loads/stores){{$}}
177177
c.unimp
178+
179+
.set absdef, 1
180+
181+
c.addi a0, absdef
182+
# CHECK-ASM-AND-OBJ: c.addi a0, 1
183+
# CHECK-ASM: encoding: [0x05,0x05]
184+
# CHECK-NO-EXT: error: instruction requires the following: 'C' (Compressed Instructions) or 'Zca' (part of the C extension, excluding compressed floating point loads/stores){{$}}
185+
186+
c.li a0, absdef
187+
# CHECK-ASM-AND-OBJ: c.li a0, 1
188+
# CHECK-ASM: encoding: [0x05,0x45]
189+
# CHECK-NO-EXT: error: instruction requires the following: 'C' (Compressed Instructions) or 'Zca' (part of the C extension, excluding compressed floating point loads/stores){{$}}
190+
191+
c.andi a0, absdef
192+
# CHECK-ASM-AND-OBJ: c.andi a0, 1
193+
# CHECK-ASM: encoding: [0x05,0x89]
194+
# CHECK-NO-EXT: error: instruction requires the following: 'C' (Compressed Instructions) or 'Zca' (part of the C extension, excluding compressed floating point loads/stores){{$}}
195+

llvm/test/MC/RISCV/xqcibi-relocations.s

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -84,11 +84,8 @@ qc.bnei t3, 14, same_section
8484
# OBJ-NEXT: qc.e.bgeui s2, 0x18, 0x28 <same_section>
8585
qc.e.bgeui s2, 24, same_section
8686

87-
.option norelax
88-
8987
## Enable compression/relaxation to check how symbols are handled.
9088
.option noexact
91-
.option relax
9289

9390
# ASM: qc.bnei t1, 10, undef
9491
# OBJ: qc.beqi t1, 0xa, 0x42 <same_section_extern+0x16>

llvm/test/MC/RISCV/xqcilb-relocations.s

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -92,11 +92,8 @@ qc.e.j same_section
9292
# OBJ-NEXT: R_RISCV_RELAX
9393
qc.e.jal same_section
9494

95-
.option norelax
96-
9795
## Enable compression/relaxation to check how symbols are handled.
9896
.option noexact
99-
.option relax
10097

10198
qc.e.j undef
10299
# ASM: j undef

0 commit comments

Comments
 (0)