5 * File name: ir/ana2/pto_init.c
6 * Purpose: Pto Initialization
9 * Created: Wed 3 Nov 2004
11 * Copyright: (c) 1999-2004 Universität Karlsruhe
12 * Licence: This file is protected by GPL - GNU GENERAL PUBLIC LICENSE.
21 # include "pto_util.h"
27 # define DBGPRINT(lvl, msg) if (get_pto_verbose () > lvl) { fprintf msg; }
29 static void pto_init_proj_load (ir_node *proj, ir_node *load)
31 assert ((mode_P == get_irn_mode (proj)) && "wrong proj(load)");
34 ir_node *ptr = get_Load_ptr (load);
35 entity *ent = get_ptr_ent (ptr);
36 type *tp = get_entity_type (ent);
37 # endif /* defined PTO_DUMMY */
39 pto_t *pto = pto_new_empty (proj);
41 DBGPRINT (1, (stdout, "%s: pto (%s[%li]) = 0x%08x\n",
43 get_op_name (get_irn_op (proj)),
44 get_irn_node_nr (proj),
50 static void pto_init_call (ir_node *call)
52 /* check return value: */
53 ir_node *ptr = get_Call_ptr (call);
54 entity *ent = get_ptr_ent (ptr);
55 type *meth_tp = get_entity_type (ent);
57 if (0 == get_method_n_ress (meth_tp)) {
58 /* can't be a pointer */
62 type *ret_tp = get_method_res_type (meth_tp, 0);
64 if (mode_P != get_type_mode (ret_tp)) {
69 ir_node *ptr = get_Call_ptr (call);
70 entity *ent = get_ptr_ent (ptr);
71 type *tp = get_entity_type (ent);
73 obj_desc_t *obj_desc = obj_desc_new (tp);
74 obj_desc_set_dummy (obj_desc);
75 # endif /* defined PTO_DUMMY */
77 pto_t *pto = pto_new_empty (call);
79 DBGPRINT (1, (stdout, "%s: pto (%s[%li]) = 0x%08x\n",
81 get_op_name (get_irn_op (call)),
82 get_irn_node_nr (call),
88 static void pto_init_raise (ir_node *raise)
90 /* assert (0 && "initialise raise?"); */
92 /* right now, do nothing and hope that a raise can always be
93 analysed on-the-fly. */
96 static void pto_init_proj (ir_node *proj)
98 ir_node *in = get_Proj_pred (proj);
99 const opcode in_op = get_irn_opcode (in);
103 ir_node *in_in = get_Proj_pred (in);
104 const opcode in_in_op = get_irn_opcode (in_in);
108 /* nothing (always initialised with actual values) */
112 /* nothing (must use call itself) */
116 fprintf (stderr, "%s: proj(proj(%s[%ld])) not handled\n",
118 get_op_name (get_irn_op (in_in)),
119 get_irn_node_nr (in_in));
122 } /* end switch(Proj.Proj.op) */
123 } break; /* iro_Proj */
126 /* ProjM (start) or ProjT (start) --- nothing */
130 /* ProjT (start) --- nothing */
134 /* Todo: ProjM (load) or ProjV(load) */
135 if (mode_P == get_irn_mode (proj)) {
136 pto_init_proj_load (proj, in);
143 /* ProjM (store) --- nothing */
147 /* nothing to do --- can always be computed on-the-fly */
151 /* ProjM (raise) or Proj???(raise) --- TODO */
159 fprintf (stderr, "%s: proj(%s[%ld]) not handled\n",
161 get_op_name (get_irn_op (in)),
162 get_irn_node_nr (in));
165 } /* end switch (Proj.op) */
169 void pto_init_node (ir_node *node)
171 const opcode op = get_irn_opcode (node);
173 DBGPRINT (1, (stdout, "%s (%s[%li])\n",
175 get_op_name (get_irn_op (node)),
176 get_irn_node_nr (node)));
180 /* nothing (not needed) */
184 /* nothing (not needed) */
188 /* nothing (not needed) */
192 /* nothing (can always be computed on-the-fly) */
196 /* Todo: Check how a Raise works */
197 pto_init_raise (node);
201 /* pretend we have a return value */
202 pto_init_call (node);
206 /* this actually does most of the work */
207 pto_init_proj (node);
211 /* nothing (can always be computed on-the-fly) */
214 case (iro_SymConst): {
215 /* nothing (can always be computed on-the-fly) */
219 /* nothing (can always be computed on-the-fly) */
223 /* nothing (this is only interesting for the end block, and that
224 can always be computed on-the-fly) */
228 /* nothing (This would need the predecessors to be initialized! Do this on-the-fly) */
231 /* now, enumerate everything else that is uninteresting */
237 /* nothing (not needed) */
241 fprintf (stderr, "%s: %s[%ld] not handled\n",
243 get_op_name (get_irn_op (node)),
244 get_irn_node_nr (node));
255 * Revision 1.1 2004/11/04 14:58:59 liekweg
256 * added initialisation