2 * This file is part of libFirm.
3 * Copyright (C) 2012 University of Karlsruhe.
8 * @brief Data structure to hold type information for nodes.
9 * @author Goetz Lindenmaier
12 * Data structure to hold type information for nodes.
14 * This module defines a field "type" of type "type *" for each ir node.
15 * It defines a flag for irgraphs to mark whether the type info of the
16 * graph is valid. Further it defines an auxiliary type "init_type".
18 #ifndef FIRM_ANA_IRTYPEINFO_H
19 #define FIRM_ANA_IRTYPEINFO_H
21 #include "firm_types.h"
24 /* ------------ Auxiliary type. --------------------------------------- */
26 /** An auxiliary type used to express that a field is uninitialized.
28 * This auxiliary type expresses that a field is uninitialized. The
29 * variable is initialized by init_irtypeinfo(). The type is freed by
32 FIRM_API ir_type *initial_type;
36 /* ------------ Initializing this module. ----------------------------- */
38 /** Initializes the type information module.
40 * Initializes the type information module.
41 * Generates a type inititial_type and sets the type of all nodes to this type.
42 * Calling set/get_irn_typeinfo_type() is invalid before calling init. Requires memory
43 * in the order of MIN(\<calls to set_irn_typeinfo_type\>, \#irnodes).
45 FIRM_API void init_irtypeinfo(void);
46 /** Frees memory used by the type information module */
47 FIRM_API void free_irtypeinfo(void);
49 /* ------------ Irgraph state handling. ------------------------------- */
51 /** typeinfo information state */
53 ir_typeinfo_none, /**< No typeinfo computed, calls to set/get_irn_typeinfo_type()
55 ir_typeinfo_consistent, /**< Type info valid, calls to set/get_irn_typeinfo_type() return
57 ir_typeinfo_inconsistent /**< Type info can be accessed, but it can be invalid
58 because of other transformations. */
61 /** Sets state of typeinfo information in graph @p irg to @p state. */
62 FIRM_API void set_irg_typeinfo_state(ir_graph *irg, ir_typeinfo_state state);
63 /** Returns state of typeinfo information in graph @p irg. */
64 FIRM_API ir_typeinfo_state get_irg_typeinfo_state(const ir_graph *irg);
66 /** Returns accumulated type information state information.
68 * Returns ir_typeinfo_consistent if the type information of all irgs is
69 * consistent. Returns ir_typeinfo_inconsistent if at least one irg has inconsistent
70 * or no type information. Returns ir_typeinfo_none if no irg contains type information.
72 FIRM_API ir_typeinfo_state get_irp_typeinfo_state(void);
73 /** Sets state of typeinfo information for the current program to @p state */
74 FIRM_API void set_irp_typeinfo_state(ir_typeinfo_state state);
75 /** Sets state of typeinfo information for the current program to #ir_typeinfo_inconsistent */
76 FIRM_API void set_irp_typeinfo_inconsistent(void);
78 /* ------------ Irnode type information. ------------------------------ */
80 /** Accessing the type information.
82 * These routines only work properly if the ir_graph is in state
83 * ir_typeinfo_consistent or ir_typeinfo_inconsistent.
85 FIRM_API ir_type *get_irn_typeinfo_type(const ir_node *n);
86 /** Sets type information of procedure graph node @p node to type @p type. */
87 FIRM_API void set_irn_typeinfo_type(ir_node *node, ir_type *type);