5 File name: ir/ana/pto_util.c
6 Purpose: Utilitites for PTO
9 Created: Sat Nov 13 19:35:27 CET 2004
11 Copyright: (c) 1999-2004 Universität Karlsruhe
12 Licence: This file is protected by the GPL - GNU GENERAL PUBLIC LICENSE.
20 pto_util: Utilitites for PTO
23 # include "pto_util.h"
29 # include "pto_debug.h"
33 /* Local Data Types: */
34 /* Environment for find_irg_args */
35 typedef struct find_irg_args_env {
38 } find_irg_args_env_t;
41 /* Local Variables: */
43 /* Local Prototypes: */
45 /* ===================================================
47 =================================================== */
48 /* Helper for find_irg_args */
49 static void find_irg_arg (ir_node *node, void *env)
51 find_irg_args_env_t *arg_env = (find_irg_args_env_t*) env;
53 if (iro_Proj == get_irn_opcode (node)) {
54 if (arg_env->arg == get_Proj_pred (node)) {
55 long n = get_Proj_proj (node);
57 assert (! arg_env->args [n]);
59 arg_env->args [n] = node;
64 /* ===================================================
65 Exported Implementation:
66 =================================================== */
67 /* Find the arguments of a graph. For a method that has n args, the
68 result array has 'n+1' entries, the last of which is written NULL. */
69 ir_node **find_irg_args (ir_graph *graph)
71 type *tp = get_entity_type (get_irg_entity (graph));
72 const int n_args = get_method_n_params (tp);
73 ir_node **args = (ir_node**) xmalloc (sizeof (ir_node*) * (n_args+1));
74 ir_node *arg = get_irg_args (graph);
75 find_irg_args_env_t *arg_env =
76 (find_irg_args_env_t*) xmalloc (sizeof (find_irg_args_env_t));
81 /* or use get_irg_end ?!? */
83 ir_graph *save = get_current_ir_graph ();
84 set_current_ir_graph (graph);
85 irg_walk (get_irg_end (graph), find_irg_arg, NULL, arg_env);
86 set_current_ir_graph (save);
95 /* Get the entity of a ptr */
96 entity *get_ptr_ent (ir_node *ptr)
99 const opcode ptr_op = get_irn_opcode (ptr);
102 ent = get_Sel_entity (ptr);
105 case (iro_SymConst): {
106 ent = get_SymConst_entity (ptr);
110 fprintf (stderr, "%s: no ent for ptr=%s[%ld]\n",
112 get_op_name (get_irn_op (ptr)),
113 get_irn_node_nr (ptr));
126 Revision 1.7 2004/11/24 14:53:56 liekweg
129 Revision 1.6 2004/11/18 16:37:07 liekweg