added missing parentesis
[libfirm] / ir / ana / trouts.h
1 /*
2  * Project:     libFIRM
3  * File name:   ir/ana/trouts.h
4  * Purpose:     Reverse edges that reference types/entities.
5  * Author:      Goetz Lindenmaier
6  * Modified by:
7  * Created:     29.10.2004
8  * CVS-ID:      $Id$
9  * Copyright:   (c) 2004 Universität Karlsruhe
10  * Licence:     This file protected by GPL -  GNU GENERAL PUBLIC LICENSE.
11  */
12
13 /**
14  * @file trouts.h
15  *
16  * Trouts list all uses of types and entities.
17  * Each type gets a list of all Alloc nodes allocating it.
18  * Each entity gets two lists:
19  *   - one containing all accesses (Load, (Call), Store),
20  *   - and one containing all uses to get a reference (Sel, SymConst).
21  *
22  * @todo
23  *   To list all uses of entities of a type, we also should list all
24  *   static/automatic allocated entities in types.  The Alloc nodes
25  *   represent only the dynamic allocated entities.
26  *
27  * @author Goetz Lindenmaier
28  *
29  */
30
31 # ifndef _TROUTS_H_
32 # define _TROUTS_H_
33
34 #include "type.h"
35 #include "entity.h"
36 #include "irnode.h"
37
38
39 /*------------------------------------------------------------------*/
40 /* Accessing the trout datastructures.                              */
41 /* These routines only work properly if firm is in state            */
42 /* trouts_consistent or trouts_inconsistent.                        */
43 /*------------------------------------------------------------------*/
44
45
46 /** Number of Load/Store nodes that possibly access this entity. */
47 int get_entity_n_accesses(entity *ent);
48 /** Load/Store node that possibly access this entity. */
49 ir_node *get_entity_access(entity *ent, int pos);
50
51
52 /** Number of references to an entity, in form of SymConst/Sel.
53  *  Including references from constant entities and the like. */
54 int get_entity_n_references(entity *ent);
55 /** References to an entity, in form of SymConst/Sel
56  *  Including references from constants. */
57 ir_node *get_entity_reference(entity *ent, int pos);
58
59
60 /** Number of Alloc nodes that create an instance of this type. */
61 int get_type_n_allocs(type *tp);
62 /** Alloc node that create an instance of this type. */
63 ir_node *get_type_alloc(type *tp, int pos);
64
65 /** Number of Cast nodes that cast a pointer to this type. */
66 int get_type_n_casts(type *tp);
67 /** Cast node that cast a pointer to this type. */
68 ir_node *get_type_cast(type *tp, int pos);
69 /** Return number of upcasts. O(#casts). */
70 int get_class_n_upcasts(type *clss);
71 /** Return number of downcasts. O(#casts). */
72 int get_class_n_downcasts(type *clss);
73
74 /* Access all pointer types that point to tp. */
75 int get_type_n_pointertypes_to(type *tp);
76 type *get_type_pointertype_to(type *tp, int pos);
77
78
79 /*------------------------------------------------------------------*/
80 /* Building and Removing the trout datastructure                    */
81 /*------------------------------------------------------------------*/
82
83 /** The state of the tr_out datastructure.
84  *
85  *  We reuse the enum of irouts. */
86 irg_outs_state get_trouts_state(void);
87 void           set_trouts_inconsistent(void);
88
89 /** Compute the outs of types and entities.
90  *
91  *  Collects all reference from irnodes to types or entities in the
92  *  corresponding types/entities.  Further reverses references between
93  *  types and entities.
94  *
95  *  Annotates the following nodes:
96  *    Alloc    --> get_Alloc_type()
97  *    Cast     --> get_Cast_type()
98  *    Sel      --> get_Sel_entity()
99  *    SymConst --> get_SymConst_entity()
100  *    Load(addr)  --> get_addr_entity() \  ent von SymConst, oder falls Sel: ent von
101  *    Store(addr) --> get_addr_entity() /  outermost im compound.  Ansonsten: nirgends.
102  *                                         d.h. wir bekommen die array Elementzugriffe
103  *                                         an die jack array Klasse annotiert.
104  *    Call(Sel)   --> get_Sel_entity()  // ev. Tabellenzugriff --> Load.
105  *
106  *   type --> pointer type refering to this type.
107  *   type --> entity of this type. @@@ to be implemented.
108  *
109  *  Sets trout state to outs_consistent.
110  *
111  *  @todo @@@ We need a flag that signs the consistency of the out information. */
112 void compute_trouts(void);
113
114 /** Free trout data. */
115 void free_trouts(void);
116
117
118 #endif /* _TROUTS_H_ */