+# This file is part of libFirm.
+# Copyright (C) 2012 Karlsruhe Institute of Technology.
+#
# Firm node specifications
# The comments are in (standard python) restructured text format and are used
# to generate documentation.
"""
mode = "mode_T"
arity = "variable"
+ input_name = "input"
flags = [ "keep", "uses_memory" ]
pinned = "memory"
pinned_init = "op_pin_state_pinned"
block = "NULL"
pinned = "yes"
arity = "variable"
+ input_name = "cfgpred"
flags = []
attr_struct = "block_attr"
attrs = [
init = '''
res->attr.block.irg.irg = irg;
- res->attr.block.backedge = new_backedge_arr(irg->obst, arity);
+ res->attr.block.backedge = new_backedge_arr(get_irg_obstack(irg), arity);
set_Block_matured(res, 1);
/* Create and initialize array for Phi-node construction. */
if (irg_is_constrained(irg, IR_GRAPH_CONSTRAINT_CONSTRUCTION)) {
- res->attr.block.graph_arr = NEW_ARR_D(ir_node *, irg->obst, irg->n_loc);
- memset(res->attr.block.graph_arr, 0, irg->n_loc * sizeof(ir_node*));
+ res->attr.block.graph_arr = NEW_ARR_DZ(ir_node*, get_irg_obstack(irg), irg->n_loc);
}
'''
-@op
-class Borrow(Binop):
- """Returns the borrow bit from and implied subtractions of its 2 operands"""
- flags = []
-
-@op
-class Bound:
- """Performs a bounds-check: if lower <= index < upper then return index,
- otherwise throw an exception."""
- ins = [
- ("mem", "memory dependency"),
- ("index", "value to test"),
- ("lower", "lower bound (inclusive)"),
- ("upper", "upper bound (exclusive)"),
- ]
- outs = [
- ("M", "memory result"),
- ("res", "the checked index"),
- ("X_regular", "control flow when no exception occurs"),
- ("X_except", "control flow when exception occured"),
- ]
- flags = [ "fragile", "highlevel" ]
- pinned = "exception"
- pinned_init = "op_pin_state_pinned"
- throws_init = "false"
- attr_struct = "bound_attr"
-
@op
class Builtin:
"""performs a backend-specific builtin."""
- ins = [
+ ins = [
("mem", "memory dependency"),
]
- arity = "variable"
- outs = [
+ arity = "variable"
+ input_name = "param"
+ outs = [
("M", "memory result"),
# results follow here
]
- flags = [ "uses_memory" ]
- attrs = [
+ flags = [ "uses_memory" ]
+ attrs = [
dict(
type = "ir_builtin_kind",
name = "kind",
pinned = "memory"
pinned_init = "op_pin_state_pinned"
attr_struct = "builtin_attr"
- init = '''
+ init = '''
assert((get_unknown_type() == type) || is_Method_type(type));
'''
operands are passed to the called code. Called code usually performs a
return operation. The operands of this return operation are the result
of the Call node."""
- ins = [
+ ins = [
("mem", "memory dependency"),
("ptr", "pointer to called code"),
]
- arity = "variable"
- outs = [
+ arity = "variable"
+ input_name = "param"
+ outs = [
("M", "memory result"),
("T_result", "tuple containing all results"),
("X_regular", "control flow when no exception occurs"),
("X_except", "control flow when exception occured"),
]
- flags = [ "fragile", "uses_memory" ]
- attrs = [
+ flags = [ "fragile", "uses_memory" ]
+ attrs = [
dict(
type = "ir_type*",
name = "type",
assert((get_unknown_type() == type) || is_Method_type(type));
'''
-@op
-class Carry(Binop):
- """Computes the value of the carry-bit that would result when adding the 2
- operands"""
- flags = [ "commutative" ]
-
-@op
-class Cast(Unop):
- """perform a high-level type cast"""
- mode = "get_irn_mode(irn_op)"
- flags = [ "highlevel" ]
- attrs = [
- dict(
- type = "ir_type*",
- name = "type",
- comment = "target type of the case",
- )
- ]
- attr_struct = "cast_attr"
- init = "assert(is_atomic_type(type));"
-
@op
class Cmp(Binop):
"""Compares its two operands and checks whether a specified
mode = "mode_X"
pinned = "yes"
arity = "dynamic"
+ input_name = "keepalive"
flags = [ "cfopcode" ]
knownBlock = True
block = "get_irg_end_block(irg)"
all phi nodes produce their nth input as result."""
pinned = "yes"
arity = "variable"
+ input_name = "pred"
flags = []
attr_struct = "phi_attr"
init = '''
- res->attr.phi.u.backedge = new_backedge_arr(irg->obst, arity);'''
- init_after_opt = '''
- /* Memory Phis in endless loops must be kept alive.
- As we can't distinguish these easily we keep all of them alive. */
- if (is_Phi(res) && mode == mode_M)
- add_End_keepalive(get_irg_end(irg), res);'''
+ res->attr.phi.u.backedge = new_backedge_arr(get_irg_obstack(irg), arity);'''
customSerializer = True
@op
class Return:
"""Returns from the current function. Takes memory and return values as
operands."""
- ins = [
+ ins = [
("mem", "memory dependency"),
]
- arity = "variable"
- mode = "mode_X"
- flags = [ "cfopcode" ]
- pinned = "yes"
+ arity = "variable"
+ input_name = "res"
+ mode = "mode_X"
+ flags = [ "cfopcode" ]
+ pinned = "yes"
class Rotl(Binop):
"""Returns its first operand bits rotated left by the amount in the 2nd
Optimisations assume that a Sel node can only produce a NULL pointer if the
ptr input was NULL."""
- ins = [
+ ins = [
("mem", "memory dependency"),
("ptr", "pointer to object to select from"),
]
- arity = "variable"
- flags = []
- mode = "is_Method_type(get_entity_type(entity)) ? mode_P_code : mode_P_data"
- pinned = "no"
- attrs = [
+ arity = "variable"
+ input_name = "index"
+ flags = []
+ mode = "is_Method_type(get_entity_type(entity)) ? mode_P_code : mode_P_data"
+ pinned = "no"
+ attrs = [
dict(
type = "ir_entity*",
name = "entity",
be identical. This operation allows to specify all operations that
eventually need several partial memory blocks as input with a single
entrance by unifying the memories with a preceding Sync operation."""
- mode = "mode_M"
- flags = []
- pinned = "no"
- arity = "dynamic"
+ mode = "mode_M"
+ flags = []
+ pinned = "no"
+ arity = "dynamic"
+ input_name = "pred"
@op
class Tuple:
the implementation with pointers in only one direction.) The Tuple node is
smaller than any other node, so that a node can be changed into a Tuple by
just changing its opcode and giving it a new in array."""
- arity = "variable"
- mode = "mode_T"
- pinned = "no"
- flags = []
+ arity = "variable"
+ input_name = "pred"
+ mode = "mode_T"
+ pinned = "no"
+ flags = []
@op
class Unknown: