[DAGCombiner] Add target hook function to decide folding (mul (add x, c1), c2)
[llvm-project.git] / llvm / test / MC / RISCV / compress-rv32i.s
blobd64c1c9e0d348f106dd9d44ecfcdee4e8947b932
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
23 # CHECK-BYTES: 2e 85
24 # CHECK-ALIAS: mv a0, a1
25 # CHECK-INST: c.mv a0, a1
26 # CHECK: # encoding: [0x2e,0x85]
27 addi a0, a1, 0
29 # CHECK-BYTES: e0 1f
30 # CHECK-ALIAS: addi s0, sp, 1020
31 # CHECK-INST: c.addi4spn s0, sp, 1020
32 # CHECK: # encoding: [0xe0,0x1f]
33 addi s0, sp, 1020
35 # CHECK-BYTES: e0 5f
36 # CHECK-ALIAS: lw s0, 124(a5)
37 # CHECK-INST: c.lw s0, 124(a5)
38 # CHECK: # encoding: [0xe0,0x5f]
39 lw s0, 124(a5)
41 # CHECK-BYTES: e0 df
42 # CHECK-ALIAS: sw s0, 124(a5)
43 # CHECK-INST: c.sw s0, 124(a5)
44 # CHECK: # encoding: [0xe0,0xdf]
45 sw s0, 124(a5)
47 # CHECK-BYTES: 01 00
48 # CHECK-ALIAS: nop
49 # CHECK-INST: c.nop
50 # CHECK: # encoding: [0x01,0x00]
51 nop
53 # CHECK-BYTES: 81 10
54 # CHECK-ALIAS: addi ra, ra, -32
55 # CHECK-INST: c.addi ra, -32
56 # CHECK: # encoding: [0x81,0x10]
57 addi ra, ra, -32
59 # CHECK-BYTES: 85 50
60 # CHECK-ALIAS: addi ra, zero, -31
61 # CHECK-INST: c.li ra, -31
62 # CHECK: # encoding: [0x85,0x50]
63 addi ra, zero, -31
65 # CHECK-BYTES: 39 71
66 # CHECK-ALIAS: addi sp, sp, -64
67 # CHECK-INST: c.addi16sp sp, -64
68 # CHECK: # encoding: [0x39,0x71]
69 addi sp, sp, -64
71 # CHECK-BYTES: fd 61
72 # CHECK-ALIAS: lui gp, 31
73 # CHECK-INST: c.lui gp, 31
74 # CHECK: # encoding: [0xfd,0x61]
75 lui gp, 31
77 # CHECK-BYTES: 7d 80
78 # CHECK-ALIAS: srli s0, s0, 31
79 # CHECK-INST: c.srli s0, 31
80 # CHECK: # encoding: [0x7d,0x80]
81 srli s0, s0, 31
83 # CHECK-BYTES: 7d 84
84 # CHECK-ALIAS: srai s0, s0, 31
85 # CHECK-INST: c.srai s0, 31
86 # CHECK: # encoding: [0x7d,0x84]
87 srai s0, s0, 31
89 # CHECK-BYTES: 7d 88
90 # CHECK-ALIAS: andi s0, s0, 31
91 # CHECK-INST: c.andi s0, 31
92 # CHECK: # encoding: [0x7d,0x88]
93 andi s0, s0, 31
95 # CHECK-BYTES: 1d 8c
96 # CHECK-ALIAS: sub s0, s0, a5
97 # CHECK-INST: c.sub s0, a5
98 # CHECK: # encoding: [0x1d,0x8c]
99 sub s0, s0, a5
101 # CHECK-BYTES: 3d 8c
102 # CHECK-ALIAS: xor s0, s0, a5
103 # CHECK-INST: c.xor s0, a5
104 # CHECK: # encoding: [0x3d,0x8c]
105 xor s0, s0, a5
107 # CHECK-BYTES: 3d 8c
108 # CHECK-ALIAS: xor s0, s0, a5
109 # CHECK-INST: c.xor s0, a5
110 # CHECK: # encoding: [0x3d,0x8c]
111 xor s0, a5, s0
113 # CHECK-BYTES: 5d 8c
114 # CHECK-ALIAS: or s0, s0, a5
115 # CHECK-INST: c.or s0, a5
116 # CHECK: # encoding: [0x5d,0x8c]
117 or s0, s0, a5
119 # CHECK-BYTES: 45 8c
120 # CHECK-ALIAS: or s0, s0, s1
121 # CHECK-INST: c.or s0, s1
122 # CHECK: # encoding: [0x45,0x8c]
123 or s0, s1, s0
125 # CHECK-BYTES: 7d 8c
126 # CHECK-ALIAS: and s0, s0, a5
127 # CHECK-INST: c.and s0, a5
128 # CHECK: # encoding: [0x7d,0x8c]
129 and s0, s0, a5
131 # CHECK-BYTES: 7d 8c
132 # CHECK-ALIAS: and s0, s0, a5
133 # CHECK-INST: c.and s0, a5
134 # CHECK: # encoding: [0x7d,0x8c]
135 and s0, a5, s0
137 # CHECK-BYTES: 01 b0
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]
145 jal zero, -2048
147 # CHECK-BYTES: 01 d0
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]
155 beq s0, zero, -256
157 # CHECK-BYTES: 7d ec
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]
165 bne s0, zero, 254
167 # CHECK-BYTES: 7e 04
168 # CHECK-ALIAS: slli s0, s0, 31
169 # CHECK-INST: c.slli s0, 31
170 # CHECK: # encoding: [0x7e,0x04]
171 slli s0, s0, 31
173 # CHECK-BYTES: fe 50
174 # CHECK-ALIAS: lw ra, 252(sp)
175 # CHECK-INST: c.lwsp ra, 252(sp)
176 # CHECK: # encoding: [0xfe,0x50]
177 lw ra, 252(sp)
179 # CHECK-BYTES: 82 80
180 # CHECK-ALIAS: ret
181 # CHECK-INST: c.jr ra
182 # CHECK: # encoding: [0x82,0x80]
183 jalr zero, 0(ra)
185 # CHECK-BYTES: 92 80
186 # CHECK-ALIAS: mv ra, tp
187 # CHECK-INST: c.mv ra, tp
188 # CHECK: # encoding: [0x92,0x80]
189 add ra, zero, tp
191 # CHECK-BYTES: 92 80
192 # CHECK-ALIAS: mv ra, tp
193 # CHECK-INST: c.mv ra, tp
194 # CHECK: # encoding: [0x92,0x80]
195 add ra, tp, zero
197 # CHECK-BYTES: 02 90
198 # CHECK-ALIAS: ebreak
199 # CHECK-INST: c.ebreak
200 # CHECK: # encoding: [0x02,0x90]
201 ebreak
203 # CHECK-BYTES: 02 94
204 # CHECK-ALIAS: jalr s0
205 # CHECK-INST: c.jalr s0
206 # CHECK: # encoding: [0x02,0x94]
207 jalr ra, 0(s0)
209 # CHECK-BYTES: 3e 94
210 # CHECK-ALIAS: add s0, s0, a5
211 # CHECK-INST: c.add s0, a5
212 # CHECK: # encoding: [0x3e,0x94]
213 add s0, a5, s0
215 # CHECK-BYTES: 3e 94
216 # CHECK-ALIAS: add s0, s0, a5
217 # CHECK-INST: c.add s0, a5
218 # CHECK: # encoding: [0x3e,0x94]
219 add s0, s0, a5
221 # CHECK-BYTES: 82 df
222 # CHECK-ALIAS: sw zero, 252(sp)
223 # CHECK-INST: c.swsp zero, 252(sp)
224 # CHECK: # encoding: [0x82,0xdf]
225 sw zero, 252(sp)
227 # CHECK-BYTES: 00 00
228 # CHECK-ALIAS: unimp
229 # CHECK-INST: c.unimp
230 # CHECK: # encoding: [0x00,0x00]
231 unimp