both .globl and .global directives are accepted by as
[tinycc.git] / tcctok.h
blob4f90fc9ec4646b5f0208afd914eb92788c7eec76
1 /* keywords */
2 DEF(TOK_INT, "int")
3 DEF(TOK_VOID, "void")
4 DEF(TOK_CHAR, "char")
5 DEF(TOK_IF, "if")
6 DEF(TOK_ELSE, "else")
7 DEF(TOK_WHILE, "while")
8 DEF(TOK_BREAK, "break")
9 DEF(TOK_RETURN, "return")
10 DEF(TOK_FOR, "for")
11 DEF(TOK_EXTERN, "extern")
12 DEF(TOK_STATIC, "static")
13 DEF(TOK_UNSIGNED, "unsigned")
14 DEF(TOK_GOTO, "goto")
15 DEF(TOK_DO, "do")
16 DEF(TOK_CONTINUE, "continue")
17 DEF(TOK_SWITCH, "switch")
18 DEF(TOK_CASE, "case")
20 DEF(TOK_CONST1, "const")
21 DEF(TOK_CONST2, "__const") /* gcc keyword */
22 DEF(TOK_CONST3, "__const__") /* gcc keyword */
23 DEF(TOK_VOLATILE1, "volatile")
24 DEF(TOK_VOLATILE2, "__volatile") /* gcc keyword */
25 DEF(TOK_VOLATILE3, "__volatile__") /* gcc keyword */
26 DEF(TOK_LONG, "long")
27 DEF(TOK_REGISTER, "register")
28 DEF(TOK_SIGNED1, "signed")
29 DEF(TOK_SIGNED2, "__signed") /* gcc keyword */
30 DEF(TOK_SIGNED3, "__signed__") /* gcc keyword */
31 DEF(TOK_AUTO, "auto")
32 DEF(TOK_INLINE1, "inline")
33 DEF(TOK_INLINE2, "__inline") /* gcc keyword */
34 DEF(TOK_INLINE3, "__inline__") /* gcc keyword */
35 DEF(TOK_RESTRICT1, "restrict")
36 DEF(TOK_RESTRICT2, "__restrict")
37 DEF(TOK_RESTRICT3, "__restrict__")
38 DEF(TOK_EXTENSION, "__extension__") /* gcc keyword */
40 DEF(TOK_FLOAT, "float")
41 DEF(TOK_DOUBLE, "double")
42 DEF(TOK_BOOL, "_Bool")
43 DEF(TOK_SHORT, "short")
44 DEF(TOK_STRUCT, "struct")
45 DEF(TOK_UNION, "union")
46 DEF(TOK_TYPEDEF, "typedef")
47 DEF(TOK_DEFAULT, "default")
48 DEF(TOK_ENUM, "enum")
49 DEF(TOK_SIZEOF, "sizeof")
50 DEF(TOK_ATTRIBUTE1, "__attribute")
51 DEF(TOK_ATTRIBUTE2, "__attribute__")
52 DEF(TOK_ALIGNOF1, "__alignof")
53 DEF(TOK_ALIGNOF2, "__alignof__")
54 DEF(TOK_TYPEOF1, "typeof")
55 DEF(TOK_TYPEOF2, "__typeof")
56 DEF(TOK_TYPEOF3, "__typeof__")
57 DEF(TOK_LABEL, "__label__")
58 DEF(TOK_ASM1, "asm")
59 DEF(TOK_ASM2, "__asm")
60 DEF(TOK_ASM3, "__asm__")
62 /*********************************************************************/
63 /* the following are not keywords. They are included to ease parsing */
64 /* preprocessor only */
65 DEF(TOK_DEFINE, "define")
66 DEF(TOK_INCLUDE, "include")
67 DEF(TOK_IFDEF, "ifdef")
68 DEF(TOK_IFNDEF, "ifndef")
69 DEF(TOK_ELIF, "elif")
70 DEF(TOK_ENDIF, "endif")
71 DEF(TOK_DEFINED, "defined")
72 DEF(TOK_UNDEF, "undef")
73 DEF(TOK_ERROR, "error")
74 DEF(TOK_WARNING, "warning")
75 DEF(TOK_LINE, "line")
76 DEF(TOK_PRAGMA, "pragma")
77 DEF(TOK___LINE__, "__LINE__")
78 DEF(TOK___FILE__, "__FILE__")
79 DEF(TOK___DATE__, "__DATE__")
80 DEF(TOK___TIME__, "__TIME__")
81 DEF(TOK___FUNCTION__, "__FUNCTION__")
82 DEF(TOK___VA_ARGS__, "__VA_ARGS__")
84 /* special identifiers */
85 DEF(TOK___FUNC__, "__func__")
87 /* attribute identifiers */
88 /* XXX: handle all tokens generically since speed is not critical */
89 DEF(TOK_SECTION1, "section")
90 DEF(TOK_SECTION2, "__section__")
91 DEF(TOK_ALIGNED1, "aligned")
92 DEF(TOK_ALIGNED2, "__aligned__")
93 DEF(TOK_UNUSED1, "unused")
94 DEF(TOK_UNUSED2, "__unused__")
95 DEF(TOK_CDECL1, "cdecl")
96 DEF(TOK_CDECL2, "__cdecl")
97 DEF(TOK_CDECL3, "__cdecl__")
98 DEF(TOK_STDCALL1, "stdcall")
99 DEF(TOK_STDCALL2, "__stdcall")
100 DEF(TOK_STDCALL3, "__stdcall__")
101 DEF(TOK_NORETURN1, "noreturn")
102 DEF(TOK_NORETURN2, "__noreturn__")
103 DEF(TOK_builtin_types_compatible_p, "__builtin_types_compatible_p")
104 DEF(TOK_builtin_constant_p, "__builtin_constant_p")
106 /* builtin functions or variables */
107 DEF(TOK_memcpy, "memcpy")
108 DEF(TOK_memset, "memset")
109 DEF(TOK_alloca, "alloca")
110 DEF(TOK___divdi3, "__divdi3")
111 DEF(TOK___moddi3, "__moddi3")
112 DEF(TOK___udivdi3, "__udivdi3")
113 DEF(TOK___umoddi3, "__umoddi3")
114 #ifdef TCC_TARGET_ARM
115 DEF(TOK___divsi3, "__divsi3")
116 DEF(TOK___modsi3, "__modsi3")
117 DEF(TOK___udivsi3, "__udivsi3")
118 DEF(TOK___umodsi3, "__umodsi3")
119 DEF(TOK___sardi3, "__ashrdi3")
120 DEF(TOK___shrdi3, "__lshrdi3")
121 DEF(TOK___shldi3, "__ashldi3")
122 #else
123 /* XXX: same names on i386 ? */
124 DEF(TOK___sardi3, "__sardi3")
125 DEF(TOK___shrdi3, "__shrdi3")
126 DEF(TOK___shldi3, "__shldi3")
127 #endif
128 DEF(TOK___tcc_int_fpu_control, "__tcc_int_fpu_control")
129 DEF(TOK___tcc_fpu_control, "__tcc_fpu_control")
130 DEF(TOK___ulltof, "__ulltof")
131 DEF(TOK___ulltod, "__ulltod")
132 DEF(TOK___ulltold, "__ulltold")
133 DEF(TOK___fixunssfdi, "__fixunssfdi")
134 DEF(TOK___fixunsdfdi, "__fixunsdfdi")
135 DEF(TOK___fixunsxfdi, "__fixunsxfdi")
137 /* bound checking symbols */
138 #ifdef CONFIG_TCC_BCHECK
139 DEF(TOK___bound_ptr_add, "__bound_ptr_add")
140 DEF(TOK___bound_ptr_indir1, "__bound_ptr_indir1")
141 DEF(TOK___bound_ptr_indir2, "__bound_ptr_indir2")
142 DEF(TOK___bound_ptr_indir4, "__bound_ptr_indir4")
143 DEF(TOK___bound_ptr_indir8, "__bound_ptr_indir8")
144 DEF(TOK___bound_ptr_indir12, "__bound_ptr_indir12")
145 DEF(TOK___bound_ptr_indir16, "__bound_ptr_indir16")
146 DEF(TOK___bound_local_new, "__bound_local_new")
147 DEF(TOK___bound_local_delete, "__bound_local_delete")
148 DEF(TOK_malloc, "malloc")
149 DEF(TOK_free, "free")
150 DEF(TOK_realloc, "realloc")
151 DEF(TOK_memalign, "memalign")
152 DEF(TOK_calloc, "calloc")
153 DEF(TOK_memmove, "memmove")
154 DEF(TOK_strlen, "strlen")
155 DEF(TOK_strcpy, "strcpy")
156 #endif
158 /* Tiny Assembler */
160 DEF_ASM(byte)
161 DEF_ASM(align)
162 DEF_ASM(skip)
163 DEF_ASM(space)
164 DEF_ASM(string)
165 DEF_ASM(globl)
166 DEF_ASM(global)
167 DEF_ASM(text)
168 DEF_ASM(data)
169 DEF_ASM(bss)
171 #ifdef TCC_TARGET_I386
173 /* WARNING: relative order of tokens is important. */
174 DEF_ASM(al)
175 DEF_ASM(cl)
176 DEF_ASM(dl)
177 DEF_ASM(bl)
178 DEF_ASM(ah)
179 DEF_ASM(ch)
180 DEF_ASM(dh)
181 DEF_ASM(bh)
182 DEF_ASM(ax)
183 DEF_ASM(cx)
184 DEF_ASM(dx)
185 DEF_ASM(bx)
186 DEF_ASM(sp)
187 DEF_ASM(bp)
188 DEF_ASM(si)
189 DEF_ASM(di)
190 DEF_ASM(eax)
191 DEF_ASM(ecx)
192 DEF_ASM(edx)
193 DEF_ASM(ebx)
194 DEF_ASM(esp)
195 DEF_ASM(ebp)
196 DEF_ASM(esi)
197 DEF_ASM(edi)
198 DEF_ASM(mm0)
199 DEF_ASM(mm1)
200 DEF_ASM(mm2)
201 DEF_ASM(mm3)
202 DEF_ASM(mm4)
203 DEF_ASM(mm5)
204 DEF_ASM(mm6)
205 DEF_ASM(mm7)
206 DEF_ASM(xmm0)
207 DEF_ASM(xmm1)
208 DEF_ASM(xmm2)
209 DEF_ASM(xmm3)
210 DEF_ASM(xmm4)
211 DEF_ASM(xmm5)
212 DEF_ASM(xmm6)
213 DEF_ASM(xmm7)
214 DEF_ASM(cr0)
215 DEF_ASM(cr1)
216 DEF_ASM(cr2)
217 DEF_ASM(cr3)
218 DEF_ASM(cr4)
219 DEF_ASM(cr5)
220 DEF_ASM(cr6)
221 DEF_ASM(cr7)
222 DEF_ASM(tr0)
223 DEF_ASM(tr1)
224 DEF_ASM(tr2)
225 DEF_ASM(tr3)
226 DEF_ASM(tr4)
227 DEF_ASM(tr5)
228 DEF_ASM(tr6)
229 DEF_ASM(tr7)
230 DEF_ASM(db0)
231 DEF_ASM(db1)
232 DEF_ASM(db2)
233 DEF_ASM(db3)
234 DEF_ASM(db4)
235 DEF_ASM(db5)
236 DEF_ASM(db6)
237 DEF_ASM(db7)
238 DEF_ASM(dr0)
239 DEF_ASM(dr1)
240 DEF_ASM(dr2)
241 DEF_ASM(dr3)
242 DEF_ASM(dr4)
243 DEF_ASM(dr5)
244 DEF_ASM(dr6)
245 DEF_ASM(dr7)
246 DEF_ASM(es)
247 DEF_ASM(cs)
248 DEF_ASM(ss)
249 DEF_ASM(ds)
250 DEF_ASM(fs)
251 DEF_ASM(gs)
252 DEF_ASM(st)
254 DEF_BWL(mov)
256 /* generic two operands */
257 DEF_BWL(add)
258 DEF_BWL(or)
259 DEF_BWL(adc)
260 DEF_BWL(sbb)
261 DEF_BWL(and)
262 DEF_BWL(sub)
263 DEF_BWL(xor)
264 DEF_BWL(cmp)
266 /* unary ops */
267 DEF_BWL(inc)
268 DEF_BWL(dec)
269 DEF_BWL(not)
270 DEF_BWL(neg)
271 DEF_BWL(mul)
272 DEF_BWL(imul)
273 DEF_BWL(div)
274 DEF_BWL(idiv)
276 DEF_BWL(xchg)
277 DEF_BWL(test)
279 /* shifts */
280 DEF_BWL(rol)
281 DEF_BWL(ror)
282 DEF_BWL(rcl)
283 DEF_BWL(rcr)
284 DEF_BWL(shl)
285 DEF_BWL(shr)
286 DEF_BWL(sar)
288 DEF_ASM(shldw)
289 DEF_ASM(shldl)
290 DEF_ASM(shld)
291 DEF_ASM(shrdw)
292 DEF_ASM(shrdl)
293 DEF_ASM(shrd)
295 DEF_ASM(pushw)
296 DEF_ASM(pushl)
297 DEF_ASM(push)
298 DEF_ASM(popw)
299 DEF_ASM(popl)
300 DEF_ASM(pop)
301 DEF_BWL(in)
302 DEF_BWL(out)
304 DEF_WL(movzb)
306 DEF_ASM(movzwl)
307 DEF_ASM(movsbw)
308 DEF_ASM(movsbl)
309 DEF_ASM(movswl)
311 DEF_WL(lea)
313 DEF_ASM(les)
314 DEF_ASM(lds)
315 DEF_ASM(lss)
316 DEF_ASM(lfs)
317 DEF_ASM(lgs)
319 DEF_ASM(call)
320 DEF_ASM(jmp)
321 DEF_ASM(lcall)
322 DEF_ASM(ljmp)
324 DEF_ASMTEST(j)
326 DEF_ASMTEST(set)
327 DEF_ASMTEST(cmov)
329 DEF_WL(bsf)
330 DEF_WL(bsr)
331 DEF_WL(bt)
332 DEF_WL(bts)
333 DEF_WL(btr)
334 DEF_WL(btc)
336 DEF_WL(lsl)
338 /* generic FP ops */
339 DEF_FP(add)
340 DEF_FP(mul)
342 DEF_ASM(fcom)
343 DEF_ASM(fcom_1) /* non existant op, just to have a regular table */
344 DEF_FP1(com)
346 DEF_FP(comp)
347 DEF_FP(sub)
348 DEF_FP(subr)
349 DEF_FP(div)
350 DEF_FP(divr)
352 DEF_BWL(xadd)
353 DEF_BWL(cmpxchg)
355 /* string ops */
356 DEF_BWL(cmps)
357 DEF_BWL(scmp)
358 DEF_BWL(ins)
359 DEF_BWL(outs)
360 DEF_BWL(lods)
361 DEF_BWL(slod)
362 DEF_BWL(movs)
363 DEF_BWL(smov)
364 DEF_BWL(scas)
365 DEF_BWL(ssca)
366 DEF_BWL(stos)
367 DEF_BWL(ssto)
369 /* generic asm ops */
371 #define ALT(x)
372 #define DEF_ASM_OP0(name, opcode) DEF_ASM(name)
373 #define DEF_ASM_OP0L(name, opcode, group, instr_type)
374 #define DEF_ASM_OP1(name, opcode, group, instr_type, op0)
375 #define DEF_ASM_OP2(name, opcode, group, instr_type, op0, op1)
376 #define DEF_ASM_OP3(name, opcode, group, instr_type, op0, op1, op2)
377 #include "i386-asm.h"
379 #define ALT(x)
380 #define DEF_ASM_OP0(name, opcode)
381 #define DEF_ASM_OP0L(name, opcode, group, instr_type) DEF_ASM(name)
382 #define DEF_ASM_OP1(name, opcode, group, instr_type, op0) DEF_ASM(name)
383 #define DEF_ASM_OP2(name, opcode, group, instr_type, op0, op1) DEF_ASM(name)
384 #define DEF_ASM_OP3(name, opcode, group, instr_type, op0, op1, op2) DEF_ASM(name)
385 #include "i386-asm.h"
387 #endif