update filelist script
[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         op_index = 0,
10         pinned   = "no",
11 ),
12
13 binop = dict(
14         abstract = True,
15         ins      = [ "left", "right" ],
16         op_index = 0,
17         pinned   = "no",
18 ),
19
20 #
21 # Real node types
22 #
23 Abs = dict(
24         is_a     = "unop",
25         flags    = "none",
26 ),
27
28 Add = dict(
29         is_a     = "binop",
30         flags    = "commutative",
31 ),
32
33 Alloc = dict(
34         ins   = [ "mem", "size" ],
35         outs  = [ "M", "X_regular", "X_except", "res" ],
36         flags = "fragile, uses_memory",
37         attrs = [
38                 dict(
39                         name = "type",
40                         type = "ir_type*"
41                 ),
42                 dict(
43                         name = "where",
44                         type = "ir_where_alloc"
45                 )
46         ],
47         pinned      = "yes",
48         attr_struct = "alloc_attr",
49         d_post = '''
50         #if PRECISE_EXC_CONTEXT
51         firm_alloc_frag_arr(res, op_Alloc, &res->attr.alloc.exc.frag_arr);
52         #endif
53         '''
54 ),
55
56 Anchor = dict(
57         mode        = "mode_ANY",
58         arity       = "variable",
59         flags       = "dump_noblock",
60         pinned      = "yes",
61         knownBlock  = True,
62         singleton   = True,
63 ),
64
65 And = dict(
66         is_a     = "binop",
67         flags    = "commutative",
68 ),
69
70 ASM = dict(
71         mode          = "mode_T",
72         arity         = "variable",
73         flags         = "keep, uses_memory",
74         attr_struct   = "asm_attr",
75         pinned        = "memory",
76         pinned_init   = "op_pin_state_pinned",
77         attrs = [
78                 dict(
79                         name = "input_constraints",
80                         type = "ir_asm_constraint*",
81                 ),
82                 dict(
83                         name = "n_output_constraints",
84                         type = "int",
85                 ),
86                 dict(
87                         name = "output_constraints",
88                         type = "ir_asm_constraint*",
89                 ),
90                 dict(
91                         name = "n_clobbers",
92                         type = "int",
93                 ),
94                 dict(
95                         name = "clobbers",
96                         type = "ident**",
97                 ),
98                 dict(
99                         name = "text",
100                         type = "ident*",
101                 ),
102         ],
103         java_noconstr = True,
104 ),
105
106 Bad = dict(
107         mode       = "mode_Bad",
108         flags      = "cfopcode, fragile, start_block, dump_noblock",
109         pinned     = "yes",
110         knownBlock = True,
111         singleton  = True,
112 ),
113
114 Block = dict(
115         mode        = "mode_BB",
116         knownBlock  = True,
117         block       = "NULL",
118         pinned      = "yes",
119         optimize    = False,
120         arity       = "variable",
121         flags       = "labeled",
122         attr_struct = "block_attr",
123         java_noconstr = True,
124
125         init = '''
126         /* macroblock header */
127         res->in[0] = res;
128
129         res->attr.block.is_dead     = 0;
130         res->attr.block.is_mb_head  = 1;
131         res->attr.block.has_label   = 0;
132         res->attr.block.irg         = irg;
133         res->attr.block.backedge    = new_backedge_arr(irg->obst, arity);
134         res->attr.block.in_cg       = NULL;
135         res->attr.block.cg_backedge = NULL;
136         res->attr.block.extblk      = NULL;
137         res->attr.block.mb_depth    = 0;
138         res->attr.block.label       = 0;
139
140         set_Block_matured(res, 1);
141         set_Block_block_visited(res, 0);
142         ''',
143
144         d_pre = '''
145         int i;
146         int has_unknown = 0;
147         ''',
148
149         d_post = '''
150         /* Create and initialize array for Phi-node construction. */
151         if (get_irg_phase_state(current_ir_graph) == phase_building) {
152                 res->attr.block.graph_arr = NEW_ARR_D(ir_node *, current_ir_graph->obst,
153                                                       current_ir_graph->n_loc);
154                 memset(res->attr.block.graph_arr, 0, sizeof(ir_node *)*current_ir_graph->n_loc);
155         }
156
157         for (i = arity - 1; i >= 0; i--)
158                 if (is_Unknown(in[i])) {
159                         has_unknown = 1;
160                         break;
161                 }
162
163         if (!has_unknown) res = optimize_node(res);
164
165         current_ir_graph->current_block = res;
166
167         IRN_VRFY_IRG(res, current_ir_graph);
168         ''',
169
170         java_add   = '''
171         public void addPred(Node node) {
172                 binding_cons.add_immBlock_pred(ptr, node.ptr);
173         }
174
175         public void mature() {
176                 binding_cons.mature_immBlock(ptr);
177         }
178
179         @Override
180         public Block getBlock() {
181                 return null;
182         }
183
184         public boolean blockVisited() {
185                 return 0 != binding.Block_block_visited(ptr);
186         }
187
188         public void markBlockVisited() {
189                 binding.mark_Block_block_visited(ptr);
190         }
191
192         public boolean isBad() {
193                 return binding.is_Bad(ptr) != 0;
194         }
195         ''',
196 ),
197
198 Borrow = dict(
199         is_a     = "binop",
200         flags    = "none",
201 ),
202
203 Bound = dict(
204         ins    = [ "mem", "index", "lower", "upper" ],
205         outs   = [ "M", "X_regular", "X_except", "res" ],
206         flags  = "fragile, highlevel",
207         pinned = "exception",
208         pinned_init = "op_pin_state_pinned",
209         attr_struct = "bound_attr",
210         d_post = '''
211         #if PRECISE_EXC_CONTEXT
212         firm_alloc_frag_arr(res, op_Bound, &res->attr.bound.exc.frag_arr);
213         #endif
214         '''
215 ),
216
217 Break = dict(
218         mode   = "mode_X",
219         flags  = "cfopcode",
220         pinned = "yes",
221 ),
222
223 Builtin = dict(
224         ins      = [ "mem" ],
225         arity    = "variable",
226         outs     = [ "M_regular", "X_regular", "X_except", "T_result", "M_except", "P_value_res_base" ],
227         flags    = "uses_memory",
228         attrs    = [
229                 dict(
230                         type = "ir_builtin_kind",
231                         name = "kind"
232                 ),
233                 dict(
234                         type = "ir_type*",
235                         name = "type"
236                 )
237         ],
238         pinned      = "memory",
239         pinned_init = "op_pin_state_pinned",
240         attr_struct = "builtin_attr",
241         init   = '''
242         assert((get_unknown_type() == type) || is_Method_type(type));
243         '''
244
245         # TODO: No firm_alloc_frag_arr??
246 ),
247
248 Call = dict(
249         ins      = [ "mem", "ptr" ],
250         arity    = "variable",
251         outs     = [ "M_regular", "X_regular", "X_except", "T_result", "M_except", "P_value_res_base" ],
252         flags    = "fragile, uses_memory",
253         attrs    = [
254                 dict(
255                         type = "ir_type*",
256                         name = "type"
257                 )
258         ],
259         attr_struct = "call_attr",
260         pinned      = "memory",
261         pinned_init = "op_pin_state_pinned",
262         init = '''
263         assert((get_unknown_type() == type) || is_Method_type(type));
264         ''',
265         d_post = '''
266         #if PRECISE_EXC_CONTEXT
267         firm_alloc_frag_arr(res, op_Call, &res->attr.call.exc.frag_arr);
268         #endif
269         '''
270 ),
271
272 CallBegin = dict(
273         ins   = [ "ptr" ],
274         outs  = [ "" ], # TODO
275         flags         = "cfopcode, ip_cfopcode",
276         pinned        = "yes",
277         # TODO: attribute with call...
278         attr_struct   = "callbegin_attr",
279         attrs         = [
280                 dict(
281                         type = "ir_node*",
282                         name = "call"
283                 )
284         ],
285         java_noconstr = True,
286 ),
287
288 Carry = dict(
289         is_a     = "binop",
290         flags    = "commutative",
291 ),
292
293 Cast = dict(
294         ins      = [ "op" ],
295         mode     = "get_irn_mode(irn_op)",
296         flags    = "highlevel",
297         pinned   = "no",
298         attrs    = [
299                 dict(
300                         type = "ir_type*",
301                         name = "type"
302                 )
303         ],
304         attr_struct = "cast_attr",
305         init     = "assert(is_atomic_type(type));"
306 ),
307
308 Cmp = dict(
309         is_a     = "binop",
310         outs     = [ "False", "Eq", "Lt", "Le", "Gt", "Ge", "Lg", "Leg", "Uo", "Ue", "Ul", "Ule", "Ug", "Uge", "Ne", "True" ],
311         flags    = "none",
312 ),
313
314 Cond = dict(
315         ins      = [ "selector" ],
316         outs     = [ "false", "true" ],
317         flags    = "cfopcode, forking",
318         pinned   = "yes",
319         attrs    = [
320                 dict(
321                         name = "kind",
322                         type = "cond_kind",
323                         init = "dense"
324                 ),
325                 dict(
326                         name = "default_proj",
327                         type = "long",
328                         init = "0"
329                 ),
330                 dict(
331                         name = "jmp_pred",
332                         type = "cond_jmp_predicate",
333                         init = "COND_JMP_PRED_NONE"
334                 )
335         ],
336         attr_struct = "cond_attr"
337 ),
338
339 Confirm = dict(
340         ins      = [ "value", "bound" ],
341         mode     = "get_irn_mode(irn_value)",
342         flags    = "highlevel",
343         pinned   = "yes",
344         attrs    = [
345                 dict(
346                         name = "cmp",
347                         type = "pn_Cmp"
348                 ),
349         ],
350         attr_struct = "confirm_attr",
351 ),
352
353 Const = dict(
354         mode       = "",
355         flags      = "constlike, start_block",
356         knownBlock = True,
357         pinned     = "no",
358         attrs_name = "con",
359         attrs      = [
360                 dict(
361                         type = "tarval*",
362                         name = "tarval",
363                 )
364         ],
365         attr_struct = "const_attr",
366 ),
367
368 Conv = dict(
369         is_a     = "unop",
370         flags    = "none",
371         attrs = [
372                 dict(
373                         name = "strict",
374                         type = "int",
375                         init = "0",
376                         special = dict(
377                                 prefix = "strict",
378                                 init = "1"
379                         )
380                 )
381         ],
382         attr_struct = "conv_attr",
383 ),
384
385 CopyB = dict(
386         ins   = [ "mem", "dst", "src" ],
387         outs  = [ "M", "X_regular", "X_except" ],
388         flags = "fragile, highlevel, uses_memory",
389         attrs = [
390                 dict(
391                         name = "type",
392                         type = "ir_type*"
393                 )
394         ],
395         attr_struct = "copyb_attr",
396         pinned      = "memory",
397         pinned_init = "op_pin_state_pinned",
398         d_post = '''
399         #if PRECISE_EXC_CONTEXT
400         firm_alloc_frag_arr(res, op_CopyB, &res->attr.copyb.exc.frag_arr);
401         #endif
402         '''
403 ),
404
405 Div = dict(
406         ins   = [ "mem", "left", "right" ],
407         outs  = [ "M", "X_regular", "X_except", "res" ],
408         flags = "fragile, uses_memory",
409         attrs_name = "divmod",
410         attrs = [
411                 dict(
412                         type = "ir_mode*",
413                         name = "resmode"
414                 ),
415                 dict(
416                         name = "no_remainder",
417                         type = "int",
418                         init = "0",
419                         special = dict(
420                                 suffix = "RL",
421                                 init = "1"
422                         )
423                 )
424         ],
425         attr_struct = "divmod_attr",
426         pinned      = "exception",
427         op_index    = 1,
428         arity_override = "oparity_binary",
429         d_post = '''
430         #if PRECISE_EXC_CONTEXT
431         firm_alloc_frag_arr(res, op_Div, &res->attr.except.frag_arr);
432         #endif
433         '''
434 ),
435
436 DivMod = dict(
437         ins   = [ "mem", "left", "right" ],
438         outs  = [ "M", "X_regular", "X_except", "res_div", "res_mod" ],
439         flags = "fragile, uses_memory",
440         attrs_name = "divmod",
441         attrs = [
442                 dict(
443                         type = "ir_mode*",
444                         name = "resmode"
445                 ),
446         ],
447         attr_struct = "divmod_attr",
448         pinned      = "exception",
449         op_index    = 1,
450         arity_override = "oparity_binary",
451         d_post = '''
452         #if PRECISE_EXC_CONTEXT
453         firm_alloc_frag_arr(res, op_DivMod, &res->attr.except.frag_arr);
454         #endif
455         '''
456 ),
457
458 Dummy = dict(
459         ins   = [],
460         flags = "cfopcode, fragile, start_block, constlike, dump_noblock",
461         knownBlock = True,
462         pinned     = "yes",
463         block      = "get_irg_start_block(irg)",
464 ),
465
466 End = dict(
467         mode       = "mode_X",
468         pinned     = "yes",
469         arity      = "dynamic",
470         flags      = "cfopcode",
471         singleton  = True,
472 ),
473
474 EndExcept = dict(
475         mode      = "mode_X",
476         pinned    = "yes",
477         arity     = "dynamic",
478         flags     = "cfopcode, ip_cfopcode",
479         singleton = True
480 ),
481
482 EndReg = dict(
483         mode      = "mode_X",
484         pinned    = "yes",
485         arity     = "dynamic",
486         flags     = "cfopcode, ip_cfopcode",
487         singleton = True
488 ),
489
490 Eor = dict(
491         is_a     = "binop",
492         flags    = "commutative",
493 ),
494
495 Filter = dict(
496         ins   = [ "pred" ],
497         flags = "none",
498         attrs = [
499                 dict(
500                         name = "proj",
501                         type = "long"
502                 )
503         ],
504         pinned      = "yes",
505         attr_struct = "filter_attr",
506         java_noconstr = True
507
508         # TODO: Broken asserts in original:
509         # assert(get_Proj_pred(res));
510         # assert(get_nodes_block(get_Proj_pred(res)));
511 ),
512
513 Free = dict(
514         ins    = [ "mem", "ptr", "size" ],
515         mode   = "mode_M",
516         flags  = "uses_memory",
517         pinned = "yes",
518         attrs  = [
519                 dict(
520                         name = "type",
521                         type = "ir_type*"
522                 ),
523                 dict(
524                         name = "where",
525                         type = "ir_where_alloc"
526                 )
527         ],
528         attr_struct = "free_attr",
529 ),
530
531 Id = dict(
532         ins    = [ "pred" ],
533         pinned = "no",
534         flags  = "none",
535 ),
536
537 IJmp = dict(
538         mode     = "mode_X",
539         pinned   = "yes",
540         ins      = [ "target" ],
541         flags    = "cfopcode, forking, keep",
542 ),
543
544 InstOf = dict(
545         ins   = [ "store", "obj" ],
546         outs  = [ "M", "X_regular", "X_except", "res", "M_except" ],
547         flags = "highlevel",
548         attrs = [
549                 dict(
550                         name = "type",
551                         type = "ir_type*"
552                 )
553         ],
554         attr_struct = "io_attr",
555         pinned      = "memory",
556         pinned_init = "op_pin_state_floats",
557 ),
558
559 Jmp = dict(
560         mode     = "mode_X",
561         pinned   = "yes",
562         ins      = [],
563         flags    = "cfopcode",
564 ),
565
566 Load = dict(
567         ins      = [ "mem", "ptr" ],
568         outs     = [ "M", "X_regular", "X_except", "res" ],
569         flags    = "fragile, uses_memory",
570         pinned   = "exception",
571         pinned_init = "flags & cons_floats ? op_pin_state_floats : op_pin_state_pinned",
572         attrs    = [
573                 dict(
574                         type = "ir_mode*",
575                         name = "mode",
576                         java_name = "load_mode"
577                 ),
578         ],
579         attr_struct = "load_attr",
580         constructor_args = [
581                 dict(
582                         type = "ir_cons_flags",
583                         name = "flags",
584                 ),
585         ],
586         d_post = '''
587 #if PRECISE_EXC_CONTEXT
588         firm_alloc_frag_arr(res, op_Load, &res->attr.load.exc.frag_arr);
589 #endif
590         '''
591 ),
592
593 Minus = dict(
594         is_a     = "unop",
595         flags    = "none",
596 ),
597
598 Mod = dict(
599         ins   = [ "mem", "left", "right" ],
600         outs  = [ "M", "X_regular", "X_except", "res" ],
601         flags = "fragile, uses_memory",
602         attrs_name = "divmod",
603         attrs = [
604                 dict(
605                         type = "ir_mode*",
606                         name = "resmode"
607                 ),
608         ],
609         attr_struct = "divmod_attr",
610         pinned      = "exception",
611         op_index    = 1,
612         arity_override = "oparity_binary",
613         d_post = '''
614         #if PRECISE_EXC_CONTEXT
615         firm_alloc_frag_arr(res, op_Mod, &res->attr.except.frag_arr);
616         #endif
617         '''
618 ),
619
620 Mul = dict(
621         is_a     = "binop",
622         flags    = "commutative",
623 ),
624
625 Mulh = dict(
626         is_a     = "binop",
627         flags    = "commutative",
628 ),
629
630 Mux = dict(
631         ins    = [ "sel", "false", "true" ],
632         flags  = "none",
633         pinned = "no",
634 ),
635
636 NoMem = dict(
637         mode       = "mode_M",
638         flags      = "dump_noblock, dump_noinput",
639         pinned     = "yes",
640         knownBlock = True,
641         singleton  = True,
642 ),
643
644 Not = dict(
645         is_a     = "unop",
646         flags    = "none",
647 ),
648
649 Or = dict(
650         is_a     = "binop",
651         flags    = "commutative",
652 ),
653
654 Phi = dict(
655         pinned      = "yes",
656         arity       = "variable",
657         flags       = "none",
658         attr_struct = "phi_attr",
659         custom_is   = True,
660         java_noconstr = True,
661 ),
662
663 Pin = dict(
664         ins      = [ "op" ],
665         mode     = "get_irn_mode(irn_op)",
666         flags    = "highlevel",
667         pinned   = "yes",
668 ),
669
670 Proj = dict(
671         ins      = [ "pred" ],
672         flags    = "none",
673         pinned   = "no",
674         attrs    = [
675                 dict(
676                         type = "long",
677                         name = "proj",
678                         initname = ""
679                 )
680         ],
681         attr_struct = "long",
682         custom_is   = True,
683 ),
684
685 Quot = dict(
686         ins   = [ "mem", "left", "right" ],
687         outs  = [ "M", "X_regular", "X_except", "res" ],
688         flags = "fragile, uses_memory",
689         attrs_name = "divmod",
690         attrs = [
691                 dict(
692                         type = "ir_mode*",
693                         name = "resmode"
694                 ),
695         ],
696         attr_struct = "divmod_attr",
697         pinned      = "exception",
698         op_index    = 1,
699         arity_override = "oparity_binary",
700         d_post = '''
701         #if PRECISE_EXC_CONTEXT
702         firm_alloc_frag_arr(res, op_Quot, &res->attr.except.frag_arr);
703         #endif
704         '''
705 ),
706
707 Raise = dict(
708         ins    = [ "mem", "exo_ptr" ],
709         outs   = [ "M", "X" ],
710         flags  = "highlevel, cfopcode",
711         pinned = "yes",
712 ),
713
714 Return = dict(
715         ins      = [ "mem" ],
716         arity    = "variable",
717         mode     = "mode_X",
718         flags    = "cfopcode",
719         pinned   = "yes",
720 ),
721
722 Rotl = dict(
723         is_a     = "binop",
724         flags    = "none",
725 ),
726
727 Sel = dict(
728         ins    = [ "mem", "ptr" ],
729         arity  = "variable",
730         flags  = "none",
731         mode   = "is_Method_type(get_entity_type(entity)) ? mode_P_code : mode_P_data",
732         pinned = "no",
733         attrs  = [
734                 dict(
735                         type = "ir_entity*",
736                         name = "entity"
737                 )
738         ],
739         attr_struct = "sel_attr",
740 ),
741
742 Shl = dict(
743         is_a     = "binop",
744         flags    = "none",
745 ),
746
747 Shr = dict(
748         is_a     = "binop",
749         flags    = "none",
750 ),
751
752 Shrs = dict(
753         is_a     = "binop",
754         flags    = "none",
755 ),
756
757 Start = dict(
758         mode       = "mode_T",
759         pinned     = "yes",
760         flags      = "cfopcode",
761         singleton  = True,
762 ),
763
764 Store = dict(
765         ins      = [ "mem", "ptr", "value" ],
766         outs     = [ "M", "X_regular", "X_except" ],
767         flags    = "fragile, uses_memory",
768         pinned   = "exception",
769         attr_struct = "store_attr",
770         pinned_init = "flags & cons_floats ? op_pin_state_floats : op_pin_state_pinned",
771         constructor_args = [
772                 dict(
773                         type = "ir_cons_flags",
774                         name = "flags",
775                 ),
776         ],
777         d_post = '''
778 #if PRECISE_EXC_CONTEXT
779         firm_alloc_frag_arr(res, op_Store, &res->attr.store.exc.frag_arr);
780 #endif
781         '''
782 ),
783
784 Sub = dict(
785         is_a     = "binop",
786         flags    = "none",
787 ),
788
789 SymConst = dict(
790         mode       = "mode_P",
791         flags      = "constlike, start_block",
792         knownBlock = True,
793         pinned     = "no",
794         attrs      = [
795                 dict(
796                         type = "ir_entity*",
797                         name = "entity"
798                 )
799         ],
800         attr_struct = "symconst_attr",
801         java_noconstr = True,
802 ),
803
804 Sync = dict(
805         mode     = "mode_M",
806         flags    = "none",
807         pinned   = "no",
808         optimize = False,
809         arity    = "dynamic"
810 ),
811
812 Tuple = dict(
813         arity  = "variable",
814         mode   = "mode_T",
815         pinned = "no",
816         flags  = "labeled",
817         java_noconstr = True
818 ),
819
820 Unknown = dict(
821         knownBlock = True,
822         pinned     = "yes",
823         block      = "get_irg_start_block(irg)",
824         flags      = "cfopcode, fragile, start_block, constlike, dump_noblock",
825 ),
826 )