From: Götz Lindenmaier Date: Tue, 19 Aug 2003 09:29:16 +0000 (+0000) Subject: Added irg field to start, more verbose irdump X-Git-Url: http://nsz.repo.hu/git/?a=commitdiff_plain;h=f00ba73c3abff21ea8bd0236e8d1487221181150;p=libfirm Added irg field to start, more verbose irdump [r1704] --- diff --git a/ir/ir/ircons.c b/ir/ir/ircons.c index 0592148eb..3c852e4d6 100644 --- a/ir/ir/ircons.c +++ b/ir/ir/ircons.c @@ -75,6 +75,7 @@ new_rd_Start (dbg_info* db, ir_graph *irg, ir_node *block) ir_node *res; res = new_ir_node (db, irg, block, op_Start, mode_T, 0, NULL); + res->attr.start.irg = irg; irn_vrfy_irg (res, irg); return res; @@ -984,6 +985,7 @@ new_d_Start (dbg_info* db) res = new_ir_node (db, current_ir_graph, current_ir_graph->current_block, op_Start, mode_T, 0, NULL); + res->attr.start.irg = current_ir_graph; res = optimize_node (res); irn_vrfy_irg (res, current_ir_graph); diff --git a/ir/ir/irdump.c b/ir/ir/irdump.c index 825a9231e..41001d51f 100644 --- a/ir/ir/irdump.c +++ b/ir/ir/irdump.c @@ -262,7 +262,42 @@ dump_node_vcgattr (ir_node *n) static INLINE void dump_node_info (ir_node *n) { - fprintf (F, " info1: \"visited: %ld\n\"", get_irn_visited(n)); + int i; + fprintf (F, " info1: \""); + fprintf (F, "visited: %ld \n", get_irn_visited(n)); + + /* Source types */ + switch(get_irn_opcode(n)) { + case iro_Start: { + type *tp = get_entity_type(get_irg_ent(get_Start_irg(n))); + fprintf(F, "start of method of type %s \n", get_type_name(tp)); + for (i = 0; i < get_method_n_params(tp); ++i) + fprintf(F, " param %d type: %s \n", i, get_type_name(get_method_param_type(tp, i))); + } break; + case iro_Alloc: { + fprintf(F, "allocating entity of type %s \n", get_type_name(get_Alloc_type(n))); + } break; + case iro_Free: { + fprintf(F, "freeing entity of type %s \n", get_type_name(get_Free_type(n))); + } break; + case iro_Sel: { + fprintf(F, "Selecting entity of type %s \n", get_type_name(get_entity_type(get_Sel_entity(n)))); + fprintf(F, " from entity of type %s \n", get_type_name(get_entity_owner(get_Sel_entity(n)))); + } break; + case iro_Call: { + type *tp = get_Call_type(n); + fprintf(F, "calling method of type %s \n", get_type_name(tp)); + for (i = 0; i < get_method_n_params(tp); ++i) + fprintf(F, " param %d type: %s \n", i, get_type_name(get_method_param_type(tp, i))); + for (i = 0; i < get_method_n_ress(tp); ++i) + fprintf(F, " resul %d type: %s \n", i, get_type_name(get_method_res_type(tp, i))); + } break; + default: ; + } + + + fprintf (F, "\""); + } static bool pred_in_wrong_graph(ir_node *n, int pos, pmap *irgmap) { diff --git a/ir/ir/irgraph.c b/ir/ir/irgraph.c index e39554b66..0cd1a8e58 100644 --- a/ir/ir/irgraph.c +++ b/ir/ir/irgraph.c @@ -185,6 +185,7 @@ ir_graph *new_const_code_irg() { res->bad = new_ir_node (NULL, res, res->start_block, op_Bad, mode_T, 0, NULL); res->unknown = new_ir_node (NULL, res, res->start_block, op_Unknown, mode_T, 0, NULL); res->start = new_Start (); + /* Proj results of start node */ projX = new_Proj (res->start, mode_X, pns_initial_exec); set_store (new_Proj (res->start, mode_M, pns_global_store)); diff --git a/ir/ir/irnode.c b/ir/ir/irnode.c index b33fbe06e..e62322215 100644 --- a/ir/ir/irnode.c +++ b/ir/ir/irnode.c @@ -638,6 +638,20 @@ void remove_Block_cg_cfgpred_arr(ir_node * node) { node->attr.block.in_cg = NULL; } +/* Start references the irg it is in. */ +INLINE ir_graph * +get_Start_irg(ir_node *node) { + assert(node->op == op_Start); + return node->attr.start.irg; +} + +INLINE void +set_Start_irg(ir_node *node, ir_graph *irg) { + assert(node->op == op_Start); + assert(is_ir_graph(irg)); + node->attr.start.irg = irg; +} + INLINE int get_End_n_keepalives(ir_node *end) { assert (end->op == op_End); @@ -2142,6 +2156,8 @@ get_irn_irg(ir_node *node) { } else if (get_irn_op(node) == op_EndReg || get_irn_op(node) == op_EndExcept) { return node->attr.end.irg; + } else if (get_irn_op(node) == op_Start) { + return node->attr.start.irg; } else { assert(0 && "no irg attr"); return NULL; diff --git a/ir/ir/irnode.h b/ir/ir/irnode.h index aa11d37b5..b2592765c 100644 --- a/ir/ir/irnode.h +++ b/ir/ir/irnode.h @@ -114,7 +114,7 @@ INLINE void set_irn_in (ir_node *node, int arity, INLINE ir_node *get_irn_n (ir_node *node, int n); INLINE void set_irn_n (ir_node *node, int n, ir_node *in); /** Sets the mode struct of node */ -INLINE void set_irn_mode (ir_node *node, ir_mode *mode); +INLINE void set_irn_mode (ir_node *node, ir_mode *mode); /** Gets the mode struct. */ INLINE ir_mode *get_irn_mode (const ir_node *node); /** Gets the mode-enum modecode. */ @@ -144,11 +144,11 @@ INLINE void *get_irn_link (const ir_node *node); /** Outputs a unique number for this node if libfirm is compiled for debugging, (configure with --enable-debug) else returns 0. */ -INLINE long get_irn_node_nr(const ir_node *node); +INLINE long get_irn_node_nr(const ir_node *node); /** Returns the ir_graph this node belongs to. Only valid for - * CallBegin, EndReg and EndExcept */ -INLINE ir_graph *get_irn_irg(ir_node *node); + * CallBegin, EndReg, EndExcept and Start */ +INLINE ir_graph *get_irn_irg(ir_node *node); /** * irnode constructor. @@ -207,15 +207,19 @@ INLINE int Block_not_block_visited(ir_node *node); * predecessors are removed, the node has the same predecessors in * both views. * @@@ Maybe better: arity is zero if no cg preds. */ -void set_Block_cg_cfgpred_arr(ir_node * node, int arity, ir_node ** in); -void set_Block_cg_cfgpred(ir_node * node, int pos, ir_node * pred); +void set_Block_cg_cfgpred_arr(ir_node * node, int arity, ir_node ** in); +void set_Block_cg_cfgpred(ir_node * node, int pos, ir_node * pred); /* @@@ not supported */ -ir_node ** get_Block_cg_cfgpred_arr(ir_node * node); +ir_node **get_Block_cg_cfgpred_arr(ir_node * node); /* Returns the number of interproc predecessors. 0 if none. */ -int get_Block_cg_n_cfgpreds(ir_node * node); -ir_node * get_Block_cg_cfgpred(ir_node * node, int pos); +int get_Block_cg_n_cfgpreds(ir_node * node); +ir_node *get_Block_cg_cfgpred(ir_node * node, int pos); /* frees the memory. */ -void remove_Block_cg_cfgpred_arr(ir_node * node); +void remove_Block_cg_cfgpred_arr(ir_node * node); + +/* Start references the irg it is in. */ +ir_graph *get_Start_irg(ir_node *node); +void set_Start_irg(ir_node *node, ir_graph *irg); INLINE int get_End_n_keepalives(ir_node *end); INLINE ir_node *get_End_keepalive(ir_node *end, int pos); diff --git a/ir/ir/irnode_t.h b/ir/ir/irnode_t.h index a84672bf6..c5e1c465d 100644 --- a/ir/ir/irnode_t.h +++ b/ir/ir/irnode_t.h @@ -51,6 +51,11 @@ typedef struct { @todo Ev. replace by bitfield! */ } block_attr; +/** Start attributes */ +typedef struct { + ir_graph *irg; +} start_attr; + /** Cond attributes */ typedef struct { cond_kind kind; /**< flavor of Cond */ @@ -128,6 +133,7 @@ typedef struct { /** Some irnodes just have one attribute, these are stored here, some have more. Their name is 'irnodename_attr' */ typedef union { + start_attr start; /**< For Start */ block_attr block; /**< For Block: Fields needed to construct it */ cond_attr c; /**< For Cond. */ struct tarval *con; /**< For Const: contains the value of the constant */ diff --git a/ir/ir/irop.c b/ir/ir/irop.c index 197d17892..bd3492cc8 100644 --- a/ir/ir/irop.c +++ b/ir/ir/irop.c @@ -98,7 +98,7 @@ init_op(void) { op_Block = new_ir_op (iro_Block, "Block", pinned, 1, sizeof (block_attr)); - op_Start = new_ir_op (iro_Start, "Start", pinned, 0, 0); + op_Start = new_ir_op (iro_Start, "Start", pinned, 0, sizeof (start_attr)); op_End = new_ir_op (iro_End, "End", pinned, 0, 0); op_Jmp = new_ir_op (iro_Jmp, "Jmp", pinned, 0, 0); op_Cond = new_ir_op (iro_Cond, "Cond", pinned, 1, sizeof(cond_attr));