3 * File name: ir/ana/trouts.h
4 * Purpose: Reverse edges that reference types/entities.
5 * Author: Goetz Lindenmaier
9 * Copyright: (c) 2004 Universität Karlsruhe
10 * Licence: This file protected by GPL - GNU GENERAL PUBLIC LICENSE.
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).
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.
27 * @author Goetz Lindenmaier
38 /*-----------------------------------------------------------------*/
39 /* Accessing the trout datastructures. */
40 /* These routines only work properly if firm is in state */
41 /* trouts_consistent or trouts_inconsistent. */
42 /*-----------------------------------------------------------------*/
44 /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
46 /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
48 /** Number of Load/Store nodes that possibly access this entity. */
49 int get_entity_n_accesses(entity *ent);
50 /** Load/Store node that possibly access this entity. */
51 ir_node *get_entity_access(entity *ent, int pos);
53 /** Number of references to an entity, in form of SymConst/Sel.
54 * Including references from constant entities and the like. */
55 int get_entity_n_references(entity *ent);
56 /** References to an entity, in form of SymConst/Sel
57 * Including references from constants. */
58 ir_node *get_entity_reference(entity *ent, int pos);
60 /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
62 /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
64 /** Number of Alloc nodes that create an instance of this type. */
65 int get_type_n_allocs(type *tp);
66 /** Alloc node that create an instance of this type. */
67 ir_node *get_type_alloc(type *tp, int pos);
69 /** Number of Cast nodes that cast a pointer to this type. */
70 int get_type_n_casts(type *tp);
71 /** Cast node that cast a pointer to this type. */
72 ir_node *get_type_cast(type *tp, int pos);
73 void add_type_cast(type *tp, ir_node *cast);
74 /** Return number of upcasts. O(#casts). */
75 int get_class_n_upcasts(type *clss);
76 /** Return number of downcasts. O(#casts). */
77 int get_class_n_downcasts(type *clss);
79 /* Access all pointer types that point to tp. */
80 int get_type_n_pointertypes_to(type *tp);
81 type *get_type_pointertype_to(type *tp, int pos);
82 void add_type_pointertype_to(type *tp, type *ptp);
84 /* @@@ TODO: compute all entities that use a type. */
86 /*------------------------------------------------------------------*/
87 /* Building and Removing the trout datastructure */
88 /*------------------------------------------------------------------*/
90 /** The state of the tr_out datastructure.
92 * We reuse the enum of irouts.
94 irg_outs_state get_trouts_state(void);
95 /** Set the tr out state to inconsistent if it is consistent. */
96 void set_trouts_inconsistent(void);
98 /** Compute the outs of types and entities.
100 * Collects all reference from irnodes to types or entities in the
101 * corresponding types/entities. Further reverses references between
102 * types and entities.
104 * Annotates the following nodes:
105 * Alloc --> get_Alloc_type()
106 * Cast --> get_Cast_type()
107 * Sel --> get_Sel_entity()
108 * SymConst --> get_SymConst_entity()
109 * Load(addr) --> get_addr_entity() \ ent von SymConst, oder falls Sel: ent von
110 * Store(addr) --> get_addr_entity() / outermost im compound. Ansonsten: nirgends.
111 * d.h. wir bekommen die array Elementzugriffe
112 * an die jack array Klasse annotiert.
113 * Call(Sel) --> get_Sel_entity() // ev. Tabellenzugriff --> Load.
115 * type --> pointer type refering to this type.
116 * type --> entity of this type. @@@ to be implemented.
118 * Sets trout state to outs_consistent.
120 void compute_trouts(void);
122 /** Free trout data. */
123 void free_trouts(void);
126 #endif /* _TROUTS_H_ */