[DAGCombiner] Add target hook function to decide folding (mul (add x, c1), c2)
[llvm-project.git] / llvm / test / MC / RISCV / rv32c-valid.s
blob07c935f0721a7d4833100378e2a2c668a819ca9d
1 # RUN: llvm-mc %s -triple=riscv32 -mattr=+c -riscv-no-aliases -show-encoding \
2 # RUN: | FileCheck -check-prefixes=CHECK-ASM,CHECK-ASM-AND-OBJ %s
3 # RUN: llvm-mc -filetype=obj -triple=riscv32 -mattr=+c < %s \
4 # RUN: | llvm-objdump --mattr=+c -M no-aliases -d -r - \
5 # RUN: | FileCheck --check-prefixes=CHECK-OBJ,CHECK-ASM-AND-OBJ %s
6 # RUN: llvm-mc %s -triple=riscv64 -mattr=+c -riscv-no-aliases -show-encoding \
7 # RUN: | FileCheck -check-prefixes=CHECK-ASM,CHECK-ASM-AND-OBJ %s
8 # RUN: llvm-mc -filetype=obj -triple=riscv64 -mattr=+c < %s \
9 # RUN: | llvm-objdump --mattr=+c -M no-aliases -d -r - \
10 # RUN: | FileCheck --check-prefix=CHECK-ASM-AND-OBJ %s
12 # TODO: more exhaustive testing of immediate encoding.
14 # CHECK-ASM-AND-OBJ: c.lwsp ra, 0(sp)
15 # CHECK-ASM: encoding: [0x82,0x40]
16 c.lwsp ra, 0(sp)
17 # CHECK-ASM-AND-OBJ: c.swsp ra, 252(sp)
18 # CHECK-ASM: encoding: [0x86,0xdf]
19 c.swsp ra, 252(sp)
20 # CHECK-ASM-AND-OBJ: c.lw a2, 0(a0)
21 # CHECK-ASM: encoding: [0x10,0x41]
22 c.lw a2, 0(a0)
23 # CHECK-ASM-AND-OBJ: c.sw a5, 124(a3)
24 # CHECK-ASM: encoding: [0xfc,0xde]
25 c.sw a5, 124(a3)
27 # CHECK-OBJ: c.j 0xfffff808
28 # CHECK-ASM: c.j -2048
29 # CHECK-ASM: encoding: [0x01,0xb0]
30 c.j -2048
31 # CHECK-ASM-AND-OBJ: c.jr a7
32 # CHECK-ASM: encoding: [0x82,0x88]
33 c.jr a7
34 # CHECK-ASM-AND-OBJ: c.jalr a1
35 # CHECK-ASM: encoding: [0x82,0x95]
36 c.jalr a1
37 # CHECK-OBJ: c.beqz a3, 0xffffff0e
38 # CHECK-ASM: c.beqz a3, -256
39 # CHECK-ASM: encoding: [0x81,0xd2]
40 c.beqz a3, -256
41 # CHECK-OBJ: c.bnez a5, 0x10e
42 # CHECK-ASM: c.bnez a5, 254
43 # CHECK-ASM: encoding: [0xfd,0xef]
44 c.bnez a5, 254
46 # CHECK-ASM-AND-OBJ: c.li a7, 31
47 # CHECK-ASM: encoding: [0xfd,0x48]
48 c.li a7, 31
49 # CHECK-ASM-AND-OBJ: c.addi a3, -32
50 # CHECK-ASM: encoding: [0x81,0x16]
51 c.addi a3, -32
52 # CHECK-ASM-AND-OBJ: c.addi16sp sp, -512
53 # CHECK-ASM: encoding: [0x01,0x71]
54 c.addi16sp sp, -512
55 # CHECK-ASM-AND-OBJ: c.addi16sp sp, 496
56 # CHECK-ASM: encoding: [0x7d,0x61]
57 c.addi16sp sp, 496
58 # CHECK-ASM-AND-OBJ: c.addi4spn a3, sp, 1020
59 # CHECK-ASM: encoding: [0xf4,0x1f]
60 c.addi4spn a3, sp, 1020
61 # CHECK-ASM-AND-OBJ: c.addi4spn a3, sp, 4
62 # CHECK-ASM: encoding: [0x54,0x00]
63 c.addi4spn a3, sp, 4
64 # CHECK-ASM-AND-OBJ: c.slli a1, 1
65 # CHECK-ASM: encoding: [0x86,0x05]
66 c.slli a1, 1
67 # CHECK-ASM-AND-OBJ: c.srli a3, 31
68 # CHECK-ASM: encoding: [0xfd,0x82]
69 c.srli a3, 31
70 # CHECK-ASM-AND-OBJ: c.srai a4, 2
71 # CHECK-ASM: encoding: [0x09,0x87]
72 c.srai a4, 2
73 # CHECK-ASM-AND-OBJ: c.andi a5, 15
74 # CHECK-ASM: encoding: [0xbd,0x8b]
75 c.andi a5, 15
76 # CHECK-ASM-AND-OBJ: c.mv a7, s0
77 # CHECK-ASM: encoding: [0xa2,0x88]
78 c.mv a7, s0
79 # CHECK-ASM-AND-OBJ: c.and a1, a2
80 # CHECK-ASM: encoding: [0xf1,0x8d]
81 c.and a1, a2
82 # CHECK-ASM-AND-OBJ: c.or a2, a3
83 # CHECK-ASM: encoding: [0x55,0x8e]
84 c.or a2, a3
85 # CHECK-ASM-AND-OBJ: c.xor a3, a4
86 # CHECK-ASM: encoding: [0xb9,0x8e]
87 c.xor a3, a4
88 # CHECK-ASM-AND-OBJ: c.sub a4, a5
89 # CHECK-ASM: encoding: [0x1d,0x8f]
90 c.sub a4, a5
91 # CHECK-ASM-AND-OBJ: c.nop
92 # CHECK-ASM: encoding: [0x01,0x00]
93 c.nop
94 # CHECK-ASM-AND-OBJ: c.ebreak
95 # CHECK-ASM: encoding: [0x02,0x90]
96 c.ebreak
97 # CHECK-ASM-AND-OBJ: c.lui s0, 1
98 # CHECK-ASM: encoding: [0x05,0x64]
99 c.lui s0, 1
100 # CHECK-ASM-AND-OBJ: c.lui s0, 31
101 # CHECK-ASM: encoding: [0x7d,0x64]
102 c.lui s0, 31
103 # CHECK-ASM-AND-OBJ: c.lui s0, 1048544
104 # CHECK-ASM: encoding: [0x01,0x74]
105 c.lui s0, 0xfffe0
106 # CHECK-ASM-AND-OBJ: c.lui s0, 1048575
107 # CHECK-ASM: encoding: [0x7d,0x74]
108 c.lui s0, 0xfffff
109 # CHECK-ASM-AND-OBJ: c.unimp
110 # CHECK-ASM: encoding: [0x00,0x00]
111 c.unimp