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_regular", "X_regular", "X_except", "T_result", "M_except", "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_regular", "X_regular", "X_except", "T_result", "M_except", "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" ]
276 mode = "get_irn_mode(irn_op)"
277 flags = [ "highlevel" ]
285 attr_struct = "cast_attr"
286 init = "assert(is_atomic_type(type));"
289 outs = [ "False", "Eq", "Lt", "Le", "Gt", "Ge", "Lg", "Leg", "Uo", "Ue", "Ul", "Ule", "Ug", "Uge", "Ne", "True" ]
294 outs = [ "false", "true" ]
295 flags = [ "cfopcode", "forking" ]
304 name = "default_proj",
310 type = "cond_jmp_predicate",
311 init = "COND_JMP_PRED_NONE"
314 attr_struct = "cond_attr"
317 ins = [ "value", "bound" ]
318 mode = "get_irn_mode(irn_value)"
319 flags = [ "highlevel" ]
327 attr_struct = "confirm_attr"
331 flags = [ "constlike", "start_block" ]
341 attr_struct = "const_attr"
356 attr_struct = "conv_attr"
359 ins = [ "mem", "dst", "src" ]
360 outs = [ "M", "X_regular", "X_except" ]
361 flags = [ "fragile", "highlevel", "uses_memory" ]
368 attr_struct = "copyb_attr"
370 pinned_init = "op_pin_state_pinned"
372 firm_alloc_frag_arr(res, op_CopyB, &res->attr.copyb.exc.frag_arr);
376 ins = [ "mem", "left", "right" ]
377 outs = [ "M", "X_regular", "X_except", "res" ]
378 flags = [ "fragile", "uses_memory" ]
379 attrs_name = "divmod"
386 name = "no_remainder",
395 attr_struct = "divmod_attr"
398 arity_override = "oparity_binary"
400 firm_alloc_frag_arr(res, op_Div, &res->attr.except.frag_arr);
404 ins = [ "mem", "left", "right" ]
405 outs = [ "M", "X_regular", "X_except", "res_div", "res_mod" ]
406 flags = [ "fragile", "uses_memory" ]
407 attrs_name = "divmod"
414 attr_struct = "divmod_attr"
417 arity_override = "oparity_binary"
419 firm_alloc_frag_arr(res, op_DivMod, &res->attr.except.frag_arr);
424 flags = [ "cfopcode", "fragile", "start_block", "constlike",
428 block = "get_irg_start_block(irg)"
434 flags = [ "cfopcode" ]
441 flags = [ "cfopcode", "ip_cfopcode" ]
448 flags = [ "cfopcode", "ip_cfopcode" ]
452 flags = [ "commutative" ]
464 attr_struct = "filter_attr"
468 ins = [ "mem", "ptr", "size" ]
470 flags = [ "uses_memory" ]
479 type = "ir_where_alloc"
482 attr_struct = "free_attr"
493 flags = [ "cfopcode", "forking", "keep" ]
496 ins = [ "store", "obj" ]
497 outs = [ "M", "X_regular", "X_except", "res", "M_except" ]
498 flags = [ "highlevel" ]
505 attr_struct = "io_attr"
507 pinned_init = "op_pin_state_floats"
513 flags = [ "cfopcode" ]
516 ins = [ "mem", "ptr" ]
517 outs = [ "M", "X_regular", "X_except", "res" ]
518 flags = [ "fragile", "uses_memory" ]
520 pinned_init = "flags & cons_floats ? op_pin_state_floats : op_pin_state_pinned"
525 java_name = "load_mode"
528 attr_struct = "load_attr"
531 type = "ir_cons_flags",
536 firm_alloc_frag_arr(res, op_Load, &res->attr.load.exc.frag_arr);
543 ins = [ "mem", "left", "right" ]
544 outs = [ "M", "X_regular", "X_except", "res" ]
545 flags = [ "fragile", "uses_memory" ]
546 attrs_name = "divmod"
553 attr_struct = "divmod_attr"
556 arity_override = "oparity_binary"
558 firm_alloc_frag_arr(res, op_Mod, &res->attr.except.frag_arr);
562 flags = [ "commutative" ]
565 flags = [ "commutative" ]
568 ins = [ "sel", "false", "true" ]
574 flags = [ "dump_noblock", "dump_noinput" ]
583 flags = [ "commutative" ]
589 attr_struct = "phi_attr"
593 /* Memory Phis in endless loops must be kept alive.
594 As we can't distinguish these easily we keep all of them alive. */
595 if (is_Phi(res) && mode == mode_M)
596 add_End_keepalive(get_irg_end(irg), res);
601 mode = "get_irn_mode(irn_op)"
602 flags = [ "highlevel" ]
620 ins = [ "mem", "left", "right" ]
621 outs = [ "M", "X_regular", "X_except", "res" ]
622 flags = [ "fragile", "uses_memory" ]
623 attrs_name = "divmod"
630 attr_struct = "divmod_attr"
633 arity_override = "oparity_binary"
635 firm_alloc_frag_arr(res, op_Quot, &res->attr.except.frag_arr);
639 ins = [ "mem", "exo_ptr" ]
641 flags = [ "highlevel", "cfopcode" ]
648 flags = [ "cfopcode" ]
655 ins = [ "mem", "ptr" ]
658 mode = "is_Method_type(get_entity_type(entity)) ? mode_P_code : mode_P_data"
666 attr_struct = "sel_attr"
680 flags = [ "cfopcode" ]
684 ins = [ "mem", "ptr", "value" ]
685 outs = [ "M", "X_regular", "X_except" ]
686 flags = [ "fragile", "uses_memory" ]
688 attr_struct = "store_attr"
689 pinned_init = "flags & cons_floats ? op_pin_state_floats : op_pin_state_pinned"
692 type = "ir_cons_flags",
697 firm_alloc_frag_arr(res, op_Store, &res->attr.store.exc.frag_arr);
705 flags = [ "constlike", "start_block" ]
714 attr_struct = "symconst_attr"
728 flags = [ "labeled" ]
734 block = "get_irg_start_block(irg)"
735 flags = [ "cfopcode", "fragile", "start_block", "constlike",
740 def getOpList(namespace):
742 for t in namespace.values():
746 if issubclass(t, Op):
751 nodes = getOpList(globals())
752 nodes = sorted(nodes, lambda x,y: cmp(x.name, y.name))