1 # RUN: llvm-mc %s -triple=riscv64 -riscv-no-aliases \
2 # RUN: | FileCheck -check-prefixes=CHECK-EXPAND,CHECK-INST %s
3 # RUN: llvm-mc %s -triple=riscv64 \
4 # RUN: | FileCheck -check-prefixes=CHECK-EXPAND,CHECK-ALIAS %s
5 # RUN: llvm-mc -filetype=obj -triple riscv64 < %s \
6 # RUN: | llvm-objdump -M no-aliases -d - \
7 # RUN: | FileCheck -check-prefixes=CHECK-OBJ-NOALIAS,CHECK-EXPAND,CHECK-INST %s
8 # RUN: llvm-mc -filetype=obj -triple riscv64 < %s \
9 # RUN: | llvm-objdump -d - \
10 # RUN: | FileCheck -check-prefixes=CHECK-EXPAND,CHECK-ALIAS %s
12 # The following check prefixes are used in this test:
13 # CHECK-INST.....Match the canonical instr (tests alias to instr. mapping)
14 # CHECK-ALIAS....Match the alias (tests instr. to alias mapping)
15 # CHECK-EXPAND...Match canonical instr. unconditionally (tests alias expansion)
20 # Needed for testing valid %pcrel_lo expressions
21 .Lpcrel_hi0: auipc a0, %pcrel_hi(foo)
23 # CHECK-INST: addi a0, zero, 0
24 # CHECK-ALIAS: mv a0, zero
26 # CHECK-EXPAND: addi a0, zero, 1
28 # CHECK-EXPAND: addi a0, zero, -1
30 # CHECK-EXPAND: addi a0, zero, 2047
32 # CHECK-EXPAND: addi a0, zero, -2047
34 # CHECK-EXPAND: lui a1, 1
35 # CHECK-EXPAND: addiw a1, a1, -2048
37 # CHECK-EXPAND: addi a1, zero, -2048
39 # CHECK-EXPAND: lui a1, 1
40 # CHECK-EXPAND: addiw a1, a1, -2047
42 # CHECK-EXPAND: lui a1, 1048575
43 # CHECK-EXPAND: addiw a1, a1, 2047
45 # CHECK-EXPAND: lui a1, 1
46 # CHECK-EXPAND: addiw a1, a1, -1
48 # CHECK-EXPAND: lui a1, 1048575
49 # CHECK-EXPAND: addiw a1, a1, 1
51 # CHECK-EXPAND: lui a2, 1
53 # CHECK-EXPAND: lui a2, 1048575
55 # CHECK-EXPAND: lui a2, 1
56 # CHECK-EXPAND-NEXT: addiw a2, a2, 1
58 # CHECK-EXPAND: lui a2, 1048575
59 # CHECK-EXPAND: addiw a2, a2, -1
61 # CHECK-EXPAND: lui a2, 524288
62 # CHECK-EXPAND-NEXT: addiw a2, a2, -1
64 # CHECK-EXPAND: lui a2, 524288
65 # CHECK-EXPAND-NEXT: addiw a2, a2, 1
67 # CHECK-EXPAND: lui a2, 524288
69 # CHECK-EXPAND: lui a2, 524288
72 # CHECK-EXPAND: addi a2, zero, 1
73 # CHECK-EXPAND-NEXT: slli a2, a2, 31
75 # CHECK-EXPAND: addi a2, zero, -1
76 # CHECK-EXPAND-NEXT: srli a2, a2, 32
79 # CHECK-EXPAND: addi t0, zero, 1
80 # CHECK-EXPAND-NEXT: slli t0, t0, 32
82 # CHECK-EXPAND: addi t1, zero, -1
83 # CHECK-EXPAND-NEXT: slli t1, t1, 63
84 li t1
, 0x8000000000000000
85 # CHECK-EXPAND: addi t1, zero, -1
86 # CHECK-EXPAND-NEXT: slli t1, t1, 63
87 li t1
, -0x8000000000000000
88 # CHECK-EXPAND: lui t2, 9321
89 # CHECK-EXPAND-NEXT: addiw t2, t2, -1329
90 # CHECK-EXPAND-NEXT: slli t2, t2, 35
91 li t2
, 0x1234567800000000
92 # CHECK-EXPAND: addi t3, zero, 7
93 # CHECK-EXPAND-NEXT: slli t3, t3, 36
94 # CHECK-EXPAND-NEXT: addi t3, t3, 11
95 # CHECK-EXPAND-NEXT: slli t3, t3, 24
96 # CHECK-EXPAND-NEXT: addi t3, t3, 15
97 li t3
, 0x700000000B00000F
98 # CHECK-EXPAND: lui t4, 583
99 # CHECK-EXPAND-NEXT: addiw t4, t4, -1875
100 # CHECK-EXPAND-NEXT: slli t4, t4, 14
101 # CHECK-EXPAND-NEXT: addi t4, t4, -947
102 # CHECK-EXPAND-NEXT: slli t4, t4, 12
103 # CHECK-EXPAND-NEXT: addi t4, t4, 1511
104 # CHECK-EXPAND-NEXT: slli t4, t4, 13
105 # CHECK-EXPAND-NEXT: addi t4, t4, -272
106 li t4
, 0x123456789abcdef0
107 # CHECK-EXPAND: addi t5, zero, -1
108 li t5
, 0xFFFFFFFFFFFFFFFF
109 # CHECK-EXPAND: lui t6, 262145
110 # CHECK-EXPAND-NEXT: slli t6, t6, 1
112 # CHECK-EXPAND: lui t0, 262145
113 # CHECK-EXPAND-NEXT: slli t0, t0, 2
115 # CHECK-EXPAND: lui t1, 4097
116 # CHECK-EXPAND-NEXT: slli t1, t1, 20
117 li x6
, 0x100100000000
118 # CHECK-EXPAND: lui t2, 983056
119 # CHECK-EXPAND-NEXT: srli t2, t2, 16
120 li x7
, 0xFFFFFFFFF001
121 # CHECK-EXPAND: lui s0, 1044481
122 # CHECK-EXPAND-NEXT: slli s0, s0, 12
123 # CHECK-EXPAND-NEXT: srli s0, s0, 24
125 # CHECK-EXPAND: lui s1, 4097
126 # CHECK-EXPAND-NEXT: slli s1, s1, 20
127 # CHECK-EXPAND-NEXT: addi s1, s1, -3
128 li x9
, 0x1000FFFFFFFD
129 # CHECK-EXPAND: addi a0, zero, -1
130 # CHECK-EXPAND-NEXT: slli a0, a0, 36
131 # CHECK-EXPAND-NEXT: addi a0, a0, 1
132 # CHECK-EXPAND-NEXT: slli a0, a0, 25
133 # CHECK-EXPAND-NEXT: addi a0, a0, -1
134 li x10
, 0xE000000001FFFFFF
135 # CHECK-EXPAND: addi a1, zero, -2047
136 # CHECK-EXPAND-NEXT: slli a1, a1, 27
137 # CHECK-EXPAND-NEXT: addi a1, a1, -1
138 # CHECK-EXPAND-NEXT: slli a1, a1, 12
139 # CHECK-EXPAND-NEXT: addi a1, a1, 2047
140 li x11
, 0xFFFC007FFFFFF7FF
142 # CHECK-EXPAND: addi a0, zero, 1110
145 # CHECK-OBJ-NOALIAS: addi a0, zero, 0
146 # CHECK-OBJ: R_RISCV_LO12
148 # CHECK-OBJ-NOALIAS: addi a0, zero, 0
149 # CHECK-OBJ: R_RISCV_PCREL_LO12
150 li a0
, %pcrel_lo
(.Lpcrel_hi0)
153 # CHECK-EXPAND: lui a0, 291
154 # CHECK-EXPAND: addiw a0, a0, 1110
158 # CHECK-EXPAND: lui a0, 1620
159 # CHECK-EXPAND: addiw a0, a0, 801
162 # CHECK-INST: subw t6, zero, ra
163 # CHECK-ALIAS: negw t6, ra
165 # CHECK-INST: addiw t6, ra, 0
166 # CHECK-ALIAS: sext.w t6, ra
169 # The following aliases are accepted as input but the canonical form
170 # of the instruction will always be printed.
171 # CHECK-INST: addiw a2, a3, 4
172 # CHECK-ALIAS: addiw a2, a3, 4
175 # CHECK-INST: slliw a2, a3, 4
176 # CHECK-ALIAS: slliw a2, a3, 4
179 # CHECK-INST: srliw a2, a3, 4
180 # CHECK-ALIAS: srliw a2, a3, 4
183 # CHECK-INST: sraiw a2, a3, 4
184 # CHECK-ALIAS: sraiw a2, a3, 4
187 # CHECK-EXPAND: lwu a0, 0(a1)
189 # CHECK-EXPAND: ld a0, 0(a1)
191 # CHECK-EXPAND: sd a0, 0(a1)
194 # CHECK-EXPAND: slli a0, a1, 56
195 # CHECK-EXPAND: srai a0, a0, 56
198 # CHECK-EXPAND: slli a0, a1, 48
199 # CHECK-EXPAND: srai a0, a0, 48
202 # CHECK-INST: andi a0, a1, 255
203 # CHECK-ALIAS: andi a0, a1, 255
206 # CHECK-EXPAND: slli a0, a1, 48
207 # CHECK-EXPAND: srli a0, a0, 48
210 # CHECK-EXPAND: slli a0, a1, 32
211 # CHECK-EXPAND: srli a0, a0, 32