- removed needless cast
[libfirm] / scripts / ir_spec.py
1 nodes = dict(
2
3 #
4 # Abstract node types
5 #
6 unop = dict(
7         abstract = True,
8         ins      = [ "op" ]
9 ),
10
11 binop = dict(
12         abstract = True,
13         ins      = [ "left", "right" ]
14 ),
15
16 #
17 # Real node types
18 #
19 Abs = dict(
20         is_a     = "unop"
21 ),
22
23 Add = dict(
24         is_a     = "binop"
25 ),
26
27 Alloc = dict(
28         ins   = [ "mem", "size" ],
29         outs  = [ "M", "X_regular", "X_except", "res" ],
30         attrs = [
31                 dict(
32                         name = "type",
33                         type = "ir_type*"
34                 ),
35                 dict(
36                         name = "where",
37                         type = "ir_where_alloc"
38                 )
39         ],
40         pinned      = "exception",
41         pinned_init = "pinned",
42         d_post = '''
43         #if PRECISE_EXC_CONTEXT
44         firm_alloc_frag_arr(res, op_Alloc, &res->attr.alloc.exc.frag_arr);
45         #endif
46         '''
47 ),
48
49 Anchor = dict(
50         mode       = "mode_ANY",
51         arity      = "variable",
52         knownBlock = True,
53         noconstr   = True
54 ),
55
56 And = dict(
57         is_a     = "binop"
58 ),
59
60 Bad = dict(
61         mode       = "mode_Bad",
62         knownBlock = True,
63 ),
64
65 Block = dict(
66         mode       = "mode_BB",
67         knownBlock = True,
68         block      = "NULL",
69         noconstr   = True,
70         optimize   = False,
71         arity      = "variable",
72
73         init = '''
74         /* macroblock header */
75         res->in[0] = res;
76
77         res->attr.block.is_dead     = 0;
78         res->attr.block.is_mb_head  = 1;
79         res->attr.block.has_label   = 0;
80         res->attr.block.irg         = irg;
81         res->attr.block.backedge    = new_backedge_arr(irg->obst, arity);
82         res->attr.block.in_cg       = NULL;
83         res->attr.block.cg_backedge = NULL;
84         res->attr.block.extblk      = NULL;
85         res->attr.block.mb_depth    = 0;
86         res->attr.block.label       = 0;
87
88         set_Block_matured(res, 1);
89         set_Block_block_visited(res, 0);
90         ''',
91
92         d_pre = '''
93         int i;
94         int has_unknown = 0;
95         ''',
96
97         d_post = '''
98         /* Create and initialize array for Phi-node construction. */
99         if (get_irg_phase_state(current_ir_graph) == phase_building) {
100                 res->attr.block.graph_arr = NEW_ARR_D(ir_node *, current_ir_graph->obst,
101                                                       current_ir_graph->n_loc);
102                 memset(res->attr.block.graph_arr, 0, sizeof(ir_node *)*current_ir_graph->n_loc);
103         }
104
105         for (i = arity - 1; i >= 0; i--)
106                 if (is_Unknown(in[i])) {
107                         has_unknown = 1;
108                         break;
109                 }
110
111         if (!has_unknown) res = optimize_node(res);
112
113         current_ir_graph->current_block = res;
114
115         IRN_VRFY_IRG(res, current_ir_graph);
116         ''',
117
118         java_add   = '''
119         public void addPred(Node node) {
120                 binding_cons.add_immBlock_pred(ptr, node.ptr);
121         }
122
123         public void mature() {
124                 binding_cons.mature_immBlock(ptr);
125         }
126
127         @Override
128         public Block getBlock() {
129                 return null;
130         }
131
132         public boolean blockVisited() {
133                 return 0 != binding.Block_block_visited(ptr);
134         }
135
136         public void markBlockVisited() {
137                 binding.mark_Block_block_visited(ptr);
138         }
139
140         public boolean isBad() {
141                 return binding.is_Bad(ptr) != 0;
142         }
143         ''',
144 ),
145
146 Borrow = dict(
147         is_a     = "binop"
148 ),
149
150 Bound = dict(
151         ins    = [ "mem", "index", "lower", "upper" ],
152         outs   = [ "M", "X_regular", "X_except", "res" ],
153         pinned = "exception",
154         pinned_init = "pinned",
155         d_post = '''
156         #if PRECISE_EXC_CONTEXT
157         firm_alloc_frag_arr(res, op_Bound, &res->attr.bound.exc.frag_arr);
158         #endif
159         '''
160 ),
161
162
163 Break = dict(
164         mode = "mode_X"
165 ),
166
167 Builtin = dict(
168         ins      = [ "mem" ],
169         arity    = "variable",
170         outs     = [ "M_regular", "X_regular", "X_except", "T_result", "M_except", "P_value_res_base" ],
171         attrs    = [
172                 dict(
173                         type = "ir_builtin_kind",
174                         name = "kind"
175                 ),
176                 dict(
177                         type = "ir_type*",
178                         name = "type"
179                 )
180         ],
181         pinned      = "memory",
182         pinned_init = "pinned",
183         init   = '''
184         assert((get_unknown_type() == type) || is_Method_type(type));
185         '''
186
187         # TODO: No firm_alloc_frag_arr??
188 ),
189
190 Call = dict(
191         ins      = [ "mem", "ptr" ],
192         arity    = "variable",
193         outs     = [ "M_regular", "X_regular", "X_except", "T_result", "M_except", "P_value_res_base" ],
194         attrs    = [
195                 dict(
196                         type = "ir_type*",
197                         name = "type"
198                 )
199         ],
200         pinned      = "memory",
201         pinned_init = "pinned",
202         init = '''
203         assert((get_unknown_type() == type) || is_Method_type(type));
204         ''',
205         d_post = '''
206         #if PRECISE_EXC_CONTEXT
207         firm_alloc_frag_arr(res, op_Call, &res->attr.call.exc.frag_arr);
208         #endif
209         '''
210 ),
211
212 Carry = dict(
213         is_a     = "binop"
214 ),
215
216 Cast = dict(
217         ins      = [ "op" ],
218         mode     = "get_irn_mode(irn_op)",
219         attrs    = [
220                 dict(
221                         type = "ir_type*",
222                         name = "type"
223                 )
224         ],
225         init     = "assert(is_atomic_type(type));"
226 ),
227
228 Cmp = dict(
229         is_a     = "binop",
230         outs     = [ "False", "Eq", "Lt", "Le", "Gt", "Ge", "Lg", "Leg", "Uo", "Ue", "Ul", "Ule", "Ug", "Uge", "Ne", "True" ],
231 ),
232
233 Cond = dict(
234         ins      = [ "selector" ],
235         outs     = [ "false", "true" ],
236         attrs    = [
237                 dict(
238                         name = "kind",
239                         type = "cond_kind",
240                         init = "dense"
241                 ),
242                 dict(
243                         name = "default_proj",
244                         type = "long",
245                         init = "0"
246                 ),
247                 dict(
248                         name = "jmp_pred",
249                         type = "cond_jmp_predicate",
250                         init = "COND_JMP_PRED_NONE"
251                 )
252         ]
253 ),
254
255 Confirm = dict(
256         ins      = [ "value", "bound" ],
257         mode     = "get_irn_mode(irn_value)",
258         attrs    = [
259                 dict(
260                         name = "cmp",
261                         type = "pn_Cmp"
262                 ),
263         ],
264 ),
265
266 Const = dict(
267         mode       = "",
268         knownBlock = True,
269         attrs_name = "con",
270         attrs      = [
271                 dict(
272                         type = "tarval*",
273                         name = "tarval",
274                 )
275         ],
276 ),
277
278 Conv = dict(
279         is_a     = "unop",
280         attrs = [
281                 dict(
282                         name = "strict",
283                         type = "int",
284                         init = "0",
285                         special = dict(
286                                 prefix = "strict",
287                                 init = "1"
288                         )
289                 )
290         ]
291 ),
292
293 CopyB = dict(
294         ins   = [ "mem", "dst", "src" ],
295         outs  = [ "M", "X_regular", "X_except" ],
296         attrs = [
297                 dict(
298                         name = "type",
299                         type = "ir_type*"
300                 )
301         ],
302         pinned      = "memory",
303         pinned_init = "pinned",
304         d_post = '''
305         #if PRECISE_EXC_CONTEXT
306         firm_alloc_frag_arr(res, op_CopyB, &res->attr.copyb.exc.frag_arr);
307         #endif
308         '''
309 ),
310
311 Div = dict(
312         ins   = [ "mem", "left", "right" ],
313         outs  = [ "M", "X_regular", "X_except", "res" ],
314         attrs_name = "divmod",
315         attrs = [
316                 dict(
317                         type = "ir_mode*",
318                         name = "resmode"
319                 ),
320                 dict(
321                         name = "no_remainder",
322                         type = "int",
323                         init = "0",
324                         special = dict(
325                                 suffix = "RL",
326                                 init = "1"
327                         )
328                 )
329         ],
330         pinned = "exception",
331         d_post = '''
332         #if PRECISE_EXC_CONTEXT
333         firm_alloc_frag_arr(res, op_Div, &res->attr.except.frag_arr);
334         #endif
335         '''
336 ),
337
338 DivMod = dict(
339         ins   = [ "mem", "left", "right" ],
340         outs  = [ "M", "X_regular", "X_except", "res_div", "res_mod" ],
341         attrs_name = "divmod",
342         attrs = [
343                 dict(
344                         type = "ir_mode*",
345                         name = "resmode"
346                 ),
347         ],
348         pinned = "exception",
349         d_post = '''
350         #if PRECISE_EXC_CONTEXT
351         firm_alloc_frag_arr(res, op_DivMod, &res->attr.except.frag_arr);
352         #endif
353         '''
354 ),
355
356 End = dict(
357         mode       = "mode_X",
358         op_flags   = "cfopcode",
359         pinned     = "yes",
360         arity      = "dynamic",
361         noconstr   = True,
362         optimize   = False
363 ),
364
365 Eor = dict(
366         is_a     = "binop"
367 ),
368
369 Filter = dict(
370         ins   = [ "pred" ],
371         attrs = [
372                 dict(
373                         name = "proj",
374                         type = "long"
375                 )
376         ]
377
378         # TODO: Broken asserts in original:
379         # assert(get_Proj_pred(res));
380         # assert(get_nodes_block(get_Proj_pred(res)));
381 ),
382
383 Free = dict(
384         ins   = [ "mem", "ptr", "size" ],
385         mode  = "mode_M",
386         attrs = [
387                 dict(
388                         name = "type",
389                         type = "ir_type*"
390                 ),
391                 dict(
392                         name = "where",
393                         type = "ir_where_alloc"
394                 )
395         ]
396 ),
397
398 Id = dict(
399         ins = [ "pred" ]
400 ),
401
402 IJmp = dict(
403         mode     = "mode_X",
404         op_flags = "cfopcode",
405         pinned   = "yes",
406         ins      = [ "target" ],
407 ),
408
409 InstOf = dict(
410         ins   = [ "store", "obj" ],
411         outs  = [ "M", "X_regular", "X_except", "res", "M_except" ],
412         attrs = [
413                 dict(
414                         name = "type",
415                         type = "ir_type*"
416                 )
417         ],
418         pinned      = "memory",
419         pinned_init = "floats",
420 ),
421
422 Jmp = dict(
423         mode     = "mode_X",
424         op_flags = "cfopcode",
425         pinned   = "yes",
426         ins      = [],
427 ),
428
429 Load = dict(
430         ins      = [ "mem", "ptr" ],
431         outs     = [ "M", "X_regular", "X_except", "res" ],
432         attrs    = [
433                 dict(
434                         type = "ir_mode*",
435                         name = "mode",
436                         java_name = "load_mode"
437                 ),
438         ],
439         constructor_args = [
440                 dict(
441                         type = "ir_cons_flags",
442                         name = "flags",
443                 ),
444         ],
445         d_post = '''
446 #if PRECISE_EXC_CONTEXT
447         firm_alloc_frag_arr(res, op_Load, &res->attr.load.exc.frag_arr);
448 #endif
449         '''
450 ),
451
452 Minus = dict(
453         is_a     = "unop"
454 ),
455
456 Mod = dict(
457         ins   = [ "mem", "left", "right" ],
458         outs  = [ "M", "X_regular", "X_except", "res" ],
459         attrs_name = "divmod",
460         attrs = [
461                 dict(
462                         type = "ir_mode*",
463                         name = "resmode"
464                 ),
465         ],
466         pinned = "exception",
467         d_post = '''
468         #if PRECISE_EXC_CONTEXT
469         firm_alloc_frag_arr(res, op_Mod, &res->attr.except.frag_arr);
470         #endif
471         '''
472 ),
473
474 Mul = dict(
475         is_a     = "binop"
476 ),
477
478 Mulh = dict(
479         is_a     = "binop"
480 ),
481
482 Mux = dict(
483         ins      = [ "sel", "false", "true" ]
484 ),
485
486 NoMem = dict(
487         mode       = "mode_M",
488         knownBlock = True,
489 ),
490
491 Not = dict(
492         is_a     = "unop"
493 ),
494
495 Or = dict(
496         is_a     = "binop"
497 ),
498
499 Phi = dict(
500         noconstr = True,
501         pinned   = "yes",
502         arity    = "variable",
503 ),
504
505 Pin = dict(
506         ins      = [ "op" ],
507         mode     = "get_irn_mode(irn_op)"
508 ),
509
510 Proj = dict(
511         ins      = [ "pred" ],
512         attrs    = [
513                 dict(
514                         type = "long",
515                         name = "proj",
516                         initname = ""
517                 )
518         ]
519 ),
520
521 Quot = dict(
522         ins   = [ "mem", "left", "right" ],
523         outs  = [ "M", "X_regular", "X_except", "res" ],
524         attrs_name = "divmod",
525         attrs = [
526                 dict(
527                         type = "ir_mode*",
528                         name = "resmode"
529                 ),
530         ],
531         pinned = "exception",
532         d_post = '''
533         #if PRECISE_EXC_CONTEXT
534         firm_alloc_frag_arr(res, op_Quot, &res->attr.except.frag_arr);
535         #endif
536         '''
537 ),
538
539 Raise = dict(
540         ins   = [ "mem", "exo_ptr" ],
541         outs  = [ "M", "X" ]
542 ),
543
544 Return = dict(
545         ins      = [ "mem" ],
546         arity    = "variable",
547         mode     = "mode_X"
548 ),
549
550 Rotl = dict(
551         is_a     = "binop"
552 ),
553
554 Sel = dict(
555         ins    = [ "mem", "ptr" ],
556         arity  = "variable",
557         mode   = "is_Method_type(get_entity_type(entity)) ? mode_P_code : mode_P_data",
558         attrs    = [
559                 dict(
560                         type = "ir_entity*",
561                         name = "entity"
562                 )
563         ]
564 ),
565
566 Shl = dict(
567         is_a     = "binop"
568 ),
569
570 Shr = dict(
571         is_a     = "binop"
572 ),
573
574 Shrs = dict(
575         is_a     = "binop"
576 ),
577
578 Start = dict(
579         mode       = "mode_T",
580         op_flags   = "cfopcode",
581         pinned     = "yes",
582         noconstr   = True,
583         optimize   = False
584 ),
585
586 Store = dict(
587         ins      = [ "mem", "ptr", "value" ],
588         outs     = [ "M", "X_regular", "X_except" ],
589         constructor_args = [
590                 dict(
591                         type = "ir_cons_flags",
592                         name = "flags",
593                 ),
594         ],
595         d_post = '''
596 #if PRECISE_EXC_CONTEXT
597         firm_alloc_frag_arr(res, op_Store, &res->attr.store.exc.frag_arr);
598 #endif
599         '''
600 ),
601
602 Sub = dict(
603         is_a     = "binop"
604 ),
605
606 SymConst = dict(
607         mode       = "mode_P",
608         knownBlock = True,
609         noconstr   = True,
610         attrs      = [
611                 dict(
612                         type = "ir_entity*",
613                         name = "entity"
614                 )
615         ],
616 ),
617
618 Sync = dict(
619         mode     = "mode_M",
620         optimize = False,
621         arity    = "dynamic"
622 ),
623
624 Tuple = dict(
625         arity    = "variable",
626         mode     = "mode_T",
627 ),
628
629 Unknown = dict(
630         knownBlock = True,
631         block      = "get_irg_start_block(irg)",
632         nodbginfo  = True
633 ),
634 )