more fixes for strange op entries
[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         java_noconstr = True,
280         init = '''
281         res->attr.callbegin.call = call;
282         ''',
283 ),
284
285 Carry = dict(
286         is_a     = "binop",
287         flags    = "commutative",
288 ),
289
290 Cast = dict(
291         ins      = [ "op" ],
292         mode     = "get_irn_mode(irn_op)",
293         flags    = "highlevel",
294         pinned   = "no",
295         attrs    = [
296                 dict(
297                         type = "ir_type*",
298                         name = "type"
299                 )
300         ],
301         attr_struct = "cast_attr",
302         init     = "assert(is_atomic_type(type));"
303 ),
304
305 Cmp = dict(
306         is_a     = "binop",
307         outs     = [ "False", "Eq", "Lt", "Le", "Gt", "Ge", "Lg", "Leg", "Uo", "Ue", "Ul", "Ule", "Ug", "Uge", "Ne", "True" ],
308         flags    = "none",
309 ),
310
311 Cond = dict(
312         ins      = [ "selector" ],
313         outs     = [ "false", "true" ],
314         flags    = "cfopcode, forking",
315         pinned   = "yes",
316         attrs    = [
317                 dict(
318                         name = "kind",
319                         type = "cond_kind",
320                         init = "dense"
321                 ),
322                 dict(
323                         name = "default_proj",
324                         type = "long",
325                         init = "0"
326                 ),
327                 dict(
328                         name = "jmp_pred",
329                         type = "cond_jmp_predicate",
330                         init = "COND_JMP_PRED_NONE"
331                 )
332         ],
333         attr_struct = "cond_attr"
334 ),
335
336 Confirm = dict(
337         ins      = [ "value", "bound" ],
338         mode     = "get_irn_mode(irn_value)",
339         flags    = "highlevel",
340         pinned   = "yes",
341         attrs    = [
342                 dict(
343                         name = "cmp",
344                         type = "pn_Cmp"
345                 ),
346         ],
347         attr_struct = "confirm_attr",
348 ),
349
350 Const = dict(
351         mode       = "",
352         flags      = "constlike, start_block",
353         knownBlock = True,
354         pinned     = "no",
355         attrs_name = "con",
356         attrs      = [
357                 dict(
358                         type = "tarval*",
359                         name = "tarval",
360                 )
361         ],
362         attr_struct = "const_attr",
363 ),
364
365 Conv = dict(
366         is_a     = "unop",
367         flags    = "none",
368         attrs = [
369                 dict(
370                         name = "strict",
371                         type = "int",
372                         init = "0",
373                         special = dict(
374                                 prefix = "strict",
375                                 init = "1"
376                         )
377                 )
378         ],
379         attr_struct = "conv_attr",
380 ),
381
382 CopyB = dict(
383         ins   = [ "mem", "dst", "src" ],
384         outs  = [ "M", "X_regular", "X_except" ],
385         flags = "fragile, highlevel, uses_memory",
386         attrs = [
387                 dict(
388                         name = "type",
389                         type = "ir_type*"
390                 )
391         ],
392         attr_struct = "copyb_attr",
393         pinned      = "memory",
394         pinned_init = "op_pin_state_pinned",
395         d_post = '''
396         #if PRECISE_EXC_CONTEXT
397         firm_alloc_frag_arr(res, op_CopyB, &res->attr.copyb.exc.frag_arr);
398         #endif
399         '''
400 ),
401
402 Div = dict(
403         ins   = [ "mem", "left", "right" ],
404         outs  = [ "M", "X_regular", "X_except", "res" ],
405         flags = "fragile, uses_memory",
406         attrs_name = "divmod",
407         attrs = [
408                 dict(
409                         type = "ir_mode*",
410                         name = "resmode"
411                 ),
412                 dict(
413                         name = "no_remainder",
414                         type = "int",
415                         init = "0",
416                         special = dict(
417                                 suffix = "RL",
418                                 init = "1"
419                         )
420                 )
421         ],
422         attr_struct = "divmod_attr",
423         pinned      = "exception",
424         op_index    = 1,
425         arity_override = "oparity_binary",
426         d_post = '''
427         #if PRECISE_EXC_CONTEXT
428         firm_alloc_frag_arr(res, op_Div, &res->attr.except.frag_arr);
429         #endif
430         '''
431 ),
432
433 DivMod = dict(
434         ins   = [ "mem", "left", "right" ],
435         outs  = [ "M", "X_regular", "X_except", "res_div", "res_mod" ],
436         flags = "fragile, uses_memory",
437         attrs_name = "divmod",
438         attrs = [
439                 dict(
440                         type = "ir_mode*",
441                         name = "resmode"
442                 ),
443         ],
444         attr_struct = "divmod_attr",
445         pinned      = "exception",
446         op_index    = 1,
447         arity_override = "oparity_binary",
448         d_post = '''
449         #if PRECISE_EXC_CONTEXT
450         firm_alloc_frag_arr(res, op_DivMod, &res->attr.except.frag_arr);
451         #endif
452         '''
453 ),
454
455 Dummy = dict(
456         ins   = [],
457         flags = "cfopcode, fragile, start_block, constlike, dump_noblock",
458         knownBlock = True,
459         pinned     = "yes",
460         block      = "get_irg_start_block(irg)",
461 ),
462
463 End = dict(
464         mode       = "mode_X",
465         pinned     = "yes",
466         arity      = "dynamic",
467         flags      = "cfopcode",
468         singleton  = True,
469 ),
470
471 EndExcept = dict(
472         mode      = "mode_X",
473         pinned    = "yes",
474         arity     = "dynamic",
475         flags     = "cfopcode, ip_cfopcode",
476         singleton = True
477 ),
478
479 EndReg = dict(
480         mode      = "mode_X",
481         pinned    = "yes",
482         arity     = "dynamic",
483         flags     = "cfopcode, ip_cfopcode",
484         singleton = True
485 ),
486
487 Eor = dict(
488         is_a     = "binop",
489         flags    = "commutative",
490 ),
491
492 Filter = dict(
493         ins   = [ "pred" ],
494         flags = "none",
495         attrs = [
496                 dict(
497                         name = "proj",
498                         type = "long"
499                 )
500         ],
501         pinned      = "yes",
502         attr_struct = "filter_attr",
503         java_noconstr = True
504
505         # TODO: Broken asserts in original:
506         # assert(get_Proj_pred(res));
507         # assert(get_nodes_block(get_Proj_pred(res)));
508 ),
509
510 Free = dict(
511         ins    = [ "mem", "ptr", "size" ],
512         mode   = "mode_M",
513         flags  = "uses_memory",
514         pinned = "yes",
515         attrs  = [
516                 dict(
517                         name = "type",
518                         type = "ir_type*"
519                 ),
520                 dict(
521                         name = "where",
522                         type = "ir_where_alloc"
523                 )
524         ],
525         attr_struct = "free_attr",
526 ),
527
528 Id = dict(
529         ins    = [ "pred" ],
530         pinned = "no",
531         flags  = "none",
532 ),
533
534 IJmp = dict(
535         mode     = "mode_X",
536         pinned   = "yes",
537         ins      = [ "target" ],
538         flags    = "cfopcode, forking, keep",
539 ),
540
541 InstOf = dict(
542         ins   = [ "store", "obj" ],
543         outs  = [ "M", "X_regular", "X_except", "res", "M_except" ],
544         flags = "highlevel",
545         attrs = [
546                 dict(
547                         name = "type",
548                         type = "ir_type*"
549                 )
550         ],
551         attr_struct = "io_attr",
552         pinned      = "memory",
553         pinned_init = "op_pin_state_floats",
554 ),
555
556 Jmp = dict(
557         mode     = "mode_X",
558         pinned   = "yes",
559         ins      = [],
560         flags    = "cfopcode",
561 ),
562
563 Load = dict(
564         ins      = [ "mem", "ptr" ],
565         outs     = [ "M", "X_regular", "X_except", "res" ],
566         flags    = "fragile, uses_memory",
567         pinned   = "exception",
568         pinned_init = "flags & cons_floats ? op_pin_state_floats : op_pin_state_pinned",
569         attrs    = [
570                 dict(
571                         type = "ir_mode*",
572                         name = "mode",
573                         java_name = "load_mode"
574                 ),
575         ],
576         attr_struct = "load_attr",
577         constructor_args = [
578                 dict(
579                         type = "ir_cons_flags",
580                         name = "flags",
581                 ),
582         ],
583         d_post = '''
584 #if PRECISE_EXC_CONTEXT
585         firm_alloc_frag_arr(res, op_Load, &res->attr.load.exc.frag_arr);
586 #endif
587         '''
588 ),
589
590 Minus = dict(
591         is_a     = "unop",
592         flags    = "none",
593 ),
594
595 Mod = dict(
596         ins   = [ "mem", "left", "right" ],
597         outs  = [ "M", "X_regular", "X_except", "res" ],
598         flags = "fragile, uses_memory",
599         attrs_name = "divmod",
600         attrs = [
601                 dict(
602                         type = "ir_mode*",
603                         name = "resmode"
604                 ),
605         ],
606         attr_struct = "divmod_attr",
607         pinned      = "exception",
608         op_index    = 1,
609         arity_override = "oparity_binary",
610         d_post = '''
611         #if PRECISE_EXC_CONTEXT
612         firm_alloc_frag_arr(res, op_Mod, &res->attr.except.frag_arr);
613         #endif
614         '''
615 ),
616
617 Mul = dict(
618         is_a     = "binop",
619         flags    = "commutative",
620 ),
621
622 Mulh = dict(
623         is_a     = "binop",
624         flags    = "commutative",
625 ),
626
627 Mux = dict(
628         ins    = [ "sel", "false", "true" ],
629         flags  = "none",
630         pinned = "no",
631 ),
632
633 NoMem = dict(
634         mode       = "mode_M",
635         flags      = "dump_noblock, dump_noinput",
636         pinned     = "yes",
637         knownBlock = True,
638         singleton  = True,
639 ),
640
641 Not = dict(
642         is_a     = "unop",
643         flags    = "none",
644 ),
645
646 Or = dict(
647         is_a     = "binop",
648         flags    = "commutative",
649 ),
650
651 Phi = dict(
652         pinned      = "yes",
653         arity       = "variable",
654         flags       = "none",
655         attr_struct = "phi_attr",
656         custom_is   = True,
657         java_noconstr = True,
658 ),
659
660 Pin = dict(
661         ins      = [ "op" ],
662         mode     = "get_irn_mode(irn_op)",
663         flags    = "highlevel",
664         pinned   = "yes",
665 ),
666
667 Proj = dict(
668         ins      = [ "pred" ],
669         flags    = "none",
670         pinned   = "no",
671         attrs    = [
672                 dict(
673                         type = "long",
674                         name = "proj",
675                         initname = ""
676                 )
677         ],
678         attr_struct = "long",
679         custom_is   = True,
680 ),
681
682 Quot = dict(
683         ins   = [ "mem", "left", "right" ],
684         outs  = [ "M", "X_regular", "X_except", "res" ],
685         flags = "fragile, uses_memory",
686         attrs_name = "divmod",
687         attrs = [
688                 dict(
689                         type = "ir_mode*",
690                         name = "resmode"
691                 ),
692         ],
693         attr_struct = "divmod_attr",
694         pinned      = "exception",
695         op_index    = 1,
696         arity_override = "oparity_binary",
697         d_post = '''
698         #if PRECISE_EXC_CONTEXT
699         firm_alloc_frag_arr(res, op_Quot, &res->attr.except.frag_arr);
700         #endif
701         '''
702 ),
703
704 Raise = dict(
705         ins    = [ "mem", "exo_ptr" ],
706         outs   = [ "M", "X" ],
707         flags  = "highlevel, cfopcode",
708         pinned = "yes",
709 ),
710
711 Return = dict(
712         ins      = [ "mem" ],
713         arity    = "variable",
714         mode     = "mode_X",
715         flags    = "cfopcode",
716         pinned   = "yes",
717 ),
718
719 Rotl = dict(
720         is_a     = "binop",
721         flags    = "none",
722 ),
723
724 Sel = dict(
725         ins    = [ "mem", "ptr" ],
726         arity  = "variable",
727         flags  = "none",
728         mode   = "is_Method_type(get_entity_type(entity)) ? mode_P_code : mode_P_data",
729         pinned = "no",
730         attrs  = [
731                 dict(
732                         type = "ir_entity*",
733                         name = "entity"
734                 )
735         ],
736         attr_struct = "sel_attr",
737 ),
738
739 Shl = dict(
740         is_a     = "binop",
741         flags    = "none",
742 ),
743
744 Shr = dict(
745         is_a     = "binop",
746         flags    = "none",
747 ),
748
749 Shrs = dict(
750         is_a     = "binop",
751         flags    = "none",
752 ),
753
754 Start = dict(
755         mode       = "mode_T",
756         pinned     = "yes",
757         flags      = "cfopcode",
758         singleton  = True,
759 ),
760
761 Store = dict(
762         ins      = [ "mem", "ptr", "value" ],
763         outs     = [ "M", "X_regular", "X_except" ],
764         flags    = "fragile, uses_memory",
765         pinned   = "exception",
766         attr_struct = "store_attr",
767         pinned_init = "flags & cons_floats ? op_pin_state_floats : op_pin_state_pinned",
768         constructor_args = [
769                 dict(
770                         type = "ir_cons_flags",
771                         name = "flags",
772                 ),
773         ],
774         d_post = '''
775 #if PRECISE_EXC_CONTEXT
776         firm_alloc_frag_arr(res, op_Store, &res->attr.store.exc.frag_arr);
777 #endif
778         '''
779 ),
780
781 Sub = dict(
782         is_a     = "binop",
783         flags    = "none",
784 ),
785
786 SymConst = dict(
787         mode       = "mode_P",
788         flags      = "constlike, start_block",
789         knownBlock = True,
790         pinned     = "no",
791         attrs      = [
792                 dict(
793                         type = "ir_entity*",
794                         name = "entity"
795                 )
796         ],
797         attr_struct = "symconst_attr",
798         java_noconstr = True,
799 ),
800
801 Sync = dict(
802         mode     = "mode_M",
803         flags    = "none",
804         pinned   = "no",
805         optimize = False,
806         arity    = "dynamic"
807 ),
808
809 Tuple = dict(
810         arity  = "variable",
811         mode   = "mode_T",
812         pinned = "no",
813         flags  = "labeled",
814         java_noconstr = True
815 ),
816
817 Unknown = dict(
818         knownBlock = True,
819         pinned     = "yes",
820         block      = "get_irg_start_block(irg)",
821         flags      = "cfopcode, fragile, start_block, constlike, dump_noblock",
822 ),
823 )