6 * File name: ir/ana/irtypeinfo.h
7 * Purpose: Data structure to hold type information for nodes.
8 * Author: Goetz Lindenmaier
12 * Copyright: (c) 2003 Universität Karlsruhe
13 * Licence: This file protected by GPL - GNU GENERAL PUBLIC LICENSE.
15 * Data structure to hold type information for nodes.
17 * This module defines a field "type" of type "type *" for each ir node.
18 * It defines a flag for irgraphs to mark whether the type info of the
19 * graph is valid. Further it defines an auxiliary type "init_type".
24 # ifndef _IRTYPEINFO_H_
25 # define _IRTYPEINFO_H_
31 /* ------------ Auxiliary type. --------------------------------------- */
33 /** An auxiliary type used to express that a field is uninitialized.
35 * This auxiliary type expresses that a field is uninitialized. The
36 * variable is set by init_irtypeinfo. The type is freed by
39 extern type *initial_type;
43 /* ------------ Initializing this module. ----------------------------- */
45 /** Initializes the type information module.
47 * Initializes the type information module.
48 * Generates a type "init_type" and sets the type of all nodes to this type.
49 * Calling set/get_irn_type is invalid before calling init. Requires memory
50 * in the order of MIN(<calls to set_irn_type>, #irnodes).
52 void init_irtypeinfo(void);
53 void free_irtypeinfo(void);
55 /* ------------ Irgraph state handling. ------------------------------- */
58 #define irg_typeinfo_none ir_typeinfo_none
59 #define irg_typeinfo_consistent ir_typeinfo_consistent
60 #define irg_typeinfo_inconsistent ir_typeinfo_inconsistent
61 #define irg_typeinfo_state ir_typeinfo_state
65 ir_typeinfo_none, /**< No typeinfo computed, calls to set/get_irn_type
67 ir_typeinfo_consistent, /**< Type info valid, calls to set/get_irn_type return
69 ir_typeinfo_inconsistent /**< Type info can be accessed, but it can be invalid
70 because of other transformations. */
73 void set_irg_typeinfo_state(ir_graph *irg, ir_typeinfo_state s);
74 ir_typeinfo_state get_irg_typeinfo_state(ir_graph *irg);
76 /** Returns accumulated type information state information.
78 * Returns ir_typeinfo_consistent if the type information of all irgs is
79 * consistent. Returns ir_typeinfo_inconsistent if at least one irg has inconsistent
80 * or no type information. Returns ir_typeinfo_none if no irg contains type information.
82 ir_typeinfo_state get_irp_typeinfo_state(void);
83 void set_irp_typeinfo_state(ir_typeinfo_state s);
84 /** If typeinfo is consistent, sets it to inconsistent. */
85 void set_irp_typeinfo_inconsistent(void);
87 /* ------------ Irnode type information. ------------------------------ */
89 /** Accessing the type information.
91 * These routines only work properly if the ir_graph is in state
92 * ir_typeinfo_consistent or ir_typeinfo_inconsistent. They
93 * assume current_ir_graph set properly.
95 type *get_irn_typeinfo_type(ir_node *n);
96 void set_irn_typeinfo_type(ir_node *n, type *tp);
98 #endif /* _IRTYPEINFO_H_ */