From f820247df1468dc6797972a3d8df60197c167375 Mon Sep 17 00:00:00 2001 From: =?utf8?q?G=C3=B6tz=20Lindenmaier?= Date: Sat, 25 Sep 2004 11:24:03 +0000 Subject: [PATCH] comments, better assertions [r3952] --- ir/ir/irgopt.c | 6 +++--- ir/ir/irgwalk.h | 3 +-- ir/ir/irnode.c | 8 ++++---- ir/ir/irnode.h | 52 +++++++++++++++++++++++++++++++++++-------------- 4 files changed, 45 insertions(+), 24 deletions(-) diff --git a/ir/ir/irgopt.c b/ir/ir/irgopt.c index 32245e53f..d914136b4 100644 --- a/ir/ir/irgopt.c +++ b/ir/ir/irgopt.c @@ -55,9 +55,9 @@ static void init_link (ir_node *n, void *env) { } #if 0 /* Old version. Avoids Ids. - This is not necessary: we do a postwalk, and get_irn_n - removes ids anyways. So it's much cheaper to call the - optimization less often and use the exchange() algorithm. */ + This is not necessary: we do a postwalk, and get_irn_n + removes ids anyways. So it's much cheaper to call the + optimization less often and use the exchange() algorithm. */ static void optimize_in_place_wrapper (ir_node *n, void *env) { int i, irn_arity; diff --git a/ir/ir/irgwalk.h b/ir/ir/irgwalk.h index ddf6ed463..1983be470 100644 --- a/ir/ir/irgwalk.h +++ b/ir/ir/irgwalk.h @@ -105,8 +105,7 @@ void all_irg_walk(irg_walk_func *pre, irg_walk_func *post, void *env); */ void cg_walk(irg_walk_func *pre, irg_walk_func *post, void *env); -/** - * Walks only over Block nodes in the graph. +/** Walks only over Block nodes in the graph. * * @param node - the start node * @param pre - walker function, executed before the predecessor of a node are visited diff --git a/ir/ir/irnode.c b/ir/ir/irnode.c index fd2b94565..a446381cf 100644 --- a/ir/ir/irnode.c +++ b/ir/ir/irnode.c @@ -1158,22 +1158,22 @@ set_Call_type (ir_node *node, type *tp) { } int Call_has_callees(ir_node *node) { - + assert(node && node->op == op_Call); return ((get_irg_callee_info_state(get_irn_irg(node)) != irg_callee_info_none) && (node->attr.call.callee_arr != NULL)); } int get_Call_n_callees(ir_node * node) { - assert(node->op == op_Call && node->attr.call.callee_arr); + assert(node && node->op == op_Call && node->attr.call.callee_arr); return ARR_LEN(node->attr.call.callee_arr); } entity * get_Call_callee(ir_node * node, int pos) { - assert(node->op == op_Call && node->attr.call.callee_arr); + assert(pos >= 0 && pos < get_Call_n_callees(node)); return node->attr.call.callee_arr[pos]; } -void set_Call_callee_arr(ir_node * node, int n, entity ** arr) { +void set_Call_callee_arr(ir_node * node, const int n, entity ** arr) { assert(node->op == op_Call); if (node->attr.call.callee_arr == NULL || get_Call_n_callees(node) != n) { node->attr.call.callee_arr = NEW_ARR_D(entity *, current_ir_graph->obst, n); diff --git a/ir/ir/irnode.h b/ir/ir/irnode.h index d2a3e6657..9fd194b24 100644 --- a/ir/ir/irnode.h +++ b/ir/ir/irnode.h @@ -221,9 +221,7 @@ new_ir_node (dbg_info *db, /** This works for all except Block. To express the difference to * access routines that work for all nodes we use infix "nodes" and do not * name this function get_irn_block. */ -#define get_nodes_block get_nodes_Block ir_node *get_nodes_block (ir_node *node); -#define set_nodes_block set_nodes_Block void set_nodes_block (ir_node *node, ir_node *block); /** @@ -470,16 +468,29 @@ void set_Call_type (ir_node *node, type *tp); /** Gets the arity of a call. Identical to get_Call_n_params(). */ int get_Call_arity (ir_node *node); -/* Set, get and remove the callee-analysis. - The array is only accessible if information is valid. - It contains NULL for called methods that are not within - the compilation unit. */ +/** Set, get and remove the callee information for a Call node. + * + * The callee information lists all method entities that can be called + * from this node. If the address expression can not be analyzed fully, + * e.g., as there are external methods that could be called, the array + * contains a single NULL entry. + * + * The array is only accessible if callee information is valid. See flag + * in graph. + * + * The memory allocated for the array is managed automatically, i.e., it must + * not be freed if the Call node is removed from the graph. + * + * @param node A Call node. + */ int Call_has_callees (ir_node *node); -int get_Call_n_callees (ir_node * node); -entity *get_Call_callee (ir_node * node, int pos); -/* assumes current_ir_graph set properly! */ -void set_Call_callee_arr (ir_node * node, int n, entity ** arr); -void remove_Call_callee_arr(ir_node * node); +int get_Call_n_callees (ir_node *node); +entity *get_Call_callee (ir_node *node, int pos); +/** Set the full callee array. + * + * The passed array is copied. Assumes current_ir_graph set properly! */ +void set_Call_callee_arr (ir_node *node, const int n, entity **arr); +void remove_Call_callee_arr(ir_node *node); ir_node *get_CallBegin_ptr (ir_node *node); void set_CallBegin_ptr (ir_node *node, ir_node *ptr); @@ -502,10 +513,21 @@ void set_FuncCall_type (ir_node *node, type *tp); /** Gets the arity of a func call. Identical to get_FuncCall_n_params(). */ int get_FuncCall_arity (ir_node *node); -/* Set, get and remove the callee-analysis. - The array is only accessible if information is valid. - It contains NULL for called methods that are not within - the compilation unit. */ +/** Set, get and remove the callee information for a Call node. + * + * The callee information lists all method entities that can be called + * from this node. If the address expression can not be analyzed fully, + * e.g., as there are external methods that could be called, the array + * contains a single NULL entry. + * + * The array is only accessible if callee information is valid. See flag + * in graph. + * + * The memory allocated for the array is managed automatically, i.e., it must + * not be freed if the Call node is removed from the graph. + * + * @param node A FuncCall node. + */ int FuncCall_has_callees (ir_node *node); int get_FuncCall_n_callees (ir_node * node); entity *get_FuncCall_callee (ir_node * node, int pos); -- 2.20.1