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-prefixes=CHECK-OBJ,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]
17 # CHECK-ASM-AND-OBJ: c.swsp ra, 252(sp)
18 # CHECK-ASM: encoding: [0x86,0xdf]
20 # CHECK-ASM-AND-OBJ: c.lw a2, 0(a0)
21 # CHECK-ASM: encoding: [0x10,0x41]
23 # CHECK-ASM-AND-OBJ: c.sw a5, 124(a3)
24 # CHECK-ASM: encoding: [0xfc,0xde]
27 # CHECK-ASM-AND-OBJ: c.j -2048
28 # CHECK-ASM: encoding: [0x01,0xb0]
30 # CHECK-ASM-AND-OBJ: c.jr a7
31 # CHECK-ASM: encoding: [0x82,0x88]
33 # CHECK-ASM-AND-OBJ: c.jalr a1
34 # CHECK-ASM: encoding: [0x82,0x95]
36 # CHECK-ASM-AND-OBJ: c.beqz a3, -256
37 # CHECK-ASM: encoding: [0x81,0xd2]
39 # CHECK-ASM-AND-OBJ: c.bnez a5, 254
40 # CHECK-ASM: encoding: [0xfd,0xef]
43 # CHECK-ASM-AND-OBJ: c.li a7, 31
44 # CHECK-ASM: encoding: [0xfd,0x48]
46 # CHECK-ASM-AND-OBJ: c.addi a3, -32
47 # CHECK-ASM: encoding: [0x81,0x16]
49 # CHECK-ASM-AND-OBJ: c.addi16sp sp, -512
50 # CHECK-ASM: encoding: [0x01,0x71]
52 # CHECK-ASM-AND-OBJ: c.addi16sp sp, 496
53 # CHECK-ASM: encoding: [0x7d,0x61]
55 # CHECK-ASM-AND-OBJ: c.addi4spn a3, sp, 1020
56 # CHECK-ASM: encoding: [0xf4,0x1f]
57 c.addi4spn a3
, sp
, 1020
58 # CHECK-ASM-AND-OBJ: c.addi4spn a3, sp, 4
59 # CHECK-ASM: encoding: [0x54,0x00]
61 # CHECK-ASM-AND-OBJ: c.slli a1, 1
62 # CHECK-ASM: encoding: [0x86,0x05]
64 # CHECK-ASM-AND-OBJ: c.srli a3, 31
65 # CHECK-ASM: encoding: [0xfd,0x82]
67 # CHECK-ASM-AND-OBJ: c.srai a4, 2
68 # CHECK-ASM: encoding: [0x09,0x87]
70 # CHECK-ASM-AND-OBJ: c.andi a5, 15
71 # CHECK-ASM: encoding: [0xbd,0x8b]
73 # CHECK-ASM-AND-OBJ: c.mv a7, s0
74 # CHECK-ASM: encoding: [0xa2,0x88]
76 # CHECK-ASM-AND-OBJ: c.and a1, a2
77 # CHECK-ASM: encoding: [0xf1,0x8d]
79 # CHECK-ASM-AND-OBJ: c.or a2, a3
80 # CHECK-ASM: encoding: [0x55,0x8e]
82 # CHECK-ASM-AND-OBJ: c.xor a3, a4
83 # CHECK-ASM: encoding: [0xb9,0x8e]
85 # CHECK-ASM-AND-OBJ: c.sub a4, a5
86 # CHECK-ASM: encoding: [0x1d,0x8f]
88 # CHECK-ASM-AND-OBJ: c.nop
89 # CHECK-ASM: encoding: [0x01,0x00]
91 # CHECK-ASM-AND-OBJ: c.ebreak
92 # CHECK-ASM: encoding: [0x02,0x90]
94 # CHECK-ASM-AND-OBJ: c.lui s0, 1
95 # CHECK-ASM: encoding: [0x05,0x64]
97 # CHECK-ASM-AND-OBJ: c.lui s0, 31
98 # CHECK-ASM: encoding: [0x7d,0x64]
100 # CHECK-ASM-AND-OBJ: c.lui s0, 1048544
101 # CHECK-ASM: encoding: [0x01,0x74]
103 # CHECK-ASM-AND-OBJ: c.lui s0, 1048575
104 # CHECK-ASM: encoding: [0x7d,0x74]
106 # CHECK-ASM-AND-OBJ: c.unimp
107 # CHECK-ASM: encoding: [0x00,0x00]