xref: /llvm-project/llvm/test/MC/RISCV/compress-rv64i.s (revision 4b3d439e7e7b4e794e523caea9863d67ff8cf85f)
1# RUN: llvm-mc -triple riscv64 -mattr=+c -show-encoding < %s \
2# RUN:   | FileCheck -check-prefixes=CHECK-ALIAS %s
3# RUN: llvm-mc -triple riscv64 -mattr=+c -show-encoding \
4# RUN:   -M no-aliases < %s | FileCheck -check-prefixes=CHECK-INST %s
5# RUN: llvm-mc -triple riscv64 -mattr=+c -filetype=obj < %s \
6# RUN:   | llvm-objdump  --triple=riscv64 --mattr=+c --no-print-imm-hex -d - \
7# RUN:   | FileCheck -check-prefixes=CHECK-BYTES,CHECK-ALIAS %s
8# RUN: llvm-mc -triple riscv64 -mattr=+c -filetype=obj < %s \
9# RUN:   | llvm-objdump  --triple=riscv64 --mattr=+c --no-print-imm-hex -d -M no-aliases - \
10# RUN:   | FileCheck -check-prefixes=CHECK-BYTES,CHECK-INST %s
11
12# Tests compressed instructions available in rv64 and not in rv32.
13
14# CHECK-BYTES: 7fe0
15# CHECK-ALIAS: ld s0, 248(a5)
16# CHECK-INST: c.ld s0, 248(a5)
17# CHECK: # encoding: [0xe0,0x7f]
18ld s0, 248(a5)
19
20# CHECK-BYTES: e3a0
21# CHECK-ALIAS: sd s0, 64(a5)
22# CHECK-INST: c.sd s0, 64(a5)
23# CHECK: # encoding: [0xa0,0xe3]
24sd s0, 64(a5)
25
26# CHECK-BYTES: 227d
27# CHEACK-ALIAS: addiw tp, tp, 31
28# CHECK-INST: c.addiw  tp, 31
29# CHECK: # encoding: [0x7d,0x22]
30addiw tp, tp, 31
31
32# CHECK-BYTES: 9c1d
33# CHEACK-ALIAS: subw s0, s0, a5
34# CHECK-INST: c.subw s0, a5
35# CHECK: # encoding:  [0x1d,0x9c]
36subw s0, s0, a5
37
38# CHECK-BYTES: 9c3d
39# CHECK-ALIAS: addw s0, s0, a5
40# CHECK-INST: c.addw s0, a5
41# CHECK: # encoding: [0x3d,0x9c]
42addw s0, s0, a5
43
44# CHECK-BYTES: 9c3d
45# CHECK-ALIAS: addw s0, s0, a5
46# CHECK-INST: c.addw s0, a5
47# CHECK: # encoding: [0x3d,0x9c]
48addw s0, a5, s0
49
50# CHECK-BYTES: 70ee
51# CHECK-ALIAS: ld ra, 248(sp)
52# CHECK-INST: c.ldsp ra, 248(sp)
53# CHECK: # encoding:  [0xee,0x70]
54ld ra, 248(sp)
55
56# CHECK-BYTES: e0a2
57# CHECK-ALIAS: sd s0, 64(sp)
58# CHECK-INST: c.sdsp s0, 64(sp)
59# CHECK: # encoding: [0xa2,0xe0]
60sd s0, 64(sp)
61