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 #if PRECISE_EXC_CONTEXT
47 firm_alloc_frag_arr(res, op_Alloc, &res->attr.alloc.exc.frag_arr);
54 flags = [ "dump_noblock" ]
60 flags = [ "commutative" ]
65 flags = [ "keep", "uses_memory" ]
66 attr_struct = "asm_attr"
68 pinned_init = "op_pin_state_pinned"
71 name = "input_constraints",
72 type = "ir_asm_constraint*",
75 name = "n_output_constraints",
79 name = "output_constraints",
80 type = "ir_asm_constraint*",
99 flags = [ "cfopcode", "fragile", "start_block", "dump_noblock" ]
104 res->attr.irg.irg = irg;
114 flags = [ "labeled" ]
115 attr_struct = "block_attr"
119 /* macroblock header */
122 res->attr.block.is_dead = 0;
123 res->attr.block.is_mb_head = 1;
124 res->attr.block.irg.irg = irg;
125 res->attr.block.backedge = new_backedge_arr(irg->obst, arity);
126 res->attr.block.in_cg = NULL;
127 res->attr.block.cg_backedge = NULL;
128 res->attr.block.extblk = NULL;
129 res->attr.block.mb_depth = 0;
130 res->attr.block.entity = NULL;
132 set_Block_matured(res, 1);
133 set_Block_block_visited(res, 0);
142 /* Create and initialize array for Phi-node construction. */
143 if (get_irg_phase_state(current_ir_graph) == phase_building) {
144 res->attr.block.graph_arr = NEW_ARR_D(ir_node *, current_ir_graph->obst,
145 current_ir_graph->n_loc);
146 memset(res->attr.block.graph_arr, 0, sizeof(ir_node *)*current_ir_graph->n_loc);
149 for (i = arity - 1; i >= 0; i--)
150 if (is_Unknown(in[i])) {
155 if (!has_unknown) res = optimize_node(res);
157 current_ir_graph->current_block = res;
159 IRN_VRFY_IRG(res, current_ir_graph);
163 public void addPred(Node node) {
164 binding_cons.add_immBlock_pred(ptr, node.ptr);
167 public void mature() {
168 binding_cons.mature_immBlock(ptr);
172 public Block getBlock() {
176 public boolean blockVisited() {
177 return 0 != binding.Block_block_visited(ptr);
180 public void markBlockVisited() {
181 binding.mark_Block_block_visited(ptr);
184 public boolean isBad() {
185 return binding.is_Bad(ptr) != 0;
193 ins = [ "mem", "index", "lower", "upper" ]
194 outs = [ "M", "X_regular", "X_except", "res" ]
195 flags = [ "fragile", "highlevel" ]
197 pinned_init = "op_pin_state_pinned"
198 attr_struct = "bound_attr"
200 #if PRECISE_EXC_CONTEXT
201 firm_alloc_frag_arr(res, op_Bound, &res->attr.bound.exc.frag_arr);
207 flags = [ "cfopcode" ]
213 outs = [ "M_regular", "X_regular", "X_except", "T_result", "M_except", "P_value_res_base" ]
214 flags = [ "uses_memory" ]
217 type = "ir_builtin_kind",
226 pinned_init = "op_pin_state_pinned"
227 attr_struct = "builtin_attr"
229 assert((get_unknown_type() == type) || is_Method_type(type));
233 ins = [ "mem", "ptr" ]
235 outs = [ "M_regular", "X_regular", "X_except", "T_result", "M_except", "P_value_res_base" ]
236 flags = [ "fragile", "uses_memory" ]
243 attr_struct = "call_attr"
245 pinned_init = "op_pin_state_pinned"
247 assert((get_unknown_type() == type) || is_Method_type(type));
250 #if PRECISE_EXC_CONTEXT
251 firm_alloc_frag_arr(res, op_Call, &res->attr.call.exc.frag_arr);
258 flags = [ "cfopcode", "ip_cfopcode" ]
260 # TODO: attribute with call...
261 attr_struct = "callbegin_attr"
271 flags = [ "commutative" ]
275 mode = "get_irn_mode(irn_op)"
276 flags = [ "highlevel" ]
284 attr_struct = "cast_attr"
285 init = "assert(is_atomic_type(type));"
288 outs = [ "False", "Eq", "Lt", "Le", "Gt", "Ge", "Lg", "Leg", "Uo", "Ue", "Ul", "Ule", "Ug", "Uge", "Ne", "True" ]
293 outs = [ "false", "true" ]
294 flags = [ "cfopcode", "forking" ]
303 name = "default_proj",
309 type = "cond_jmp_predicate",
310 init = "COND_JMP_PRED_NONE"
313 attr_struct = "cond_attr"
316 ins = [ "value", "bound" ]
317 mode = "get_irn_mode(irn_value)"
318 flags = [ "highlevel" ]
326 attr_struct = "confirm_attr"
330 flags = [ "constlike", "start_block" ]
340 attr_struct = "const_attr"
355 attr_struct = "conv_attr"
358 ins = [ "mem", "dst", "src" ]
359 outs = [ "M", "X_regular", "X_except" ]
360 flags = [ "fragile", "highlevel", "uses_memory" ]
367 attr_struct = "copyb_attr"
369 pinned_init = "op_pin_state_pinned"
371 #if PRECISE_EXC_CONTEXT
372 firm_alloc_frag_arr(res, op_CopyB, &res->attr.copyb.exc.frag_arr);
377 ins = [ "mem", "left", "right" ]
378 outs = [ "M", "X_regular", "X_except", "res" ]
379 flags = [ "fragile", "uses_memory" ]
380 attrs_name = "divmod"
387 name = "no_remainder",
396 attr_struct = "divmod_attr"
399 arity_override = "oparity_binary"
401 #if PRECISE_EXC_CONTEXT
402 firm_alloc_frag_arr(res, op_Div, &res->attr.except.frag_arr);
407 ins = [ "mem", "left", "right" ]
408 outs = [ "M", "X_regular", "X_except", "res_div", "res_mod" ]
409 flags = [ "fragile", "uses_memory" ]
410 attrs_name = "divmod"
417 attr_struct = "divmod_attr"
420 arity_override = "oparity_binary"
422 #if PRECISE_EXC_CONTEXT
423 firm_alloc_frag_arr(res, op_DivMod, &res->attr.except.frag_arr);
429 flags = [ "cfopcode", "fragile", "start_block", "constlike",
433 block = "get_irg_start_block(irg)"
439 flags = [ "cfopcode" ]
446 flags = [ "cfopcode", "ip_cfopcode" ]
453 flags = [ "cfopcode", "ip_cfopcode" ]
457 flags = [ "commutative" ]
469 attr_struct = "filter_attr"
473 ins = [ "mem", "ptr", "size" ]
475 flags = [ "uses_memory" ]
484 type = "ir_where_alloc"
487 attr_struct = "free_attr"
498 flags = [ "cfopcode", "forking", "keep" ]
501 ins = [ "store", "obj" ]
502 outs = [ "M", "X_regular", "X_except", "res", "M_except" ]
503 flags = [ "highlevel" ]
510 attr_struct = "io_attr"
512 pinned_init = "op_pin_state_floats"
518 flags = [ "cfopcode" ]
521 ins = [ "mem", "ptr" ]
522 outs = [ "M", "X_regular", "X_except", "res" ]
523 flags = [ "fragile", "uses_memory" ]
525 pinned_init = "flags & cons_floats ? op_pin_state_floats : op_pin_state_pinned"
530 java_name = "load_mode"
533 attr_struct = "load_attr"
536 type = "ir_cons_flags",
541 #if PRECISE_EXC_CONTEXT
542 firm_alloc_frag_arr(res, op_Load, &res->attr.load.exc.frag_arr);
550 ins = [ "mem", "left", "right" ]
551 outs = [ "M", "X_regular", "X_except", "res" ]
552 flags = [ "fragile", "uses_memory" ]
553 attrs_name = "divmod"
560 attr_struct = "divmod_attr"
563 arity_override = "oparity_binary"
565 #if PRECISE_EXC_CONTEXT
566 firm_alloc_frag_arr(res, op_Mod, &res->attr.except.frag_arr);
571 flags = [ "commutative" ]
574 flags = [ "commutative" ]
577 ins = [ "sel", "false", "true" ]
583 flags = [ "dump_noblock", "dump_noinput" ]
592 flags = [ "commutative" ]
598 attr_struct = "phi_attr"
602 /* Memory Phis in endless loops must be kept alive.
603 As we can't distinguish these easily we keep all of them alive. */
604 if (is_Phi(res) && mode == mode_M)
605 add_End_keepalive(get_irg_end(irg), res);
610 mode = "get_irn_mode(irn_op)"
611 flags = [ "highlevel" ]
629 ins = [ "mem", "left", "right" ]
630 outs = [ "M", "X_regular", "X_except", "res" ]
631 flags = [ "fragile", "uses_memory" ]
632 attrs_name = "divmod"
639 attr_struct = "divmod_attr"
642 arity_override = "oparity_binary"
644 #if PRECISE_EXC_CONTEXT
645 firm_alloc_frag_arr(res, op_Quot, &res->attr.except.frag_arr);
650 ins = [ "mem", "exo_ptr" ]
652 flags = [ "highlevel", "cfopcode" ]
659 flags = [ "cfopcode" ]
666 ins = [ "mem", "ptr" ]
669 mode = "is_Method_type(get_entity_type(entity)) ? mode_P_code : mode_P_data"
677 attr_struct = "sel_attr"
691 flags = [ "cfopcode" ]
695 ins = [ "mem", "ptr", "value" ]
696 outs = [ "M", "X_regular", "X_except" ]
697 flags = [ "fragile", "uses_memory" ]
699 attr_struct = "store_attr"
700 pinned_init = "flags & cons_floats ? op_pin_state_floats : op_pin_state_pinned"
703 type = "ir_cons_flags",
708 #if PRECISE_EXC_CONTEXT
709 firm_alloc_frag_arr(res, op_Store, &res->attr.store.exc.frag_arr);
718 flags = [ "constlike", "start_block" ]
727 attr_struct = "symconst_attr"
741 flags = [ "labeled" ]
747 block = "get_irg_start_block(irg)"
748 flags = [ "cfopcode", "fragile", "start_block", "constlike",
753 def getOpList(namespace):
755 for t in namespace.values():
759 if issubclass(t, Op):
764 nodes = getOpList(globals())
765 nodes = sorted(nodes, lambda x,y: cmp(x.name, y.name))