From c1c5433da7f12ee9490d4ffa4908d3ba4343d02b Mon Sep 17 00:00:00 2001 From: Michael Beck Date: Fri, 19 Dec 2008 15:00:57 +0000 Subject: [PATCH] - fixed CSE and Combo for Builtin nodes [r24811] --- ir/ir/irnode.c | 5 +++++ ir/ir/irnode_t.h | 1 + ir/ir/iropt.c | 11 +++++++++++ ir/opt/combo.c | 12 +++++++++++- 4 files changed, 28 insertions(+), 1 deletion(-) diff --git a/ir/ir/irnode.c b/ir/ir/irnode.c index 61f9b7066..e1d7b57e4 100644 --- a/ir/ir/irnode.c +++ b/ir/ir/irnode.c @@ -571,6 +571,11 @@ divmod_attr *get_irn_divmod_attr(ir_node *node) { return &node->attr.divmod; } +builtin_attr *get_irn_builtin_attr(ir_node *node) { + assert(is_Builtin(node)); + return &node->attr.builtin; +} + void *(get_irn_generic_attr)(ir_node *node) { assert(is_ir_node(node)); return _get_irn_generic_attr(node); diff --git a/ir/ir/irnode_t.h b/ir/ir/irnode_t.h index d65b3aaa2..9ee3fe72b 100644 --- a/ir/ir/irnode_t.h +++ b/ir/ir/irnode_t.h @@ -58,6 +58,7 @@ load_attr *get_irn_load_attr (ir_node *node); store_attr *get_irn_store_attr (ir_node *node); except_attr *get_irn_except_attr (ir_node *node); divmod_attr *get_irn_divmod_attr (ir_node *node); +builtin_attr *get_irn_builtin_attr (ir_node *node); /** @} */ /** diff --git a/ir/ir/iropt.c b/ir/ir/iropt.c index 92df9f6f2..054541dc9 100644 --- a/ir/ir/iropt.c +++ b/ir/ir/iropt.c @@ -5943,9 +5943,19 @@ static int node_cmp_attr_Quot(ir_node *a, ir_node *b) { /** Compares the attributes of two Confirm nodes. */ static int node_cmp_attr_Confirm(ir_node *a, ir_node *b) { + /* no need to compare the bound, as this is a input */ return (get_Confirm_cmp(a) != get_Confirm_cmp(b)); } /* node_cmp_attr_Confirm */ +/** Compares the attributes of two Builtin nodes. */ +static int node_cmp_attr_Builtin(ir_node *a, ir_node *b) { + const builtin_attr *ma = get_irn_builtin_attr(a); + const builtin_attr *mb = get_irn_builtin_attr(b); + + /* no need to compare the type, equal kind means equal type */ + return ma->kind != mb->kind; +} /* node_cmp_attr_Builtin */ + /** Compares the attributes of two ASM nodes. */ static int node_cmp_attr_ASM(ir_node *a, ir_node *b) { int i, n; @@ -6029,6 +6039,7 @@ static ir_op_ops *firm_set_default_node_cmp_attr(ir_opcode code, ir_op_ops *ops) CASE(Mod); CASE(Quot); CASE(Bound); + CASE(Builtin); /* FIXME CopyB */ default: /* leave NULL */; diff --git a/ir/opt/combo.c b/ir/opt/combo.c index a2f8ee934..f1c00fddf 100644 --- a/ir/opt/combo.c +++ b/ir/opt/combo.c @@ -112,6 +112,7 @@ struct opcode_key_t { long proj; /**< For Proj nodes, its proj number */ ir_entity *ent; /**< For Sel Nodes, its entity */ int intVal; /**< For Conv/Div Nodes: strict/remainderless */ + unsigned uintVal;/**< for Builtin: the kind */ ir_node *block; /**< for Block: itself */ void *ptr; /**< generic pointer for hash/cmp */ } u; @@ -295,6 +296,9 @@ static void check_opcode(const partition_t *Z) { case iro_Load: key.mode = get_Load_mode(irn); break; + case iro_Builtin: + key.u.uintVal = get_Builtin_kind(irn); + break; default: break; } @@ -323,6 +327,9 @@ static void check_opcode(const partition_t *Z) { case iro_Load: assert(key.mode == get_Load_mode(irn)); break; + case iro_Builtin: + assert(key.u.uintVal == get_Builtin_kind(irn)); + break; default: break; } @@ -578,7 +585,7 @@ static int cmp_opcode(const void *elt, const void *key, size_t size) { return o1->code != o2->code || o1->mode != o2->mode || o1->arity != o2->arity || o1->u.proj != o2->u.proj || - o1->u.intVal != o2->u.intVal || + o1->u.intVal != o2->u.intVal || /* this already checks uIntVal */ o1->u.ptr != o2->u.ptr; } /* cmp_opcode */ @@ -1680,6 +1687,9 @@ static void *lambda_opcode(const node_t *node, environment_t *env) { case iro_Load: key.mode = get_Load_mode(irn); break; + case iro_Builtin: + key.u.uintVal = get_Builtin_kind(irn); + break; default: break; } -- 2.20.1