From ea931ee5adfa947b301765044e228d27fed408cd Mon Sep 17 00:00:00 2001 From: Sebastian Hack Date: Mon, 16 Jan 2006 16:59:19 +0000 Subject: [PATCH] Added the Keep node [r7253] --- ir/ir/ircons.c | 40 ++++++++++++++++++++++++++++++++++++++++ ir/ir/ircons.h | 27 +++++++++++++++++++++++++++ ir/ir/irop.c | 5 +++++ ir/ir/irop.h | 2 ++ 4 files changed, 74 insertions(+) diff --git a/ir/ir/ircons.c b/ir/ir/ircons.c index 7de95dcb7..eb771e358 100644 --- a/ir/ir/ircons.c +++ b/ir/ir/ircons.c @@ -985,6 +985,20 @@ new_bd_Bound (dbg_info *db, ir_node *block, return res; } +static ir_node * +new_bd_Keep(dbg_info *db, ir_node *block, int n, ir_node *in[]) +{ + ir_graph *irg = current_ir_graph; + ir_node *res; + + res = new_ir_node(db, irg, block, op_Keep, mode_ANY, n, in); + keep_alive(res); + + res = optimize_node(res); + IRN_VRFY_IRG(res, irg); + return res; +} + /* --------------------------------------------- */ /* private interfaces, for professional use only */ /* --------------------------------------------- */ @@ -1784,6 +1798,18 @@ ir_node *new_rd_Bound(dbg_info *db, ir_graph *irg, ir_node *block, return res; } +ir_node *new_rd_Keep(dbg_info *db, ir_graph *irg, ir_node *block, int n, ir_node *in[]) +{ + ir_node *res; + ir_graph *rem = current_ir_graph; + + current_ir_graph = irg; + res = new_bd_Keep(db, block, n, in); + current_ir_graph = rem; + + return res; +} + ir_node *new_r_Block (ir_graph *irg, int arity, ir_node **in) { return new_rd_Block(NULL, irg, arity, in); } @@ -2002,6 +2028,12 @@ ir_node *new_r_Bound(ir_graph *irg, ir_node *block, return new_rd_Bound(NULL, irg, block, store, idx, lower, upper); } +ir_node *new_r_Keep(ir_graph *irg, ir_node *block, + int n, ir_node *in[]) +{ + return new_rd_Keep(NULL, irg, block, n, in); +} + /** ********************/ /** public interfaces */ /** construction tools */ @@ -3359,6 +3391,11 @@ ir_node *new_d_Bound(dbg_info *db,ir_node *store, return res; } +ir_node *new_d_Keep(dbg_info *db, int n, ir_node *in[]) +{ + return new_bd_Keep(db, current_ir_graph->current_block, n, in); +} + /* ********************************************************************* */ /* Comfortable interface with automatic Phi node construction. */ /* (Uses also constructors of ?? interface, except new_Block. */ @@ -3693,3 +3730,6 @@ ir_node *new_CopyB(ir_node *store, ir_node *dst, ir_node *src, ir_type *data_typ ir_node *new_Bound(ir_node *store, ir_node *idx, ir_node *lower, ir_node *upper) { return new_d_Bound(NULL, store, idx, lower, upper); } +ir_node *new_Keep(int n, ir_node *in[]) { + return new_d_Keep(NULL, n, in); +} diff --git a/ir/ir/ircons.h b/ir/ir/ircons.h index 735211e32..2cebb0956 100644 --- a/ir/ir/ircons.h +++ b/ir/ir/ircons.h @@ -1862,6 +1862,13 @@ ir_node *new_rd_CopyB(dbg_info *db, ir_graph *irg, ir_node *block, ir_node *new_rd_Bound(dbg_info *db, ir_graph *irg, ir_node *block, ir_node *store, ir_node *idx, ir_node *lower, ir_node *upper); +/** + * Construct a new Keep node. + * @see new_Keep(). + */ +ir_node *new_rd_Keep(dbg_info *db, ir_graph *irg, ir_node *block, + int n, ir_node *in[]); + /*-------------------------------------------------------------------------*/ /* The raw interface without debug support */ /*-------------------------------------------------------------------------*/ @@ -2572,6 +2579,12 @@ ir_node *new_r_CopyB(ir_graph *irg, ir_node *block, ir_node *new_r_Bound(ir_graph *irg, ir_node *block, ir_node *store, ir_node *idx, ir_node *lower, ir_node *upper); +/** + * Constructor of a Keep node. + * @see new_Keep() + */ +ir_node *new_r_Keep(ir_graph *irg, ir_node *block, int n, ir_node *in[]); + /*-----------------------------------------------------------------------*/ /* The block oriented interface */ /*-----------------------------------------------------------------------*/ @@ -3291,6 +3304,12 @@ ir_node *new_d_CopyB(dbg_info *db, ir_node *store, ir_node *dst, ir_node *src, i */ ir_node *new_d_Bound(dbg_info *db, ir_node *store, ir_node *idx, ir_node *lower, ir_node *upper); +/** + * Constructor for a Keep node. + * @see new_Keep. + */ +ir_node *new_d_Keep(dbg_info *db, int n, ir_node *in[]); + /*-----------------------------------------------------------------------*/ /* The block oriented interface without debug support */ /*-----------------------------------------------------------------------*/ @@ -3915,6 +3934,14 @@ ir_node *new_CopyB(ir_node *store, ir_node *dst, ir_node *src, ir_type *data_typ */ ir_node *new_Bound(ir_node *store, ir_node *idx, ir_node *lower, ir_node *upper); +/** + * Constructor for a Keep node. + * @param n Number of inputs. + * @param in Input array. + * @reutrn A new Keep node. + */ +ir_node *new_Keep(int n, ir_node *in[]); + /*---------------------------------------------------------------------*/ /* The comfortable interface. */ /* Supports automatic Phi node construction. */ diff --git a/ir/ir/irop.c b/ir/ir/irop.c index eacd49a82..a04437d25 100644 --- a/ir/ir/irop.c +++ b/ir/ir/irop.c @@ -95,6 +95,7 @@ ir_op *op_Mux; ir_op *get_op_Mux (void) { return op_Mux; } ir_op *op_CopyB; ir_op *get_op_CopyB (void) { return op_CopyB; } ir_op *op_Bound; ir_op *get_op_Bound (void) { return op_Bound; } +ir_op *op_Keep; ir_op *get_op_Keep (void) { return op_Keep; } /* * Copies all attributes stored in the old node to the new node. @@ -268,6 +269,8 @@ init_op(void) op_CopyB = new_ir_op(iro_CopyB, "CopyB", op_pin_state_mem_pinned, L|F|H, oparity_trinary, -1, sizeof(copyb_attr), NULL); op_Bound = new_ir_op(iro_Bound, "Bound", op_pin_state_mem_pinned, L|F|H, oparity_trinary, -1, sizeof(bound_attr), NULL); + op_Keep = new_ir_op(iro_Keep, "Keep", op_pin_state_pinned, N, oparity_variable, -1, 0, NULL); + #undef H #undef Y #undef F @@ -342,6 +345,8 @@ void finish_op(void) { free_ir_op (op_Mux ); op_Mux = NULL; free_ir_op (op_CopyB ); op_CopyB = NULL; free_ir_op (op_Bound ); op_Bound = NULL; + + free_ir_op (op_Keep ); op_Keep = NULL; } /* Returns the string for the opcode. */ diff --git a/ir/ir/irop.h b/ir/ir/irop.h index c5471dfe8..4fc1666f4 100644 --- a/ir/ir/irop.h +++ b/ir/ir/irop.h @@ -75,6 +75,7 @@ typedef enum { iro_Proj, iro_Tuple, iro_Id, iro_Bad, iro_Confirm, iro_Unknown, iro_Filter, iro_Break, iro_CallBegin, iro_EndReg, iro_EndExcept, iro_NoMem, iro_Mux, iro_CopyB, iro_Bound, + iro_Keep, iro_MaxOpcode } opcode; @@ -143,6 +144,7 @@ extern ir_op *op_NoMem; ir_op *get_op_NoMem (void); extern ir_op *op_Mux; ir_op *get_op_Mux (void); extern ir_op *op_CopyB; ir_op *get_op_CopyB (void); extern ir_op *op_Bound; ir_op *get_op_Bound (void); +extern ir_op *op_Keep; ir_op *get_op_Keep (void); /** Returns the ident for the opcode name */ ident *get_op_ident(const ir_op *op); -- 2.20.1