1 # RUN: llvm-mc -triple riscv32 -mattr=+c -show-encoding < %s \
2 # RUN: | FileCheck -check-prefixes=CHECK,CHECK-ALIAS,CHECK-ALIASASM %s
3 # RUN: llvm-mc -triple riscv32 -mattr=+c -show-encoding \
4 # RUN: -riscv-no-aliases < %s | FileCheck -check-prefixes=CHECK,CHECK-INST,CHECK-INSTASM %s
5 # RUN: llvm-mc -triple riscv32 -mattr=+c -filetype=obj < %s \
6 # RUN: | llvm-objdump --triple=riscv32 --mattr=+c -d - \
7 # RUN: | FileCheck -check-prefixes=CHECK-BYTES,CHECK-ALIAS,CHECK-ALIASOBJ32 %s
8 # RUN: llvm-mc -triple riscv32 -mattr=+c -filetype=obj < %s \
9 # RUN: | llvm-objdump --triple=riscv32 --mattr=+c -d -M no-aliases - \
10 # RUN: | FileCheck -check-prefixes=CHECK-BYTES,CHECK-INST,CHECK-INSTOBJ32 %s
12 # RUN: llvm-mc -triple riscv64 -mattr=+c -show-encoding < %s \
13 # RUN: | FileCheck -check-prefixes=CHECK-ALIAS,CHECK-ALIASASM %s
14 # RUN: llvm-mc -triple riscv64 -mattr=+c -show-encoding \
15 # RUN: -riscv-no-aliases < %s | FileCheck -check-prefixes=CHECK-INST,CHECK-INSTASM %s
16 # RUN: llvm-mc -triple riscv64 -mattr=+c -filetype=obj < %s \
17 # RUN: | llvm-objdump --triple=riscv64 --mattr=+c -d - \
18 # RUN: | FileCheck -check-prefixes=CHECK-BYTES,CHECK-ALIAS,CHECK-ALIASOBJ64 %s
19 # RUN: llvm-mc -triple riscv64 -mattr=+c -filetype=obj < %s \
20 # RUN: | llvm-objdump --triple=riscv64 --mattr=+c -d -M no-aliases - \
21 # RUN: | FileCheck -check-prefixes=CHECK-BYTES,CHECK-INST,CHECK-INSTOBJ64 %s
24 # CHECK-ALIAS: mv a0, a1
25 # CHECK-INST: c.mv a0, a1
26 # CHECK: # encoding: [0x2e,0x85]
30 # CHECK-ALIAS: addi s0, sp, 1020
31 # CHECK-INST: c.addi4spn s0, sp, 1020
32 # CHECK: # encoding: [0xe0,0x1f]
36 # CHECK-ALIAS: lw s0, 124(a5)
37 # CHECK-INST: c.lw s0, 124(a5)
38 # CHECK: # encoding: [0xe0,0x5f]
42 # CHECK-ALIAS: sw s0, 124(a5)
43 # CHECK-INST: c.sw s0, 124(a5)
44 # CHECK: # encoding: [0xe0,0xdf]
50 # CHECK: # encoding: [0x01,0x00]
54 # CHECK-ALIAS: addi ra, ra, -32
55 # CHECK-INST: c.addi ra, -32
56 # CHECK: # encoding: [0x81,0x10]
60 # CHECK-ALIAS: addi ra, zero, -31
61 # CHECK-INST: c.li ra, -31
62 # CHECK: # encoding: [0x85,0x50]
66 # CHECK-ALIAS: addi sp, sp, -64
67 # CHECK-INST: c.addi16sp sp, -64
68 # CHECK: # encoding: [0x39,0x71]
72 # CHECK-ALIAS: lui gp, 31
73 # CHECK-INST: c.lui gp, 31
74 # CHECK: # encoding: [0xfd,0x61]
78 # CHECK-ALIAS: srli s0, s0, 31
79 # CHECK-INST: c.srli s0, 31
80 # CHECK: # encoding: [0x7d,0x80]
84 # CHECK-ALIAS: srai s0, s0, 31
85 # CHECK-INST: c.srai s0, 31
86 # CHECK: # encoding: [0x7d,0x84]
90 # CHECK-ALIAS: andi s0, s0, 31
91 # CHECK-INST: c.andi s0, 31
92 # CHECK: # encoding: [0x7d,0x88]
96 # CHECK-ALIAS: sub s0, s0, a5
97 # CHECK-INST: c.sub s0, a5
98 # CHECK: # encoding: [0x1d,0x8c]
102 # CHECK-ALIAS: xor s0, s0, a5
103 # CHECK-INST: c.xor s0, a5
104 # CHECK: # encoding: [0x3d,0x8c]
108 # CHECK-ALIAS: xor s0, s0, a5
109 # CHECK-INST: c.xor s0, a5
110 # CHECK: # encoding: [0x3d,0x8c]
114 # CHECK-ALIAS: or s0, s0, a5
115 # CHECK-INST: c.or s0, a5
116 # CHECK: # encoding: [0x5d,0x8c]
120 # CHECK-ALIAS: or s0, s0, s1
121 # CHECK-INST: c.or s0, s1
122 # CHECK: # encoding: [0x45,0x8c]
126 # CHECK-ALIAS: and s0, s0, a5
127 # CHECK-INST: c.and s0, a5
128 # CHECK: # encoding: [0x7d,0x8c]
132 # CHECK-ALIAS: and s0, s0, a5
133 # CHECK-INST: c.and s0, a5
134 # CHECK: # encoding: [0x7d,0x8c]
138 # CHECK-ALIASASM: j -2048
139 # CHECK-ALIASOBJ32: j 0xfffff826
140 # CHECK-ALIASOBJ64: j 0xfffffffffffff826
141 # CHECK-INSTASM: c.j -2048
142 # CHECK-INSTOBJ32: c.j 0xfffff826
143 # CHECK-INSTOBJ64: c.j 0xfffffffffffff826
144 # CHECK: # encoding: [0x01,0xb0]
148 # CHECK-ALIASASM: beqz s0, -256
149 # CHECK-ALIASOBJ32: beqz s0, 0xffffff28
150 # CHECK-ALIASOBJ64: beqz s0, 0xffffffffffffff28
151 # CHECK-INSTASM: c.beqz s0, -256
152 # CHECK-INSTOBJ32: c.beqz s0, 0xffffff28
153 # CHECK-INSTOBJ64: c.beqz s0, 0xffffffffffffff28
154 # CHECK: # encoding: [0x01,0xd0]
158 # CHECK-ALIASASM: bnez s0, 254
159 # CHECK-ALIASOBJ32: bnez s0, 0x128
160 # CHECK-ALIASOBJ64: bnez s0, 0x128
161 # CHECK-INSTASM: c.bnez s0, 254
162 # CHECK-INSTOBJ32: c.bnez s0, 0x128
163 # CHECK-INSTOBJ64: c.bnez s0, 0x128
164 # CHECK: # encoding: [0x7d,0xec]
168 # CHECK-ALIAS: slli s0, s0, 31
169 # CHECK-INST: c.slli s0, 31
170 # CHECK: # encoding: [0x7e,0x04]
174 # CHECK-ALIAS: lw ra, 252(sp)
175 # CHECK-INST: c.lwsp ra, 252(sp)
176 # CHECK: # encoding: [0xfe,0x50]
181 # CHECK-INST: c.jr ra
182 # CHECK: # encoding: [0x82,0x80]
186 # CHECK-ALIAS: mv ra, tp
187 # CHECK-INST: c.mv ra, tp
188 # CHECK: # encoding: [0x92,0x80]
192 # CHECK-ALIAS: mv ra, tp
193 # CHECK-INST: c.mv ra, tp
194 # CHECK: # encoding: [0x92,0x80]
198 # CHECK-ALIAS: ebreak
199 # CHECK-INST: c.ebreak
200 # CHECK: # encoding: [0x02,0x90]
204 # CHECK-ALIAS: jalr s0
205 # CHECK-INST: c.jalr s0
206 # CHECK: # encoding: [0x02,0x94]
210 # CHECK-ALIAS: add s0, s0, a5
211 # CHECK-INST: c.add s0, a5
212 # CHECK: # encoding: [0x3e,0x94]
216 # CHECK-ALIAS: add s0, s0, a5
217 # CHECK-INST: c.add s0, a5
218 # CHECK: # encoding: [0x3e,0x94]
222 # CHECK-ALIAS: sw zero, 252(sp)
223 # CHECK-INST: c.swsp zero, 252(sp)
224 # CHECK: # encoding: [0x82,0xdf]
229 # CHECK-INST: c.unimp
230 # CHECK: # encoding: [0x00,0x00]