Commit 54df0836 authored by Matthias Braun's avatar Matthias Braun
Browse files

add comments to attributes and inputs in spec file

[r28237]
parent 7efd3927
...@@ -62,14 +62,14 @@ def format_insdecl(node): ...@@ -62,14 +62,14 @@ def format_insdecl(node):
res += "\n\tNEW_ARR_A(ir_node *, r_in, r_arity);" res += "\n\tNEW_ARR_A(ir_node *, r_in, r_arity);"
i = 0 i = 0
for input in node.ins: for input in node.ins:
res += "\n\tr_in[" + `i` + "] = irn_" + input + ";" res += "\n\tr_in[" + `i` + "] = irn_" + input[0] + ";"
i += 1 i += 1
res += "\n\tmemcpy(&r_in[" + `insarity` + "], in, sizeof(ir_node *) * arity);\n\t" res += "\n\tmemcpy(&r_in[" + `insarity` + "], in, sizeof(ir_node *) * arity);\n\t"
else: else:
res = "ir_node *in[" + `arity` + "];" res = "ir_node *in[" + `arity` + "];"
i = 0 i = 0
for input in node.ins: for input in node.ins:
res += "\n\tin[" + `i` + "] = irn_" + input + ";" res += "\n\tin[" + `i` + "] = irn_" + input[0] + ";"
i += 1 i += 1
return res return res
...@@ -196,7 +196,7 @@ def preprocess_node(node): ...@@ -196,7 +196,7 @@ def preprocess_node(node):
arguments = [ ] arguments = [ ]
initattrs = [ ] initattrs = [ ]
for input in node.ins: for input in node.ins:
arguments.append(dict(type = "ir_node *", name = "irn_" + input)) arguments.append(dict(type = "ir_node *", name = "irn_" + input[0]))
if node.arity == "variable" or node.arity == "dynamic": if node.arity == "variable" or node.arity == "dynamic":
arguments.append(dict(type = "int", name = "arity")) arguments.append(dict(type = "int", name = "arity"))
...@@ -378,16 +378,16 @@ void (set_{{node.name}}_{{attr.name}})(ir_node *node, {{attr.type}} {{attr.name} ...@@ -378,16 +378,16 @@ void (set_{{node.name}}_{{attr.name}})(ir_node *node, {{attr.type}} {{attr.name}
{%- for node in nodes %} {%- for node in nodes %}
{%- for in in node.ins %} {%- for in in node.ins %}
ir_node *(get_{{node.name}}_{{in}})(const ir_node *node) ir_node *(get_{{node.name}}_{{in[0]}})(const ir_node *node)
{ {
assert(is_{{node.name}}(node)); assert(is_{{node.name}}(node));
return get_irn_n(node, {{node.ins.index(in)}}); return get_irn_n(node, {{node.ins.index(in)}});
} }
void (set_{{node.name}}_{{in}})(ir_node *node, ir_node *{{in|escape_keywords}}) void (set_{{node.name}}_{{in[0]}})(ir_node *node, ir_node *{{in[0]|escape_keywords}})
{ {
assert(is_{{node.name}}(node)); assert(is_{{node.name}}(node));
set_irn_n(node, {{node.ins.index(in)}}, {{in|escape_keywords}}); set_irn_n(node, {{node.ins.index(in)}}, {{in[0]|escape_keywords}});
} }
{% endfor %} {% endfor %}
{% endfor %} {% endfor %}
...@@ -461,8 +461,8 @@ FIRM_API int is_{{node.name}}(const ir_node *node); ...@@ -461,8 +461,8 @@ FIRM_API int is_{{node.name}}(const ir_node *node);
{% for node in nodes %} {% for node in nodes %}
{% for in in node.ins -%} {% for in in node.ins -%}
FIRM_API ir_node *get_{{node.name}}_{{in}}(const ir_node *node); FIRM_API ir_node *get_{{node.name}}_{{in[0]}}(const ir_node *node);
void set_{{node.name}}_{{in}}(ir_node *node, ir_node *{{in|escape_keywords}}); void set_{{node.name}}_{{in[0]}}(ir_node *node, ir_node *{{in[0]|escape_keywords}});
{% endfor -%} {% endfor -%}
{% for attr in node.attrs|hasnot("noprop") -%} {% for attr in node.attrs|hasnot("noprop") -%}
FIRM_API {{attr.type}} get_{{node.name}}_{{attr.name}}(const ir_node *node); FIRM_API {{attr.type}} get_{{node.name}}_{{attr.name}}(const ir_node *node);
......
...@@ -7,7 +7,9 @@ abstract(Op) ...@@ -7,7 +7,9 @@ abstract(Op)
class Unop(Op): class Unop(Op):
"""Unary nodes have exactly 1 input""" """Unary nodes have exactly 1 input"""
name = "unop" name = "unop"
ins = [ "op" ] ins = [
("op", "operand"),
]
op_index = 0 op_index = 0
pinned = "no" pinned = "no"
abstract(Unop) abstract(Unop)
...@@ -15,37 +17,45 @@ abstract(Unop) ...@@ -15,37 +17,45 @@ abstract(Unop)
class Binop(Op): class Binop(Op):
"""Binary nodes have exactly 2 inputs""" """Binary nodes have exactly 2 inputs"""
name = "binop" name = "binop"
ins = [ "left", "right" ] ins = [
( "left", "first operand" ),
( "right", "second operand" ),
]
op_index = 0 op_index = 0
pinned = "no" pinned = "no"
abstract(Binop) abstract(Binop)
class Add(Binop): class Add(Binop):
"""returns the sum of its operands""" """returns the sum of its operands"""
flags = ["commutative"] flags = [ "commutative" ]
class Alloc(Op): class Alloc(Op):
"""allocates a block of memory. """allocates a block of memory.
It can be specified whether the variable should be allocated to the stack It can be specified whether the variable should be allocated to the stack
or to the heap.""" or to the heap."""
ins = [ "mem", "count" ] ins = [
("mem", "memory dependency" ),
("count", "number of objects to allocate" ),
]
outs = [ outs = [
("M", "memory result", "pn_Generic_M"), ("M", "memory result", "pn_Generic_M"),
("X_regular", "control flow when no exception occurs", "pn_Generic_X_regular"), ("X_regular", "control flow when no exception occurs", "pn_Generic_X_regular"),
("X_except", "control flow when exception occured", "pn_Generic_X_except"), ("X_except", "control flow when exception occured", "pn_Generic_X_except"),
("res", "pointer to newly allocated memory", "pn_Generic_other"), ("res", "pointer to newly allocated memory", "pn_Generic_other"),
] ]
flags = [ "fragile", "uses_memory" ]
attrs = [ attrs = [
dict( dict(
name = "type", name = "type",
type = "ir_type*" type = "ir_type*",
comment = "type of the allocated variable",
), ),
dict( dict(
name = "where", name = "where",
type = "ir_where_alloc" type = "ir_where_alloc",
comment = "whether to allocate the variable on the stack or heap",
) )
] ]
flags = [ "fragile", "uses_memory" ]
pinned = "yes" pinned = "yes"
attr_struct = "alloc_attr" attr_struct = "alloc_attr"
...@@ -82,30 +92,36 @@ class ASM(Op): ...@@ -82,30 +92,36 @@ class ASM(Op):
customSerializer = True customSerializer = True
attrs = [ attrs = [
dict( dict(
name = "input_constraints", name = "input_constraints",
type = "ir_asm_constraint*", type = "ir_asm_constraint*",
comment = "input constraints",
), ),
dict( dict(
name = "n_output_constraints", name = "n_output_constraints",
type = "int", type = "int",
noprop = True, noprop = True,
comment = "number of output constraints",
), ),
dict( dict(
name = "output_constraints", name = "output_constraints",
type = "ir_asm_constraint*", type = "ir_asm_constraint*",
comment = "output constraints",
), ),
dict( dict(
name = "n_clobbers", name = "n_clobbers",
type = "int", type = "int",
noprop = True, noprop = True,
comment = "number of clobbered registers/memory",
), ),
dict( dict(
name = "clobbers", name = "clobbers",
type = "ident**", type = "ident**",
comment = "list of clobbered registers/memory",
), ),
dict( dict(
name = "text", name = "text",
type = "ident*", type = "ident*",
comment = "assembler text",
), ),
] ]
# constructor is written manually at the moment, because of the clobbers+ # constructor is written manually at the moment, because of the clobbers+
...@@ -180,7 +196,12 @@ class Borrow(Binop): ...@@ -180,7 +196,12 @@ class Borrow(Binop):
class Bound(Op): class Bound(Op):
"""Performs a bounds-check: if lower <= index < upper then return index, """Performs a bounds-check: if lower <= index < upper then return index,
otherwise throw an exception.""" otherwise throw an exception."""
ins = [ "mem", "index", "lower", "upper" ] ins = [
("mem", "memory dependency"),
("index", "value to test"),
("lower", "lower bound (inclusive)"),
("upper", "upper bound (exclusive)"),
]
outs = [ outs = [
("M", "memory result", "pn_Generic_M"), ("M", "memory result", "pn_Generic_M"),
("X_regular", "control flow when no exception occurs", "pn_Generic_X_regular"), ("X_regular", "control flow when no exception occurs", "pn_Generic_X_regular"),
...@@ -195,7 +216,9 @@ class Bound(Op): ...@@ -195,7 +216,9 @@ class Bound(Op):
class Builtin(Op): class Builtin(Op):
"""performs a backend-specific builtin.""" """performs a backend-specific builtin."""
ins = [ "mem" ] ins = [
("mem", "memory dependency"),
]
arity = "variable" arity = "variable"
outs = [ outs = [
("M", "memory result", "pn_Generic_M"), ("M", "memory result", "pn_Generic_M"),
...@@ -204,12 +227,14 @@ class Builtin(Op): ...@@ -204,12 +227,14 @@ class Builtin(Op):
flags = [ "uses_memory" ] flags = [ "uses_memory" ]
attrs = [ attrs = [
dict( dict(
type = "ir_builtin_kind", type = "ir_builtin_kind",
name = "kind" name = "kind",
comment = "kind of builtin",
), ),
dict( dict(
type = "ir_type*", type = "ir_type*",
name = "type" name = "type",
comment = "method type for the builtin call",
) )
] ]
pinned = "memory" pinned = "memory"
...@@ -224,7 +249,10 @@ class Call(Op): ...@@ -224,7 +249,10 @@ class Call(Op):
operands are passed to the called code. Called code usually performs a operands are passed to the called code. Called code usually performs a
return operation. The operands of this return operation are the result return operation. The operands of this return operation are the result
of the Call node.""" of the Call node."""
ins = [ "mem", "ptr" ] ins = [
("mem", "memory dependency"),
("ptr", "pointer to called code"),
]
arity = "variable" arity = "variable"
outs = [ outs = [
("M", "memory result", "pn_Generic_M"), ("M", "memory result", "pn_Generic_M"),
...@@ -236,14 +264,15 @@ class Call(Op): ...@@ -236,14 +264,15 @@ class Call(Op):
flags = [ "fragile", "uses_memory" ] flags = [ "fragile", "uses_memory" ]
attrs = [ attrs = [
dict( dict(
type = "ir_type*", type = "ir_type*",
name = "type" name = "type",
comment = "type of the call (usually type of the called procedure)",
), ),
dict( dict(
type = "unsigned", type = "unsigned",
name = "tail_call", name = "tail_call",
# the tail call attribute can only be set by analysis # the tail call attribute can only be set by analysis
init = "0" init = "0",
) )
] ]
attr_struct = "call_attr" attr_struct = "call_attr"
...@@ -264,8 +293,9 @@ class Cast(Unop): ...@@ -264,8 +293,9 @@ class Cast(Unop):
flags = [ "highlevel" ] flags = [ "highlevel" ]
attrs = [ attrs = [
dict( dict(
type = "ir_type*", type = "ir_type*",
name = "type" name = "type",
comment = "target type of the case",
) )
] ]
attr_struct = "cast_attr" attr_struct = "cast_attr"
...@@ -307,7 +337,9 @@ class Cond(Op): ...@@ -307,7 +337,9 @@ class Cond(Op):
will proceed along output i. If the input is >= n control flow proceeds will proceed along output i. If the input is >= n control flow proceeds
along output def_proj. along output def_proj.
""" """
ins = [ "selector" ] ins = [
("selector", "condition parameter"),
]
outs = [ outs = [
("false", "control flow if operand is \"false\""), ("false", "control flow if operand is \"false\""),
("true", "control flow if operand is \"true\""), ("true", "control flow if operand is \"true\""),
...@@ -316,14 +348,16 @@ class Cond(Op): ...@@ -316,14 +348,16 @@ class Cond(Op):
pinned = "yes" pinned = "yes"
attrs = [ attrs = [
dict( dict(
name = "default_proj", name = "default_proj",
type = "long", type = "long",
init = "0" init = "0",
comment = "Proj-number of default case for switch-Cond",
), ),
dict( dict(
name = "jmp_pred", name = "jmp_pred",
type = "cond_jmp_predicate", type = "cond_jmp_predicate",
init = "COND_JMP_PRED_NONE" init = "COND_JMP_PRED_NONE",
comment = "can indicate the most likely jump",
) )
] ]
attr_struct = "cond_attr" attr_struct = "cond_attr"
...@@ -338,14 +372,18 @@ class Confirm(Op): ...@@ -338,14 +372,18 @@ class Confirm(Op):
value is always returned. value is always returned.
Note that this node does NOT check or assert the constraint, it merely Note that this node does NOT check or assert the constraint, it merely
specifies it.""" specifies it."""
ins = [ "value", "bound" ] ins = [
("value", "value to express a constraint for"),
("bound", "value to compare against"),
]
mode = "get_irn_mode(irn_value)" mode = "get_irn_mode(irn_value)"
flags = [ "highlevel" ] flags = [ "highlevel" ]
pinned = "yes" pinned = "yes"
attrs = [ attrs = [
dict( dict(
name = "cmp", name = "cmp",
type = "pn_Cmp" type = "pn_Cmp",
comment = "compare operation",
), ),
] ]
attr_struct = "confirm_attr" attr_struct = "confirm_attr"
...@@ -360,8 +398,9 @@ class Const(Op): ...@@ -360,8 +398,9 @@ class Const(Op):
pinned = "no" pinned = "no"
attrs = [ attrs = [
dict( dict(
type = "ir_tarval*", type = "ir_tarval*",
name = "tarval", name = "tarval",
comment = "constant value (a tarval object)",
) )
] ]
attr_struct = "const_attr" attr_struct = "const_attr"
...@@ -372,9 +411,10 @@ class Conv(Unop): ...@@ -372,9 +411,10 @@ class Conv(Unop):
flags = [] flags = []
attrs = [ attrs = [
dict( dict(
name = "strict", name = "strict",
type = "int", type = "int",
init = "0", init = "0",
comment = "force floating point to restrict precision even if backend computes in higher precision (deprecated)",
) )
] ]
attr_struct = "conv_attr" attr_struct = "conv_attr"
...@@ -382,7 +422,11 @@ class Conv(Unop): ...@@ -382,7 +422,11 @@ class Conv(Unop):
class CopyB(Op): class CopyB(Op):
"""Copies a block of memory""" """Copies a block of memory"""
ins = [ "mem", "dst", "src" ] ins = [
("mem", "memory dependency"),
("dst", "destination address"),
("src", "source address"),
]
outs = [ outs = [
("M", "memory result", "pn_Generic_M"), ("M", "memory result", "pn_Generic_M"),
("X_regular", "control flow when no exception occurs", "pn_Generic_X_regular"), ("X_regular", "control flow when no exception occurs", "pn_Generic_X_regular"),
...@@ -391,8 +435,9 @@ class CopyB(Op): ...@@ -391,8 +435,9 @@ class CopyB(Op):
flags = [ "fragile", "uses_memory" ] flags = [ "fragile", "uses_memory" ]
attrs = [ attrs = [
dict( dict(
name = "type", name = "type",
type = "ir_type*" type = "ir_type*",
comment = "type of copied data",
) )
] ]
attr_struct = "copyb_attr" attr_struct = "copyb_attr"
...@@ -402,7 +447,11 @@ class CopyB(Op): ...@@ -402,7 +447,11 @@ class CopyB(Op):
class Div(Op): class Div(Op):
"""returns the quotient of its 2 operands, integer version""" """returns the quotient of its 2 operands, integer version"""
ins = [ "mem", "left", "right" ] ins = [
("mem", "memory dependency"),
("left", "first operand"),
("right", "second operand"),
]
outs = [ outs = [
("M", "memory result", "pn_Generic_M"), ("M", "memory result", "pn_Generic_M"),
("X_regular", "control flow when no exception occurs", "pn_Generic_X_regular"), ("X_regular", "control flow when no exception occurs", "pn_Generic_X_regular"),
...@@ -413,8 +462,9 @@ class Div(Op): ...@@ -413,8 +462,9 @@ class Div(Op):
attrs_name = "divmod" attrs_name = "divmod"
attrs = [ attrs = [
dict( dict(
type = "ir_mode*", type = "ir_mode*",
name = "resmode" name = "resmode",
comment = "mode of the result value",
), ),
dict( dict(
name = "no_remainder", name = "no_remainder",
...@@ -429,7 +479,11 @@ class Div(Op): ...@@ -429,7 +479,11 @@ class Div(Op):
class DivMod(Op): class DivMod(Op):
"""divides its 2 operands and computes the remainder of the division""" """divides its 2 operands and computes the remainder of the division"""
ins = [ "mem", "left", "right" ] ins = [
("mem", "memory dependency"),
("left", "first operand"),
("right", "second operand"),
]
outs = [ outs = [
("M", "memory result", "pn_Generic_M"), ("M", "memory result", "pn_Generic_M"),
("X_regular", "control flow when no exception occurs", "pn_Generic_X_regular"), ("X_regular", "control flow when no exception occurs", "pn_Generic_X_regular"),
...@@ -441,8 +495,9 @@ class DivMod(Op): ...@@ -441,8 +495,9 @@ class DivMod(Op):
attrs_name = "divmod" attrs_name = "divmod"
attrs = [ attrs = [
dict( dict(
type = "ir_mode*", type = "ir_mode*",
name = "resmode" name = "resmode",
comment = "mode of the result value",
), ),
] ]
attr_struct = "divmod_attr" attr_struct = "divmod_attr"
...@@ -478,25 +533,33 @@ class Eor(Binop): ...@@ -478,25 +533,33 @@ class Eor(Binop):
class Free(Op): class Free(Op):
"""Frees a block of memory previously allocated by an Alloc node""" """Frees a block of memory previously allocated by an Alloc node"""
ins = [ "mem", "ptr", "size" ] ins = [
("mem", "memory dependency" ),
("ptr", "pointer to the object to free"),
("size", "number of objects to allocate" ),
]
mode = "mode_M" mode = "mode_M"
flags = [ "uses_memory" ] flags = [ "uses_memory" ]
pinned = "yes" pinned = "yes"
attrs = [ attrs = [
dict( dict(
name = "type", name = "type",
type = "ir_type*" type = "ir_type*",
comment = "type of the allocated variable",
), ),
dict( dict(
name = "where", name = "where",
type = "ir_where_alloc" type = "ir_where_alloc",
comment = "whether allocation was on the stack or heap",
) )
] ]
attr_struct = "free_attr" attr_struct = "free_attr"
class Id(Op): class Id(Op):
"""Returns its operand unchanged.""" """Returns its operand unchanged."""
ins = [ "pred" ] ins = [
("pred", "the value which is returned unchanged")
]
pinned = "no" pinned = "no"
flags = [] flags = []
...@@ -506,12 +569,17 @@ class IJmp(Op): ...@@ -506,12 +569,17 @@ class IJmp(Op):
by the tuple results""" by the tuple results"""
mode = "mode_X" mode = "mode_X"
pinned = "yes" pinned = "yes"
ins = [ "target" ] ins = [
("target", "target address of the jump"),
]
flags = [ "cfopcode", "forking", "keep" ] flags = [ "cfopcode", "forking", "keep" ]
class InstOf(Op): class InstOf(Op):
"""Tests wether an object is an instance of a class-type""" """Tests wether an object is an instance of a class-type"""
ins = [ "store", "obj" ] ins = [
("store", "memory dependency"),
("obj", "pointer to object being queried")
]
outs = [ outs = [
("M", "memory result", "pn_Generic_M"), ("M", "memory result", "pn_Generic_M"),
("X_regular", "control flow when no exception occurs", "pn_Generic_X_regular"), ("X_regular", "control flow when no exception occurs", "pn_Generic_X_regular"),
...@@ -521,8 +589,9 @@ class InstOf(Op): ...@@ -521,8 +589,9 @@ class InstOf(Op):
flags = [ "highlevel"