2 * Copyright (C) 1995-2011 University of Karlsruhe. All right reserved.
4 * This file is part of libFirm.
6 * This file may be distributed and/or modified under the terms of the
7 * GNU General Public License version 2 as published by the Free Software
8 * Foundation and appearing in the file LICENSE.GPL included in the
9 * packaging of this file.
11 * Licensees holding valid libFirm Professional Edition licenses may use
12 * this file in accordance with the libFirm Commercial License.
13 * Agreement provided with the Software.
15 * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
16 * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * @brief Reverse edges that reference types/entities.
23 * @author Goetz Lindenmaier
27 * Trouts list all uses of types and entities.
28 * Each type gets a list of all Alloc nodes allocating it.
29 * Each entity gets two lists:
30 * - one containing all accesses (Load, (Call), Store),
31 * - and one containing all uses to get a reference (Sel, SymConst).
33 #ifndef FIRM_ANA_TROUTS_H
34 #define FIRM_ANA_TROUTS_H
36 #include "firm_types.h"
41 /** Number of Load/Store nodes that possibly access this entity. */
42 FIRM_API size_t get_entity_n_accesses(const ir_entity *ent);
43 /** Load/Store node that possibly access this entity. */
44 FIRM_API ir_node *get_entity_access(const ir_entity *ent, size_t pos);
46 /** Number of references to an entity, in form of SymConst/Sel.
47 * Including references from constant entities and the like. */
48 FIRM_API size_t get_entity_n_references(const ir_entity *ent);
49 /** References to an entity, in form of SymConst/Sel
50 * Including references from constants. */
51 FIRM_API ir_node *get_entity_reference(const ir_entity *ent, size_t pos);
53 /** Number of Alloc nodes that create an instance of this type. */
54 FIRM_API size_t get_type_n_allocs(const ir_type *tp);
55 /** Alloc node that create an instance of this type. */
56 FIRM_API ir_node *get_type_alloc(const ir_type *tp, size_t pos);
58 /** Number of Cast nodes that cast a pointer to this type. */
59 FIRM_API size_t get_type_n_casts(const ir_type *tp);
60 /** Cast node that cast a pointer to this type. */
61 FIRM_API ir_node *get_type_cast(const ir_type *tp, size_t pos);
62 FIRM_API void add_type_cast(const ir_type *tp, ir_node *cast);
63 /** Return number of upcasts. O(\#casts). */
64 FIRM_API size_t get_class_n_upcasts(const ir_type *clss);
65 /** Return number of downcasts. O(\#casts). */
66 FIRM_API size_t get_class_n_downcasts(const ir_type *clss);
68 FIRM_API size_t get_type_n_pointertypes_to(const ir_type *tp);
69 FIRM_API ir_type *get_type_pointertype_to(const ir_type *tp, size_t pos);
70 FIRM_API void add_type_pointertype_to(const ir_type *tp, ir_type *ptp);
72 FIRM_API size_t get_type_n_arraytypes_of(const ir_type *tp);
73 FIRM_API ir_type *get_type_arraytype_of(const ir_type *tp, size_t pos);
74 FIRM_API void add_type_arraytype_of(const ir_type *tp, ir_type *atp);
76 /** Compute the outs of types and entities.
78 * Collects all reference from irnodes to types or entities in the
79 * corresponding types/entities. Further reverses references between
82 * Annotates the following nodes:
83 * Alloc --> get_Alloc_type()
84 * Cast --> get_Cast_type()
85 * Sel --> get_Sel_entity()
86 * SymConst --> get_SymConst_entity()
87 * Load(addr) --> get_addr_entity() \ ent von SymConst, oder falls Sel: ent von
88 * Store(addr) --> get_addr_entity() / outermost im compound. Ansonsten: nirgends.
89 * d.h. wir bekommen die array Elementzugriffe
90 * an die jack array Klasse annotiert.
91 * Call(Sel) --> get_Sel_entity() // ev. Tabellenzugriff --> Load.
93 * type --> pointer type refering to this type.
94 * type --> entity of this type. @@@ to be implemented.
96 * Sets trout state to outs_consistent.
98 FIRM_API void compute_trouts(void);
100 /** Free trout data. */
101 FIRM_API void free_trouts(void);