1 from spec_util import abstract, setnodedefaults
4 "Base class for firm nodes"
8 "Unary nodes have exactly 1 input"
16 "Binary nodes have exactly 2 inputs"
18 ins = [ "left", "right" ]
27 flags = ["commutative"]
30 ins = [ "mem", "size" ]
31 outs = [ "M", "X_regular", "X_except", "res" ]
32 flags = [ "fragile", "uses_memory" ]
40 type = "ir_where_alloc"
44 attr_struct = "alloc_attr"
46 firm_alloc_frag_arr(res, op_Alloc, &res->attr.alloc.exc.frag_arr);
52 flags = [ "dump_noblock" ]
58 flags = [ "commutative" ]
63 flags = [ "keep", "uses_memory" ]
64 attr_struct = "asm_attr"
66 pinned_init = "op_pin_state_pinned"
69 name = "input_constraints",
70 type = "ir_asm_constraint*",
73 name = "n_output_constraints",
77 name = "output_constraints",
78 type = "ir_asm_constraint*",
97 flags = [ "cfopcode", "fragile", "start_block", "dump_noblock" ]
101 attr_struct = "irg_attr"
103 res->attr.irg.irg = irg;
113 flags = [ "labeled" ]
114 attr_struct = "block_attr"
118 /* macroblock header */
121 res->attr.block.is_dead = 0;
122 res->attr.block.is_mb_head = 1;
123 res->attr.block.irg.irg = irg;
124 res->attr.block.backedge = new_backedge_arr(irg->obst, arity);
125 res->attr.block.in_cg = NULL;
126 res->attr.block.cg_backedge = NULL;
127 res->attr.block.extblk = NULL;
128 res->attr.block.mb_depth = 0;
129 res->attr.block.entity = NULL;
131 set_Block_matured(res, 1);
132 set_Block_block_visited(res, 0);
141 /* Create and initialize array for Phi-node construction. */
142 if (get_irg_phase_state(current_ir_graph) == phase_building) {
143 res->attr.block.graph_arr = NEW_ARR_D(ir_node *, current_ir_graph->obst,
144 current_ir_graph->n_loc);
145 memset(res->attr.block.graph_arr, 0, sizeof(ir_node *)*current_ir_graph->n_loc);
148 for (i = arity - 1; i >= 0; i--)
149 if (is_Unknown(in[i])) {
154 if (!has_unknown) res = optimize_node(res);
156 current_ir_graph->current_block = res;
158 IRN_VRFY_IRG(res, current_ir_graph);
162 public void addPred(Node node) {
163 binding_cons.add_immBlock_pred(ptr, node.ptr);
166 public void mature() {
167 binding_cons.mature_immBlock(ptr);
171 public Block getBlock() {
175 public boolean blockVisited() {
176 return 0 != binding.Block_block_visited(ptr);
179 public void markBlockVisited() {
180 binding.mark_Block_block_visited(ptr);
183 public boolean isBad() {
184 return binding.is_Bad(ptr) != 0;
192 ins = [ "mem", "index", "lower", "upper" ]
193 outs = [ "M", "X_regular", "X_except", "res" ]
194 flags = [ "fragile", "highlevel" ]
196 pinned_init = "op_pin_state_pinned"
197 attr_struct = "bound_attr"
199 firm_alloc_frag_arr(res, op_Bound, &res->attr.bound.exc.frag_arr);
204 flags = [ "cfopcode" ]
210 outs = [ "M", "X_regular", "X_except", "T_result", "P_value_res_base" ]
211 flags = [ "uses_memory" ]
214 type = "ir_builtin_kind",
223 pinned_init = "op_pin_state_pinned"
224 attr_struct = "builtin_attr"
226 assert((get_unknown_type() == type) || is_Method_type(type));
230 ins = [ "mem", "ptr" ]
232 outs = [ "M", "X_regular", "X_except", "T_result", "P_value_res_base" ]
233 flags = [ "fragile", "uses_memory" ]
242 # the tail call attribute can only be set by analysis
246 attr_struct = "call_attr"
248 pinned_init = "op_pin_state_pinned"
250 assert((get_unknown_type() == type) || is_Method_type(type));
253 firm_alloc_frag_arr(res, op_Call, &res->attr.call.exc.frag_arr);
259 flags = [ "cfopcode", "ip_cfopcode" ]
261 # TODO: attribute with call...
262 attr_struct = "callbegin_attr"
272 flags = [ "commutative" ]
275 mode = "get_irn_mode(irn_op)"
276 flags = [ "highlevel" ]
283 attr_struct = "cast_attr"
284 init = "assert(is_atomic_type(type));"
287 outs = [ "False", "Eq", "Lt", "Le", "Gt", "Ge", "Lg", "Leg", "Uo", "Ue", "Ul", "Ule", "Ug", "Uge", "Ne", "True" ]
292 outs = [ "false", "true" ]
293 flags = [ "cfopcode", "forking" ]
297 name = "default_proj",
303 type = "cond_jmp_predicate",
304 init = "COND_JMP_PRED_NONE"
307 attr_struct = "cond_attr"
310 ins = [ "value", "bound" ]
311 mode = "get_irn_mode(irn_value)"
312 flags = [ "highlevel" ]
320 attr_struct = "confirm_attr"
324 flags = [ "constlike", "start_block" ]
334 attr_struct = "const_attr"
349 attr_struct = "conv_attr"
352 ins = [ "mem", "dst", "src" ]
353 outs = [ "M", "X_regular", "X_except" ]
354 flags = [ "fragile", "highlevel", "uses_memory" ]
361 attr_struct = "copyb_attr"
363 pinned_init = "op_pin_state_pinned"
365 firm_alloc_frag_arr(res, op_CopyB, &res->attr.copyb.exc.frag_arr);
369 ins = [ "mem", "left", "right" ]
370 outs = [ "M", "X_regular", "X_except", "res" ]
371 flags = [ "fragile", "uses_memory" ]
372 attrs_name = "divmod"
379 name = "no_remainder",
388 attr_struct = "divmod_attr"
391 arity_override = "oparity_binary"
393 firm_alloc_frag_arr(res, op_Div, &res->attr.except.frag_arr);
397 ins = [ "mem", "left", "right" ]
398 outs = [ "M", "X_regular", "X_except", "res_div", "res_mod" ]
399 flags = [ "fragile", "uses_memory" ]
400 attrs_name = "divmod"
407 attr_struct = "divmod_attr"
410 arity_override = "oparity_binary"
412 firm_alloc_frag_arr(res, op_DivMod, &res->attr.except.frag_arr);
417 flags = [ "cfopcode", "fragile", "start_block", "constlike",
421 block = "get_irg_start_block(irg)"
427 flags = [ "cfopcode" ]
434 flags = [ "cfopcode", "ip_cfopcode" ]
441 flags = [ "cfopcode", "ip_cfopcode" ]
445 flags = [ "commutative" ]
457 attr_struct = "filter_attr"
461 ins = [ "mem", "ptr", "size" ]
463 flags = [ "uses_memory" ]
472 type = "ir_where_alloc"
475 attr_struct = "free_attr"
486 flags = [ "cfopcode", "forking", "keep" ]
489 ins = [ "store", "obj" ]
490 outs = [ "M", "X_regular", "X_except", "res" ]
491 flags = [ "highlevel" ]
498 attr_struct = "io_attr"
500 pinned_init = "op_pin_state_floats"
506 flags = [ "cfopcode" ]
509 ins = [ "mem", "ptr" ]
510 outs = [ "M", "X_regular", "X_except", "res" ]
511 flags = [ "fragile", "uses_memory" ]
513 pinned_init = "flags & cons_floats ? op_pin_state_floats : op_pin_state_pinned"
518 java_name = "load_mode"
521 attr_struct = "load_attr"
524 type = "ir_cons_flags",
529 firm_alloc_frag_arr(res, op_Load, &res->attr.load.exc.frag_arr);
536 ins = [ "mem", "left", "right" ]
537 outs = [ "M", "X_regular", "X_except", "res" ]
538 flags = [ "fragile", "uses_memory" ]
539 attrs_name = "divmod"
546 attr_struct = "divmod_attr"
549 arity_override = "oparity_binary"
551 firm_alloc_frag_arr(res, op_Mod, &res->attr.except.frag_arr);
555 flags = [ "commutative" ]
558 flags = [ "commutative" ]
561 ins = [ "sel", "false", "true" ]
567 flags = [ "dump_noblock", "dump_noinput" ]
576 flags = [ "commutative" ]
582 attr_struct = "phi_attr"
586 /* Memory Phis in endless loops must be kept alive.
587 As we can't distinguish these easily we keep all of them alive. */
588 if (is_Phi(res) && mode == mode_M)
589 add_End_keepalive(get_irg_end(irg), res);
594 mode = "get_irn_mode(irn_op)"
595 flags = [ "highlevel" ]
613 ins = [ "mem", "left", "right" ]
614 outs = [ "M", "X_regular", "X_except", "res" ]
615 flags = [ "fragile", "uses_memory" ]
616 attrs_name = "divmod"
623 attr_struct = "divmod_attr"
626 arity_override = "oparity_binary"
628 firm_alloc_frag_arr(res, op_Quot, &res->attr.except.frag_arr);
632 ins = [ "mem", "exo_ptr" ]
634 flags = [ "highlevel", "cfopcode" ]
641 flags = [ "cfopcode" ]
648 ins = [ "mem", "ptr" ]
651 mode = "is_Method_type(get_entity_type(entity)) ? mode_P_code : mode_P_data"
659 attr_struct = "sel_attr"
673 flags = [ "cfopcode" ]
677 ins = [ "mem", "ptr", "value" ]
678 outs = [ "M", "X_regular", "X_except" ]
679 flags = [ "fragile", "uses_memory" ]
681 attr_struct = "store_attr"
682 pinned_init = "flags & cons_floats ? op_pin_state_floats : op_pin_state_pinned"
685 type = "ir_cons_flags",
690 firm_alloc_frag_arr(res, op_Store, &res->attr.store.exc.frag_arr);
698 flags = [ "constlike", "start_block" ]
707 attr_struct = "symconst_attr"
721 flags = [ "labeled" ]
727 block = "get_irg_start_block(irg)"
728 flags = [ "cfopcode", "fragile", "start_block", "constlike",
733 def getOpList(namespace):
735 for t in namespace.values():
739 if issubclass(t, Op):
744 nodes = getOpList(globals())
745 nodes = sorted(nodes, lambda x,y: cmp(x.name, y.name))