Update to run on apple 13.0 (Ventura)
[tinycc.git] / tcctok.h
blob563984a3870b67f34cf7352df5bbe83e58d008bd
1 /*********************************************************************/
2 /* keywords */
3 DEF(TOK_INT, "int")
4 DEF(TOK_VOID, "void")
5 DEF(TOK_CHAR, "char")
6 DEF(TOK_IF, "if")
7 DEF(TOK_ELSE, "else")
8 DEF(TOK_WHILE, "while")
9 DEF(TOK_BREAK, "break")
10 DEF(TOK_RETURN, "return")
11 DEF(TOK_FOR, "for")
12 DEF(TOK_EXTERN, "extern")
13 DEF(TOK_STATIC, "static")
14 DEF(TOK_UNSIGNED, "unsigned")
15 DEF(TOK_GOTO, "goto")
16 DEF(TOK_DO, "do")
17 DEF(TOK_CONTINUE, "continue")
18 DEF(TOK_SWITCH, "switch")
19 DEF(TOK_CASE, "case")
21 DEF(TOK__Atomic, "_Atomic")
22 DEF(TOK_CONST1, "const")
23 DEF(TOK_CONST2, "__const") /* gcc keyword */
24 DEF(TOK_CONST3, "__const__") /* gcc keyword */
25 DEF(TOK_VOLATILE1, "volatile")
26 DEF(TOK_VOLATILE2, "__volatile") /* gcc keyword */
27 DEF(TOK_VOLATILE3, "__volatile__") /* gcc keyword */
28 DEF(TOK_LONG, "long")
29 DEF(TOK_REGISTER, "register")
30 DEF(TOK_SIGNED1, "signed")
31 DEF(TOK_SIGNED2, "__signed") /* gcc keyword */
32 DEF(TOK_SIGNED3, "__signed__") /* gcc keyword */
33 DEF(TOK_AUTO, "auto")
34 DEF(TOK_INLINE1, "inline")
35 DEF(TOK_INLINE2, "__inline") /* gcc keyword */
36 DEF(TOK_INLINE3, "__inline__") /* gcc keyword */
37 DEF(TOK_RESTRICT1, "restrict")
38 DEF(TOK_RESTRICT2, "__restrict")
39 DEF(TOK_RESTRICT3, "__restrict__")
40 DEF(TOK_EXTENSION, "__extension__") /* gcc keyword */
42 DEF(TOK_GENERIC, "_Generic")
43 DEF(TOK_STATIC_ASSERT, "_Static_assert")
45 DEF(TOK_FLOAT, "float")
46 DEF(TOK_DOUBLE, "double")
47 DEF(TOK_BOOL, "_Bool")
48 DEF(TOK_COMPLEX, "_Complex")
49 DEF(TOK_SHORT, "short")
50 DEF(TOK_STRUCT, "struct")
51 DEF(TOK_UNION, "union")
52 DEF(TOK_TYPEDEF, "typedef")
53 DEF(TOK_DEFAULT, "default")
54 DEF(TOK_ENUM, "enum")
55 DEF(TOK_SIZEOF, "sizeof")
56 DEF(TOK_ATTRIBUTE1, "__attribute")
57 DEF(TOK_ATTRIBUTE2, "__attribute__")
58 DEF(TOK_ALIGNOF1, "__alignof")
59 DEF(TOK_ALIGNOF2, "__alignof__")
60 DEF(TOK_ALIGNOF3, "_Alignof")
61 DEF(TOK_ALIGNAS, "_Alignas")
62 DEF(TOK_TYPEOF1, "typeof")
63 DEF(TOK_TYPEOF2, "__typeof")
64 DEF(TOK_TYPEOF3, "__typeof__")
65 DEF(TOK_LABEL, "__label__")
66 DEF(TOK_ASM1, "asm")
67 DEF(TOK_ASM2, "__asm")
68 DEF(TOK_ASM3, "__asm__")
70 #ifdef TCC_TARGET_ARM64
71 DEF(TOK_UINT128, "__uint128_t")
72 #endif
74 /*********************************************************************/
75 /* the following are not keywords. They are included to ease parsing */
76 /* preprocessor only */
77 DEF(TOK_DEFINE, "define")
78 DEF(TOK_INCLUDE, "include")
79 DEF(TOK_INCLUDE_NEXT, "include_next")
80 DEF(TOK_IFDEF, "ifdef")
81 DEF(TOK_IFNDEF, "ifndef")
82 DEF(TOK_ELIF, "elif")
83 DEF(TOK_ENDIF, "endif")
84 DEF(TOK_DEFINED, "defined")
85 DEF(TOK_UNDEF, "undef")
86 DEF(TOK_ERROR, "error")
87 DEF(TOK_WARNING, "warning")
88 DEF(TOK_LINE, "line")
89 DEF(TOK_PRAGMA, "pragma")
90 DEF(TOK___LINE__, "__LINE__")
91 DEF(TOK___FILE__, "__FILE__")
92 DEF(TOK___DATE__, "__DATE__")
93 DEF(TOK___TIME__, "__TIME__")
94 DEF(TOK___FUNCTION__, "__FUNCTION__")
95 DEF(TOK___VA_ARGS__, "__VA_ARGS__")
96 DEF(TOK___COUNTER__, "__COUNTER__")
97 DEF(TOK___HAS_INCLUDE, "__has_include")
98 DEF(TOK___HAS_INCLUDE_NEXT, "__has_include_next")
100 /* special identifiers */
101 DEF(TOK___FUNC__, "__func__")
103 /* special floating point values */
104 DEF(TOK___NAN__, "__nan__")
105 DEF(TOK___SNAN__, "__snan__")
106 DEF(TOK___INF__, "__inf__")
107 #if defined TCC_TARGET_X86_64
108 DEF(TOK___mzerosf, "__mzerosf") /* -0.0 */
109 DEF(TOK___mzerodf, "__mzerodf") /* -0.0 */
110 #endif
112 /* attribute identifiers */
113 /* XXX: handle all tokens generically since speed is not critical */
114 DEF(TOK_SECTION1, "section")
115 DEF(TOK_SECTION2, "__section__")
116 DEF(TOK_ALIGNED1, "aligned")
117 DEF(TOK_ALIGNED2, "__aligned__")
118 DEF(TOK_PACKED1, "packed")
119 DEF(TOK_PACKED2, "__packed__")
120 DEF(TOK_WEAK1, "weak")
121 DEF(TOK_WEAK2, "__weak__")
122 DEF(TOK_ALIAS1, "alias")
123 DEF(TOK_ALIAS2, "__alias__")
124 DEF(TOK_UNUSED1, "unused")
125 DEF(TOK_UNUSED2, "__unused__")
126 DEF(TOK_CDECL1, "cdecl")
127 DEF(TOK_CDECL2, "__cdecl")
128 DEF(TOK_CDECL3, "__cdecl__")
129 DEF(TOK_STDCALL1, "stdcall")
130 DEF(TOK_STDCALL2, "__stdcall")
131 DEF(TOK_STDCALL3, "__stdcall__")
132 DEF(TOK_FASTCALL1, "fastcall")
133 DEF(TOK_FASTCALL2, "__fastcall")
134 DEF(TOK_FASTCALL3, "__fastcall__")
135 DEF(TOK_REGPARM1, "regparm")
136 DEF(TOK_REGPARM2, "__regparm__")
137 DEF(TOK_CLEANUP1, "cleanup")
138 DEF(TOK_CLEANUP2, "__cleanup__")
139 DEF(TOK_CONSTRUCTOR1, "constructor")
140 DEF(TOK_CONSTRUCTOR2, "__constructor__")
141 DEF(TOK_DESTRUCTOR1, "destructor")
142 DEF(TOK_DESTRUCTOR2, "__destructor__")
143 DEF(TOK_ALWAYS_INLINE1, "always_inline")
144 DEF(TOK_ALWAYS_INLINE2, "__always_inline__")
146 DEF(TOK_MODE, "__mode__")
147 DEF(TOK_MODE_QI, "__QI__")
148 DEF(TOK_MODE_DI, "__DI__")
149 DEF(TOK_MODE_HI, "__HI__")
150 DEF(TOK_MODE_SI, "__SI__")
151 DEF(TOK_MODE_word, "__word__")
153 DEF(TOK_DLLEXPORT, "dllexport")
154 DEF(TOK_DLLIMPORT, "dllimport")
155 DEF(TOK_NODECORATE, "nodecorate")
156 DEF(TOK_NORETURN1, "noreturn")
157 DEF(TOK_NORETURN2, "__noreturn__")
158 DEF(TOK_NORETURN3, "_Noreturn")
159 DEF(TOK_VISIBILITY1, "visibility")
160 DEF(TOK_VISIBILITY2, "__visibility__")
162 DEF(TOK_builtin_types_compatible_p, "__builtin_types_compatible_p")
163 DEF(TOK_builtin_choose_expr, "__builtin_choose_expr")
164 DEF(TOK_builtin_constant_p, "__builtin_constant_p")
165 DEF(TOK_builtin_frame_address, "__builtin_frame_address")
166 DEF(TOK_builtin_return_address, "__builtin_return_address")
167 DEF(TOK_builtin_expect, "__builtin_expect")
168 /*DEF(TOK_builtin_va_list, "__builtin_va_list")*/
169 #if defined TCC_TARGET_PE && defined TCC_TARGET_X86_64
170 DEF(TOK_builtin_va_start, "__builtin_va_start")
171 #elif defined TCC_TARGET_X86_64
172 DEF(TOK_builtin_va_arg_types, "__builtin_va_arg_types")
173 #elif defined TCC_TARGET_ARM64
174 DEF(TOK_builtin_va_start, "__builtin_va_start")
175 DEF(TOK_builtin_va_arg, "__builtin_va_arg")
176 #elif defined TCC_TARGET_RISCV64
177 DEF(TOK_builtin_va_start, "__builtin_va_start")
178 #endif
180 /* atomic operations */
181 #define DEF_ATOMIC(ID) DEF(TOK_##__##ID, "__"#ID)
182 DEF_ATOMIC(atomic_store)
183 DEF_ATOMIC(atomic_load)
184 DEF_ATOMIC(atomic_exchange)
185 DEF_ATOMIC(atomic_compare_exchange)
186 DEF_ATOMIC(atomic_fetch_add)
187 DEF_ATOMIC(atomic_fetch_sub)
188 DEF_ATOMIC(atomic_fetch_or)
189 DEF_ATOMIC(atomic_fetch_xor)
190 DEF_ATOMIC(atomic_fetch_and)
191 DEF_ATOMIC(atomic_fetch_nand)
192 DEF_ATOMIC(atomic_add_fetch)
193 DEF_ATOMIC(atomic_sub_fetch)
194 DEF_ATOMIC(atomic_or_fetch)
195 DEF_ATOMIC(atomic_xor_fetch)
196 DEF_ATOMIC(atomic_and_fetch)
197 DEF_ATOMIC(atomic_nand_fetch)
199 /* pragma */
200 DEF(TOK_pack, "pack")
201 #if !defined(TCC_TARGET_I386) && !defined(TCC_TARGET_X86_64) && \
202 !defined(TCC_TARGET_ARM) && !defined(TCC_TARGET_ARM64)
203 /* already defined for assembler */
204 DEF(TOK_ASM_push, "push")
205 DEF(TOK_ASM_pop, "pop")
206 #endif
207 DEF(TOK_comment, "comment")
208 DEF(TOK_lib, "lib")
209 DEF(TOK_push_macro, "push_macro")
210 DEF(TOK_pop_macro, "pop_macro")
211 DEF(TOK_once, "once")
212 DEF(TOK_option, "option")
214 /* builtin functions or variables */
215 #ifndef TCC_ARM_EABI
216 DEF(TOK_memcpy, "memcpy")
217 DEF(TOK_memmove, "memmove")
218 DEF(TOK_memset, "memset")
219 DEF(TOK___divdi3, "__divdi3")
220 DEF(TOK___moddi3, "__moddi3")
221 DEF(TOK___udivdi3, "__udivdi3")
222 DEF(TOK___umoddi3, "__umoddi3")
223 DEF(TOK___ashrdi3, "__ashrdi3")
224 DEF(TOK___lshrdi3, "__lshrdi3")
225 DEF(TOK___ashldi3, "__ashldi3")
226 DEF(TOK___floatundisf, "__floatundisf")
227 DEF(TOK___floatundidf, "__floatundidf")
228 # ifndef TCC_ARM_VFP
229 DEF(TOK___floatundixf, "__floatundixf")
230 DEF(TOK___fixunsxfdi, "__fixunsxfdi")
231 # endif
232 DEF(TOK___fixunssfdi, "__fixunssfdi")
233 DEF(TOK___fixunsdfdi, "__fixunsdfdi")
234 #endif
236 #if defined TCC_TARGET_ARM
237 # ifdef TCC_ARM_EABI
238 DEF(TOK_memcpy, "__aeabi_memcpy")
239 DEF(TOK_memmove, "__aeabi_memmove")
240 DEF(TOK_memmove4, "__aeabi_memmove4")
241 DEF(TOK_memmove8, "__aeabi_memmove8")
242 DEF(TOK_memset, "__aeabi_memset")
243 DEF(TOK___aeabi_ldivmod, "__aeabi_ldivmod")
244 DEF(TOK___aeabi_uldivmod, "__aeabi_uldivmod")
245 DEF(TOK___aeabi_idivmod, "__aeabi_idivmod")
246 DEF(TOK___aeabi_uidivmod, "__aeabi_uidivmod")
247 DEF(TOK___divsi3, "__aeabi_idiv")
248 DEF(TOK___udivsi3, "__aeabi_uidiv")
249 DEF(TOK___floatdisf, "__aeabi_l2f")
250 DEF(TOK___floatdidf, "__aeabi_l2d")
251 DEF(TOK___fixsfdi, "__aeabi_f2lz")
252 DEF(TOK___fixdfdi, "__aeabi_d2lz")
253 DEF(TOK___ashrdi3, "__aeabi_lasr")
254 DEF(TOK___lshrdi3, "__aeabi_llsr")
255 DEF(TOK___ashldi3, "__aeabi_llsl")
256 DEF(TOK___floatundisf, "__aeabi_ul2f")
257 DEF(TOK___floatundidf, "__aeabi_ul2d")
258 DEF(TOK___fixunssfdi, "__aeabi_f2ulz")
259 DEF(TOK___fixunsdfdi, "__aeabi_d2ulz")
260 # else
261 DEF(TOK___modsi3, "__modsi3")
262 DEF(TOK___umodsi3, "__umodsi3")
263 DEF(TOK___divsi3, "__divsi3")
264 DEF(TOK___udivsi3, "__udivsi3")
265 DEF(TOK___floatdisf, "__floatdisf")
266 DEF(TOK___floatdidf, "__floatdidf")
267 # ifndef TCC_ARM_VFP
268 DEF(TOK___floatdixf, "__floatdixf")
269 DEF(TOK___fixunssfsi, "__fixunssfsi")
270 DEF(TOK___fixunsdfsi, "__fixunsdfsi")
271 DEF(TOK___fixunsxfsi, "__fixunsxfsi")
272 DEF(TOK___fixxfdi, "__fixxfdi")
273 # endif
274 DEF(TOK___fixsfdi, "__fixsfdi")
275 DEF(TOK___fixdfdi, "__fixdfdi")
276 # endif
277 #endif
279 #if defined TCC_TARGET_C67
280 DEF(TOK__divi, "_divi")
281 DEF(TOK__divu, "_divu")
282 DEF(TOK__divf, "_divf")
283 DEF(TOK__divd, "_divd")
284 DEF(TOK__remi, "_remi")
285 DEF(TOK__remu, "_remu")
286 #endif
288 #if defined TCC_TARGET_I386
289 DEF(TOK___fixsfdi, "__fixsfdi")
290 DEF(TOK___fixdfdi, "__fixdfdi")
291 DEF(TOK___fixxfdi, "__fixxfdi")
292 #endif
294 #if defined TCC_TARGET_I386 || defined TCC_TARGET_X86_64
295 DEF(TOK_alloca, "alloca")
296 #endif
298 #if defined TCC_TARGET_PE
299 DEF(TOK___chkstk, "__chkstk")
300 #endif
301 #if defined TCC_TARGET_ARM64 || defined TCC_TARGET_RISCV64
302 DEF(TOK___arm64_clear_cache, "__arm64_clear_cache")
303 DEF(TOK___addtf3, "__addtf3")
304 DEF(TOK___subtf3, "__subtf3")
305 DEF(TOK___multf3, "__multf3")
306 DEF(TOK___divtf3, "__divtf3")
307 DEF(TOK___extendsftf2, "__extendsftf2")
308 DEF(TOK___extenddftf2, "__extenddftf2")
309 DEF(TOK___trunctfsf2, "__trunctfsf2")
310 DEF(TOK___trunctfdf2, "__trunctfdf2")
311 DEF(TOK___fixtfsi, "__fixtfsi")
312 DEF(TOK___fixtfdi, "__fixtfdi")
313 DEF(TOK___fixunstfsi, "__fixunstfsi")
314 DEF(TOK___fixunstfdi, "__fixunstfdi")
315 DEF(TOK___floatsitf, "__floatsitf")
316 DEF(TOK___floatditf, "__floatditf")
317 DEF(TOK___floatunsitf, "__floatunsitf")
318 DEF(TOK___floatunditf, "__floatunditf")
319 DEF(TOK___eqtf2, "__eqtf2")
320 DEF(TOK___netf2, "__netf2")
321 DEF(TOK___lttf2, "__lttf2")
322 DEF(TOK___letf2, "__letf2")
323 DEF(TOK___gttf2, "__gttf2")
324 DEF(TOK___getf2, "__getf2")
325 #endif
327 /* bound checking symbols */
328 #ifdef CONFIG_TCC_BCHECK
329 DEF(TOK___bound_ptr_add, "__bound_ptr_add")
330 DEF(TOK___bound_ptr_indir1, "__bound_ptr_indir1")
331 DEF(TOK___bound_ptr_indir2, "__bound_ptr_indir2")
332 DEF(TOK___bound_ptr_indir4, "__bound_ptr_indir4")
333 DEF(TOK___bound_ptr_indir8, "__bound_ptr_indir8")
334 DEF(TOK___bound_ptr_indir12, "__bound_ptr_indir12")
335 DEF(TOK___bound_ptr_indir16, "__bound_ptr_indir16")
336 DEF(TOK___bound_main_arg, "__bound_main_arg")
337 DEF(TOK___bound_local_new, "__bound_local_new")
338 DEF(TOK___bound_local_delete, "__bound_local_delete")
339 DEF(TOK___bound_setjmp, "__bound_setjmp")
340 DEF(TOK___bound_longjmp, "__bound_longjmp")
341 DEF(TOK___bound_new_region, "__bound_new_region")
342 # ifdef TCC_TARGET_PE
343 # ifdef TCC_TARGET_X86_64
344 DEF(TOK___bound_alloca_nr, "__bound_alloca_nr")
345 # endif
346 # else
347 DEF(TOK_sigsetjmp, "sigsetjmp")
348 DEF(TOK___sigsetjmp, "__sigsetjmp")
349 DEF(TOK_siglongjmp, "siglongjmp")
350 # endif
351 DEF(TOK_setjmp, "setjmp")
352 DEF(TOK__setjmp, "_setjmp")
353 DEF(TOK_longjmp, "longjmp")
354 #endif
357 /*********************************************************************/
358 /* Tiny Assembler */
359 #define DEF_ASM(x) DEF(TOK_ASM_ ## x, #x)
360 #define DEF_ASMDIR(x) DEF(TOK_ASMDIR_ ## x, "." #x)
361 #define TOK_ASM_int TOK_INT
363 #define TOK_ASMDIR_FIRST TOK_ASMDIR_byte
364 #define TOK_ASMDIR_LAST TOK_ASMDIR_section
366 DEF_ASMDIR(byte) /* must be first directive */
367 DEF_ASMDIR(word)
368 DEF_ASMDIR(align)
369 DEF_ASMDIR(balign)
370 DEF_ASMDIR(p2align)
371 DEF_ASMDIR(set)
372 DEF_ASMDIR(skip)
373 DEF_ASMDIR(space)
374 DEF_ASMDIR(string)
375 DEF_ASMDIR(asciz)
376 DEF_ASMDIR(ascii)
377 DEF_ASMDIR(file)
378 DEF_ASMDIR(globl)
379 DEF_ASMDIR(global)
380 DEF_ASMDIR(weak)
381 DEF_ASMDIR(hidden)
382 DEF_ASMDIR(ident)
383 DEF_ASMDIR(size)
384 DEF_ASMDIR(type)
385 DEF_ASMDIR(text)
386 DEF_ASMDIR(data)
387 DEF_ASMDIR(bss)
388 DEF_ASMDIR(previous)
389 DEF_ASMDIR(pushsection)
390 DEF_ASMDIR(popsection)
391 DEF_ASMDIR(fill)
392 DEF_ASMDIR(rept)
393 DEF_ASMDIR(endr)
394 DEF_ASMDIR(org)
395 DEF_ASMDIR(quad)
396 #if defined(TCC_TARGET_I386)
397 DEF_ASMDIR(code16)
398 DEF_ASMDIR(code32)
399 #elif defined(TCC_TARGET_X86_64)
400 DEF_ASMDIR(code64)
401 #endif
402 DEF_ASMDIR(short)
403 DEF_ASMDIR(long)
404 DEF_ASMDIR(int)
405 DEF_ASMDIR(section) /* must be last directive */
407 #if defined TCC_TARGET_I386 || defined TCC_TARGET_X86_64
408 #include "i386-tok.h"
409 #endif
411 #if defined TCC_TARGET_ARM || defined TCC_TARGET_ARM64
412 #include "arm-tok.h"
413 #endif
415 #if defined TCC_TARGET_RISCV64
416 #include "riscv64-tok.h"
417 #endif