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
26 #ifndef FIRM_ANA_TROUTS_H
27 #define FIRM_ANA_TROUTS_H
29 #include "firm_types.h"
36 * @defgroup trouts Reverse Type Edges
37 * Trouts list all uses of types and entities.
38 * Each type gets a list of all Alloc nodes allocating it.
39 * Each entity gets two lists:
40 * - one containing all accesses (Load, (Call), Store),
41 * - and one containing all uses to get a reference (Sel, SymConst).
45 /** Returns number of Load/Store nodes that possibly access entity @p entity. */
46 FIRM_API size_t get_entity_n_accesses(const ir_entity *entity);
47 /** Returns Load/Store node number @p pos that possibly accesses entity @p entity. */
48 FIRM_API ir_node *get_entity_access(const ir_entity *entity, size_t pos);
50 /** Returns number of references to entity @p entity, in form of SymConst/Sel,
51 * including references from constant entities and the like. */
52 FIRM_API size_t get_entity_n_references(const ir_entity *entity);
53 /** Returns reference number @p pos of references to an entity, in form of
54 * SymConst/Sel, including references from constants. */
55 FIRM_API ir_node *get_entity_reference(const ir_entity *entity, size_t pos);
57 /** Returns number of Alloc nodes that create an instance of type @p type. */
58 FIRM_API size_t get_type_n_allocs(const ir_type *type);
59 /** Returns Alloc node number @p pos that create an instance of type @p type. */
60 FIRM_API ir_node *get_type_alloc(const ir_type *type, size_t pos);
62 /** Returns number of Cast nodes that cast a pointer to type @p type. */
63 FIRM_API size_t get_type_n_casts(const ir_type *type);
64 /** Cast node that cast a pointer to this type. */
65 FIRM_API ir_node *get_type_cast(const ir_type *type, size_t pos);
66 /** Returns number of upcasts. O(\#casts). */
67 FIRM_API size_t get_class_n_upcasts(const ir_type *clss);
68 /** Returns number of downcasts. O(\#casts). */
69 FIRM_API size_t get_class_n_downcasts(const ir_type *clss);
71 /** Returns number of pointertypes that point to type @p type. */
72 FIRM_API size_t get_type_n_pointertypes_to(const ir_type *type);
73 /** Returns pointer type number @p pos that points to type @p type. */
74 FIRM_API ir_type *get_type_pointertype_to(const ir_type *type, size_t pos);
76 /** Returns number of array types with element type @p type. */
77 FIRM_API size_t get_type_n_arraytypes_of(const ir_type *type);
78 /** Returns array type number @p pos with element type @p type. */
79 FIRM_API ir_type *get_type_arraytype_of(const ir_type *type, size_t pos);
81 /** Computes the outs of types and entities.
83 * Collects all reference from irnodes to types or entities in the
84 * corresponding types/entities. Further reverses references between
87 * Annotates the following nodes:
88 * Alloc --> get_Alloc_type()
89 * Cast --> get_Cast_type()
90 * Sel --> get_Sel_entity()
91 * SymConst --> get_SymConst_entity()
92 * Load(addr) --> get_addr_entity() \ ent von SymConst, oder falls Sel: ent von
93 * Store(addr) --> get_addr_entity() / outermost im compound. Ansonsten: nirgends.
94 * d.h. wir bekommen die array Elementzugriffe
95 * an die jack array Klasse annotiert.
96 * Call(Sel) --> get_Sel_entity() // ev. Tabellenzugriff --> Load.
98 * type --> pointer type refering to this type.
99 * type --> entity of this type. @@@ to be implemented.
101 * Sets trout state to outs_consistent.
103 FIRM_API void compute_trouts(void);
105 /** Frees trout data. */
106 FIRM_API void free_trouts(void);