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".
22 #ifndef _IRTYPEINFO_H_
23 #define _IRTYPEINFO_H_
25 #include "firm_types.h"
27 /* ------------ Auxiliary type. --------------------------------------- */
29 /** An auxiliary type used to express that a field is uninitialized.
31 * This auxiliary type expresses that a field is uninitialized. The
32 * variable is set by init_irtypeinfo. The type is freed by
35 extern ir_type *initial_type;
39 /* ------------ Initializing this module. ----------------------------- */
41 /** Initializes the type information module.
43 * Initializes the type information module.
44 * Generates a type "init_type" and sets the type of all nodes to this type.
45 * Calling set/get_irn_type is invalid before calling init. Requires memory
46 * in the order of MIN(<calls to set_irn_type>, #irnodes).
48 void init_irtypeinfo(void);
49 void free_irtypeinfo(void);
51 /* ------------ Irgraph state handling. ------------------------------- */
54 #define irg_typeinfo_none ir_typeinfo_none
55 #define irg_typeinfo_consistent ir_typeinfo_consistent
56 #define irg_typeinfo_inconsistent ir_typeinfo_inconsistent
57 #define irg_typeinfo_state ir_typeinfo_state
61 ir_typeinfo_none, /**< No typeinfo computed, calls to set/get_irn_type
63 ir_typeinfo_consistent, /**< Type info valid, calls to set/get_irn_type return
65 ir_typeinfo_inconsistent /**< Type info can be accessed, but it can be invalid
66 because of other transformations. */
69 void set_irg_typeinfo_state(ir_graph *irg, ir_typeinfo_state s);
70 ir_typeinfo_state get_irg_typeinfo_state(ir_graph *irg);
72 /** Returns accumulated type information state information.
74 * Returns ir_typeinfo_consistent if the type information of all irgs is
75 * consistent. Returns ir_typeinfo_inconsistent if at least one irg has inconsistent
76 * or no type information. Returns ir_typeinfo_none if no irg contains type information.
78 ir_typeinfo_state get_irp_typeinfo_state(void);
79 void set_irp_typeinfo_state(ir_typeinfo_state s);
80 /** If typeinfo is consistent, sets it to inconsistent. */
81 void set_irp_typeinfo_inconsistent(void);
83 /* ------------ Irnode type information. ------------------------------ */
85 /** Accessing the type information.
87 * These routines only work properly if the ir_graph is in state
88 * ir_typeinfo_consistent or ir_typeinfo_inconsistent. They
89 * assume current_ir_graph set properly.
91 ir_type *get_irn_typeinfo_type(ir_node *n);
92 void set_irn_typeinfo_type(ir_node *n, ir_type *tp);
94 #endif /* _IRTYPEINFO_H_ */