Cthulhu  0.2.10
Cthulhu compiler collection
tree.inc
Go to the documentation of this file.
1 // SPDX-License-Identifier: LGPL-3.0-only
2 
3 #ifndef TREE_TAG
4 # define TREE_TAG(ID, NAME, BIT)
5 #endif
6 
7 TREE_TAG(eTagNone, "none", (0 << 0))
8 TREE_TAG(eTagName, "name", (1 << 0))
9 TREE_TAG(eTagQual, "qual", (1 << 1))
10 TREE_TAG(eTagIsType, "is_a_type", (1 << 2))
11 TREE_TAG(eTagHasType, "has_a_type", (1 << 3))
12 TREE_TAG(eTagStorage, "storage", (1 << 4))
13 TREE_TAG(eTagEval, "eval", (1 << 5))
14 
15 #undef TREE_TAG
16 
18 #ifndef TREE_KIND
19 # define TREE_KIND(ID, NAME, TAGS)
20 #endif
21 
25 
28 TREE_KIND(eTreeTypeEmpty, "type_empty", eTagName | eTagQual | eTagIsType)
29 
30 TREE_KIND(eTreeTypeUnit, "type_unit", eTagName | eTagQual | eTagIsType)
33 
34 TREE_KIND(eTreeTypeBool, "type_bool", eTagName | eTagQual | eTagIsType)
36 
37 TREE_KIND(eTreeTypeOpaque, "type_opaque", eTagName | eTagQual | eTagIsType)
40 
41 TREE_KIND(eTreeTypeDigit, "type_digit", eTagName | eTagQual | eTagIsType)
43 
44 TREE_KIND(eTreeTypeClosure, "type_closure", eTagName | eTagQual | eTagIsType)
46 
47 TREE_KIND(eTreeTypeString, "type_string", eTagName | eTagQual | eTagIsType)
51 
52 TREE_KIND(eTreeTypeReference, "type_reference", eTagName | eTagQual | eTagIsType)
55 
56 TREE_KIND(eTreeTypePointer, "type_pointer", eTagName | eTagQual | eTagIsType)
59 
60 TREE_KIND(eTreeTypeArray, "type_array", eTagName | eTagQual | eTagIsType)
63 
64 TREE_KIND(eTreeTypeClass, "type_class", eTagName | eTagIsType)
66 
67 TREE_KIND(eTreeTypeStruct, "type_struct", eTagName | eTagIsType)
69 
70 TREE_KIND(eTreeTypeUnion, "type_union", eTagName | eTagIsType)
72 
73 TREE_KIND(eTreeTypeEnum, "type_enum", eTagName | eTagIsType)
75 
76 TREE_KIND(eTreeTypeVariant, "type_variant", eTagName | eTagIsType)
78 
79 TREE_KIND(eTreeTypeAlias, "type_alias", eTagName | eTagIsType | eTagHasType)
81 
82 
88 TREE_KIND(eTreeExprSizeOf, "expr_sizeof", eTagHasType)
89 
90 TREE_KIND(eTreeExprAlignOf, "expr_alignof", eTagHasType)
92 
93 TREE_KIND(eTreeExprOffsetOf, "expr_offsetof", eTagHasType)
95 
96 TREE_KIND(eTreeExprEmpty, "expr_empty", eTagHasType)
98 
99 TREE_KIND(eTreeExprUnit, "expr_unit", eTagHasType)
101 
102 TREE_KIND(eTreeExprBool, "expr_bool", eTagHasType)
104 
105 TREE_KIND(eTreeExprDigit, "expr_digit", eTagHasType)
107 
108 TREE_KIND(eTreeExprString, "expr_string", eTagHasType)
110 
111 TREE_KIND(eTreeExprCast, "expr_cast", eTagHasType)
114 
115 TREE_KIND(eTreeExprLoad, "expr_load", eTagHasType)
119 
120 TREE_KIND(eTreeExprAddressOf, "expr_addressof", eTagHasType)
122 
123 TREE_KIND(eTreeExprUnary, "expr_unary", eTagHasType)
125 
126 TREE_KIND(eTreeExprBinary, "expr_binary", eTagHasType)
128 
129 TREE_KIND(eTreeExprCompare, "expr_compare", eTagHasType)
131 
132 TREE_KIND(eTreeExprField, "expr_field", eTagHasType)
135 
136 TREE_KIND(eTreeExprOffset, "expr_offset", eTagHasType)
139 
140 TREE_KIND(eTreeExprCall, "expr_call", eTagHasType)
143 
144 
151 TREE_KIND(eTreeStmtBuiltin, "stmt_builtin", eTagNone)
152 TREE_KIND(eTreeStmtBlock, "stmt_block", eTagNone)
153 TREE_KIND(eTreeStmtReturn, "stmt_return", eTagNone)
154 TREE_KIND(eTreeStmtAssign, "stmt_assign", eTagNone)
155 TREE_KIND(eTreeStmtLoop, "stmt_loop", eTagNone)
156 TREE_KIND(eTreeStmtBranch, "stmt_branch", eTagNone)
157 TREE_KIND(eTreeStmtJump, "stmt_jump", eTagNone)
158 
159 
163 TREE_KIND(eTreeDeclAttrib, "decl_attrib", eTagName)
164 TREE_KIND(eTreeDeclGlobal, "decl_global", eTagName | eTagStorage | eTagEval | eTagHasType)
165 TREE_KIND(eTreeDeclLocal, "decl_local", eTagName | eTagStorage | eTagEval | eTagHasType)
166 TREE_KIND(eTreeDeclParam, "decl_param", eTagName | eTagHasType)
167 TREE_KIND(eTreeDeclCase, "decl_case", eTagName | eTagHasType)
168 TREE_KIND(eTreeDeclField, "decl_field", eTagName | eTagHasType)
169 TREE_KIND(eTreeDeclFunction, "decl_function", eTagName | eTagEval | eTagHasType)
170 TREE_KIND(eTreeDeclModule, "decl_module", eTagName)
171 
172 TREE_KIND(eTreeQualified, "qualified", eTagName)
173 TREE_KIND(eTreePartial, "partial_type", eTagName | eTagIsType)
174 TREE_KIND(eTreeError, "error", eTagName | eTagHasType)
175 
176 #undef TREE_KIND
177 
178 #ifndef DIGIT_KIND
179 # define DIGIT_KIND(ID, STR)
180 #endif
181 
182 DIGIT_KIND(eDigitChar, "char")
183 DIGIT_KIND(eDigitShort, "short")
184 DIGIT_KIND(eDigitInt, "int")
185 DIGIT_KIND(eDigitLong, "long")
186 DIGIT_KIND(eDigitLongLong, "longlong")
187 
188 DIGIT_KIND(eDigitPtr, "intptr")
189 DIGIT_KIND(eDigitSize, "intsize")
190 DIGIT_KIND(eDigitMax, "intmax")
191 
192 DIGIT_KIND(eDigit8, "int8")
193 DIGIT_KIND(eDigit16, "int16")
194 DIGIT_KIND(eDigit32, "int32")
195 DIGIT_KIND(eDigit64, "int64")
196 
197 DIGIT_KIND(eDigitFast8, "fast8")
198 DIGIT_KIND(eDigitFast16, "fast16")
199 DIGIT_KIND(eDigitFast32, "fast32")
200 DIGIT_KIND(eDigitFast64, "fast64")
201 
202 DIGIT_KIND(eDigitLeast8, "least8")
203 DIGIT_KIND(eDigitLeast16, "least16")
204 DIGIT_KIND(eDigitLeast32, "least32")
205 DIGIT_KIND(eDigitLeast64, "least64")
206 
207 DIGIT_KIND(eDigitHalf, "half")
208 DIGIT_KIND(eDigitFloat, "float")
209 DIGIT_KIND(eDigitDouble, "double")
210 
211 #undef DIGIT_KIND
212 
213 #ifndef SIGN_KIND
214 # define SIGN_KIND(ID, STR)
215 #endif
216 
217 SIGN_KIND(eSignDefault, "default")
218 SIGN_KIND(eSignUnsigned, "unsigned")
219 SIGN_KIND(eSignSigned, "signed")
220 
221 #undef SIGN_KIND
222 
223 #ifndef TYPE_QUALIFIER
224 # define TYPE_QUALIFIER(ID, STR, BIT)
225 #endif
226 
227 TYPE_QUALIFIER(eQualNone, "none", (0 << 0)) // defer qualifiers to parent
228 TYPE_QUALIFIER(eQualConst, "const", (1 << 0))
229 TYPE_QUALIFIER(eQualMutable, "mutable", (1 << 1))
230 TYPE_QUALIFIER(eQualVolatile, "volatile", (1 << 2))
231 TYPE_QUALIFIER(eQualAtomic, "atomic", (1 << 3))
232 TYPE_QUALIFIER(eQualRestrict, "restrict", (1 << 4))
233 
234 #undef TYPE_QUALIFIER
235 
237 #ifndef TREE_LINKAGE
238 # define TREE_LINKAGE(ID, STR)
239 #endif
240 
241 TREE_LINKAGE(eLinkExport, "exported")
242 TREE_LINKAGE(eLinkImport, "imported")
243 TREE_LINKAGE(eLinkModule, "internal")
244 TREE_LINKAGE(eLinkEntryCli, "entry_cli")
245 TREE_LINKAGE(eLinkEntryGui, "entry_gui")
246 TREE_LINKAGE(eLinkPixelShader, "pixel_shader")
247 TREE_LINKAGE(eLinkVertexShader, "vertex_shader")
248 TREE_LINKAGE(eLinkComputeShader, "compute_shader")
249 
250 #undef TREE_LINKAGE
251 
253 #ifndef TREE_VISIBILITY
254 # define TREE_VISIBILITY(ID, NAME)
255 #endif
256 
257 TREE_VISIBILITY(eVisiblePublic, "public")
258 TREE_VISIBILITY(eVisiblePrivate, "private")
259 
260 #undef TREE_VISIBILITY
261 
262 #ifndef UNARY_OP
263 # define UNARY_OP(ID, NAME, SYMBOL)
264 #endif
265 
266 UNARY_OP(eUnaryAbs, "abs", "+")
267 UNARY_OP(eUnaryNeg, "neg", "-")
268 UNARY_OP(eUnaryFlip, "flip", "~")
269 UNARY_OP(eUnaryNot, "not", "!")
270 
271 #undef UNARY_OP
272 
273 #ifndef BINARY_OP
274 # define BINARY_OP(ID, NAME, SYMBOL)
275 #endif
276 
277 BINARY_OP(eBinaryAdd, "add", "+")
278 BINARY_OP(eBinarySub, "sub", "-")
279 BINARY_OP(eBinaryMul, "mul", "*")
280 BINARY_OP(eBinaryDiv, "div", "/")
281 BINARY_OP(eBinaryRem, "rem", "%")
282 
283 BINARY_OP(eBinaryBitAnd, "bitand", "&")
284 BINARY_OP(eBinaryBitOr, "bitor", "|")
285 BINARY_OP(eBinaryXor, "xor", "^")
286 BINARY_OP(eBinaryShl, "shl", ">>")
287 BINARY_OP(eBinaryShr, "shr", "<<")
288 
289 #undef BINARY_OP
290 
291 #ifndef COMPARE_OP
292 # define COMPARE_OP(ID, NAME, SYMBOL)
293 #endif
294 
295 COMPARE_OP(eCompareAnd, "and", "&&")
296 COMPARE_OP(eCompareOr, "or", "||")
297 
298 COMPARE_OP(eCompareEq, "eq", "==")
299 COMPARE_OP(eCompareNeq, "neq", "!=")
300 COMPARE_OP(eCompareLt, "lt", "<")
301 COMPARE_OP(eCompareLte, "lte", "<=")
302 COMPARE_OP(eCompareGt, "gt", ">")
303 COMPARE_OP(eCompareGte, "gte", ">=")
304 
305 #undef COMPARE_OP
306 
307 #ifndef CAST_OP
308 # define CAST_OP(ID, NAME)
309 #endif
310 
311 CAST_OP(eCastZeroExtend, "zero_extend")
312 CAST_OP(eCastSignExtend, "sign_extend")
313 CAST_OP(eCastBit, "bit_cast")
314 
315 #undef CAST_OP
316 
317 #ifndef TREE_ARITY
318 # define TREE_ARITY(ID, NAME)
319 #endif
320 
321 TREE_ARITY(eArityFixed, "fixed") // fixed number of arguments
322 TREE_ARITY(eArityVariable, "variable") // variable number of arguments, same as C varargs
323 
324 #undef TREE_ARITY
325 
326 #ifndef TREE_JUMP
327 # define TREE_JUMP(ID, NAME)
328 #endif
329 
330 TREE_JUMP(eJumpBreak, "break")
331 TREE_JUMP(eJumpContinue, "continue")
332 
333 #undef TREE_JUMP
334 
335 #ifndef TREE_EVAL_MODEL
336 # define TREE_EVAL_MODEL(ID, NAME, BIT)
337 #endif
338 
339 TREE_EVAL_MODEL(eEvalRuntime, "runtime", (1 << 0)) // can be evaluated at runtime
340 TREE_EVAL_MODEL(eEvalCompile, "compile", (1 << 1)) // can be evaluated at compile time
341 
342 #undef TREE_EVAL_MODEL
#define SIGN_KIND(ID, STR)
dealing with C interop
Definition: tree.inc:217
#define CAST_OP(ID, NAME)
Definition: tree.inc:314
#define TREE_JUMP(ID, NAME)
Definition: tree.inc:333
#define TREE_EVAL_MODEL(ID, NAME, BIT)
Definition: tree.inc:342
#define TREE_LINKAGE(ID, STR)
symbol visibility during linking
Definition: tree.inc:244
#define TREE_KIND(ID, NAME, TAGS)
tree kind defs
Definition: tree.inc:22
#define TREE_VISIBILITY(ID, NAME)
symbol visibility during compilation
Definition: tree.inc:260
#define UNARY_OP(ID, NAME, SYMBOL)
Definition: tree.inc:269
#define TREE_ARITY(ID, NAME)
Definition: tree.inc:324
#define COMPARE_OP(ID, NAME, SYMBOL)
Definition: tree.inc:298
#define TYPE_QUALIFIER(ID, STR, BIT)
Definition: tree.inc:230
#define TREE_TAG(ID, NAME, BIT)
Definition: tree.inc:4
#define DIGIT_KIND(ID, STR)
boolean logic type
Definition: tree.inc:182
#define BINARY_OP(ID, NAME, SYMBOL)
Definition: tree.inc:280