remove $Id$, it doesn't work with git anyway
[libfirm] / include / libfirm / trouts.h
1 /*
2  * Copyright (C) 1995-2011 University of Karlsruhe.  All right reserved.
3  *
4  * This file is part of libFirm.
5  *
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.
10  *
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.
14  *
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
17  * PURPOSE.
18  */
19
20 /**
21  * @file
22  * @brief    Reverse edges that reference types/entities.
23  * @author   Goetz Lindenmaier
24  * @date     29.10.2004
25  * @brief
26  *  Trouts list all uses of types and entities.
27  *  Each type gets a list of all Alloc nodes allocating it.
28  *  Each entity gets two lists:
29  *    - one containing all accesses (Load, (Call), Store),
30  *    - and one containing all uses to get a reference (Sel, SymConst).
31  */
32 #ifndef FIRM_ANA_TROUTS_H
33 #define FIRM_ANA_TROUTS_H
34
35 #include "firm_types.h"
36 #include "irgraph.h"
37
38 #include "begin.h"
39
40 /** Number of Load/Store nodes that possibly access this entity. */
41 FIRM_API size_t get_entity_n_accesses(const ir_entity *ent);
42 /** Load/Store node that possibly access this entity. */
43 FIRM_API ir_node *get_entity_access(const ir_entity *ent, size_t pos);
44
45 /** Number of references to an entity, in form of SymConst/Sel.
46  *  Including references from constant entities and the like. */
47 FIRM_API size_t get_entity_n_references(const ir_entity *ent);
48 /** References to an entity, in form of SymConst/Sel
49  *  Including references from constants. */
50 FIRM_API ir_node *get_entity_reference(const ir_entity *ent, size_t pos);
51
52 /** Number of Alloc nodes that create an instance of this type. */
53 FIRM_API size_t get_type_n_allocs(const ir_type *tp);
54 /** Alloc node that create an instance of this type. */
55 FIRM_API ir_node *get_type_alloc(const ir_type *tp, size_t pos);
56
57 /** Number of Cast nodes that cast a pointer to this type. */
58 FIRM_API size_t get_type_n_casts(const ir_type *tp);
59 /** Cast node that cast a pointer to this type. */
60 FIRM_API ir_node *get_type_cast(const ir_type *tp, size_t pos);
61 FIRM_API void add_type_cast(const ir_type *tp, ir_node *cast);
62 /** Return number of upcasts. O(\#casts). */
63 FIRM_API size_t get_class_n_upcasts(const ir_type *clss);
64 /** Return number of downcasts. O(\#casts). */
65 FIRM_API size_t get_class_n_downcasts(const ir_type *clss);
66
67 FIRM_API size_t  get_type_n_pointertypes_to(const ir_type *tp);
68 FIRM_API ir_type *get_type_pointertype_to(const ir_type *tp, size_t pos);
69 FIRM_API void    add_type_pointertype_to(const ir_type *tp, ir_type *ptp);
70
71 FIRM_API size_t  get_type_n_arraytypes_of(const ir_type *tp);
72 FIRM_API ir_type *get_type_arraytype_of(const ir_type *tp, size_t pos);
73 FIRM_API void    add_type_arraytype_of(const ir_type *tp, ir_type *atp);
74
75 /** Compute the outs of types and entities.
76  *
77  *  Collects all reference from irnodes to types or entities in the
78  *  corresponding types/entities.  Further reverses references between
79  *  types and entities.
80  *
81  *  Annotates the following nodes:
82  *    Alloc    --> get_Alloc_type()
83  *    Cast     --> get_Cast_type()
84  *    Sel      --> get_Sel_entity()
85  *    SymConst --> get_SymConst_entity()
86  *    Load(addr)  --> get_addr_entity() \  ent von SymConst, oder falls Sel: ent von
87  *    Store(addr) --> get_addr_entity() /  outermost im compound.  Ansonsten: nirgends.
88  *                                         d.h. wir bekommen die array Elementzugriffe
89  *                                         an die jack array Klasse annotiert.
90  *    Call(Sel)   --> get_Sel_entity()  // ev. Tabellenzugriff --> Load.
91  *
92  *   type --> pointer type refering to this type.
93  *   type --> entity of this type. @@@ to be implemented.
94  *
95  *  Sets trout state to outs_consistent.
96  */
97 FIRM_API void compute_trouts(void);
98
99 /** Free trout data. */
100 FIRM_API void free_trouts(void);
101
102 #include "end.h"
103
104 #endif