Commit 1e799c3b authored by Matthias Braun's avatar Matthias Braun
Browse files

generate irdump proj-number lookup tables

parent 9f7a1e68
......@@ -1341,7 +1341,7 @@ static ir_node *gen_Proj_Builtin(ir_node *proj)
case ir_bk_parity:
case ir_bk_popcount:
case ir_bk_bswap:
assert(get_Proj_proj(proj) == pn_Builtin_1_result);
assert(get_Proj_proj(proj) == pn_Builtin_max+1);
return new_node;
case ir_bk_trap:
case ir_bk_debugbreak:
......
......@@ -5471,7 +5471,7 @@ static ir_node *gen_Proj_Builtin(ir_node *proj)
case ir_bk_parity:
case ir_bk_popcount:
case ir_bk_bswap:
assert(get_Proj_proj(proj) == pn_Builtin_1_result);
assert(get_Proj_proj(proj) == pn_Builtin_max+1);
return new_node;
case ir_bk_trap:
case ir_bk_debugbreak:
......@@ -5480,14 +5480,14 @@ static ir_node *gen_Proj_Builtin(ir_node *proj)
assert(get_Proj_proj(proj) == pn_Builtin_M);
return new_node;
case ir_bk_inport:
if (get_Proj_proj(proj) == pn_Builtin_1_result) {
if (get_Proj_proj(proj) == pn_Builtin_max+1) {
return new_r_Proj(new_node, get_irn_mode(proj), pn_ia32_Inport_res);
} else {
assert(get_Proj_proj(proj) == pn_Builtin_M);
return new_r_Proj(new_node, mode_M, pn_ia32_Inport_M);
}
case ir_bk_inner_trampoline:
if (get_Proj_proj(proj) == pn_Builtin_1_result) {
if (get_Proj_proj(proj) == pn_Builtin_max+1) {
return get_Tuple_pred(new_node, 1);
} else {
assert(get_Proj_proj(proj) == pn_Builtin_M);
......
......@@ -66,6 +66,19 @@
#include "pset.h"
#include "util.h"
typedef struct pns_lookup {
long nr; /**< the proj number */
const char *name; /**< the name of the Proj */
} pns_lookup_t;
typedef struct proj_lookup {
unsigned code; /**< the opcode of the Proj predecessor */
unsigned num_data; /**< number of data entries */
const pns_lookup_t *data; /**< the data */
} proj_lookup_t;
#include "gen_irdump.c.inl"
/** Dump only irgs with names that start with this prefix. */
static ident *dump_file_filter_id = NULL;
......@@ -789,149 +802,6 @@ static int dump_node_typeinfo(FILE *F, ir_node *n)
return bad;
}
typedef struct pns_lookup {
long nr; /**< the proj number */
const char *name; /**< the name of the Proj */
} pns_lookup_t;
typedef struct proj_lookup {
unsigned code; /**< the opcode of the Proj predecessor */
unsigned num_data; /**< number of data entries */
const pns_lookup_t *data; /**< the data */
} proj_lookup_t;
/** the lookup table for Proj(Start) names */
static const pns_lookup_t start_lut[] = {
#define X(a) { pn_Start_##a, #a }
X(X_initial_exec),
X(M),
X(P_frame_base),
X(T_args),
#undef X
};
/** the lookup table for Proj(Cond) names */
static const pns_lookup_t cond_lut[] = {
#define X(a) { pn_Cond_##a, #a }
X(false),
X(true)
#undef X
};
/** the lookup table for Proj(Call) names */
static const pns_lookup_t call_lut[] = {
#define X(a) { pn_Call_##a, #a }
X(M),
X(X_regular),
X(X_except),
X(T_result),
#undef X
};
/** the lookup table for Proj(Div) names */
static const pns_lookup_t div_lut[] = {
#define X(a) { pn_Div_##a, #a }
X(M),
X(X_regular),
X(X_except),
X(res)
#undef X
};
/** the lookup table for Proj(Mod) names */
static const pns_lookup_t mod_lut[] = {
#define X(a) { pn_Mod_##a, #a }
X(M),
X(X_regular),
X(X_except),
X(res)
#undef X
};
/** the lookup table for Proj(Load) names */
static const pns_lookup_t load_lut[] = {
#define X(a) { pn_Load_##a, #a }
X(M),
X(X_regular),
X(X_except),
X(res)
#undef X
};
/** the lookup table for Proj(Store) names */
static const pns_lookup_t store_lut[] = {
#define X(a) { pn_Store_##a, #a }
X(M),
X(X_regular),
X(X_except)
#undef X
};
/** the lookup table for Proj(Alloc) names */
static const pns_lookup_t alloc_lut[] = {
#define X(a) { pn_Alloc_##a, #a }
X(M),
X(X_regular),
X(X_except),
X(res)
#undef X
};
/** the lookup table for Proj(CopyB) names */
static const pns_lookup_t copyb_lut[] = {
#define X(a) { pn_CopyB_##a, #a }
X(M),
X(X_regular),
X(X_except),
#undef X
};
/** the lookup table for Proj(InstOf) names */
static const pns_lookup_t instof_lut[] = {
#define X(a) { pn_InstOf_##a, #a }
X(M),
X(X_regular),
X(X_except),
X(res),
#undef X
};
/** the lookup table for Proj(Raise) names */
static const pns_lookup_t raise_lut[] = {
#define X(a) { pn_Raise_##a, #a }
X(M),
X(X),
#undef X
};
/** the lookup table for Proj(Bound) names */
static const pns_lookup_t bound_lut[] = {
#define X(a) { pn_Bound_##a, #a }
X(M),
X(X_regular),
X(X_except),
X(res),
#undef X
};
/** the Proj lookup table */
static const proj_lookup_t proj_lut[] = {
#define E(a) ARRAY_SIZE(a), a
{ iro_Start, E(start_lut) },
{ iro_Cond, E(cond_lut) },
{ iro_Call, E(call_lut) },
{ iro_Div, E(div_lut) },
{ iro_Mod, E(mod_lut) },
{ iro_Load, E(load_lut) },
{ iro_Store, E(store_lut) },
{ iro_Alloc, E(alloc_lut) },
{ iro_CopyB, E(copyb_lut) },
{ iro_InstOf, E(instof_lut) },
{ iro_Raise, E(raise_lut) },
{ iro_Bound, E(bound_lut) }
#undef E
};
/**
* Dump additional node attributes of some nodes to a file F.
*/
......
......@@ -114,7 +114,7 @@ static void replace_with_call(ir_node *node)
turn_into_tuple(node, 2);
set_irn_n(node, pn_Builtin_M, call_mem);
set_irn_n(node, pn_Builtin_1_result, call_res);
set_irn_n(node, pn_Builtin_max+1, call_res);
}
static void lower_builtin(ir_node *node, void *env)
......
......@@ -2546,10 +2546,10 @@ static void lower_Builtin(ir_node *builtin, ir_mode *mode)
ir_node *cmp_low = new_rd_Cmp(dbgi, block, entry->low_word, zero_unsigned, ir_relation_equal);
ir_node *cmp_high = new_rd_Cmp(dbgi, block, entry->high_word, zero_unsigned, ir_relation_equal);
ir_node *ffs_high = new_rd_Builtin(dbgi, block, mem, 1, in_high, kind, lowered_type_high);
ir_node *high_proj = new_r_Proj(ffs_high, mode_Is, pn_Builtin_1_result);
ir_node *high_proj = new_r_Proj(ffs_high, mode_Is, pn_Builtin_max+1);
ir_node *high = new_rd_Add(dbgi, block, high_proj, number_of_bits, mode_Is);
ir_node *ffs_low = new_rd_Builtin(dbgi, block, mem, 1, in_low, kind, lowered_type_low);
ir_node *low = new_r_Proj(ffs_low, mode_Is, pn_Builtin_1_result);
ir_node *low = new_r_Proj(ffs_low, mode_Is, pn_Builtin_max+1);
ir_node *mux_high = new_rd_Mux(dbgi, block, cmp_high, high, zero_signed, mode_Is);
if (! allow_ifconv(cmp_high, high, zero_signed))
......@@ -2569,9 +2569,9 @@ static void lower_Builtin(ir_node *builtin, ir_mode *mode)
ir_node *zero_unsigned = new_rd_Const(dbgi, irg, get_mode_null(mode_Iu));
ir_node *cmp_high = new_rd_Cmp(dbgi, block, entry->high_word, zero_unsigned, ir_relation_equal);
ir_node *clz_high = new_rd_Builtin(dbgi, block, mem, 1, in_high, kind, lowered_type_high);
ir_node *high = new_r_Proj(clz_high, mode_Is, pn_Builtin_1_result);
ir_node *high = new_r_Proj(clz_high, mode_Is, pn_Builtin_max+1);
ir_node *clz_low = new_rd_Builtin(dbgi, block, mem, 1, in_low, kind, lowered_type_low);
ir_node *low_proj = new_r_Proj(clz_low, mode_Is, pn_Builtin_1_result);
ir_node *low_proj = new_r_Proj(clz_low, mode_Is, pn_Builtin_max+1);
ir_node *low = new_rd_Add(dbgi, block, low_proj, number_of_bits, mode_Is);
res = new_rd_Mux(dbgi, block, cmp_high, high, low, mode_Is);
......@@ -2588,10 +2588,10 @@ static void lower_Builtin(ir_node *builtin, ir_mode *mode)
ir_node *zero_unsigned = new_rd_Const(dbgi, irg, get_mode_null(mode_Iu));
ir_node *cmp_low = new_rd_Cmp(dbgi, block, entry->low_word, zero_unsigned, ir_relation_equal);
ir_node *ffs_high = new_rd_Builtin(dbgi, block, mem, 1, in_high, kind, lowered_type_high);
ir_node *high_proj = new_r_Proj(ffs_high, mode_Is, pn_Builtin_1_result);
ir_node *high_proj = new_r_Proj(ffs_high, mode_Is, pn_Builtin_max+1);
ir_node *high = new_rd_Add(dbgi, block, high_proj, number_of_bits, mode_Is);
ir_node *ffs_low = new_rd_Builtin(dbgi, block, mem, 1, in_low, kind, lowered_type_low);
ir_node *low = new_r_Proj(ffs_low, mode_Is, pn_Builtin_1_result);
ir_node *low = new_r_Proj(ffs_low, mode_Is, pn_Builtin_max+1);
res = new_rd_Mux(dbgi, block, cmp_low, low, high, mode_Is);
......@@ -2605,8 +2605,8 @@ static void lower_Builtin(ir_node *builtin, ir_mode *mode)
ir_node *in_low[1] = {entry->low_word};
ir_node *popcount_high = new_rd_Builtin(dbgi, block, mem, 1, in_high, kind, lowered_type_high);
ir_node *popcount_low = new_rd_Builtin(dbgi, block, mem, 1, in_low, kind, lowered_type_low);
ir_node *high = new_r_Proj(popcount_high, mode_Is, pn_Builtin_1_result);
ir_node *low = new_r_Proj(popcount_low, mode_Is, pn_Builtin_1_result);
ir_node *high = new_r_Proj(popcount_high, mode_Is, pn_Builtin_max+1);
ir_node *low = new_r_Proj(popcount_low, mode_Is, pn_Builtin_max+1);
res = new_rd_Add(dbgi, block, high, low, mode_Is);
break;
......@@ -2623,9 +2623,9 @@ static void lower_Builtin(ir_node *builtin, ir_mode *mode)
assert(arity == 2);
parity_high = new_rd_Builtin(dbgi, block, mem, 1, in_high, kind, lowered_type_high);
high = new_r_Proj(parity_high, mode_Is, pn_Builtin_1_result);
high = new_r_Proj(parity_high, mode_Is, pn_Builtin_max+1);
parity_low = new_rd_Builtin(dbgi, block, mem, 1, in_low, kind, lowered_type_low);
low = new_r_Proj(parity_low, mode_Is, pn_Builtin_1_result);
low = new_r_Proj(parity_low, mode_Is, pn_Builtin_max+1);
res = new_rd_Eor(dbgi, block, high, low, mode_Is);
break;
}
......@@ -2635,7 +2635,7 @@ static void lower_Builtin(ir_node *builtin, ir_mode *mode)
turn_into_tuple(builtin, 2);
set_irn_n(builtin, pn_Builtin_M, mem);
set_irn_n(builtin, pn_Builtin_1_result, res);
set_irn_n(builtin, pn_Builtin_max+1, res);
}
/**
......
......@@ -275,7 +275,7 @@ int i_mapper_bswap(ir_node *call, void *ctx)
irn = new_rd_Builtin(dbg, block, get_irg_no_mem(current_ir_graph), 1, &op, ir_bk_bswap, tp);
set_irn_pinned(irn, op_pin_state_floats);
irn = new_r_Proj(irn, get_irn_mode(op), pn_Builtin_1_result);
irn = new_r_Proj(irn, get_irn_mode(op), pn_Builtin_max+1);
replace_call(irn, call, mem, NULL, NULL);
return 1;
} /* i_mapper_bswap */
......
......@@ -440,6 +440,27 @@ void (set_{{node.name}}_{{input[0]}})(ir_node *node, ir_node *{{input[0]|escape_
{% endfor %}
''')
irdump_template = env.from_string(
'''/* Warning: automatically generated code */
{% for node in nodes %}
{%- if node.outs %}
static const pns_lookup_t {{node.name}}_lut[] = {
{%- for out in node.outs %}
{ pn_{{node.name}}_{{out[0]}}, "{{out[0]}}" },
{%- endfor %}
};
{% endif -%}
{%- endfor %}
static const proj_lookup_t proj_lut[] = {
{%- for node in nodes -%}
{%- if node.outs %}
{ iro_{{node.name}}, ARRAY_SIZE({{node.name}}_lut), {{node.name}}_lut },
{%- endif %}
{%- endfor %}
};
''')
irop_template = env.from_string(
'''/* Warning: automatically generated code */
{% for node in nodes %}
......@@ -680,6 +701,10 @@ def main(argv):
file.write(irop_template.render(nodes = real_nodes))
file.close()
file = open(gendir + "/gen_irdump.c.inl", "w")
file.write(irdump_template.render(nodes = real_nodes))
file.close()
file = open(gendir2 + "/opcodes.h", "w")
file.write(opcodes_h_template.render(nodes = real_nodes))
file.close()
......
......@@ -222,8 +222,8 @@ class Builtin(Op):
]
arity = "variable"
outs = [
("M", "memory result"),
("1_result", "first result"),
("M", "memory result"),
# results follow here
]
flags = [ "uses_memory" ]
attrs = [
......
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