expanded pto, added initialisation, added debugging printing
[libfirm] / ir / ana2 / pto_util.h
1 /* -*- c -*- */
2
3 /*
4  * Project:     libFIRM
5  * File name:   ir/ana2/pto_util.c
6  * Purpose:     Pto Utilities
7  * Author:      Florian
8  * Modified by:
9  * Created:     Mon 18 Oct 2004
10  * CVS-ID:      $Id$
11  * Copyright:   (c) 1999-2004 Universität Karlsruhe
12  * Licence:     This file is protected by GPL -  GNU GENERAL PUBLIC LICENSE.
13  */
14
15 # ifndef _PTO_UTIL_H_
16 # define _PTO_UTIL_H_
17
18 # include "irgraph.h"
19 # include "qset.h"
20
21 # define N_INITIAL_OBJS         5
22
23 typedef enum obj_kind_enum {
24   obj_kind_obj,
25   obj_kind_array,
26 } obj_kind_t;
27
28 typedef struct obj_desc_str
29 {
30   obj_kind_t kind;              /* written obj_kind_obj or obj_kind_array */
31   struct obj_desc_str *next;    /* link all descrs into a linked list */
32 # ifdef PTO_DUMMY
33   int is_dummy;                 /* allow to filter out dummy objects */
34 # endif /* defined PTO_DUMMY */
35   type *tp;                     /* type of described object */
36 } obj_desc_t;
37
38 typedef struct obj_obj_desc_str
39 {
40   obj_kind_t kind;              /* always written obj_kind_obj */
41   struct obj_desc_str *next;    /* link all descrs into a linked list */
42 # ifdef PTO_DUMMY
43   int is_dummy;                 /* allow to filter out dummy objects */
44 # endif /* defined PTO_DUMMY */
45   type *tp;                     /* type of described object */
46   entity **fields;              /* fields of described object */
47   int n_fields;                 /* number of fields */
48   qset_t **vals;                /* qsets of values of the fields */
49 } obj_obj_desc_t;
50
51 typedef struct obj_arr_desc_str
52 {
53   obj_kind_t kind;              /* always written obj_kind_array */
54   struct obj_desc_str *next;    /* link all descrs into a linked list */
55 # ifdef PTO_DUMMY
56   int is_dummy;                 /* allow to filter out dummy objects */
57 # endif /* defined PTO_DUMMY */
58   type *tp;                     /* (array) type of described object */
59   qset_t *val;                  /* all values of 'the' 'field' */
60 } obj_arr_desc_t;
61
62 typedef struct pto_str
63 {
64   void *kind;                   /* always written to &pto_id */
65   ir_node *node;                /* Rubbish: node for which this pto_t was constructed */
66   qset_t *objs;                 /* qset of obj_desc_t* */
67 } pto_t;
68
69
70 /* Get the entity of a ptr */
71 entity *get_ptr_ent (ir_node*);
72
73 /* Ctors for the pto types */
74 obj_desc_t *obj_desc_new (type*);
75
76 # ifdef PTO_DUMMY
77 /* Mark an obj desc as a dummy */
78 void obj_desc_set_dummy (obj_desc_t*);
79
80 /* Say whether an obj desc is a dummy */
81 int obj_desc_is_dummy (obj_desc_t*);
82 # endif /* defined PTO_DUMMY */
83
84
85 /* Deallocate an obj desc */
86 void obj_desc_delete (obj_desc_t*);
87
88 /* List all obj descs that have been created.  If tp is given non-NULL,
89   only descs for this type are listed, else all types are listed. */
90 void obj_desc_list_all (type*);
91
92 /* Create a new pto value containing a name of the given type. */
93 pto_t *pto_new_name (ir_node*, type*);
94
95 /* Create a new pto value containing no names. */
96 pto_t *pto_new_empty (ir_node*);
97
98 /* Deallocate a pto */
99 void pto_delete (pto_t*);
100
101 /* Sanity checking on a pto_t */
102 void check_pto (pto_t*);
103
104 /*   Add the given name to the given pto. */
105 void pto_add_name (pto_t*, obj_desc_t*);
106
107 /* Add all the given names to the given pto. */
108 void pto_add_all_names (pto_t*, qset_t*);
109
110
111 /* Find the arguments of a graph. For a method that has n args, the
112   result array has 'n+1' entries, the last of which is written NULL.
113   If an argument is not used, it is also written NULL in this array. */
114 ir_node **find_irg_args (ir_graph*);
115 /* int is_field (entity*); */
116
117
118 /* Perform a lookup of the contents of the given field in the given pto */
119 qset_t *pto_lookup (obj_desc_t*, entity*);
120
121 # endif /* not defined _PTO_UTIL_H_ */
122
123 \f
124 /*
125   $Log$
126   Revision 1.2  2004/11/04 14:58:38  liekweg
127   expanded pto, added initialisation, added debugging printing
128
129   Revision 1.1  2004/10/22 15:10:51  liekweg
130   moved utils to pto_util
131
132
133  */