properly mark symbols in the public API to be exported. This allows us to use -fvisib...
[libfirm] / include / libfirm / irtypeinfo.h
1 /*
2  * Copyright (C) 1995-2008 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    Data structure to hold type information for nodes.
23  * @author   Goetz Lindenmaier
24  * @date     28.8.2003
25  * @version  $Id$
26  * @brief
27  *   Data structure to hold type information for nodes.
28  *
29  *   This module defines a field "type" of type "type *" for each ir node.
30  *   It defines a flag for irgraphs to mark whether the type info of the
31  *   graph is valid.  Further it defines an auxiliary type "init_type".
32  */
33 #ifndef FIRM_ANA_IRTYPEINFO_H
34 #define FIRM_ANA_IRTYPEINFO_H
35
36 #include "firm_types.h"
37 #include "begin.h"
38
39 /* ------------ Auxiliary type. --------------------------------------- */
40
41 /** An auxiliary type used to express that a field is uninitialized.
42  *
43  *  This auxiliary type expresses that a field is uninitialized.  The
44  *  variable is initialized by init_irtypeinfo().  The type is freed by
45  *  free_irtypeinfo().
46  */
47 FIRM_DLL ir_type *initial_type;
48
49
50
51 /* ------------ Initializing this module. ----------------------------- */
52
53 /** Initializes the type information module.
54  *
55  *  Initializes the type information module.
56  *  Generates a type inititial_type and sets the type of all nodes to this type.
57  *  Calling set/get_irn_typeinfo_type() is invalid before calling init. Requires memory
58  *  in the order of MIN(\<calls to set_irn_typeinfo_type\>, \#irnodes).
59  */
60 FIRM_DLL void init_irtypeinfo(void);
61 FIRM_DLL void free_irtypeinfo(void);
62
63 /* ------------ Irgraph state handling. ------------------------------- */
64
65 typedef enum {
66         ir_typeinfo_none,        /**< No typeinfo computed, calls to set/get_irn_typeinfo_type()
67                                       are invalid. */
68         ir_typeinfo_consistent,  /**< Type info valid, calls to set/get_irn_typeinfo_type() return
69                                       the proper type. */
70         ir_typeinfo_inconsistent /**< Type info can be accessed, but it can be invalid
71                                       because of other transformations. */
72 } ir_typeinfo_state;
73
74 FIRM_DLL void set_irg_typeinfo_state(ir_graph *irg, ir_typeinfo_state s);
75 FIRM_DLL ir_typeinfo_state get_irg_typeinfo_state(const ir_graph *irg);
76
77 /** Returns accumulated type information state information.
78  *
79  * Returns ir_typeinfo_consistent if the type information of all irgs is
80  * consistent.  Returns ir_typeinfo_inconsistent if at least one irg has inconsistent
81  * or no type information.  Returns ir_typeinfo_none if no irg contains type information.
82  */
83 FIRM_DLL ir_typeinfo_state get_irp_typeinfo_state(void);
84 FIRM_DLL void              set_irp_typeinfo_state(ir_typeinfo_state s);
85 /** If typeinfo is consistent, sets it to inconsistent. */
86 FIRM_DLL void              set_irp_typeinfo_inconsistent(void);
87
88 /* ------------ Irnode type information. ------------------------------ */
89
90 /** Accessing the type information.
91  *
92  * These routines only work properly if the ir_graph is in state
93  * ir_typeinfo_consistent or ir_typeinfo_inconsistent.  They
94  * assume current_ir_graph set properly.
95  */
96 FIRM_DLL ir_type *get_irn_typeinfo_type(const ir_node *n);
97 FIRM_DLL void     set_irn_typeinfo_type(ir_node *n, ir_type *tp);
98
99 #include "end.h"
100
101 #endif