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"
25 # include "irnode_t.h"
29 # include "pto_debug.h"
35 # endif /* not defined TRUE */
37 /* Local Data Types: */
38 /* Environment for find_irg_args */
39 typedef struct find_irg_args_env {
42 } find_irg_args_env_t;
45 /* Local Variables: */
47 /* Local Prototypes: */
49 /* ===================================================
51 =================================================== */
52 /* Helper for find_irg_args */
53 static void find_irg_arg (ir_node *node, void *env)
55 find_irg_args_env_t *arg_env = (find_irg_args_env_t*) env;
57 if (iro_Proj == get_irn_opcode (node)) {
58 if (arg_env->arg == get_Proj_pred (node)) {
59 long n = get_Proj_proj (node);
61 assert (! arg_env->args [n]);
63 arg_env->args [n] = node;
68 /* ===================================================
69 Exported Implementation:
70 =================================================== */
71 /* Find the arguments of a graph. For a method that has n args, the
72 result array has 'n+1' entries, the last of which is written NULL. */
73 ir_node **find_irg_args (ir_graph *graph)
75 type *tp = get_entity_type (get_irg_entity (graph));
76 const int n_args = get_method_n_params (tp);
77 ir_node **args = (ir_node**) xmalloc (sizeof (ir_node*) * (n_args+1));
78 ir_node *arg = get_irg_args (graph);
79 find_irg_args_env_t *arg_env =
80 (find_irg_args_env_t*) xmalloc (sizeof (find_irg_args_env_t));
85 /* or use get_irg_end ?!? */
87 ir_graph *save = get_current_ir_graph ();
88 set_current_ir_graph (graph);
89 irg_walk (get_irg_end (graph), find_irg_arg, NULL, arg_env);
90 set_current_ir_graph (save);
100 /* Get the entity of a ptr */
101 entity *get_ptr_ent (ir_node *ptr)
104 const opcode ptr_op = get_irn_opcode (ptr);
107 ent = get_ptr_ent (get_Cast_op (ptr));
110 ent = get_Sel_entity (ptr);
113 case (iro_SymConst): {
114 ent = get_SymConst_entity (ptr);
118 fprintf (stderr, "%s: no ent for ptr=%s[%ld]\n",
120 get_op_name (get_irn_op (ptr)),
121 get_irn_node_nr (ptr));
129 /* Check whether the load of the given ptr is a dummy */
130 int is_dummy_load_ptr (ir_node *ptr)
132 const opcode ptr_op = get_irn_opcode (ptr);
136 return (is_dummy_load_ptr (get_Cast_op (ptr)));
139 case (iro_SymConst): {
154 Revision 1.9 2004/12/02 16:17:51 beck
155 fixed config.h include
157 Revision 1.8 2004/11/26 15:59:14 liekweg
158 recognize dummy loads
160 Revision 1.7 2004/11/24 14:53:56 liekweg
163 Revision 1.6 2004/11/18 16:37:07 liekweg