1 # RUN: llvm-mc %s -triple=riscv32 -riscv-no-aliases -show-encoding \
2 # RUN: | FileCheck -check-prefixes=CHECK-INST,CHECK-ENC %s
3 # RUN: llvm-mc -filetype=obj -triple riscv32 < %s \
4 # RUN: | llvm-objdump -d - \
5 # RUN: | FileCheck -check-prefix=CHECK-INST-ALIAS %s
7 # RUN: llvm-mc %s -triple=riscv64 -riscv-no-aliases -show-encoding \
8 # RUN: | FileCheck -check-prefixes=CHECK-INST,CHECK-ENC %s
9 # RUN: llvm-mc -filetype=obj -triple riscv64 < %s \
10 # RUN: | llvm-objdump -d - \
11 # RUN: | FileCheck -check-prefix=CHECK-INST-ALIAS %s
13 ##################################
15 ##################################
19 # CHECK-INST: csrrs t1, ustatus, zero
20 # CHECK-ENC: encoding: [0x73,0x23,0x00,0x00]
21 # CHECK-INST-ALIAS: csrr t1, ustatus
23 # CHECK-INST: csrrs t2, ustatus, zero
24 # CHECK-ENC: encoding: [0xf3,0x23,0x00,0x00]
25 # CHECK-INST-ALIAS: csrr t2, ustatus
26 csrrs t1
, ustatus
, zero
32 # CHECK-INST: csrrs t1, uie, zero
33 # CHECK-ENC: encoding: [0x73,0x23,0x40,0x00]
34 # CHECK-INST-ALIAS: csrr t1, uie
36 # CHECK-INST: csrrs t2, uie, zero
37 # CHECK-ENC: encoding: [0xf3,0x23,0x40,0x00]
38 # CHECK-INST-ALIAS: csrr t2, uie
46 # CHECK-INST: csrrs t1, utvec, zero
47 # CHECK-ENC: encoding: [0x73,0x23,0x50,0x00]
48 # CHECK-INST-ALIAS: csrr t1, utvec
50 # CHECK-INST: csrrs t2, utvec, zero
51 # CHECK-ENC: encoding: [0xf3,0x23,0x50,0x00]
52 # CHECK-INST-ALIAS: csrr t2, utvec
58 ##################################
60 ##################################
64 # CHECK-INST: csrrs t1, uscratch, zero
65 # CHECK-ENC: encoding: [0x73,0x23,0x00,0x04]
66 # CHECK-INST-ALIAS: csrr t1, uscratch
68 # CHECK-INST: csrrs t2, uscratch, zero
69 # CHECK-ENC: encoding: [0xf3,0x23,0x00,0x04]
70 # CHECK-INST-ALIAS: csrr t2, uscratch
72 csrrs t1
, uscratch
, zero
78 # CHECK-INST: csrrs t1, uepc, zero
79 # CHECK-ENC: encoding: [0x73,0x23,0x10,0x04]
80 # CHECK-INST-ALIAS: csrr t1, uepc
82 # CHECK-INST: csrrs t2, uepc, zero
83 # CHECK-ENC: encoding: [0xf3,0x23,0x10,0x04]
84 # CHECK-INST-ALIAS: csrr t2, uepc
92 # CHECK-INST: csrrs t1, ucause, zero
93 # CHECK-ENC: encoding: [0x73,0x23,0x20,0x04]
94 # CHECK-INST-ALIAS: csrr t1, ucause
96 # CHECK-INST: csrrs t2, ucause, zero
97 # CHECK-ENC: encoding: [0xf3,0x23,0x20,0x04]
98 # CHECK-INST-ALIAS: csrr t2, ucause
100 csrrs t1
, ucause
, zero
102 csrrs t2
, 0x042, zero
106 # CHECK-INST: csrrs t1, utval, zero
107 # CHECK-ENC: encoding: [0x73,0x23,0x30,0x04]
108 # CHECK-INST-ALIAS: csrr t1, utval
110 # CHECK-INST: csrrs t2, utval, zero
111 # CHECK-ENC: encoding: [0xf3,0x23,0x30,0x04]
112 # CHECK-INST-ALIAS: csrr t2, utval
114 csrrs t1
, utval
, zero
116 csrrs t2
, 0x043, zero
120 # CHECK-INST: csrrs t1, uip, zero
121 # CHECK-ENC: encoding: [0x73,0x23,0x40,0x04]
122 # CHECK-INST-ALIAS: csrr t1, uip
124 # CHECK-INST: csrrs t2, uip, zero
125 # CHECK-ENC: encoding: [0xf3,0x23,0x40,0x04]
126 # CHECK-INST-ALIAS: csrr t2, uip
130 csrrs t2
, 0x044, zero
132 ##################################
133 # User Floating Pont CSRs
134 ##################################
135 # Tests in rvf-user-mode-csr.s
137 ##################################
138 # User Counter and Timers
139 ##################################
143 # CHECK-INST: csrrs t1, cycle, zero
144 # CHECK-ENC: encoding: [0x73,0x23,0x00,0xc0]
145 # CHECK-INST-ALIAS: rdcycle t1
147 # CHECK-INST: csrrs t2, cycle, zero
148 # CHECK-ENC: encoding: [0xf3,0x23,0x00,0xc0]
149 # CHECK-INST-ALIAS: rdcycle t2
151 csrrs t1
, cycle
, zero
153 csrrs t2
, 0xC00, zero
157 # CHECK-INST: csrrs t1, time, zero
158 # CHECK-ENC: encoding: [0x73,0x23,0x10,0xc0]
159 # CHECK-INST-ALIAS: rdtime t1
161 # CHECK-INST: csrrs t2, time, zero
162 # CHECK-ENC: encoding: [0xf3,0x23,0x10,0xc0]
163 # CHECK-INST-ALIAS: rdtime t2
167 csrrs t2
, 0xC01, zero
171 # CHECK-INST: csrrs t1, instret, zero
172 # CHECK-ENC: encoding: [0x73,0x23,0x20,0xc0]
173 # CHECK-INST-ALIAS: rdinstret t1
175 # CHECK-INST: csrrs t2, instret, zero
176 # CHECK-ENC: encoding: [0xf3,0x23,0x20,0xc0]
177 # CHECK-INST-ALIAS: rdinstret t2
179 csrrs t1
, instret
, zero
181 csrrs t2
, 0xC02, zero
185 # CHECK-INST: csrrs t1, hpmcounter3, zero
186 # CHECK-ENC: encoding: [0x73,0x23,0x30,0xc0]
187 # CHECK-INST-ALIAS: csrr t1, hpmcounter3
189 # CHECK-INST: csrrs t2, hpmcounter3, zero
190 # CHECK-ENC: encoding: [0xf3,0x23,0x30,0xc0]
191 # CHECK-INST-ALIAS: csrr t2, hpmcounter3
193 csrrs t1
, hpmcounter3
, zero
195 csrrs t2
, 0xC03, zero
199 # CHECK-INST: csrrs t1, hpmcounter4, zero
200 # CHECK-ENC: encoding: [0x73,0x23,0x40,0xc0]
201 # CHECK-INST-ALIAS: csrr t1, hpmcounter4
203 # CHECK-INST: csrrs t2, hpmcounter4, zero
204 # CHECK-ENC: encoding: [0xf3,0x23,0x40,0xc0]
205 # CHECK-INST-ALIAS: csrr t2, hpmcounter4
207 csrrs t1
, hpmcounter4
, zero
209 csrrs t2
, 0xC04, zero
213 # CHECK-INST: csrrs t1, hpmcounter5, zero
214 # CHECK-ENC: encoding: [0x73,0x23,0x50,0xc0]
215 # CHECK-INST-ALIAS: csrr t1, hpmcounter5
217 # CHECK-INST: csrrs t2, hpmcounter5, zero
218 # CHECK-ENC: encoding: [0xf3,0x23,0x50,0xc0]
219 # CHECK-INST-ALIAS: csrr t2, hpmcounter5
221 csrrs t1
, hpmcounter5
, zero
223 csrrs t2
, 0xC05, zero
227 # CHECK-INST: csrrs t1, hpmcounter6, zero
228 # CHECK-ENC: encoding: [0x73,0x23,0x60,0xc0]
229 # CHECK-INST-ALIAS: csrr t1, hpmcounter6
231 # CHECK-INST: csrrs t2, hpmcounter6, zero
232 # CHECK-ENC: encoding: [0xf3,0x23,0x60,0xc0]
233 # CHECK-INST-ALIAS: csrr t2, hpmcounter6
235 csrrs t1
, hpmcounter6
, zero
237 csrrs t2
, 0xC06, zero
241 # CHECK-INST: csrrs t1, hpmcounter7, zero
242 # CHECK-ENC: encoding: [0x73,0x23,0x70,0xc0]
243 # CHECK-INST-ALIAS: csrr t1, hpmcounter7
245 # CHECK-INST: csrrs t2, hpmcounter7, zero
246 # CHECK-ENC: encoding: [0xf3,0x23,0x70,0xc0]
247 # CHECK-INST-ALIAS: csrr t2, hpmcounter7
249 csrrs t1
, hpmcounter7
, zero
251 csrrs t2
, 0xC07, zero
255 # CHECK-INST: csrrs t1, hpmcounter8, zero
256 # CHECK-ENC: encoding: [0x73,0x23,0x80,0xc0]
257 # CHECK-INST-ALIAS: csrr t1, hpmcounter8
259 # CHECK-INST: csrrs t2, hpmcounter8, zero
260 # CHECK-ENC: encoding: [0xf3,0x23,0x80,0xc0]
261 # CHECK-INST-ALIAS: csrr t2, hpmcounter8
263 csrrs t1
, hpmcounter8
, zero
265 csrrs t2
, 0xC08, zero
269 # CHECK-INST: csrrs t1, hpmcounter9, zero
270 # CHECK-ENC: encoding: [0x73,0x23,0x90,0xc0]
271 # CHECK-INST-ALIAS: csrr t1, hpmcounter9
273 # CHECK-INST: csrrs t2, hpmcounter9, zero
274 # CHECK-ENC: encoding: [0xf3,0x23,0x90,0xc0]
275 # CHECK-INST-ALIAS: csrr t2, hpmcounter9
277 csrrs t1
, hpmcounter9
, zero
279 csrrs t2
, 0xC09, zero
283 # CHECK-INST: csrrs t1, hpmcounter10, zero
284 # CHECK-ENC: encoding: [0x73,0x23,0xa0,0xc0]
285 # CHECK-INST-ALIAS: csrr t1, hpmcounter10
287 # CHECK-INST: csrrs t2, hpmcounter10, zero
288 # CHECK-ENC: encoding: [0xf3,0x23,0xa0,0xc0]
289 # CHECK-INST-ALIAS: csrr t2, hpmcounter10
291 csrrs t1
, hpmcounter10
, zero
293 csrrs t2
, 0xC0A, zero
297 # CHECK-INST: csrrs t1, hpmcounter11, zero
298 # CHECK-ENC: encoding: [0x73,0x23,0xb0,0xc0]
299 # CHECK-INST-ALIAS: csrr t1, hpmcounter11
301 # CHECK-INST: csrrs t2, hpmcounter11, zero
302 # CHECK-ENC: encoding: [0xf3,0x23,0xb0,0xc0]
303 # CHECK-INST-ALIAS: csrr t2, hpmcounter11
305 csrrs t1
, hpmcounter11
, zero
307 csrrs t2
, 0xC0B, zero
311 # CHECK-INST: csrrs t1, hpmcounter12, zero
312 # CHECK-ENC: encoding: [0x73,0x23,0xc0,0xc0]
313 # CHECK-INST-ALIAS: csrr t1, hpmcounter12
315 # CHECK-INST: csrrs t2, hpmcounter12, zero
316 # CHECK-ENC: encoding: [0xf3,0x23,0xc0,0xc0]
317 # CHECK-INST-ALIAS: csrr t2, hpmcounter12
319 csrrs t1
, hpmcounter12
, zero
321 csrrs t2
, 0xC0C, zero
325 # CHECK-INST: csrrs t1, hpmcounter13, zero
326 # CHECK-ENC: encoding: [0x73,0x23,0xd0,0xc0]
327 # CHECK-INST-ALIAS: csrr t1, hpmcounter13
329 # CHECK-INST: csrrs t2, hpmcounter13, zero
330 # CHECK-ENC: encoding: [0xf3,0x23,0xd0,0xc0]
331 # CHECK-INST-ALIAS: csrr t2, hpmcounter13
333 csrrs t1
, hpmcounter13
, zero
335 csrrs t2
, 0xC0D, zero
339 # CHECK-INST: csrrs t1, hpmcounter14, zero
340 # CHECK-ENC: encoding: [0x73,0x23,0xe0,0xc0]
341 # CHECK-INST-ALIAS: csrr t1, hpmcounter14
343 # CHECK-INST: csrrs t2, hpmcounter14, zero
344 # CHECK-ENC: encoding: [0xf3,0x23,0xe0,0xc0]
345 # CHECK-INST-ALIAS: csrr t2, hpmcounter14
347 csrrs t1
, hpmcounter14
, zero
349 csrrs t2
, 0xC0E, zero
353 # CHECK-INST: csrrs t1, hpmcounter15, zero
354 # CHECK-ENC: encoding: [0x73,0x23,0xf0,0xc0]
355 # CHECK-INST-ALIAS: csrr t1, hpmcounter15
357 # CHECK-INST: csrrs t2, hpmcounter15, zero
358 # CHECK-ENC: encoding: [0xf3,0x23,0xf0,0xc0]
359 # CHECK-INST-ALIAS: csrr t2, hpmcounter15
361 csrrs t1
, hpmcounter15
, zero
363 csrrs t2
, 0xC0F, zero
367 # CHECK-INST: csrrs t1, hpmcounter16, zero
368 # CHECK-ENC: encoding: [0x73,0x23,0x00,0xc1]
369 # CHECK-INST-ALIAS: csrr t1, hpmcounter16
371 # CHECK-INST: csrrs t2, hpmcounter16, zero
372 # CHECK-ENC: encoding: [0xf3,0x23,0x00,0xc1]
373 # CHECK-INST-ALIAS: csrr t2, hpmcounter16
375 csrrs t1
, hpmcounter16
, zero
377 csrrs t2
, 0xC10, zero
381 # CHECK-INST: csrrs t1, hpmcounter17, zero
382 # CHECK-ENC: encoding: [0x73,0x23,0x10,0xc1]
383 # CHECK-INST-ALIAS: csrr t1, hpmcounter17
385 # CHECK-INST: csrrs t2, hpmcounter17, zero
386 # CHECK-ENC: encoding: [0xf3,0x23,0x10,0xc1]
387 # CHECK-INST-ALIAS: csrr t2, hpmcounter17
389 csrrs t1
, hpmcounter17
, zero
391 csrrs t2
, 0xC11, zero
395 # CHECK-INST: csrrs t1, hpmcounter18, zero
396 # CHECK-ENC: encoding: [0x73,0x23,0x20,0xc1]
397 # CHECK-INST-ALIAS: csrr t1, hpmcounter18
399 # CHECK-INST: csrrs t2, hpmcounter18, zero
400 # CHECK-ENC: encoding: [0xf3,0x23,0x20,0xc1]
401 # CHECK-INST-ALIAS: csrr t2, hpmcounter18
403 csrrs t1
, hpmcounter18
, zero
405 csrrs t2
, 0xC12, zero
409 # CHECK-INST: csrrs t1, hpmcounter19, zero
410 # CHECK-ENC: encoding: [0x73,0x23,0x30,0xc1]
411 # CHECK-INST-ALIAS: csrr t1, hpmcounter19
413 # CHECK-INST: csrrs t2, hpmcounter19, zero
414 # CHECK-ENC: encoding: [0xf3,0x23,0x30,0xc1]
415 # CHECK-INST-ALIAS: csrr t2, hpmcounter19
417 csrrs t1
, hpmcounter19
, zero
419 csrrs t2
, 0xC13, zero
423 # CHECK-INST: csrrs t1, hpmcounter20, zero
424 # CHECK-ENC: encoding: [0x73,0x23,0x40,0xc1]
425 # CHECK-INST-ALIAS: csrr t1, hpmcounter20
427 # CHECK-INST: csrrs t2, hpmcounter20, zero
428 # CHECK-ENC: encoding: [0xf3,0x23,0x40,0xc1]
429 # CHECK-INST-ALIAS: csrr t2, hpmcounter20
431 csrrs t1
, hpmcounter20
, zero
433 csrrs t2
, 0xC14, zero
437 # CHECK-INST: csrrs t1, hpmcounter21, zero
438 # CHECK-ENC: encoding: [0x73,0x23,0x50,0xc1]
439 # CHECK-INST-ALIAS: csrr t1, hpmcounter21
441 # CHECK-INST: csrrs t2, hpmcounter21, zero
442 # CHECK-ENC: encoding: [0xf3,0x23,0x50,0xc1]
443 # CHECK-INST-ALIAS: csrr t2, hpmcounter21
445 csrrs t1
, hpmcounter21
, zero
447 csrrs t2
, 0xC15, zero
451 # CHECK-INST: csrrs t1, hpmcounter22, zero
452 # CHECK-ENC: encoding: [0x73,0x23,0x60,0xc1]
453 # CHECK-INST-ALIAS: csrr t1, hpmcounter22
455 # CHECK-INST: csrrs t2, hpmcounter22, zero
456 # CHECK-ENC: encoding: [0xf3,0x23,0x60,0xc1]
457 # CHECK-INST-ALIAS: csrr t2, hpmcounter22
459 csrrs t1
, hpmcounter22
, zero
461 csrrs t2
, 0xC16, zero
465 # CHECK-INST: csrrs t1, hpmcounter23, zero
466 # CHECK-ENC: encoding: [0x73,0x23,0x70,0xc1]
467 # CHECK-INST-ALIAS: csrr t1, hpmcounter23
469 # CHECK-INST: csrrs t2, hpmcounter23, zero
470 # CHECK-ENC: encoding: [0xf3,0x23,0x70,0xc1]
471 # CHECK-INST-ALIAS: csrr t2, hpmcounter23
473 csrrs t1
, hpmcounter23
, zero
475 csrrs t2
, 0xC17, zero
479 # CHECK-INST: csrrs t1, hpmcounter24, zero
480 # CHECK-ENC: encoding: [0x73,0x23,0x80,0xc1]
481 # CHECK-INST-ALIAS: csrr t1, hpmcounter24
483 # CHECK-INST: csrrs t2, hpmcounter24, zero
484 # CHECK-ENC: encoding: [0xf3,0x23,0x80,0xc1]
485 # CHECK-INST-ALIAS: csrr t2, hpmcounter24
487 csrrs t1
, hpmcounter24
, zero
489 csrrs t2
, 0xC18, zero
493 # CHECK-INST: csrrs t1, hpmcounter25, zero
494 # CHECK-ENC: encoding: [0x73,0x23,0x90,0xc1]
495 # CHECK-INST-ALIAS: csrr t1, hpmcounter25
497 # CHECK-INST: csrrs t2, hpmcounter25, zero
498 # CHECK-ENC: encoding: [0xf3,0x23,0x90,0xc1]
499 # CHECK-INST-ALIAS: csrr t2, hpmcounter25
501 csrrs t1
, hpmcounter25
, zero
503 csrrs t2
, 0xC19, zero
507 # CHECK-INST: csrrs t1, hpmcounter26, zero
508 # CHECK-ENC: encoding: [0x73,0x23,0xa0,0xc1]
509 # CHECK-INST-ALIAS: csrr t1, hpmcounter26
511 # CHECK-INST: csrrs t2, hpmcounter26, zero
512 # CHECK-ENC: encoding: [0xf3,0x23,0xa0,0xc1]
513 # CHECK-INST-ALIAS: csrr t2, hpmcounter26
515 csrrs t1
, hpmcounter26
, zero
517 csrrs t2
, 0xC1A, zero
521 # CHECK-INST: csrrs t1, hpmcounter27, zero
522 # CHECK-ENC: encoding: [0x73,0x23,0xb0,0xc1]
523 # CHECK-INST-ALIAS: csrr t1, hpmcounter27
525 # CHECK-INST: csrrs t2, hpmcounter27, zero
526 # CHECK-ENC: encoding: [0xf3,0x23,0xb0,0xc1]
527 # CHECK-INST-ALIAS: csrr t2, hpmcounter27
529 csrrs t1
, hpmcounter27
, zero
531 csrrs t2
, 0xC1B, zero
535 # CHECK-INST: csrrs t1, hpmcounter28, zero
536 # CHECK-ENC: encoding: [0x73,0x23,0xc0,0xc1]
537 # CHECK-INST-ALIAS: csrr t1, hpmcounter28
539 # CHECK-INST: csrrs t2, hpmcounter28, zero
540 # CHECK-ENC: encoding: [0xf3,0x23,0xc0,0xc1]
541 # CHECK-INST-ALIAS: csrr t2, hpmcounter28
543 csrrs t1
, hpmcounter28
, zero
545 csrrs t2
, 0xC1C, zero
549 # CHECK-INST: csrrs t1, hpmcounter29, zero
550 # CHECK-ENC: encoding: [0x73,0x23,0xd0,0xc1]
551 # CHECK-INST-ALIAS: csrr t1, hpmcounter29
553 # CHECK-INST: csrrs t2, hpmcounter29, zero
554 # CHECK-ENC: encoding: [0xf3,0x23,0xd0,0xc1]
555 # CHECK-INST-ALIAS: csrr t2, hpmcounter29
557 csrrs t1
, hpmcounter29
, zero
559 csrrs t2
, 0xC1D, zero
563 # CHECK-INST: csrrs t1, hpmcounter30, zero
564 # CHECK-ENC: encoding: [0x73,0x23,0xe0,0xc1]
565 # CHECK-INST-ALIAS: csrr t1, hpmcounter30
567 # CHECK-INST: csrrs t2, hpmcounter30, zero
568 # CHECK-ENC: encoding: [0xf3,0x23,0xe0,0xc1]
569 # CHECK-INST-ALIAS: csrr t2, hpmcounter30
571 csrrs t1
, hpmcounter30
, zero
573 csrrs t2
, 0xC1E, zero
577 # CHECK-INST: csrrs t1, hpmcounter31, zero
578 # CHECK-ENC: encoding: [0x73,0x23,0xf0,0xc1]
579 # CHECK-INST-ALIAS: csrr t1, hpmcounter31
581 # CHECK-INST: csrrs t2, hpmcounter31, zero
582 # CHECK-ENC: encoding: [0xf3,0x23,0xf0,0xc1]
583 # CHECK-INST-ALIAS: csrr t2, hpmcounter31
585 csrrs t1
, hpmcounter31
, zero
587 csrrs t2
, 0xC1F, zero