5 * File name: ir/ana2/pto_util.c
6 * Purpose: Pto Utilities
9 * Created: Mon 18 Oct 2004
11 * Copyright: (c) 1999-2004 Universität Karlsruhe
12 * Licence: This file is protected by GPL - GNU GENERAL PUBLIC LICENSE.
20 # include "pto_util.h"
29 Environment for find_irg_args
31 typedef struct find_irg_args_env {
34 } find_irg_args_env_t;
37 Helper for find_irg_args
39 static void find_irg_arg (ir_node *node, void *env)
41 find_irg_args_env_t *arg_env = (find_irg_args_env_t*) env;
43 if (iro_Proj == get_irn_opcode (node)) {
44 if (arg_env->arg == get_Proj_pred (node)) {
45 long n = get_Proj_proj (node);
47 assert (! arg_env->args [n]);
49 arg_env->args [n] = node;
55 Find the arguments of a graph. For a method that has n args, the
56 result array has 'n+1' entries, the last of which is written NULL.
58 ir_node **find_irg_args (ir_graph *graph)
60 type *tp = get_entity_type (get_irg_entity (graph));
61 const int n_args = get_method_n_params (tp);
62 ir_node **args = (ir_node**) xmalloc (sizeof (ir_node*) * (n_args+1));
63 ir_node *arg = get_irg_args (graph);
64 find_irg_args_env_t *arg_env =
65 (find_irg_args_env_t*) xmalloc (sizeof (find_irg_args_env_t));
70 /* or use get_irg_end ?!? */
72 ir_graph *save = get_current_ir_graph ();
73 set_current_ir_graph (graph);
74 irg_walk (get_irg_end (graph), find_irg_arg, NULL, arg_env);
75 set_current_ir_graph (save);
89 Revision 1.2 2004/10/25 11:59:45 liekweg
92 Revision 1.1 2004/10/22 15:10:51 liekweg
93 moved utils to pto_util