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" ]
302 name = "default_proj",
308 type = "cond_jmp_predicate",
309 init = "COND_JMP_PRED_NONE"
312 attr_struct = "cond_attr"
315 ins = [ "value", "bound" ]
316 mode = "get_irn_mode(irn_value)"
317 flags = [ "highlevel" ]
325 attr_struct = "confirm_attr"
329 flags = [ "constlike", "start_block" ]
339 attr_struct = "const_attr"
354 attr_struct = "conv_attr"
357 ins = [ "mem", "dst", "src" ]
358 outs = [ "M", "X_regular", "X_except" ]
359 flags = [ "fragile", "highlevel", "uses_memory" ]
366 attr_struct = "copyb_attr"
368 pinned_init = "op_pin_state_pinned"
370 firm_alloc_frag_arr(res, op_CopyB, &res->attr.copyb.exc.frag_arr);
374 ins = [ "mem", "left", "right" ]
375 outs = [ "M", "X_regular", "X_except", "res" ]
376 flags = [ "fragile", "uses_memory" ]
377 attrs_name = "divmod"
384 name = "no_remainder",
393 attr_struct = "divmod_attr"
396 arity_override = "oparity_binary"
398 firm_alloc_frag_arr(res, op_Div, &res->attr.except.frag_arr);
402 ins = [ "mem", "left", "right" ]
403 outs = [ "M", "X_regular", "X_except", "res_div", "res_mod" ]
404 flags = [ "fragile", "uses_memory" ]
405 attrs_name = "divmod"
412 attr_struct = "divmod_attr"
415 arity_override = "oparity_binary"
417 firm_alloc_frag_arr(res, op_DivMod, &res->attr.except.frag_arr);
422 flags = [ "cfopcode", "fragile", "start_block", "constlike",
426 block = "get_irg_start_block(irg)"
432 flags = [ "cfopcode" ]
439 flags = [ "cfopcode", "ip_cfopcode" ]
446 flags = [ "cfopcode", "ip_cfopcode" ]
450 flags = [ "commutative" ]
462 attr_struct = "filter_attr"
466 ins = [ "mem", "ptr", "size" ]
468 flags = [ "uses_memory" ]
477 type = "ir_where_alloc"
480 attr_struct = "free_attr"
491 flags = [ "cfopcode", "forking", "keep" ]
494 ins = [ "store", "obj" ]
495 outs = [ "M", "X_regular", "X_except", "res" ]
496 flags = [ "highlevel" ]
503 attr_struct = "io_attr"
505 pinned_init = "op_pin_state_floats"
511 flags = [ "cfopcode" ]
514 ins = [ "mem", "ptr" ]
515 outs = [ "M", "X_regular", "X_except", "res" ]
516 flags = [ "fragile", "uses_memory" ]
518 pinned_init = "flags & cons_floats ? op_pin_state_floats : op_pin_state_pinned"
523 java_name = "load_mode"
526 attr_struct = "load_attr"
529 type = "ir_cons_flags",
534 firm_alloc_frag_arr(res, op_Load, &res->attr.load.exc.frag_arr);
541 ins = [ "mem", "left", "right" ]
542 outs = [ "M", "X_regular", "X_except", "res" ]
543 flags = [ "fragile", "uses_memory" ]
544 attrs_name = "divmod"
551 attr_struct = "divmod_attr"
554 arity_override = "oparity_binary"
556 firm_alloc_frag_arr(res, op_Mod, &res->attr.except.frag_arr);
560 flags = [ "commutative" ]
563 flags = [ "commutative" ]
566 ins = [ "sel", "false", "true" ]
572 flags = [ "dump_noblock", "dump_noinput" ]
581 flags = [ "commutative" ]
587 attr_struct = "phi_attr"
591 /* Memory Phis in endless loops must be kept alive.
592 As we can't distinguish these easily we keep all of them alive. */
593 if (is_Phi(res) && mode == mode_M)
594 add_End_keepalive(get_irg_end(irg), res);
599 mode = "get_irn_mode(irn_op)"
600 flags = [ "highlevel" ]
618 ins = [ "mem", "left", "right" ]
619 outs = [ "M", "X_regular", "X_except", "res" ]
620 flags = [ "fragile", "uses_memory" ]
621 attrs_name = "divmod"
628 attr_struct = "divmod_attr"
631 arity_override = "oparity_binary"
633 firm_alloc_frag_arr(res, op_Quot, &res->attr.except.frag_arr);
637 ins = [ "mem", "exo_ptr" ]
639 flags = [ "highlevel", "cfopcode" ]
646 flags = [ "cfopcode" ]
653 ins = [ "mem", "ptr" ]
656 mode = "is_Method_type(get_entity_type(entity)) ? mode_P_code : mode_P_data"
664 attr_struct = "sel_attr"
678 flags = [ "cfopcode" ]
682 ins = [ "mem", "ptr", "value" ]
683 outs = [ "M", "X_regular", "X_except" ]
684 flags = [ "fragile", "uses_memory" ]
686 attr_struct = "store_attr"
687 pinned_init = "flags & cons_floats ? op_pin_state_floats : op_pin_state_pinned"
690 type = "ir_cons_flags",
695 firm_alloc_frag_arr(res, op_Store, &res->attr.store.exc.frag_arr);
703 flags = [ "constlike", "start_block" ]
712 attr_struct = "symconst_attr"
726 flags = [ "labeled" ]
732 block = "get_irg_start_block(irg)"
733 flags = [ "cfopcode", "fragile", "start_block", "constlike",
738 def getOpList(namespace):
740 for t in namespace.values():
744 if issubclass(t, Op):
749 nodes = getOpList(globals())
750 nodes = sorted(nodes, lambda x,y: cmp(x.name, y.name))