From 8afc2ffa646f8d7510c014b8179b812c7ca9a769 Mon Sep 17 00:00:00 2001 From: Sebastian Hack Date: Thu, 10 Feb 2005 10:45:47 +0000 Subject: [PATCH] Added support for out edges. Added classify_Const for easier const access. [r5064] --- ir/ir/irnode.c | 39 ++++++++++++++++++++++++++++++++++----- ir/ir/irnode.h | 43 +++++++++++++++++-------------------------- 2 files changed, 51 insertions(+), 31 deletions(-) diff --git a/ir/ir/irnode.c b/ir/ir/irnode.c index 231d6a28c..d4e9c683a 100644 --- a/ir/ir/irnode.c +++ b/ir/ir/irnode.c @@ -27,6 +27,7 @@ #include "irdump.h" #include "irop_t.h" #include "irprog_t.h" +#include "iredges_t.h" #include "irhooks.h" @@ -147,6 +148,7 @@ new_ir_node (dbg_info *db, ir_graph *irg, ir_node *block, ir_op *op, ir_mode *mo res->in = NEW_ARR_D (ir_node *, irg->obst, (arity+1)); memcpy (&res->in[1], in, sizeof (ir_node *) * arity); } + res->in[0] = block; set_irn_dbg_info(res, db); res->out = NULL; @@ -155,7 +157,19 @@ new_ir_node (dbg_info *db, ir_graph *irg, ir_node *block, ir_op *op, ir_mode *mo res->node_nr = get_irp_new_node_nr(); #endif - hook_new_node(res); +#ifdef FIRM_EDGES_INPLACE + { + int i, n; + int not_a_block = !is_Block(res); + + INIT_LIST_HEAD(&res->edge_info.outs_head); + + for(i = 0, n = arity + not_a_block; i < n; ++i) + edges_notify_edge(res, i - not_a_block, res->in[i], NULL, irg); + } +#endif + + hook_new_node(irg, res); return res; } @@ -249,7 +263,9 @@ ir_node * void set_irn_n (ir_node *node, int n, ir_node *in) { - assert(node && node->kind == k_ir_node && -1 <= n && n < get_irn_arity(node)); + assert(node && node->kind == k_ir_node); + assert(-1 <= n); + assert(n < get_irn_arity(node)); assert(in && in->kind == k_ir_node); if ((n == -1) && (get_irn_opcode(node) == iro_Filter)) { @@ -270,6 +286,15 @@ set_irn_n (ir_node *node, int n, ir_node *in) { } /* else fall through */ } + + /* Call the hook */ + hook_set_irn_n(node, n, in, node->in[n + 1]); + +#ifdef FIRM_EDGES_INPLACE + /* Here, we rely on src and tgt being in the current ir graph */ + edges_notify_edge(node, n, in, node->in[n + 1], current_ir_graph); +#endif + node->in[n + 1] = in; } @@ -874,9 +899,8 @@ set_Raise_exo_ptr (ir_node *node, ir_node *exo_ptr) { set_irn_n(node, 1, exo_ptr); } -tarval *get_Const_tarval (ir_node *node) { - assert (node->op == op_Const); - return node->attr.con.tv; +tarval *(get_Const_tarval)(ir_node *node) { + return _get_Const_tarval(node); } void @@ -885,6 +909,11 @@ set_Const_tarval (ir_node *node, tarval *con) { node->attr.con.tv = con; } +cnst_classify_t (classify_Const)(ir_node *node) +{ + return _classify_Const(node); +} + /* The source language type. Must be an atomic type. Mode of type must be mode of node. For tarvals from entities type must be pointer to diff --git a/ir/ir/irnode.h b/ir/ir/irnode.h index 49f2a21bd..d81c8e976 100644 --- a/ir/ir/irnode.h +++ b/ir/ir/irnode.h @@ -15,31 +15,7 @@ #include -/** - * Projection numbers of compare: use for Proj nodes! - * @remark there are numbers with normalized names below! - */ -typedef enum { - False = 0, /**< false */ - Eq, /**< equal */ - Lt, /**< less */ - Le, /**< less or equal */ - Gt, /**< greater */ - Ge, /**< greater or equal */ - Lg, /**< less or greater */ - Leg = 7, /**< less, equal or greater = ordered */ - Uo, /**< unordered */ - Ue, /**< unordered or equal */ - Ul, /**< unordered or less */ - Ule, /**< unordered, less or equal */ - Ug, /**< unordered or greater */ - Uge, /**< unordered, greater or equal */ - Ne, /**< unordered, less or greater = not equal */ - True = 15 /**< true */ - /* not_mask = Leg*/ /* bits to flip to negate comparison * @@ hack for jni interface */ -} pnc_number; /* pnc: Projection Number Cmp */ -#define not_mask Leg - +# include "pnc.h" # include "tv.h" # include "irgraph.h" # include "entity.h" @@ -48,7 +24,6 @@ typedef enum { # include "irmode.h" # include "type.h" # include "dbginfo.h" -/* # include "exc.h" */ /** * @file irnode.h @@ -378,9 +353,25 @@ typedef enum { pn_Raise_max /**< number of projections from a Raise */ } pn_Raise; /* Projection numbers for Raise. */ +typedef enum { + CNST_NULL = TV_CLASSIFY_NULL, /**< The node is a const(0). */ + CNST_ONE = TV_CLASSIFY_ONE, /**< The node is a const(1). */ + CNST_ALL_ONE = TV_CLASSIFY_ALL_ONE, /**< The node is a const(11111...). */ + CNST_OTHER = TV_CLASSIFY_OTHER, /**< The tarvel of the const has another value. */ + CNST_SYMCONST, /**< The node is symconst. */ + CNST_NO_CONST /**< The node is no const at all. */ +} cnst_classify_t; + tarval *get_Const_tarval (ir_node *node); void set_Const_tarval (ir_node *node, tarval *con); +/** + * Classify a node concerning constant properties. + * @param irn A node to check for. + * @return Constant properties of that node. + */ +cnst_classify_t classify_Const(ir_node *irn); + /** Returns the source language type of a Const node. * Must be an atomic type. Mode of type must be mode of node. */ -- 2.20.1