• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# RUN: llvm-mc %s -triple=riscv32 -riscv-no-aliases -show-encoding \
2# RUN:     | FileCheck -check-prefixes=CHECK,CHECK-INST %s
3# RUN: llvm-mc %s -triple=riscv64 -riscv-no-aliases -show-encoding \
4# RUN:     | FileCheck -check-prefixes=CHECK,CHECK-INST %s
5# RUN: llvm-mc -filetype=obj -triple riscv32 < %s \
6# RUN:     | llvm-objdump -riscv-no-aliases -d - \
7# RUN:     | FileCheck -check-prefix=CHECK-INST %s
8# RUN: llvm-mc -filetype=obj -triple riscv64 < %s \
9# RUN:     | llvm-objdump -riscv-no-aliases -d - \
10# RUN:     | FileCheck -check-prefix=CHECK-INST %s
11
12# CHECK-INST: lui a0, 2
13# CHECK: encoding: [0x37,0x25,0x00,0x00]
14lui a0, 2
15# CHECK-INST: lui s11, 552960
16# CHECK: encoding: [0xb7,0x0d,0x00,0x87]
17lui s11, (0x87000000>>12)
18# CHECK-INST: lui a0, 0
19# CHECK: encoding: [0x37,0x05,0x00,0x00]
20lui a0, %hi(2)
21# CHECK-INST: lui s11, 552960
22# CHECK: encoding: [0xb7,0x0d,0x00,0x87]
23lui s11, (0x87000000>>12)
24# CHECK-INST: lui s11, 552960
25# CHECK: encoding: [0xb7,0x0d,0x00,0x87]
26lui s11, %hi(0x87000000)
27# CHECK-INST: lui t0, 1048575
28# CHECK: encoding: [0xb7,0xf2,0xff,0xff]
29lui t0, 1048575
30# CHECK-INST: lui gp, 0
31# CHECK: encoding: [0xb7,0x01,0x00,0x00]
32lui gp, 0
33
34# CHECK-INST: auipc a0, 2
35# CHECK: encoding: [0x17,0x25,0x00,0x00]
36auipc a0, 2
37# CHECK-INST: auipc s11, 552960
38# CHECK: encoding: [0x97,0x0d,0x00,0x87]
39auipc s11, (0x87000000>>12)
40# CHECK-INST: auipc t0, 1048575
41# CHECK: encoding: [0x97,0xf2,0xff,0xff]
42auipc t0, 1048575
43# CHECK-INST: auipc gp, 0
44# CHECK: encoding: [0x97,0x01,0x00,0x00]
45auipc gp, 0
46
47# CHECK-INST: jal a2, 1048574
48# CHECK: encoding: [0x6f,0xf6,0xff,0x7f]
49jal a2, 1048574
50# CHECK-INST: jal a3, 256
51# CHECK: encoding: [0xef,0x06,0x00,0x10]
52jal a3, 256
53
54# CHECK-INST: jalr a0, a1, -2048
55# CHECK: encoding: [0x67,0x85,0x05,0x80]
56jalr a0, a1, -2048
57# CHECK-INST: jalr a0, a1, -2048
58# CHECK: encoding: [0x67,0x85,0x05,0x80]
59jalr a0, a1, %lo(2048)
60# CHECK-INST: jalr t2, t1, 2047
61# CHECK: encoding: [0xe7,0x03,0xf3,0x7f]
62jalr t2, t1, 2047
63# CHECK-INST: jalr sp, zero, 256
64# CHECK: encoding: [0x67,0x01,0x00,0x10]
65jalr sp, zero, 256
66
67# CHECK-INST: beq s1, s1, 102
68# CHECK: encoding: [0x63,0x83,0x94,0x06]
69beq s1, s1, 102
70# CHECK-INST: bne a4, a5, -4096
71# CHECK: encoding: [0x63,0x10,0xf7,0x80]
72bne a4, a5, -4096
73# CHECK-INST: blt sp, gp, 4094
74# CHECK: encoding: [0xe3,0x4f,0x31,0x7e]
75blt sp, gp, 4094
76# CHECK-INST: bge s2, ra, -224
77# CHECK: encoding: [0xe3,0x50,0x19,0xf2]
78bge s2, ra, -224
79# CHECK-INST: bltu zero, zero, 0
80# CHECK: encoding: [0x63,0x60,0x00,0x00]
81bltu zero, zero, 0
82# CHECK-INST: bgeu s8, sp, 512
83# CHECK: encoding: [0x63,0x70,0x2c,0x20]
84bgeu s8, sp, 512
85
86# CHECK-INST: lb s3, 4(ra)
87# CHECK: encoding: [0x83,0x89,0x40,0x00]
88lb s3, 4(ra)
89# CHECK-INST: lb s3, 4(ra)
90# CHECK: encoding: [0x83,0x89,0x40,0x00]
91lb s3, +4(ra)
92# CHECK-INST: lh t1, -2048(zero)
93# CHECK: encoding: [0x03,0x13,0x00,0x80]
94lh t1, -2048(zero)
95# CHECK-INST: lh t1, -2048(zero)
96# CHECK: encoding: [0x03,0x13,0x00,0x80]
97lh t1, %lo(2048)(zero)
98# CHECK-INST: lh sp, 2047(a0)
99# CHECK: encoding: [0x03,0x11,0xf5,0x7f]
100lh sp, 2047(a0)
101# CHECK-INST: lw a0, 97(a2)
102# CHECK: encoding: [0x03,0x25,0x16,0x06]
103lw a0, 97(a2)
104# CHECK-INST: lbu s5, 0(s6)
105# CHECK: encoding: [0x83,0x4a,0x0b,0x00]
106lbu s5, 0(s6)
107# CHECK-INST: lhu t3, 255(t3)
108# CHECK: encoding: [0x03,0x5e,0xfe,0x0f]
109lhu t3, 255(t3)
110
111# CHECK-INST: sb a0, 2047(a2)
112# CHECK: encoding: [0xa3,0x0f,0xa6,0x7e]
113sb a0, 2047(a2)
114# CHECK-INST: sh t3, -2048(t5)
115# CHECK: encoding: [0x23,0x10,0xcf,0x81]
116sh t3, -2048(t5)
117# CHECK-INST: sh t3, -2048(t5)
118# CHECK: encoding: [0x23,0x10,0xcf,0x81]
119sh t3, %lo(2048)(t5)
120# CHECK-INST: sw ra, 999(zero)
121# CHECK: encoding: [0xa3,0x23,0x10,0x3e]
122sw ra, 999(zero)
123
124# CHECK-INST: addi ra, sp, 2
125# CHECK: encoding: [0x93,0x00,0x21,0x00]
126addi ra, sp, 2
127# CHECK-INST: slti a0, a2, -20
128# CHECK: encoding: [0x13,0x25,0xc6,0xfe]
129slti a0, a2, -20
130# CHECK-INST: sltiu s2, s3, 80
131# CHECK: encoding: [0x13,0xb9,0x09,0x05]
132sltiu s2, s3, 0x50
133# CHECK-INST: xori tp, t1, -99
134# CHECK: encoding: [0x13,0x42,0xd3,0xf9]
135xori tp, t1, -99
136# CHECK-INST: ori a0, a1, -2048
137# CHECK: encoding: [0x13,0xe5,0x05,0x80]
138ori a0, a1, -2048
139# CHECK-INST: ori a0, a1, -2048
140# CHECK: encoding: [0x13,0xe5,0x05,0x80]
141ori a0, a1, %lo(2048)
142# CHECK-INST: andi ra, sp, 2047
143# CHECK: encoding: [0x93,0x70,0xf1,0x7f]
144andi ra, sp, 2047
145# CHECK-INST: andi ra, sp, 2047
146# CHECK: encoding: [0x93,0x70,0xf1,0x7f]
147andi x1, x2, 2047
148
149# CHECK-INST: slli t3, t3, 31
150# CHECK: encoding: [0x13,0x1e,0xfe,0x01]
151slli t3, t3, 31
152# CHECK-INST: srli a0, a4, 0
153# CHECK: encoding: [0x13,0x55,0x07,0x00]
154srli a0, a4, 0
155# CHECK-INST: srai a2, sp, 15
156# CHECK: encoding: [0x13,0x56,0xf1,0x40]
157srai a2, sp, 15
158
159# CHECK-INST: add ra, zero, zero
160# CHECK: encoding: [0xb3,0x00,0x00,0x00]
161add ra, zero, zero
162# CHECK-INST: add ra, zero, zero
163# CHECK: encoding: [0xb3,0x00,0x00,0x00]
164add x1, x0, x0
165# CHECK-INST: sub t0, t2, t1
166# CHECK: encoding: [0xb3,0x82,0x63,0x40]
167sub t0, t2, t1
168# CHECK-INST: sll a5, a4, a3
169# CHECK: encoding: [0xb3,0x17,0xd7,0x00]
170sll a5, a4, a3
171# CHECK-INST: slt s0, s0, s0
172# CHECK: encoding: [0x33,0x24,0x84,0x00]
173slt s0, s0, s0
174# CHECK-INST: sltu gp, a0, a1
175# CHECK: encoding: [0xb3,0x31,0xb5,0x00]
176sltu gp, a0, a1
177# CHECK-INST: xor s2, s2, s8
178# CHECK: encoding: [0x33,0x49,0x89,0x01]
179xor s2, s2, s8
180# CHECK-INST: xor s2, s2, s8
181# CHECK: encoding: [0x33,0x49,0x89,0x01]
182xor x18, x18, x24
183# CHECK-INST: srl a0, s0, t0
184# CHECK: encoding: [0x33,0x55,0x54,0x00]
185srl a0, s0, t0
186# CHECK-INST: sra t0, s2, zero
187# CHECK: encoding: [0xb3,0x52,0x09,0x40]
188sra t0, s2, zero
189# CHECK-INST: or s10, t1, ra
190# CHECK: encoding: [0x33,0x6d,0x13,0x00]
191or s10, t1, ra
192# CHECK-INST: and a0, s2, s3
193# CHECK: encoding: [0x33,0x75,0x39,0x01]
194and a0, s2, s3
195
196# CHECK-INST: fence iorw, iorw
197# CHECK: encoding: [0x0f,0x00,0xf0,0x0f]
198fence iorw, iorw
199# CHECK-INST: fence io, rw
200# CHECK: encoding: [0x0f,0x00,0x30,0x0c]
201fence io, rw
202# CHECK-INST: fence r, w
203# CHECK: encoding: [0x0f,0x00,0x10,0x02]
204fence r,w
205# CHECK-INST: fence w, ir
206# CHECK: encoding: [0x0f,0x00,0xa0,0x01]
207fence w,ir
208# CHECK-INST: fence.tso
209# CHECK: encoding: [0x0f,0x00,0x30,0x83]
210fence.tso
211
212# CHECK-INST: fence.i
213# CHECK: encoding: [0x0f,0x10,0x00,0x00]
214fence.i
215
216# CHECK-INST: ecall
217# CHECK: encoding: [0x73,0x00,0x00,0x00]
218ecall
219# CHECK-INST: ebreak
220# CHECK: encoding: [0x73,0x00,0x10,0x00]
221ebreak
222
223# CHECK-INST: csrrw t0, 4095, t1
224# CHECK: encoding: [0xf3,0x12,0xf3,0xff]
225csrrw t0, 0xfff, t1
226# CHECK-INST: csrrs s0, 3072, zero
227# CHECK: encoding: [0x73,0x24,0x00,0xc0]
228csrrs s0, 0xc00, x0
229# CHECK-INST: csrrs s3, 1, s5
230# CHECK: encoding: [0xf3,0xa9,0x1a,0x00]
231csrrs s3, 0x001, s5
232# CHECK-INST: csrrc sp, 0, ra
233# CHECK: encoding: [0x73,0xb1,0x00,0x00]
234csrrc sp, 0x000, ra
235# CHECK-INST: csrrwi a5, 0, 0
236# CHECK: encoding: [0xf3,0x57,0x00,0x00]
237csrrwi a5, 0x000, 0
238# CHECK-INST: csrrsi t2, 4095, 31
239# CHECK: encoding: [0xf3,0xe3,0xff,0xff]
240csrrsi t2, 0xfff, 31
241# CHECK-INST: csrrci t1, 320, 5
242# CHECK: encoding: [0x73,0xf3,0x02,0x14]
243csrrci t1, 0x140, 5
244