2 * Copyright (C) 1995-2008 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 Data structure to hold type information for nodes.
23 * @author Goetz Lindenmaier
26 * Data structure to hold type information for nodes.
28 * This module defines a field "type" of type "type *" for each ir node.
29 * It defines a flag for irgraphs to mark whether the type info of the
30 * graph is valid. Further it defines an auxiliary type "init_type".
32 #ifndef FIRM_ANA_IRTYPEINFO_H
33 #define FIRM_ANA_IRTYPEINFO_H
35 #include "firm_types.h"
38 /* ------------ Auxiliary type. --------------------------------------- */
40 /** An auxiliary type used to express that a field is uninitialized.
42 * This auxiliary type expresses that a field is uninitialized. The
43 * variable is initialized by init_irtypeinfo(). The type is freed by
46 FIRM_API ir_type *initial_type;
50 /* ------------ Initializing this module. ----------------------------- */
52 /** Initializes the type information module.
54 * Initializes the type information module.
55 * Generates a type inititial_type and sets the type of all nodes to this type.
56 * Calling set/get_irn_typeinfo_type() is invalid before calling init. Requires memory
57 * in the order of MIN(\<calls to set_irn_typeinfo_type\>, \#irnodes).
59 FIRM_API void init_irtypeinfo(void);
60 /** Frees memory used by the type information module */
61 FIRM_API void free_irtypeinfo(void);
63 /* ------------ Irgraph state handling. ------------------------------- */
65 /** typeinfo information state */
67 ir_typeinfo_none, /**< No typeinfo computed, calls to set/get_irn_typeinfo_type()
69 ir_typeinfo_consistent, /**< Type info valid, calls to set/get_irn_typeinfo_type() return
71 ir_typeinfo_inconsistent /**< Type info can be accessed, but it can be invalid
72 because of other transformations. */
75 /** Sets state of typeinfo information in graph @p irg to @p state. */
76 FIRM_API void set_irg_typeinfo_state(ir_graph *irg, ir_typeinfo_state state);
77 /** Returns state of typeinfo information in graph @p irg. */
78 FIRM_API ir_typeinfo_state get_irg_typeinfo_state(const ir_graph *irg);
80 /** Returns accumulated type information state information.
82 * Returns ir_typeinfo_consistent if the type information of all irgs is
83 * consistent. Returns ir_typeinfo_inconsistent if at least one irg has inconsistent
84 * or no type information. Returns ir_typeinfo_none if no irg contains type information.
86 FIRM_API ir_typeinfo_state get_irp_typeinfo_state(void);
87 /** Sets state of typeinfo information for the current program to @p state */
88 FIRM_API void set_irp_typeinfo_state(ir_typeinfo_state state);
89 /** Sets state of typeinfo information for the current program to #ir_typeinfo_inconsistent */
90 FIRM_API void set_irp_typeinfo_inconsistent(void);
92 /* ------------ Irnode type information. ------------------------------ */
94 /** Accessing the type information.
96 * These routines only work properly if the ir_graph is in state
97 * ir_typeinfo_consistent or ir_typeinfo_inconsistent. They
98 * assume current_ir_graph set properly.
100 FIRM_API ir_type *get_irn_typeinfo_type(const ir_node *n);
101 /** Sets type information of procedure graph node @p node to type @p type. */
102 FIRM_API void set_irn_typeinfo_type(ir_node *node, ir_type *type);