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 /** Return number of upcasts. O(#casts). */
74 int get_class_n_upcasts(type *clss);
75 /** Return number of downcasts. O(#casts). */
76 int get_class_n_downcasts(type *clss);
78 /* Access all pointer types that point to tp. */
79 int get_type_n_pointertypes_to(type *tp);
80 type *get_type_pointertype_to(type *tp, int pos);
82 /* @@@ TODO: compute all entities that use a type. */
84 /*------------------------------------------------------------------*/
85 /* Building and Removing the trout datastructure */
86 /*------------------------------------------------------------------*/
88 /** The state of the tr_out datastructure.
90 * We reuse the enum of irouts.
92 irg_outs_state get_trouts_state(void);
93 void set_trouts_inconsistent(void);
95 /** Compute the outs of types and entities.
97 * Collects all reference from irnodes to types or entities in the
98 * corresponding types/entities. Further reverses references between
101 * Annotates the following nodes:
102 * Alloc --> get_Alloc_type()
103 * Cast --> get_Cast_type()
104 * Sel --> get_Sel_entity()
105 * SymConst --> get_SymConst_entity()
106 * Load(addr) --> get_addr_entity() \ ent von SymConst, oder falls Sel: ent von
107 * Store(addr) --> get_addr_entity() / outermost im compound. Ansonsten: nirgends.
108 * d.h. wir bekommen die array Elementzugriffe
109 * an die jack array Klasse annotiert.
110 * Call(Sel) --> get_Sel_entity() // ev. Tabellenzugriff --> Load.
112 * type --> pointer type refering to this type.
113 * type --> entity of this type. @@@ to be implemented.
115 * Sets trout state to outs_consistent.
117 void compute_trouts(void);
119 /** Free trout data. */
120 void free_trouts(void);
123 #endif /* _TROUTS_H_ */