1 # RUN: llvm-mc %s -triple=riscv64 -riscv-no-aliases \
2 # RUN: | FileCheck -check-prefixes=CHECK-EXPAND,CHECK-INST %s
3 # RUN: llvm-mc %s -triple=riscv64 \
4 # RUN: | FileCheck -check-prefixes=CHECK-EXPAND,CHECK-ALIAS %s
5 # RUN: llvm-mc -filetype=obj -triple riscv64 < %s \
6 # RUN: | llvm-objdump -M no-aliases -d - \
7 # RUN: | FileCheck -check-prefixes=CHECK-OBJ-NOALIAS,CHECK-EXPAND,CHECK-INST %s
8 # RUN: llvm-mc -filetype=obj -triple riscv64 < %s \
9 # RUN: | llvm-objdump -d - \
10 # RUN: | FileCheck -check-prefixes=CHECK-EXPAND,CHECK-ALIAS %s
12 # The following check prefixes are used in this test:
13 # CHECK-INST.....Match the canonical instr (tests alias to instr. mapping)
14 # CHECK-ALIAS....Match the alias (tests instr. to alias mapping)
15 # CHECK-EXPAND...Match canonical instr. unconditionally (tests alias expansion)
20 # CHECK-INST: addi a0, zero, 0
21 # CHECK-ALIAS: mv a0, zero
23 # CHECK-EXPAND: addi a0, zero, 1
25 # CHECK-EXPAND: addi a0, zero, -1
27 # CHECK-EXPAND: addi a0, zero, 2047
29 # CHECK-EXPAND: addi a0, zero, -2047
31 # CHECK-EXPAND: lui a1, 1
32 # CHECK-EXPAND: addiw a1, a1, -2048
34 # CHECK-EXPAND: addi a1, zero, -2048
36 # CHECK-EXPAND: lui a1, 1
37 # CHECK-EXPAND: addiw a1, a1, -2047
39 # CHECK-EXPAND: lui a1, 1048575
40 # CHECK-EXPAND: addiw a1, a1, 2047
42 # CHECK-EXPAND: lui a1, 1
43 # CHECK-EXPAND: addiw a1, a1, -1
45 # CHECK-EXPAND: lui a1, 1048575
46 # CHECK-EXPAND: addiw a1, a1, 1
48 # CHECK-EXPAND: lui a2, 1
50 # CHECK-EXPAND: lui a2, 1048575
52 # CHECK-EXPAND: lui a2, 1
53 # CHECK-EXPAND: addiw a2, a2, 1
55 # CHECK-EXPAND: lui a2, 1048575
56 # CHECK-EXPAND: addiw a2, a2, -1
58 # CHECK-EXPAND: lui a2, 524288
59 # CHECK-EXPAND: addiw a2, a2, -1
61 # CHECK-EXPAND: lui a2, 524288
62 # CHECK-EXPAND: addiw a2, a2, 1
64 # CHECK-EXPAND: lui a2, 524288
66 # CHECK-EXPAND: lui a2, 524288
69 # CHECK-EXPAND: addi a2, zero, 1
70 # CHECK-EXPAND: slli a2, a2, 31
72 # CHECK-EXPAND: addi a2, zero, 1
73 # CHECK-EXPAND: slli a2, a2, 32
74 # CHECK-EXPAND: addi a2, a2, -1
77 # CHECK-EXPAND: addi t0, zero, 1
78 # CHECK-EXPAND: slli t0, t0, 32
80 # CHECK-EXPAND: addi t1, zero, -1
81 # CHECK-EXPAND: slli t1, t1, 63
82 li t1
, 0x8000000000000000
83 # CHECK-EXPAND: addi t1, zero, -1
84 # CHECK-EXPAND: slli t1, t1, 63
85 li t1
, -0x8000000000000000
86 # CHECK-EXPAND: lui t2, 9321
87 # CHECK-EXPAND: addiw t2, t2, -1329
88 # CHECK-EXPAND: slli t2, t2, 35
89 li t2
, 0x1234567800000000
90 # CHECK-EXPAND: addi t3, zero, 7
91 # CHECK-EXPAND: slli t3, t3, 36
92 # CHECK-EXPAND: addi t3, t3, 11
93 # CHECK-EXPAND: slli t3, t3, 24
94 # CHECK-EXPAND: addi t3, t3, 15
95 li t3
, 0x700000000B00000F
96 # CHECK-EXPAND: lui t4, 583
97 # CHECK-EXPAND: addiw t4, t4, -1875
98 # CHECK-EXPAND: slli t4, t4, 14
99 # CHECK-EXPAND: addi t4, t4, -947
100 # CHECK-EXPAND: slli t4, t4, 12
101 # CHECK-EXPAND: addi t4, t4, 1511
102 # CHECK-EXPAND: slli t4, t4, 13
103 # CHECK-EXPAND: addi t4, t4, -272
104 li t4
, 0x123456789abcdef0
105 # CHECK-EXPAND: addi t5, zero, -1
106 li t5
, 0xFFFFFFFFFFFFFFFF
108 # CHECK-EXPAND: addi a0, zero, 1110
110 # CHECK-OBJ-NOALIAS: addi a0, zero, 0
111 # CHECK-OBJ: R_RISCV_PCREL_LO12
112 li a0
, %pcrel_lo
(0x123456)
114 # CHECK-OBJ-NOALIAS: addi a0, zero, 0
115 # CHECK-OBJ: R_RISCV_LO12
117 # CHECK-OBJ-NOALIAS: addi a0, zero, 0
118 # CHECK-OBJ: R_RISCV_PCREL_LO12
119 li a0
, %pcrel_lo
(foo
)
122 # CHECK-EXPAND: lui a0, 291
123 # CHECK-EXPAND: addiw a0, a0, 1110
127 # CHECK-EXPAND: lui a0, 1620
128 # CHECK-EXPAND: addiw a0, a0, 801
131 # CHECK-INST: subw t6, zero, ra
132 # CHECK-ALIAS: negw t6, ra
134 # CHECK-INST: addiw t6, ra, 0
135 # CHECK-ALIAS: sext.w t6, ra
138 # The following aliases are accepted as input but the canonical form
139 # of the instruction will always be printed.
140 # CHECK-INST: addiw a2, a3, 4
141 # CHECK-ALIAS: addiw a2, a3, 4
144 # CHECK-INST: slliw a2, a3, 4
145 # CHECK-ALIAS: slliw a2, a3, 4
148 # CHECK-INST: srliw a2, a3, 4
149 # CHECK-ALIAS: srliw a2, a3, 4
152 # CHECK-INST: sraiw a2, a3, 4
153 # CHECK-ALIAS: sraiw a2, a3, 4
156 # CHECK-EXPAND: lwu a0, 0(a1)
158 # CHECK-EXPAND: ld a0, 0(a1)
160 # CHECK-EXPAND: sd a0, 0(a1)