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", "count" ]
32 ("M", "memory result", "pn_Generic_M"),
33 ("X_regular", "control flow when no exception occurs", "pn_Generic_X_regular"),
34 ("X_except", "control flow when exception occured", "pn_Generic_X_except"),
35 ("res", "pointer to newly allocated memory", "pn_Generic_other"),
37 flags = [ "fragile", "uses_memory" ]
45 type = "ir_where_alloc"
49 attr_struct = "alloc_attr"
51 firm_alloc_frag_arr(res, op_Alloc, &res->attr.alloc.exc.frag_arr);
57 flags = [ "dump_noblock" ]
63 flags = [ "commutative" ]
68 flags = [ "keep", "uses_memory" ]
70 pinned_init = "op_pin_state_pinned"
71 attr_struct = "asm_attr"
75 name = "input_constraints",
76 type = "ir_asm_constraint*",
79 name = "n_output_constraints",
84 name = "output_constraints",
85 type = "ir_asm_constraint*",
105 flags = [ "cfopcode", "fragile", "start_block", "dump_noblock" ]
109 attr_struct = "irg_attr"
111 res->attr.irg.irg = irg;
121 flags = [ "labeled" ]
122 attr_struct = "block_attr"
126 /* macroblock header */
129 res->attr.block.is_dead = 0;
130 res->attr.block.is_mb_head = 1;
131 res->attr.block.irg.irg = irg;
132 res->attr.block.backedge = new_backedge_arr(irg->obst, arity);
133 res->attr.block.in_cg = NULL;
134 res->attr.block.cg_backedge = NULL;
135 res->attr.block.extblk = NULL;
136 res->attr.block.mb_depth = 0;
137 res->attr.block.entity = NULL;
139 set_Block_matured(res, 1);
140 set_Block_block_visited(res, 0);
142 /* Create and initialize array for Phi-node construction. */
143 if (get_irg_phase_state(irg) == phase_building) {
144 res->attr.block.graph_arr = NEW_ARR_D(ir_node *, irg->obst, irg->n_loc);
145 memset(res->attr.block.graph_arr, 0, irg->n_loc * sizeof(ir_node*));
150 public void addPred(Node node) {
151 binding_cons.add_immBlock_pred(ptr, node.ptr);
154 public void mature() {
155 binding_cons.mature_immBlock(ptr);
159 public Block getBlock() {
163 public boolean blockVisited() {
164 return 0 != binding.Block_block_visited(ptr);
167 public void markBlockVisited() {
168 binding.mark_Block_block_visited(ptr);
171 public boolean isBad() {
172 return binding.is_Bad(ptr) != 0;
180 ins = [ "mem", "index", "lower", "upper" ]
182 ("M", "memory result", "pn_Generic_M"),
183 ("X_regular", "control flow when no exception occurs", "pn_Generic_X_regular"),
184 ("X_except", "control flow when exception occured", "pn_Generic_X_except"),
185 ("res", "the checked index", "pn_Generic_other"),
187 flags = [ "fragile", "highlevel" ]
189 pinned_init = "op_pin_state_pinned"
190 attr_struct = "bound_attr"
193 firm_alloc_frag_arr(res, op_Bound, &res->attr.bound.exc.frag_arr);
200 ("M", "memory result", "pn_Generic_M"),
201 ("1_result", "first result", "pn_Generic_other"),
203 flags = [ "uses_memory" ]
206 type = "ir_builtin_kind",
215 pinned_init = "op_pin_state_pinned"
216 attr_struct = "builtin_attr"
218 assert((get_unknown_type() == type) || is_Method_type(type));
222 ins = [ "mem", "ptr" ]
225 ("M", "memory result", "pn_Generic_M"),
226 ("X_regular", "control flow when no exception occurs", "pn_Generic_X_regular"),
227 ("X_except", "control flow when exception occured", "pn_Generic_X_except"),
228 ("T_result", "tuple containing all results", "pn_Generic_other"),
229 ("P_value_res_base", "pointer to memory register containing copied results passed by value"),
231 flags = [ "fragile", "uses_memory" ]
240 # the tail call attribute can only be set by analysis
244 attr_struct = "call_attr"
246 pinned_init = "op_pin_state_pinned"
248 assert((get_unknown_type() == type) || is_Method_type(type));
251 firm_alloc_frag_arr(res, op_Call, &res->attr.call.exc.frag_arr);
255 flags = [ "commutative" ]
258 mode = "get_irn_mode(irn_op)"
259 flags = [ "highlevel" ]
266 attr_struct = "cast_attr"
267 init = "assert(is_atomic_type(type));"
271 ("False", "always false", "0"),
272 ("Eq", "equal", "1"),
274 ("Le", "less or equal", "pn_Cmp_Eq|pn_Cmp_Lt"),
275 ("Gt", "greater", "4"),
276 ("Ge", "greater or equal", "pn_Cmp_Eq|pn_Cmp_Gt"),
277 ("Lg", "less or greater ('not equal' for integer numbers)", "pn_Cmp_Lt|pn_Cmp_Gt"),
278 ("Leg", "less, equal or greater ('not unordered')", "pn_Cmp_Lt|pn_Cmp_Eq|pn_Cmp_Gt"),
279 ("Uo", "unordered", "8"),
280 ("Ue", "unordered or equal", "pn_Cmp_Uo|pn_Cmp_Eq"),
281 ("Ul", "unordered or less", "pn_Cmp_Uo|pn_Cmp_Lt"),
282 ("Ule", "unordered, less or equal", "pn_Cmp_Uo|pn_Cmp_Lt|pn_Cmp_Eq"),
283 ("Ug", "unordered or greater", "pn_Cmp_Uo|pn_Cmp_Gt"),
284 ("Uge", "onordered, greater or equal", "pn_Cmp_Uo|pn_Cmp_Gt|pn_Cmp_Eq"),
285 ("Ne", "unordered, less or greater ('not equal' for floatingpoint numbers)", "pn_Cmp_Uo|pn_Cmp_Lt|pn_Cmp_Gt"),
286 ("True", "always true", "15"),
293 ("false", "control flow if operand is \"false\""),
294 ("true", "control flow if operand is \"true\""),
296 flags = [ "cfopcode", "forking" ]
300 name = "default_proj",
306 type = "cond_jmp_predicate",
307 init = "COND_JMP_PRED_NONE"
310 attr_struct = "cond_attr"
313 ins = [ "value", "bound" ]
314 mode = "get_irn_mode(irn_value)"
315 flags = [ "highlevel" ]
323 attr_struct = "confirm_attr"
324 attrs_name = "confirm"
328 flags = [ "constlike", "start_block" ]
338 attr_struct = "const_attr"
353 attr_struct = "conv_attr"
357 ins = [ "mem", "dst", "src" ]
359 ("M", "memory result", "pn_Generic_M"),
360 ("X_regular", "control flow when no exception occurs", "pn_Generic_X_regular"),
361 ("X_except", "control flow when exception occured", "pn_Generic_X_except"),
363 flags = [ "fragile", "highlevel", "uses_memory" ]
370 attr_struct = "copyb_attr"
373 pinned_init = "op_pin_state_pinned"
375 firm_alloc_frag_arr(res, op_CopyB, &res->attr.copyb.exc.frag_arr);
379 ins = [ "mem", "left", "right" ]
381 ("M", "memory result", "pn_Generic_M"),
382 ("X_regular", "control flow when no exception occurs", "pn_Generic_X_regular"),
383 ("X_except", "control flow when exception occured", "pn_Generic_X_except"),
384 ("res", "result of computation", "pn_Generic_other"),
386 flags = [ "fragile", "uses_memory" ]
387 attrs_name = "divmod"
394 name = "no_remainder",
403 attr_struct = "divmod_attr"
406 arity_override = "oparity_binary"
408 firm_alloc_frag_arr(res, op_Div, &res->attr.except.frag_arr);
412 ins = [ "mem", "left", "right" ]
414 ("M", "memory result", "pn_Generic_M"),
415 ("X_regular", "control flow when no exception occurs", "pn_Generic_X_regular"),
416 ("X_except", "control flow when exception occured", "pn_Generic_X_except"),
417 ("res_div", "result of computation a/b", "pn_Generic_other"),
418 ("res_mod", "result of computation a%b"),
420 flags = [ "fragile", "uses_memory" ]
421 attrs_name = "divmod"
428 attr_struct = "divmod_attr"
431 arity_override = "oparity_binary"
433 firm_alloc_frag_arr(res, op_DivMod, &res->attr.except.frag_arr);
438 flags = [ "cfopcode", "fragile", "start_block", "constlike",
442 block = "get_irg_start_block(irg)"
448 flags = [ "cfopcode" ]
452 flags = [ "commutative" ]
455 ins = [ "mem", "ptr", "size" ]
457 flags = [ "uses_memory" ]
466 type = "ir_where_alloc"
469 attr_struct = "free_attr"
480 flags = [ "cfopcode", "forking", "keep" ]
483 ins = [ "store", "obj" ]
485 ("M", "memory result", "pn_Generic_M"),
486 ("X_regular", "control flow when no exception occurs", "pn_Generic_X_regular"),
487 ("X_except", "control flow when exception occured", "pn_Generic_X_except"),
488 ("res", "checked object pointer", "pn_Generic_other"),
490 flags = [ "highlevel" ]
497 attr_struct = "io_attr"
499 pinned_init = "op_pin_state_floats"
505 flags = [ "cfopcode" ]
508 ins = [ "mem", "ptr" ]
510 ("M", "memory result", "pn_Generic_M"),
511 ("X_regular", "control flow when no exception occurs", "pn_Generic_X_regular"),
512 ("X_except", "control flow when exception occured", "pn_Generic_X_except"),
513 ("res", "result of load operation", "pn_Generic_other"),
515 flags = [ "fragile", "uses_memory" ]
517 pinned_init = "flags & cons_floats ? op_pin_state_floats : op_pin_state_pinned"
522 java_name = "load_mode"
525 attr_struct = "load_attr"
528 type = "ir_cons_flags",
533 firm_alloc_frag_arr(res, op_Load, &res->attr.load.exc.frag_arr);
540 ins = [ "mem", "left", "right" ]
542 ("M", "memory result", "pn_Generic_M"),
543 ("X_regular", "control flow when no exception occurs", "pn_Generic_X_regular"),
544 ("X_except", "control flow when exception occured", "pn_Generic_X_except"),
545 ("res", "result of computation", "pn_Generic_other"),
547 flags = [ "fragile", "uses_memory" ]
548 attrs_name = "divmod"
555 attr_struct = "divmod_attr"
558 arity_override = "oparity_binary"
560 firm_alloc_frag_arr(res, op_Mod, &res->attr.except.frag_arr);
564 flags = [ "commutative" ]
567 flags = [ "commutative" ]
570 ins = [ "sel", "false", "true" ]
576 flags = [ "dump_noblock", "dump_noinput" ]
585 flags = [ "commutative" ]
591 attr_struct = "phi_attr"
594 /* Memory Phis in endless loops must be kept alive.
595 As we can't distinguish these easily we keep all of them alive. */
596 if (is_Phi(res) && mode == mode_M)
597 add_End_keepalive(get_irg_end(irg), res);
602 mode = "get_irn_mode(irn_op)"
603 flags = [ "highlevel" ]
612 block = "get_nodes_block(irn_pred)"
613 graph = "get_irn_irg(irn_pred)"
625 ins = [ "mem", "left", "right" ]
627 ("M", "memory result", "pn_Generic_M"),
628 ("X_regular", "control flow when no exception occurs", "pn_Generic_X_regular"),
629 ("X_except", "control flow when exception occured", "pn_Generic_X_except"),
630 ("res", "result of computation", "pn_Generic_other"),
632 flags = [ "fragile", "uses_memory" ]
633 attrs_name = "divmod"
640 attr_struct = "divmod_attr"
643 arity_override = "oparity_binary"
645 firm_alloc_frag_arr(res, op_Quot, &res->attr.except.frag_arr);
649 ins = [ "mem", "exo_ptr" ]
651 ("M", "memory result", "pn_Generic_M"),
652 ("X", "control flow to exception handler", "pn_Generic_X_regular"),
654 flags = [ "highlevel", "cfopcode" ]
661 flags = [ "cfopcode" ]
668 ins = [ "mem", "ptr" ]
671 mode = "is_Method_type(get_entity_type(entity)) ? mode_P_code : mode_P_data"
679 attr_struct = "sel_attr"
692 ("X_initial_exec", "control flow"),
693 ("M", "initial memory"),
694 ("P_frame_base", "frame base pointer"),
695 ("P_tls", "pointer to thread local storage segment"),
696 ("T_args", "function arguments")
700 flags = [ "cfopcode" ]
704 ins = [ "mem", "ptr", "value" ]
706 ("M", "memory result", "pn_Generic_M"),
707 ("X_regular", "control flow when no exception occurs", "pn_Generic_X_regular"),
708 ("X_except", "control flow when exception occured", "pn_Generic_X_except"),
710 flags = [ "fragile", "uses_memory" ]
712 attr_struct = "store_attr"
713 pinned_init = "flags & cons_floats ? op_pin_state_floats : op_pin_state_pinned"
716 type = "ir_cons_flags",
721 firm_alloc_frag_arr(res, op_Store, &res->attr.store.exc.frag_arr);
729 flags = [ "constlike", "start_block" ]
739 attr_struct = "symconst_attr"
753 flags = [ "labeled" ]
759 block = "get_irg_start_block(irg)"
760 flags = [ "cfopcode", "fragile", "start_block", "constlike",
765 def getOpList(namespace):
767 for t in namespace.values():
771 if issubclass(t, Op):
776 nodes = getOpList(globals())
777 nodes = sorted(nodes, lambda x,y: cmp(x.name, y.name))