Commit cd502534 authored by Matthias Braun's avatar Matthias Braun
Browse files

generate inline versions of node get/set functions

parent e7f232ba
......@@ -64,7 +64,6 @@
#define mark_Block_block_visited(node) mark_Block_block_visited_(node)
#define Block_block_visited(node) Block_block_visited_(node)
#define get_Block_irg(block) get_Block_irg_(block)
#define get_Const_tarval(node) get_Const_tarval_(node)
#define is_Const_null(node) is_Const_null_(node)
#define is_Const_one(node) is_Const_one_(node)
#define is_Const_all_one(node) is_Const_all_one_(node)
......@@ -77,8 +76,6 @@
#define is_irn_keep(node) is_irn_keep_(node)
#define is_irn_start_block_placed(node) is_irn_start_block_placed_(node)
#define is_irn_cse_neutral(node) is_irn_cse_neutral_(node)
#define get_Cond_jmp_pred(node) get_Cond_jmp_pred_(node)
#define set_Cond_jmp_pred(node, pred) set_Cond_jmp_pred_(node, pred)
#define get_irn_generic_attr(node) get_irn_generic_attr_(node)
#define get_irn_generic_attr_const(node) get_irn_generic_attr_const_(node)
#define get_irn_idx(node) get_irn_idx_(node)
......@@ -148,9 +145,6 @@ static inline ir_op *get_irn_op_(const ir_node *node)
return node->op;
}
/* include generated code */
#include "gen_irnode.h"
static inline void set_irn_op_(ir_node *node, ir_op *op)
{
node->op = op;
......@@ -186,6 +180,10 @@ static inline int get_irn_arity_(const ir_node *node)
return (int)(ARR_LEN(node->in) - 1);
}
/* forward decl... */
#define is_Id(node) is_Id_(node)
static inline int is_Id_(const ir_node *node);
/**
* Intern version for libFirm.
*/
......@@ -201,6 +199,9 @@ static inline ir_node *get_irn_n_(const ir_node *node, int n)
return (node->in[n + 1] = skip_Id(nn));
}
/* include generated code */
#include "gen_irnode.h"
/**
* returns a hash value for a node
*/
......@@ -440,12 +441,6 @@ static inline int Block_block_visited_(const ir_node *node)
return node->attr.block.block_visited >= get_irg_block_visited(irg);
}
static inline ir_tarval *get_Const_tarval_(const ir_node *node)
{
assert(is_Const(node));
return node->attr.con.tarval;
}
static inline int is_Const_null_(const ir_node *node)
{
return tarval_is_null(get_Const_tarval_(node));
......@@ -496,18 +491,6 @@ static inline int is_irn_cse_neutral_(const ir_node *node)
return is_op_cse_neutral(get_irn_op_(node));
}
static inline cond_jmp_predicate get_Cond_jmp_pred_(const ir_node *node)
{
assert(is_Cond(node));
return node->attr.cond.jmp_pred;
}
static inline void set_Cond_jmp_pred_(ir_node *node, cond_jmp_predicate pred)
{
assert(is_Cond(node));
node->attr.cond.jmp_pred = pred;
}
static inline void *get_irn_generic_attr_(ir_node *node)
{
return &node->attr;
......
......@@ -361,14 +361,49 @@ irnode_h_template = env.from_string(
{% for node in nodes %}
#define is_{{node.name}}(node) is_{{node.name}}_(node)
{%- for attr in node.attrs|hasnot("noprop") %}
#define get_{{node.name}}_{{attr.name}}(node) get_{{node.name}}_{{attr.name}}_(node)
#define set_{{node.name}}_{{attr.name}}(node, {{attr.name}}) set_{{node.name}}_{{attr.name}}_(node, {{attr.name}})
{%- endfor -%}
{%- for input in node.ins %}
#define get_{{node.name}}_{{input[0]}}(node) get_{{node.name}}_{{input[0]}}_(node)
#define set_{{node.name}}_{{input[0]}}(node, {{input[0]|escape_keywords}}) set_{{node.name}}_{{input[0]}}_(node, {{input[0]|escape_keywords}})
{% endfor %}
{%- endfor %}
{%- for node in nodes|isnot('custom_is') %}
{%- for node in nodes %}
static inline int is_{{node.name}}_(const ir_node *node)
{
return get_irn_op(node) == op_{{node.name}};
}
{%- endfor %}
{%- for attr in node.attrs|hasnot("noprop") %}
static inline {{attr.type}} get_{{node.name}}_{{attr.name}}_(const ir_node *node)
{
assert(is_{{node.name}}(node));
return node->attr.{{node.attrs_name}}.{{attr.name}};
}
static inline void set_{{node.name}}_{{attr.name}}_(ir_node *node, {{attr.type}} {{attr.name}})
{
assert(is_{{node.name}}(node));
node->attr.{{node.attrs_name}}.{{attr.name}} = {{attr.name}};
}
{% endfor -%}
{%- for input in node.ins %}
static inline ir_node *get_{{node.name}}_{{input[0]}}_(const ir_node *node)
{
assert(is_{{node.name}}(node));
return get_irn_n(node, n_{{node.name}}_{{input[0]}});
}
static inline void set_{{node.name}}_{{input[0]}}_(ir_node *node, ir_node *{{input[0]|escape_keywords}})
{
assert(is_{{node.name}}(node));
set_irn_n(node, n_{{node.name}}_{{input[0]}}, {{input[0]|escape_keywords}});
}
{% endfor %}
{% endfor -%}
''')
irnode_template = env.from_string(
......@@ -378,36 +413,26 @@ int (is_{{node.name}})(const ir_node *node)
{
return is_{{node.name}}_(node);
}
{% endfor %}
{%- for node in nodes %}
{%- for attr in node.attrs|hasnot("noprop") %}
{{attr.type}} (get_{{node.name}}_{{attr.name}})(const ir_node *node)
{
assert(is_{{node.name}}(node));
return node->attr.{{node.attrs_name}}.{{attr.name}};
return get_{{node.name}}_{{attr.name}}_(node);
}
void (set_{{node.name}}_{{attr.name}})(ir_node *node, {{attr.type}} {{attr.name}})
{
assert(is_{{node.name}}(node));
node->attr.{{node.attrs_name}}.{{attr.name}} = {{attr.name}};
set_{{node.name}}_{{attr.name}}_(node, {{attr.name}});
}
{% endfor -%}
{% endfor -%}
{%- for node in nodes %}
{%- for input in node.ins %}
ir_node *(get_{{node.name}}_{{input[0]}})(const ir_node *node)
{
assert(is_{{node.name}}(node));
return get_irn_n(node, n_{{node.name}}_{{input[0]}});
return get_{{node.name}}_{{input[0]}}(node);
}
void (set_{{node.name}}_{{input[0]}})(ir_node *node, ir_node *{{input[0]|escape_keywords}})
{
assert(is_{{node.name}}(node));
set_irn_n(node, n_{{node.name}}_{{input[0]}}, {{input[0]|escape_keywords}});
set_{{node.name}}_{{input[0]}}_(node, {{input[0]|escape_keywords}});
}
{% endfor %}
{% endfor %}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment