Commit 5aed52c8 authored by Florian Liekweg's avatar Florian Liekweg
Browse files

initialisation; sanitize print levels, misc fixes

[r4302]
parent f07d7abf
......@@ -66,11 +66,23 @@ static pto_t *compute_pto (ir_node *node, void *env)
{
pto_t *node_pto = get_pto (node);
if ((NULL != node_pto) && (pto_is_dummy (node_pto))) {
/* weed out initialisation data as good as possible */
DBGPRINT (0, (stdout, "%s: dummy pto for (%s[%li])\n",
__FUNCTION__,
get_op_name (get_irn_op (node)),
get_irn_node_nr (node)));
pto_delete (node_pto);
node_pto = NULL;
}
if (NULL == node_pto) {
DBGPRINT (1, (stdout, "%s: must compute pto for %s[%li]\n",
__FUNCTION__,
get_op_name (get_irn_op (node)),
get_irn_node_nr (node)));
__FUNCTION__,
get_op_name (get_irn_op (node)),
get_irn_node_nr (node)));
pto_node (node, env);
......@@ -100,10 +112,10 @@ static void set_call_args (ir_node *call, ir_graph *graph, void *env)
if (NULL != args [i-2]) {
if (mode_P == get_irn_mode (args [i-2])) {
pto_t *arg_pto = compute_pto (get_irn_n (call, i), env);
/* off-by-one because of ProjT bd */
/* off-by-two because of ProjT bd */
set_pto (args [i-2], arg_pto);
} else {
/* nothing */
/* not a pointer value */
}
}
}
......@@ -118,6 +130,17 @@ static void get_call_ret (ir_node *call, ir_graph *graph, void *env)
entity *ent = get_irg_ent (graph);
type *ent_tp = get_entity_type (ent);
if (NULL != get_pto (call)) {
pto_t *old = get_pto (call);
if (pto_is_dummy (old)) {
DBGPRINT (2, (stdout, "%s: dummy pto (0x%08x) from call[%li]\n",
__FUNCTION__, (int) old, get_irn_node_nr (call)));
}
pto_delete (old);
}
if (0 != get_method_n_ress (ent_tp)) {
type *ent_ret_tp = get_method_res_type (ent_tp, 0);
......@@ -256,14 +279,26 @@ static void pto_node_obj_load (ir_node *load, ir_node *ptr,
const char *own_name = (char*) get_type_name (get_entity_owner (ent));
DBGPRINT (1, (stdout, "%s for (%s[%li])\n",
__FUNCTION__,
get_op_name (get_irn_op (ptr)),
get_irn_node_nr (ptr)));
__FUNCTION__,
get_op_name (get_irn_op (ptr)),
get_irn_node_nr (ptr)));
if (! is_pointer_type (get_entity_type (ent))) {
return;
}
DBGPRINT (2, (stdout, "%s: obj load from ent (0x%08x) \"%s.%s\"\n",
if (NULL != get_pto (load)) {
pto_t *old = get_pto (load);
if (pto_is_dummy (old)) {
DBGPRINT (0, (stdout, "%s: dummy pto (0x%08x) from load[%li]\n",
__FUNCTION__, (int) old, get_irn_node_nr (load)));
}
pto_delete (old);
}
DBGPRINT (0, (stdout, "%s: obj load from ent (0x%08x) \"%s.%s\"\n",
__FUNCTION__,
(int) ent,
own_name,
......@@ -271,23 +306,26 @@ static void pto_node_obj_load (ir_node *load, ir_node *ptr,
pto_t *ptr_objs = compute_pto (ptr, env);
qset_t *objs = ptr_objs->objs;
pto_t *res = pto_new_empty (load);
/* todo: iterate over 'objs' ... for each obj in objs, perform
lookup using 'ent' ... assemble results in new qset ... return
that as the new value */
obj_desc_t *obj_desc = (obj_desc_t*) qset_start (objs);
/* fprintf (stdout, "%s: load ptr = ", __FUNCTION__); */
/* qset_print (ptr_objs->objs, stdout); */
while (NULL != obj_desc) {
qset_t *cnts = pto_lookup (obj_desc, ent);
pto_add_all_names (res, cnts);
/* fprintf (stdout, "%s: load val = ", __FUNCTION__); */
/* qset_print (cnts, stdout); */
obj_desc = (obj_desc_t*) qset_next (objs);
}
/* fprintf (stdout, "%s: load res = ", __FUNCTION__); */
/* qset_print (res->objs, stdout); */
set_pto (load, res);
}
......@@ -315,7 +353,7 @@ static void pto_node_arr_load (ir_node *load, ir_node *ptr,
return;
}
DBGPRINT (2, (stdout, "%s: array load from ent (0x%08x) \"%s.%s\"\n",
DBGPRINT (0, (stdout, "%s: array load from ent (0x%08x) \"%s.%s\"\n",
__FUNCTION__,
(int) ent,
own_name,
......@@ -400,7 +438,7 @@ static void pto_node_obj_store (ir_node *store,
const char *ent_name = (char*) get_entity_name (ent);
const char *own_name = (char*) get_type_name (get_entity_owner (ent));
DBGPRINT (1, (stdout, "%s: obj store from ent (0x%08x) \"%s.%s\"\n",
DBGPRINT (0, (stdout, "%s: obj store from ent (0x%08x) \"%s.%s\"\n",
__FUNCTION__,
(int) ent, own_name, ent_name));
......@@ -437,7 +475,7 @@ static void pto_node_arr_store (ir_node *store,
const char *ent_name = (char*) get_entity_name (ent);
const char *own_name = (char*) get_type_name (get_entity_owner (ent));
DBGPRINT (1, (stdout, "%s: array store from ent (0x%08x) \"%s.%s\"\n",
DBGPRINT (0, (stdout, "%s: array store from ent (0x%08x) \"%s.%s\"\n",
__FUNCTION__,
(int) ent, own_name, ent_name));
......@@ -565,7 +603,7 @@ static void pto_node_call (ir_node *call, void *env)
ir_node *ptr = get_Call_ptr (call);
entity *ent = get_ptr_ent (ptr);
DBGPRINT (0, (stdout, "%s (%s[%li])\n",
DBGPRINT (1, (stdout, "%s (%s[%li])\n",
__FUNCTION__,
get_op_name (get_irn_op (call)),
get_irn_node_nr (call)));
......@@ -589,10 +627,8 @@ static void pto_node_call (ir_node *call, void *env)
get_call_ret (call, graph, env);
}
} else {
DBGPRINT (0, (stdout, "%s:%i: Warning: no graph for ent \"%s.%s\"\n",
__FILE__, __LINE__, own_name, ent_name));
DBGPRINT (0, (stdout, "%s:%i: Warning: no graph for call call[%li]\n",
__FILE__, __LINE__, get_irn_node_nr (call)));
DBGPRINT (0, (stdout, "%s:%i: Warning: no graph for ent \"%s.%s\" in call[%li]\n",
__FILE__, __LINE__, own_name, ent_name, get_irn_node_nr (call)));
}
}
......@@ -656,7 +692,7 @@ static void pto_node_phi (ir_node *phi, void *env)
pto_t *in_pto = compute_pto (in, env);
DBGPRINT (1, (stdout, "%s: IN PHI Node (%ld) (%s) (pto = 0x%08x)\n",
DBGPRINT (0, (stdout, "%s: IN PHI Node (%ld) (%s) (pto = 0x%08x)\n",
__FUNCTION__,
get_irn_node_nr (in),
get_op_name (get_irn_op (in)),
......@@ -817,8 +853,8 @@ static void pto_node (ir_node *node, void *env)
case (iro_DivMod):
set_pto (node, NULL);
break;
/* stopgap measure */
default: {
/* stopgap measure */
DBGPRINT (0, (stdout, "%s: not handled: node[%li].op = %s\n",
__FUNCTION__,
get_irn_node_nr (node),
......@@ -973,6 +1009,9 @@ void pto_cleanup ()
/*
* $Log$
* Revision 1.5 2004/11/08 12:33:06 liekweg
* initialisation; sanitize print levels, misc fixes
*
* Revision 1.4 2004/11/04 14:58:38 liekweg
* expanded pto, added initialisation, added debugging printing
*
......
......@@ -30,13 +30,8 @@ static void pto_init_proj_load (ir_node *proj, ir_node *load)
{
assert ((mode_P == get_irn_mode (proj)) && "wrong proj(load)");
# ifdef PTO_DUMMY
ir_node *ptr = get_Load_ptr (load);
entity *ent = get_ptr_ent (ptr);
type *tp = get_entity_type (ent);
# endif /* defined PTO_DUMMY */
pto_t *pto = pto_new_empty (proj);
pto_set_dummy (pto);
DBGPRINT (1, (stdout, "%s: pto (%s[%li]) = 0x%08x\n",
__FUNCTION__,
......@@ -55,26 +50,19 @@ static void pto_init_call (ir_node *call)
type *meth_tp = get_entity_type (ent);
if (0 == get_method_n_ress (meth_tp)) {
/* can't be a pointer */
/* no return value at all */
return;
}
type *ret_tp = get_method_res_type (meth_tp, 0);
if (mode_P != get_type_mode (ret_tp)) {
/* no pointer-valued return value */
return;
}
# ifdef PTO_DUMMY
ir_node *ptr = get_Call_ptr (call);
entity *ent = get_ptr_ent (ptr);
type *tp = get_entity_type (ent);
obj_desc_t *obj_desc = obj_desc_new (tp);
obj_desc_set_dummy (obj_desc);
# endif /* defined PTO_DUMMY */
pto_t *pto = pto_new_empty (call);
pto_set_dummy (pto);
DBGPRINT (1, (stdout, "%s: pto (%s[%li]) = 0x%08x\n",
__FUNCTION__,
......@@ -131,11 +119,11 @@ static void pto_init_proj (ir_node *proj)
} break;
case (iro_Load): {
/* Todo: ProjM (load) or ProjV(load) */
if (mode_P == get_irn_mode (proj)) {
/* ProjV(load) */
pto_init_proj_load (proj, in);
} else {
/* nothing to do */
/* ProjM(load) --- nothing to do */
}
} break;
......@@ -148,7 +136,7 @@ static void pto_init_proj (ir_node *proj)
} break;
case (iro_Raise): {
/* ProjM (raise) or Proj???(raise) --- TODO */
/* ProjX (raise) --- TODO */
} break;
case (iro_Cast): {
......@@ -252,6 +240,9 @@ void pto_init_node (ir_node *node)
/*
* $Log$
* Revision 1.2 2004/11/08 12:33:06 liekweg
* initialisation; sanitize print levels, misc fixes
*
* Revision 1.1 2004/11/04 14:58:59 liekweg
* added initialisation
*
......
......@@ -158,17 +158,22 @@ static void find_irg_arg (ir_node *node, void *env)
*/
static void obj_desc_print (obj_desc_t *obj)
{
const char *tp_name = get_type_name (obj->tp);
if (obj_kind_obj == obj->kind) {
/* object desc */
obj_obj_desc_t *obj_obj = (obj_obj_desc_t*) obj;
int i;
fprintf (stdout, "obj desc 0x%08x for type \"%s\"\n",
(int) obj, get_type_name (obj->tp));
(int) obj, tp_name);
for (i = 0; i < obj_obj->n_fields; i ++) {
fprintf (stdout, " \"%s\" -> ", get_entity_name (obj_obj->fields [i]));
qset_print (obj_obj->vals [i], stdout);
if (! qset_is_empty (obj_obj->vals [i])) {
fprintf (stdout, " \"%s.%s\" -> ",
tp_name, get_entity_name (obj_obj->fields [i]));
qset_print (obj_obj->vals [i], stdout);
}
}
} else if (obj_kind_array == obj->kind) {
......@@ -178,8 +183,10 @@ static void obj_desc_print (obj_desc_t *obj)
fprintf (stdout, "arr desc 0x%08x for type \"%s\"\n",
(int) obj, get_type_name (obj->tp));
fprintf (stdout, " [] -> ");
qset_print (obj_arr->val, stdout);
if (! qset_is_empty (obj_arr->val)) {
fprintf (stdout, " %s.[] -> ", tp_name);
qset_print (obj_arr->val, stdout);
}
} else {
fprintf (stderr, "%s:%i: Invalid desc\n", __FILE__, __LINE__);
}
......@@ -354,6 +361,7 @@ pto_t *pto_new_empty (ir_node *node)
pto->kind = &pto_id;
pto->node = node;
pto->is_dummy = FALSE;
pto->objs = qset_new (N_INITIAL_OBJS);
return (pto);
......@@ -412,6 +420,17 @@ void pto_add_all_names (pto_t *pto, qset_t *objs)
qset_insert_all (pto->objs, objs);
}
/* Mark the given pto as a dumy */
void pto_set_dummy (pto_t *pto)
{
pto->is_dummy = TRUE;
}
/* Say whether the given pto is a dummy */
int pto_is_dummy (pto_t *pto)
{
return (pto->is_dummy);
}
/*
Find the arguments of a graph. For a method that has n args, the
......@@ -507,6 +526,9 @@ void pto_enter (obj_desc_t *obj_desc, entity *ent, pto_t *pto)
/*
$Log$
Revision 1.4 2004/11/08 12:33:06 liekweg
initialisation; sanitize print levels, misc fixes
Revision 1.3 2004/11/04 14:58:38 liekweg
expanded pto, added initialisation, added debugging printing
......
......@@ -29,9 +29,6 @@ typedef struct obj_desc_str
{
obj_kind_t kind; /* written obj_kind_obj or obj_kind_array */
struct obj_desc_str *next; /* link all descrs into a linked list */
# ifdef PTO_DUMMY
int is_dummy; /* allow to filter out dummy objects */
# endif /* defined PTO_DUMMY */
type *tp; /* type of described object */
} obj_desc_t;
......@@ -39,9 +36,6 @@ typedef struct obj_obj_desc_str
{
obj_kind_t kind; /* always written obj_kind_obj */
struct obj_desc_str *next; /* link all descrs into a linked list */
# ifdef PTO_DUMMY
int is_dummy; /* allow to filter out dummy objects */
# endif /* defined PTO_DUMMY */
type *tp; /* type of described object */
entity **fields; /* fields of described object */
int n_fields; /* number of fields */
......@@ -52,9 +46,6 @@ typedef struct obj_arr_desc_str
{
obj_kind_t kind; /* always written obj_kind_array */
struct obj_desc_str *next; /* link all descrs into a linked list */
# ifdef PTO_DUMMY
int is_dummy; /* allow to filter out dummy objects */
# endif /* defined PTO_DUMMY */
type *tp; /* (array) type of described object */
qset_t *val; /* all values of 'the' 'field' */
} obj_arr_desc_t;
......@@ -63,6 +54,7 @@ typedef struct pto_str
{
void *kind; /* always written to &pto_id */
ir_node *node; /* Rubbish: node for which this pto_t was constructed */
int is_dummy; /* allow to filter out dummy values */
qset_t *objs; /* qset of obj_desc_t* */
} pto_t;
......@@ -73,15 +65,6 @@ entity *get_ptr_ent (ir_node*);
/* Ctors for the pto types */
obj_desc_t *obj_desc_new (type*);
# ifdef PTO_DUMMY
/* Mark an obj desc as a dummy */
void obj_desc_set_dummy (obj_desc_t*);
/* Say whether an obj desc is a dummy */
int obj_desc_is_dummy (obj_desc_t*);
# endif /* defined PTO_DUMMY */
/* Deallocate an obj desc */
void obj_desc_delete (obj_desc_t*);
......@@ -107,6 +90,11 @@ void pto_add_name (pto_t*, obj_desc_t*);
/* Add all the given names to the given pto. */
void pto_add_all_names (pto_t*, qset_t*);
/* Mark the given pto as a dumy */
void pto_set_dummy (pto_t*);
/* Say whether the given pto is a dummy */
int pto_is_dummy (pto_t*);
/* Find the arguments of a graph. For a method that has n args, the
result array has 'n+1' entries, the last of which is written NULL.
......@@ -123,6 +111,9 @@ qset_t *pto_lookup (obj_desc_t*, entity*);
/*
$Log$
Revision 1.3 2004/11/08 12:33:06 liekweg
initialisation; sanitize print levels, misc fixes
Revision 1.2 2004/11/04 14:58:38 liekweg
expanded pto, added initialisation, added debugging printing
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment