Debian Codegraph @

llvm/test/MC/LoongArch/Basic/Integer/invalid.s

raw
1 ## Test invalid instructions on both loongarch32 and loongarch64 target.
2
3 # RUN: not llvm-mc --triple=loongarch32 %s 2>&1 | FileCheck %s --check-prefixes=CHECK,CHECK64
4 # RUN: not llvm-mc --triple=loongarch64 %s 2>&1 --defsym=LA64=1 | FileCheck %s
5
6 ## Out of range immediates
7 ## uimm2
8 bytepick.w $a0, $a0, $a0, -1
9 # CHECK: :[[#@LINE-1]]:27: error: immediate must be an integer in the range [0, 3]
10 bytepick.w $a0, $a0, $a0, 4
11 # CHECK: :[[#@LINE-1]]:27: error: immediate must be an integer in the range [0, 3]
12
13 ## uimm2_plus1
14 alsl.w $a0, $a0, $a0, 0
15 # CHECK: :[[#@LINE-1]]:23: error: immediate must be an integer in the range [1, 4]
16 alsl.w $a0, $a0, $a0, 5
17 # CHECK: :[[#@LINE-1]]:23: error: immediate must be an integer in the range [1, 4]
18
19 ## uimm5
20 slli.w $a0, $a0, -1
21 # CHECK: :[[#@LINE-1]]:18: error: immediate must be an integer in the range [0, 31]
22 srli.w $a0, $a0, -1
23 # CHECK: :[[#@LINE-1]]:18: error: immediate must be an integer in the range [0, 31]
24 srai.w $a0, $a0, 32
25 # CHECK: :[[#@LINE-1]]:18: error: immediate must be an integer in the range [0, 31]
26 rotri.w $a0, $a0, 32
27 # CHECK: :[[#@LINE-1]]:19: error: immediate must be an integer in the range [0, 31]
28 bstrins.w $a0, $a0, 31, -1
29 # CHECK: :[[#@LINE-1]]:25: error: immediate must be an integer in the range [0, 31]
30 bstrpick.w $a0, $a0, 32, 0
31 # CHECK: :[[#@LINE-1]]:22: error: immediate must be an integer in the range [0, 31]
32 preld -1, $a0, 0
33 # CHECK: :[[#@LINE-1]]:7: error: immediate must be an integer in the range [0, 31]
34 preld 32, $a0, 0
35 # CHECK: :[[#@LINE-1]]:7: error: immediate must be an integer in the range [0, 31]
36
37 ## uimm12
38 andi $a0, $a0, -1
39 # CHECK: :[[#@LINE-1]]:16: error: immediate must be an integer in the range [0, 4095]
40 xori $a0, $a0, 4096
41 # CHECK: :[[#@LINE-1]]:16: error: immediate must be an integer in the range [0, 4095]
42
43 ## uimm12_ori
44 ori $a0, $a0, 4096
45 # CHECK: :[[#@LINE-1]]:15: error: operand must be a symbol with modifier (e.g. %abs_lo12) or an integer in the range [0, 4095]
46
47 ## simm12
48 slti $a0, $a0, -2049
49 # CHECK: :[[#@LINE-1]]:16: error: immediate must be an integer in the range [-2048, 2047]
50 sltui $a0, $a0, 2048
51 # CHECK: :[[#@LINE-1]]:17: error: immediate must be an integer in the range [-2048, 2047]
52 preld 0, $a0, 2048
53 # CHECK: :[[#@LINE-1]]:15: error: immediate must be an integer in the range [-2048, 2047]
54
55 ## simm12_addlike
56 addi.w $a0, $a0, -2049
57 # CHECK: :[[#@LINE-1]]:18: error: operand must be a symbol with modifier (e.g. %pc_lo12) or an integer in the range [-2048, 2047]
58 ld.b $a0, $a0, 2048
59 # CHECK: :[[#@LINE-1]]:16: error: operand must be a symbol with modifier (e.g. %pc_lo12) or an integer in the range [-2048, 2047]
60 ld.h $a0, $a0, 2048
61 # CHECK: :[[#@LINE-1]]:16: error: operand must be a symbol with modifier (e.g. %pc_lo12) or an integer in the range [-2048, 2047]
62 ld.w $a0, $a0, 2048
63 # CHECK: :[[#@LINE-1]]:16: error: operand must be a symbol with modifier (e.g. %pc_lo12) or an integer in the range [-2048, 2047]
64 ld.bu $a0, $a0, -2049
65 # CHECK: :[[#@LINE-1]]:17: error: operand must be a symbol with modifier (e.g. %pc_lo12) or an integer in the range [-2048, 2047]
66 ld.hu $a0, $a0, -2049
67 # CHECK: :[[#@LINE-1]]:17: error: operand must be a symbol with modifier (e.g. %pc_lo12) or an integer in the range [-2048, 2047]
68 st.b $a0, $a0, 2048
69 # CHECK: :[[#@LINE-1]]:16: error: operand must be a symbol with modifier (e.g. %pc_lo12) or an integer in the range [-2048, 2047]
70 st.h $a0, $a0, 2048
71 # CHECK: :[[#@LINE-1]]:16: error: operand must be a symbol with modifier (e.g. %pc_lo12) or an integer in the range [-2048, 2047]
72 st.w $a0, $a0, -2049
73 # CHECK: :[[#@LINE-1]]:16: error: operand must be a symbol with modifier (e.g. %pc_lo12) or an integer in the range [-2048, 2047]
74
75 ## simm14_lsl2
76 ll.w $a0, $a0, -32772
77 # CHECK: :[[#@LINE-1]]:16: error: immediate must be a multiple of 4 in the range [-32768, 32764]
78 ll.w $a0, $a0, -32769
79 # CHECK: :[[#@LINE-1]]:16: error: immediate must be a multiple of 4 in the range [-32768, 32764]
80 sc.w $a0, $a0, 32767
81 # CHECK: :[[#@LINE-1]]:16: error: immediate must be a multiple of 4 in the range [-32768, 32764]
82 sc.w $a0, $a0, 32768
83 # CHECK: :[[#@LINE-1]]:16: error: immediate must be a multiple of 4 in the range [-32768, 32764]
84
85 ## simm16_lsl2
86 beq $a0, $a0, -0x20004
87 # CHECK: :[[#@LINE-1]]:15: error: operand must be a symbol with modifier (e.g. %b16) or an integer in the range [-131072, 131068]
88 bne $a0, $a0, -0x20004
89 # CHECK: :[[#@LINE-1]]:15: error: operand must be a symbol with modifier (e.g. %b16) or an integer in the range [-131072, 131068]
90 blt $a0, $a0, -0x1FFFF
91 # CHECK: :[[#@LINE-1]]:15: error: operand must be a symbol with modifier (e.g. %b16) or an integer in the range [-131072, 131068]
92 bge $a0, $a0, -0x1FFFF
93 # CHECK: :[[#@LINE-1]]:15: error: operand must be a symbol with modifier (e.g. %b16) or an integer in the range [-131072, 131068]
94 bltu $a0, $a0, 0x1FFFF
95 # CHECK: :[[#@LINE-1]]:16: error: operand must be a symbol with modifier (e.g. %b16) or an integer in the range [-131072, 131068]
96 bgeu $a0, $a0, 0x1FFFF
97 # CHECK: :[[#@LINE-1]]:16: error: operand must be a symbol with modifier (e.g. %b16) or an integer in the range [-131072, 131068]
98 jirl $a0, $a0, 0x20000
99 # CHECK: :[[#@LINE-1]]:16: error: operand must be a symbol with modifier (e.g. %b16) or an integer in the range [-131072, 131068]
100
101 ## simm20
102 pcaddu12i $a0, 0x80000
103 # CHECK: :[[#@LINE-1]]:16: error: immediate must be an integer in the range [-524288, 524287]
104
105 ## simm20_pcaddi
106 pcaddi $a0, -0x80001
107 # CHECK: :[[#@LINE-1]]:13: error: operand must be a symbol with modifier (e.g. %pcrel_20) or an integer in the range [-524288, 524287]
108
109 ## simm20_lu12iw
110 lu12i.w $a0, -0x80001
111 # CHECK: :[[#@LINE-1]]:14: error: operand must be a symbol with modifier (e.g. %abs_hi20) or an integer in the range [-524288, 524287]
112
113 ## simm20_pcalau12i
114 pcalau12i $a0, 0x80000
115 # CHECK: :[[#@LINE-1]]:16: error: operand must be a symbol with modifier (e.g. %pc_hi20) or an integer in the range [-524288, 524287]
116
117 ## simm21_lsl2
118 beqz $a0, -0x400001
119 # CHECK: :[[#@LINE-1]]:11: error: operand must be a symbol with modifier (e.g. %b21) or an integer in the range [-4194304, 4194300]
120 bnez $a0, -0x3FFFFF
121 # CHECK: :[[#@LINE-1]]:11: error: operand must be a symbol with modifier (e.g. %b21) or an integer in the range [-4194304, 4194300]
122 beqz $a0, 0x3FFFFF
123 # CHECK: :[[#@LINE-1]]:11: error: operand must be a symbol with modifier (e.g. %b21) or an integer in the range [-4194304, 4194300]
124 bnez $a0, 0x400000
125 # CHECK: :[[#@LINE-1]]:11: error: operand must be a symbol with modifier (e.g. %b21) or an integer in the range [-4194304, 4194300]
126
127 ## simm26_lsl2
128 b -0x8000001
129 # CHECK: :[[#@LINE-1]]:3: error: operand must be a bare symbol name or an immediate must be a multiple of 4 in the range [-134217728, 134217724]
130 b 0x1
131 # CHECK: :[[#@LINE-1]]:3: error: operand must be a bare symbol name or an immediate must be a multiple of 4 in the range [-134217728, 134217724]
132 bl 0x7FFFFFF
133 # CHECK: :[[#@LINE-1]]:4: error: operand must be a bare symbol name or an immediate must be a multiple of 4 in the range [-134217728, 134217724]
134 bl 0x8000000
135 # CHECK: :[[#@LINE-1]]:4: error: operand must be a bare symbol name or an immediate must be a multiple of 4 in the range [-134217728, 134217724]
136
137 ## Invalid mnemonics
138 nori $a0, $a0, 0
139 # CHECK: :[[#@LINE-1]]:1: error: unrecognized instruction mnemonic
140 andni $a0, $a0, 0
141 # CHECK: :[[#@LINE-1]]:1: error: unrecognized instruction mnemonic
142 orni $a0, $a0, 0
143 # CHECK: :[[#@LINE-1]]:1: error: unrecognized instruction mnemonic
144
145 ## Invalid register names
146 add.w $foo, $a0, $a0
147 # CHECK: :[[#@LINE-1]]:8: error: invalid operand for instruction
148 sub.w $a8, $a0, $a0
149 # CHECK: :[[#@LINE-1]]:8: error: invalid operand for instruction
150 addi.w $x0, $a0, 0
151 # CHECK: :[[#@LINE-1]]:9: error: invalid operand for instruction
152 alsl.w $t9, $a0, $a0, 1
153 # CHECK: :[[#@LINE-1]]:9: error: invalid operand for instruction
154 lu12i.w $s10, 0
155 # CHECK: :[[#@LINE-1]]:10: error: invalid operand for instruction
156
157 .ifndef LA64
158 ## LoongArch64 mnemonics
159 add.d $a0, $a0, $a0
160 # CHECK64: :[[#@LINE-1]]:1: error: instruction requires the following: LA64 Basic Integer and Privilege Instruction Set
161 addi.d $a0, $a0, 0
162 # CHECK64: :[[#@LINE-1]]:1: error: instruction requires the following: LA64 Basic Integer and Privilege Instruction Set
163 .endif
164
165 ## Invalid operand types
166 slt $a0, $a0, 0
167 # CHECK: :[[#@LINE-1]]:15: error: invalid operand for instruction
168 slti $a0, 0, 0
169 # CHECK: :[[#@LINE-1]]:11: error: invalid operand for instruction
170
171 ## Too many operands
172 andi $a0, $a0, 0, 0
173 # CHECK: :[[#@LINE-1]]:19: error: invalid operand for instruction
174
175 ## Too few operands
176 and $a0, $a0
177 # CHECK: :[[#@LINE-1]]:1: error: too few operands for instruction
178 andi $a0, $a0
179 # CHECK: :[[#@LINE-1]]:1: error: too few operands for instruction
180
181 ## Instructions outside the base integer ISA
182 ## TODO: Test instructions in LSX/LASX/LBT/LVZ after their introduction.
183
184 ## Using floating point registers when integer registers are expected
185 sll.w $a0, $a0, $fa0
186 # CHECK: :[[#@LINE-1]]:18: error: invalid operand for instruction
187
188 ## msbw < lsbw
189 # CHECK: :[[#@LINE+1]]:21: error: msb is less than lsb
190 bstrins.w $a0, $a0, 1, 2
191 # CHECK: ^~~~
192
193 # CHECK: :[[#@LINE+1]]:22: error: msb is less than lsb
194 bstrpick.w $a0, $a0, 30, 31
195 # CHECK: ^~~~~~