riscv64-asm.c: correct check for 12-bit immediate
[tinycc.git] / arm-tok.h
blob297b1055553ac01e82150f670f88fae7f3c74196
1 /* ------------------------------------------------------------------ */
2 /* WARNING: relative order of tokens is important. */
4 /* register */
6 DEF_ASM(r0)
7 DEF_ASM(r1)
8 DEF_ASM(r2)
9 DEF_ASM(r3)
10 DEF_ASM(r4)
11 DEF_ASM(r5)
12 DEF_ASM(r6)
13 DEF_ASM(r7)
14 DEF_ASM(r8)
15 DEF_ASM(r9)
16 DEF_ASM(r10)
17 DEF_ASM(r11) /* fp */
18 DEF_ASM(r12) /* ip[c] */
19 DEF_ASM(r13) /* sp */
20 DEF_ASM(r14) /* lr */
21 DEF_ASM(r15) /* pc */
23 /* register macros */
25 DEF_ASM(fp) /* alias for r11 */
26 DEF_ASM(ip) /* alias for r12 */
27 DEF_ASM(sp) /* alias for r13 */
28 DEF_ASM(lr) /* alias for r14 */
29 DEF_ASM(pc) /* alias for r15 */
31 /* coprocessors */
33 DEF_ASM(p0)
34 DEF_ASM(p1)
35 DEF_ASM(p2)
36 DEF_ASM(p3)
37 DEF_ASM(p4)
38 DEF_ASM(p5)
39 DEF_ASM(p6)
40 DEF_ASM(p7)
41 DEF_ASM(p8)
42 DEF_ASM(p9)
43 DEF_ASM(p10)
44 DEF_ASM(p11)
45 DEF_ASM(p12)
46 DEF_ASM(p13)
47 DEF_ASM(p14)
48 DEF_ASM(p15)
50 /* coprocessor registers */
52 DEF_ASM(c0)
53 DEF_ASM(c1)
54 DEF_ASM(c2)
55 DEF_ASM(c3)
56 DEF_ASM(c4)
57 DEF_ASM(c5)
58 DEF_ASM(c6)
59 DEF_ASM(c7)
60 DEF_ASM(c8)
61 DEF_ASM(c9)
62 DEF_ASM(c10)
63 DEF_ASM(c11)
64 DEF_ASM(c12)
65 DEF_ASM(c13)
66 DEF_ASM(c14)
67 DEF_ASM(c15)
69 /* single-precision VFP registers */
71 DEF_ASM(s0)
72 DEF_ASM(s1)
73 DEF_ASM(s2)
74 DEF_ASM(s3)
75 DEF_ASM(s4)
76 DEF_ASM(s5)
77 DEF_ASM(s6)
78 DEF_ASM(s7)
79 DEF_ASM(s8)
80 DEF_ASM(s9)
81 DEF_ASM(s10)
82 DEF_ASM(s11)
83 DEF_ASM(s12)
84 DEF_ASM(s13)
85 DEF_ASM(s14)
86 DEF_ASM(s15)
87 DEF_ASM(s16)
88 DEF_ASM(s17)
89 DEF_ASM(s18)
90 DEF_ASM(s19)
91 DEF_ASM(s20)
92 DEF_ASM(s21)
93 DEF_ASM(s22)
94 DEF_ASM(s23)
95 DEF_ASM(s24)
96 DEF_ASM(s25)
97 DEF_ASM(s26)
98 DEF_ASM(s27)
99 DEF_ASM(s28)
100 DEF_ASM(s29)
101 DEF_ASM(s30)
102 DEF_ASM(s31)
104 /* double-precision VFP registers */
106 DEF_ASM(d0)
107 DEF_ASM(d1)
108 DEF_ASM(d2)
109 DEF_ASM(d3)
110 DEF_ASM(d4)
111 DEF_ASM(d5)
112 DEF_ASM(d6)
113 DEF_ASM(d7)
114 DEF_ASM(d8)
115 DEF_ASM(d9)
116 DEF_ASM(d10)
117 DEF_ASM(d11)
118 DEF_ASM(d12)
119 DEF_ASM(d13)
120 DEF_ASM(d14)
121 DEF_ASM(d15)
123 /* VFP status registers */
125 DEF_ASM(fpsid)
126 DEF_ASM(fpscr)
127 DEF_ASM(fpexc)
129 /* VFP magical ARM register */
131 DEF_ASM(apsr_nzcv)
133 /* data processing directives */
135 DEF_ASM(asl)
137 /* instructions that have no condition code */
139 DEF_ASM(cdp2)
140 DEF_ASM(ldc2)
141 DEF_ASM(ldc2l)
142 DEF_ASM(stc2)
143 DEF_ASM(stc2l)
145 #define ARM_INSTRUCTION_GROUP(tok) ((((tok) - TOK_ASM_nopeq) & 0xFFFFFFF0) + TOK_ASM_nopeq)
147 /* Note: condition code is 4 bits */
148 #define DEF_ASM_CONDED(x) \
149 DEF(TOK_ASM_ ## x ## eq, #x "eq") \
150 DEF(TOK_ASM_ ## x ## ne, #x "ne") \
151 DEF(TOK_ASM_ ## x ## cs, #x "cs") \
152 DEF(TOK_ASM_ ## x ## cc, #x "cc") \
153 DEF(TOK_ASM_ ## x ## mi, #x "mi") \
154 DEF(TOK_ASM_ ## x ## pl, #x "pl") \
155 DEF(TOK_ASM_ ## x ## vs, #x "vs") \
156 DEF(TOK_ASM_ ## x ## vc, #x "vc") \
157 DEF(TOK_ASM_ ## x ## hi, #x "hi") \
158 DEF(TOK_ASM_ ## x ## ls, #x "ls") \
159 DEF(TOK_ASM_ ## x ## ge, #x "ge") \
160 DEF(TOK_ASM_ ## x ## lt, #x "lt") \
161 DEF(TOK_ASM_ ## x ## gt, #x "gt") \
162 DEF(TOK_ASM_ ## x ## le, #x "le") \
163 DEF(TOK_ASM_ ## x, #x) \
164 DEF(TOK_ASM_ ## x ## rsvd, #x "rsvd")
166 /* Note: condition code is 4 bits */
167 #define DEF_ASM_CONDED_WITH_SUFFIX(x, y) \
168 DEF(TOK_ASM_ ## x ## eq ## _ ## y, #x "eq." #y) \
169 DEF(TOK_ASM_ ## x ## ne ## _ ## y, #x "ne." #y) \
170 DEF(TOK_ASM_ ## x ## cs ## _ ## y, #x "cs." #y) \
171 DEF(TOK_ASM_ ## x ## cc ## _ ## y, #x "cc." #y) \
172 DEF(TOK_ASM_ ## x ## mi ## _ ## y, #x "mi." #y) \
173 DEF(TOK_ASM_ ## x ## pl ## _ ## y, #x "pl." #y) \
174 DEF(TOK_ASM_ ## x ## vs ## _ ## y, #x "vs." #y) \
175 DEF(TOK_ASM_ ## x ## vc ## _ ## y, #x "vc." #y) \
176 DEF(TOK_ASM_ ## x ## hi ## _ ## y, #x "hi." #y) \
177 DEF(TOK_ASM_ ## x ## ls ## _ ## y, #x "ls." #y) \
178 DEF(TOK_ASM_ ## x ## ge ## _ ## y, #x "ge." #y) \
179 DEF(TOK_ASM_ ## x ## lt ## _ ## y, #x "lt." #y) \
180 DEF(TOK_ASM_ ## x ## gt ## _ ## y, #x "gt." #y) \
181 DEF(TOK_ASM_ ## x ## le ## _ ## y, #x "le." #y) \
182 DEF(TOK_ASM_ ## x ## _ ## y, #x "." #y) \
183 DEF(TOK_ASM_ ## x ## rsvd ## _ ## y, #x "rsvd." #y)
185 #define DEF_ASM_CONDED_VFP_F32_F64(x) \
186 DEF_ASM_CONDED_WITH_SUFFIX(x, f32) \
187 DEF_ASM_CONDED_WITH_SUFFIX(x, f64)
189 #define DEF_ASM_CONDED_WITH_TWO_SUFFIXES(x, y, z) \
190 DEF(TOK_ASM_ ## x ## eq ## _ ## y ## _ ## z, #x "eq." #y "." #z) \
191 DEF(TOK_ASM_ ## x ## ne ## _ ## y ## _ ## z, #x "ne." #y "." #z) \
192 DEF(TOK_ASM_ ## x ## cs ## _ ## y ## _ ## z, #x "cs." #y "." #z) \
193 DEF(TOK_ASM_ ## x ## cc ## _ ## y ## _ ## z, #x "cc." #y "." #z) \
194 DEF(TOK_ASM_ ## x ## mi ## _ ## y ## _ ## z, #x "mi." #y "." #z) \
195 DEF(TOK_ASM_ ## x ## pl ## _ ## y ## _ ## z, #x "pl." #y "." #z) \
196 DEF(TOK_ASM_ ## x ## vs ## _ ## y ## _ ## z, #x "vs." #y "." #z) \
197 DEF(TOK_ASM_ ## x ## vc ## _ ## y ## _ ## z, #x "vc." #y "." #z) \
198 DEF(TOK_ASM_ ## x ## hi ## _ ## y ## _ ## z, #x "hi." #y "." #z) \
199 DEF(TOK_ASM_ ## x ## ls ## _ ## y ## _ ## z, #x "ls." #y "." #z) \
200 DEF(TOK_ASM_ ## x ## ge ## _ ## y ## _ ## z, #x "ge." #y "." #z) \
201 DEF(TOK_ASM_ ## x ## lt ## _ ## y ## _ ## z, #x "lt." #y "." #z) \
202 DEF(TOK_ASM_ ## x ## gt ## _ ## y ## _ ## z, #x "gt." #y "." #z) \
203 DEF(TOK_ASM_ ## x ## le ## _ ## y ## _ ## z, #x "le." #y "." #z) \
204 DEF(TOK_ASM_ ## x ## _ ## y ## _ ## z, #x "." #y "." #z) \
205 DEF(TOK_ASM_ ## x ## rsvd ## _ ## y ## _ ## z, #x "rsvd." #y "." #z)
207 /* Note: add new tokens after nop (MUST always use DEF_ASM_CONDED) */
209 DEF_ASM_CONDED(nop)
210 DEF_ASM_CONDED(wfe)
211 DEF_ASM_CONDED(wfi)
212 DEF_ASM_CONDED(swi)
213 DEF_ASM_CONDED(svc)
215 /* misc */
216 DEF_ASM_CONDED(clz)
218 /* size conversion */
220 DEF_ASM_CONDED(sxtb)
221 DEF_ASM_CONDED(sxth)
222 DEF_ASM_CONDED(uxtb)
223 DEF_ASM_CONDED(uxth)
224 DEF_ASM_CONDED(movt)
225 DEF_ASM_CONDED(movw)
227 /* multiplication */
229 DEF_ASM_CONDED(mul)
230 DEF_ASM_CONDED(muls)
231 DEF_ASM_CONDED(mla)
232 DEF_ASM_CONDED(mlas)
233 DEF_ASM_CONDED(smull)
234 DEF_ASM_CONDED(smulls)
235 DEF_ASM_CONDED(umull)
236 DEF_ASM_CONDED(umulls)
237 DEF_ASM_CONDED(smlal)
238 DEF_ASM_CONDED(smlals)
239 DEF_ASM_CONDED(umlal)
240 DEF_ASM_CONDED(umlals)
242 /* load/store */
244 DEF_ASM_CONDED(ldr)
245 DEF_ASM_CONDED(ldrb)
246 DEF_ASM_CONDED(str)
247 DEF_ASM_CONDED(strb)
248 DEF_ASM_CONDED(ldrex)
249 DEF_ASM_CONDED(ldrexb)
250 DEF_ASM_CONDED(strex)
251 DEF_ASM_CONDED(strexb)
252 DEF_ASM_CONDED(ldrh)
253 DEF_ASM_CONDED(ldrsh)
254 DEF_ASM_CONDED(ldrsb)
255 DEF_ASM_CONDED(strh)
257 DEF_ASM_CONDED(stmda)
258 DEF_ASM_CONDED(ldmda)
259 DEF_ASM_CONDED(stm)
260 DEF_ASM_CONDED(ldm)
261 DEF_ASM_CONDED(stmia)
262 DEF_ASM_CONDED(ldmia)
263 DEF_ASM_CONDED(stmdb)
264 DEF_ASM_CONDED(ldmdb)
265 DEF_ASM_CONDED(stmib)
266 DEF_ASM_CONDED(ldmib)
268 DEF_ASM_CONDED(ldc)
269 DEF_ASM_CONDED(ldcl)
270 DEF_ASM_CONDED(stc)
271 DEF_ASM_CONDED(stcl)
273 /* instruction macros */
275 DEF_ASM_CONDED(push)
276 DEF_ASM_CONDED(pop)
278 /* branches */
280 DEF_ASM_CONDED(b)
281 DEF_ASM_CONDED(bl)
282 DEF_ASM_CONDED(bx)
283 DEF_ASM_CONDED(blx)
285 /* data processing instructions; order is important */
287 DEF_ASM_CONDED(and)
288 DEF_ASM_CONDED(ands)
289 DEF_ASM_CONDED(eor)
290 DEF_ASM_CONDED(eors)
291 DEF_ASM_CONDED(sub)
292 DEF_ASM_CONDED(subs)
293 DEF_ASM_CONDED(rsb)
294 DEF_ASM_CONDED(rsbs)
295 DEF_ASM_CONDED(add)
296 DEF_ASM_CONDED(adds)
297 DEF_ASM_CONDED(adc)
298 DEF_ASM_CONDED(adcs)
299 DEF_ASM_CONDED(sbc)
300 DEF_ASM_CONDED(sbcs)
301 DEF_ASM_CONDED(rsc)
302 DEF_ASM_CONDED(rscs)
303 DEF_ASM_CONDED(tst)
304 DEF_ASM_CONDED(tsts) // necessary here--but not useful to the user
305 DEF_ASM_CONDED(teq)
306 DEF_ASM_CONDED(teqs) // necessary here--but not useful to the user
307 DEF_ASM_CONDED(cmp)
308 DEF_ASM_CONDED(cmps) // necessary here--but not useful to the user
309 DEF_ASM_CONDED(cmn)
310 DEF_ASM_CONDED(cmns) // necessary here--but not useful to the user
311 DEF_ASM_CONDED(orr)
312 DEF_ASM_CONDED(orrs)
313 DEF_ASM_CONDED(mov)
314 DEF_ASM_CONDED(movs)
315 DEF_ASM_CONDED(bic)
316 DEF_ASM_CONDED(bics)
317 DEF_ASM_CONDED(mvn)
318 DEF_ASM_CONDED(mvns)
320 DEF_ASM_CONDED(lsl)
321 DEF_ASM_CONDED(lsls)
322 DEF_ASM_CONDED(lsr)
323 DEF_ASM_CONDED(lsrs)
324 DEF_ASM_CONDED(asr)
325 DEF_ASM_CONDED(asrs)
326 DEF_ASM_CONDED(ror)
327 DEF_ASM_CONDED(rors)
328 DEF_ASM_CONDED(rrx)
329 DEF_ASM_CONDED(rrxs)
331 DEF_ASM_CONDED(cdp)
332 DEF_ASM_CONDED(mcr)
333 DEF_ASM_CONDED(mrc)
335 // Floating point high-level instructions
337 DEF_ASM_CONDED(vldr)
338 DEF_ASM_CONDED(vstr)
340 DEF_ASM_CONDED_VFP_F32_F64(vmla)
341 DEF_ASM_CONDED_VFP_F32_F64(vmls)
342 DEF_ASM_CONDED_VFP_F32_F64(vnmls)
343 DEF_ASM_CONDED_VFP_F32_F64(vnmla)
344 DEF_ASM_CONDED_VFP_F32_F64(vmul)
345 DEF_ASM_CONDED_VFP_F32_F64(vnmul)
346 DEF_ASM_CONDED_VFP_F32_F64(vadd)
347 DEF_ASM_CONDED_VFP_F32_F64(vsub)
348 DEF_ASM_CONDED_VFP_F32_F64(vdiv)
349 DEF_ASM_CONDED_VFP_F32_F64(vneg)
350 DEF_ASM_CONDED_VFP_F32_F64(vabs)
351 DEF_ASM_CONDED_VFP_F32_F64(vsqrt)
352 DEF_ASM_CONDED_VFP_F32_F64(vcmp)
353 DEF_ASM_CONDED_VFP_F32_F64(vcmpe)
354 DEF_ASM_CONDED_VFP_F32_F64(vmov)
356 DEF_ASM_CONDED_WITH_TWO_SUFFIXES(vcvtr, s32, f64)
357 DEF_ASM_CONDED_WITH_TWO_SUFFIXES(vcvtr, s32, f32)
358 DEF_ASM_CONDED_WITH_TWO_SUFFIXES(vcvtr, u32, f64)
359 DEF_ASM_CONDED_WITH_TWO_SUFFIXES(vcvtr, u32, f32)
361 DEF_ASM_CONDED_WITH_TWO_SUFFIXES(vcvt, s32, f64)
362 DEF_ASM_CONDED_WITH_TWO_SUFFIXES(vcvt, s32, f32)
363 DEF_ASM_CONDED_WITH_TWO_SUFFIXES(vcvt, u32, f64)
364 DEF_ASM_CONDED_WITH_TWO_SUFFIXES(vcvt, u32, f32)
366 DEF_ASM_CONDED_WITH_TWO_SUFFIXES(vcvt, f64, s32)
367 DEF_ASM_CONDED_WITH_TWO_SUFFIXES(vcvt, f32, s32)
368 DEF_ASM_CONDED_WITH_TWO_SUFFIXES(vcvt, f64, u32)
369 DEF_ASM_CONDED_WITH_TWO_SUFFIXES(vcvt, f32, u32)
371 DEF_ASM_CONDED_WITH_TWO_SUFFIXES(vcvt, f64, f32)
372 DEF_ASM_CONDED_WITH_TWO_SUFFIXES(vcvt, f32, f64)
374 DEF_ASM_CONDED(vpush)
375 DEF_ASM_CONDED(vpop)
376 DEF_ASM_CONDED(vldm)
377 DEF_ASM_CONDED(vldmia)
378 DEF_ASM_CONDED(vldmdb)
379 DEF_ASM_CONDED(vstm)
380 DEF_ASM_CONDED(vstmia)
381 DEF_ASM_CONDED(vstmdb)
382 DEF_ASM_CONDED(vmsr)
383 DEF_ASM_CONDED(vmrs)