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" ]
103 attr_struct = "irg_attr"
105 res->attr.irg.irg = irg;
115 flags = [ "labeled" ]
116 attr_struct = "block_attr"
120 /* macroblock header */
123 res->attr.block.is_dead = 0;
124 res->attr.block.is_mb_head = 1;
125 res->attr.block.irg.irg = irg;
126 res->attr.block.backedge = new_backedge_arr(irg->obst, arity);
127 res->attr.block.in_cg = NULL;
128 res->attr.block.cg_backedge = NULL;
129 res->attr.block.extblk = NULL;
130 res->attr.block.mb_depth = 0;
131 res->attr.block.entity = NULL;
133 set_Block_matured(res, 1);
134 set_Block_block_visited(res, 0);
143 /* Create and initialize array for Phi-node construction. */
144 if (get_irg_phase_state(current_ir_graph) == phase_building) {
145 res->attr.block.graph_arr = NEW_ARR_D(ir_node *, current_ir_graph->obst,
146 current_ir_graph->n_loc);
147 memset(res->attr.block.graph_arr, 0, sizeof(ir_node *)*current_ir_graph->n_loc);
150 for (i = arity - 1; i >= 0; i--)
151 if (is_Unknown(in[i])) {
156 if (!has_unknown) res = optimize_node(res);
158 current_ir_graph->current_block = res;
160 IRN_VRFY_IRG(res, current_ir_graph);
164 public void addPred(Node node) {
165 binding_cons.add_immBlock_pred(ptr, node.ptr);
168 public void mature() {
169 binding_cons.mature_immBlock(ptr);
173 public Block getBlock() {
177 public boolean blockVisited() {
178 return 0 != binding.Block_block_visited(ptr);
181 public void markBlockVisited() {
182 binding.mark_Block_block_visited(ptr);
185 public boolean isBad() {
186 return binding.is_Bad(ptr) != 0;
194 ins = [ "mem", "index", "lower", "upper" ]
195 outs = [ "M", "X_regular", "X_except", "res" ]
196 flags = [ "fragile", "highlevel" ]
198 pinned_init = "op_pin_state_pinned"
199 attr_struct = "bound_attr"
201 #if PRECISE_EXC_CONTEXT
202 firm_alloc_frag_arr(res, op_Bound, &res->attr.bound.exc.frag_arr);
208 flags = [ "cfopcode" ]
214 outs = [ "M_regular", "X_regular", "X_except", "T_result", "M_except", "P_value_res_base" ]
215 flags = [ "uses_memory" ]
218 type = "ir_builtin_kind",
227 pinned_init = "op_pin_state_pinned"
228 attr_struct = "builtin_attr"
230 assert((get_unknown_type() == type) || is_Method_type(type));
234 ins = [ "mem", "ptr" ]
236 outs = [ "M_regular", "X_regular", "X_except", "T_result", "M_except", "P_value_res_base" ]
237 flags = [ "fragile", "uses_memory" ]
244 attr_struct = "call_attr"
246 pinned_init = "op_pin_state_pinned"
248 assert((get_unknown_type() == type) || is_Method_type(type));
251 #if PRECISE_EXC_CONTEXT
252 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 #if PRECISE_EXC_CONTEXT
373 firm_alloc_frag_arr(res, op_CopyB, &res->attr.copyb.exc.frag_arr);
378 ins = [ "mem", "left", "right" ]
379 outs = [ "M", "X_regular", "X_except", "res" ]
380 flags = [ "fragile", "uses_memory" ]
381 attrs_name = "divmod"
388 name = "no_remainder",
397 attr_struct = "divmod_attr"
400 arity_override = "oparity_binary"
402 #if PRECISE_EXC_CONTEXT
403 firm_alloc_frag_arr(res, op_Div, &res->attr.except.frag_arr);
408 ins = [ "mem", "left", "right" ]
409 outs = [ "M", "X_regular", "X_except", "res_div", "res_mod" ]
410 flags = [ "fragile", "uses_memory" ]
411 attrs_name = "divmod"
418 attr_struct = "divmod_attr"
421 arity_override = "oparity_binary"
423 #if PRECISE_EXC_CONTEXT
424 firm_alloc_frag_arr(res, op_DivMod, &res->attr.except.frag_arr);
430 flags = [ "cfopcode", "fragile", "start_block", "constlike",
434 block = "get_irg_start_block(irg)"
440 flags = [ "cfopcode" ]
447 flags = [ "cfopcode", "ip_cfopcode" ]
454 flags = [ "cfopcode", "ip_cfopcode" ]
458 flags = [ "commutative" ]
470 attr_struct = "filter_attr"
474 ins = [ "mem", "ptr", "size" ]
476 flags = [ "uses_memory" ]
485 type = "ir_where_alloc"
488 attr_struct = "free_attr"
499 flags = [ "cfopcode", "forking", "keep" ]
502 ins = [ "store", "obj" ]
503 outs = [ "M", "X_regular", "X_except", "res", "M_except" ]
504 flags = [ "highlevel" ]
511 attr_struct = "io_attr"
513 pinned_init = "op_pin_state_floats"
519 flags = [ "cfopcode" ]
522 ins = [ "mem", "ptr" ]
523 outs = [ "M", "X_regular", "X_except", "res" ]
524 flags = [ "fragile", "uses_memory" ]
526 pinned_init = "flags & cons_floats ? op_pin_state_floats : op_pin_state_pinned"
531 java_name = "load_mode"
534 attr_struct = "load_attr"
537 type = "ir_cons_flags",
542 #if PRECISE_EXC_CONTEXT
543 firm_alloc_frag_arr(res, op_Load, &res->attr.load.exc.frag_arr);
551 ins = [ "mem", "left", "right" ]
552 outs = [ "M", "X_regular", "X_except", "res" ]
553 flags = [ "fragile", "uses_memory" ]
554 attrs_name = "divmod"
561 attr_struct = "divmod_attr"
564 arity_override = "oparity_binary"
566 #if PRECISE_EXC_CONTEXT
567 firm_alloc_frag_arr(res, op_Mod, &res->attr.except.frag_arr);
572 flags = [ "commutative" ]
575 flags = [ "commutative" ]
578 ins = [ "sel", "false", "true" ]
584 flags = [ "dump_noblock", "dump_noinput" ]
593 flags = [ "commutative" ]
599 attr_struct = "phi_attr"
603 /* Memory Phis in endless loops must be kept alive.
604 As we can't distinguish these easily we keep all of them alive. */
605 if (is_Phi(res) && mode == mode_M)
606 add_End_keepalive(get_irg_end(irg), res);
611 mode = "get_irn_mode(irn_op)"
612 flags = [ "highlevel" ]
630 ins = [ "mem", "left", "right" ]
631 outs = [ "M", "X_regular", "X_except", "res" ]
632 flags = [ "fragile", "uses_memory" ]
633 attrs_name = "divmod"
640 attr_struct = "divmod_attr"
643 arity_override = "oparity_binary"
645 #if PRECISE_EXC_CONTEXT
646 firm_alloc_frag_arr(res, op_Quot, &res->attr.except.frag_arr);
651 ins = [ "mem", "exo_ptr" ]
653 flags = [ "highlevel", "cfopcode" ]
660 flags = [ "cfopcode" ]
667 ins = [ "mem", "ptr" ]
670 mode = "is_Method_type(get_entity_type(entity)) ? mode_P_code : mode_P_data"
678 attr_struct = "sel_attr"
692 flags = [ "cfopcode" ]
696 ins = [ "mem", "ptr", "value" ]
697 outs = [ "M", "X_regular", "X_except" ]
698 flags = [ "fragile", "uses_memory" ]
700 attr_struct = "store_attr"
701 pinned_init = "flags & cons_floats ? op_pin_state_floats : op_pin_state_pinned"
704 type = "ir_cons_flags",
709 #if PRECISE_EXC_CONTEXT
710 firm_alloc_frag_arr(res, op_Store, &res->attr.store.exc.frag_arr);
719 flags = [ "constlike", "start_block" ]
728 attr_struct = "symconst_attr"
742 flags = [ "labeled" ]
748 block = "get_irg_start_block(irg)"
749 flags = [ "cfopcode", "fragile", "start_block", "constlike",
754 def getOpList(namespace):
756 for t in namespace.values():
760 if issubclass(t, Op):
765 nodes = getOpList(globals())
766 nodes = sorted(nodes, lambda x,y: cmp(x.name, y.name))