• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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
11
12# TODO: more exhaustive testing of immediate encoding.
13
14# CHECK-ASM-AND-OBJ: c.lwsp ra, 0(sp)
15# CHECK-ASM: encoding: [0x82,0x40]
16c.lwsp ra, 0(sp)
17# CHECK-ASM-AND-OBJ: c.swsp ra, 252(sp)
18# CHECK-ASM: encoding: [0x86,0xdf]
19c.swsp ra, 252(sp)
20# CHECK-ASM-AND-OBJ: c.lw a2, 0(a0)
21# CHECK-ASM: encoding: [0x10,0x41]
22c.lw a2, 0(a0)
23# CHECK-ASM-AND-OBJ: c.sw a5, 124(a3)
24# CHECK-ASM: encoding: [0xfc,0xde]
25c.sw a5, 124(a3)
26
27# CHECK-OBJ: c.j 0xfffff808
28# CHECK-ASM: c.j -2048
29# CHECK-ASM: encoding: [0x01,0xb0]
30c.j -2048
31# CHECK-ASM-AND-OBJ: c.jr a7
32# CHECK-ASM: encoding: [0x82,0x88]
33c.jr a7
34# CHECK-ASM-AND-OBJ: c.jalr a1
35# CHECK-ASM: encoding: [0x82,0x95]
36c.jalr a1
37# CHECK-OBJ: c.beqz a3, 0xffffff0e
38# CHECK-ASM: c.beqz a3, -256
39# CHECK-ASM: encoding: [0x81,0xd2]
40c.beqz a3, -256
41# CHECK-OBJ: c.bnez a5, 0x10e
42# CHECK-ASM: c.bnez a5, 254
43# CHECK-ASM: encoding: [0xfd,0xef]
44c.bnez a5,  254
45
46# CHECK-ASM-AND-OBJ: c.li a7, 31
47# CHECK-ASM: encoding: [0xfd,0x48]
48c.li a7, 31
49# CHECK-ASM-AND-OBJ: c.addi a3, -32
50# CHECK-ASM: encoding: [0x81,0x16]
51c.addi a3, -32
52# CHECK-ASM-AND-OBJ: c.addi16sp sp, -512
53# CHECK-ASM: encoding: [0x01,0x71]
54c.addi16sp sp, -512
55# CHECK-ASM-AND-OBJ: c.addi16sp sp, 496
56# CHECK-ASM: encoding: [0x7d,0x61]
57c.addi16sp sp, 496
58# CHECK-ASM-AND-OBJ: c.addi4spn a3, sp, 1020
59# CHECK-ASM: encoding: [0xf4,0x1f]
60c.addi4spn a3, sp, 1020
61# CHECK-ASM-AND-OBJ: c.addi4spn a3, sp, 4
62# CHECK-ASM: encoding: [0x54,0x00]
63c.addi4spn a3, sp, 4
64# CHECK-ASM-AND-OBJ: c.slli a1, 1
65# CHECK-ASM: encoding: [0x86,0x05]
66c.slli a1, 1
67# CHECK-ASM-AND-OBJ: c.srli a3, 31
68# CHECK-ASM: encoding: [0xfd,0x82]
69c.srli a3, 31
70# CHECK-ASM-AND-OBJ: c.srai a4, 2
71# CHECK-ASM: encoding: [0x09,0x87]
72c.srai a4, 2
73# CHECK-ASM-AND-OBJ: c.andi a5, 15
74# CHECK-ASM: encoding: [0xbd,0x8b]
75c.andi a5, 15
76# CHECK-ASM-AND-OBJ: c.mv a7, s0
77# CHECK-ASM: encoding: [0xa2,0x88]
78c.mv a7, s0
79# CHECK-ASM-AND-OBJ: c.and a1, a2
80# CHECK-ASM: encoding: [0xf1,0x8d]
81c.and a1, a2
82# CHECK-ASM-AND-OBJ: c.or a2, a3
83# CHECK-ASM: encoding: [0x55,0x8e]
84c.or a2, a3
85# CHECK-ASM-AND-OBJ: c.xor a3, a4
86# CHECK-ASM: encoding: [0xb9,0x8e]
87c.xor a3, a4
88# CHECK-ASM-AND-OBJ: c.sub a4, a5
89# CHECK-ASM: encoding: [0x1d,0x8f]
90c.sub a4, a5
91# CHECK-ASM-AND-OBJ: c.nop
92# CHECK-ASM: encoding: [0x01,0x00]
93c.nop
94# CHECK-ASM-AND-OBJ: c.ebreak
95# CHECK-ASM: encoding: [0x02,0x90]
96c.ebreak
97# CHECK-ASM-AND-OBJ: c.lui s0, 1
98# CHECK-ASM: encoding: [0x05,0x64]
99c.lui s0, 1
100# CHECK-ASM-AND-OBJ: c.lui s0, 31
101# CHECK-ASM: encoding: [0x7d,0x64]
102c.lui s0, 31
103# CHECK-ASM-AND-OBJ: c.lui s0, 1048544
104# CHECK-ASM: encoding: [0x01,0x74]
105c.lui s0, 0xfffe0
106# CHECK-ASM-AND-OBJ: c.lui s0, 1048575
107# CHECK-ASM: encoding: [0x7d,0x74]
108c.lui s0, 0xfffff
109# CHECK-ASM-AND-OBJ: c.unimp
110# CHECK-ASM: encoding: [0x00,0x00]
111c.unimp
112