becopyheur2: Remove unnecessary indirection.
[libfirm] / include / libfirm / irtypeinfo.h
1 /*
2  * This file is part of libFirm.
3  * Copyright (C) 2012 University of Karlsruhe.
4  */
5
6 /**
7  * @file
8  * @brief    Data structure to hold type information for nodes.
9  * @author   Goetz Lindenmaier
10  * @date     28.8.2003
11  * @brief
12  *   Data structure to hold type information for nodes.
13  *
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".
17  */
18 #ifndef FIRM_ANA_IRTYPEINFO_H
19 #define FIRM_ANA_IRTYPEINFO_H
20
21 #include "firm_types.h"
22 #include "begin.h"
23
24 /* ------------ Auxiliary type. --------------------------------------- */
25
26 /** An auxiliary type used to express that a field is uninitialized.
27  *
28  *  This auxiliary type expresses that a field is uninitialized.  The
29  *  variable is initialized by init_irtypeinfo().  The type is freed by
30  *  free_irtypeinfo().
31  */
32 FIRM_API ir_type *initial_type;
33
34
35
36 /* ------------ Initializing this module. ----------------------------- */
37
38 /** Initializes the type information module.
39  *
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).
44  */
45 FIRM_API void init_irtypeinfo(void);
46 /** Frees memory used by the type information module */
47 FIRM_API void free_irtypeinfo(void);
48
49 /* ------------ Irgraph state handling. ------------------------------- */
50
51 /** typeinfo information state */
52 typedef enum {
53         ir_typeinfo_none,        /**< No typeinfo computed, calls to set/get_irn_typeinfo_type()
54                                       are invalid. */
55         ir_typeinfo_consistent,  /**< Type info valid, calls to set/get_irn_typeinfo_type() return
56                                       the proper type. */
57         ir_typeinfo_inconsistent /**< Type info can be accessed, but it can be invalid
58                                       because of other transformations. */
59 } ir_typeinfo_state;
60
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);
65
66 /** Returns accumulated type information state information.
67  *
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.
71  */
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);
77
78 /* ------------ Irnode type information. ------------------------------ */
79
80 /** Accessing the type information.
81  *
82  * These routines only work properly if the ir_graph is in state
83  * ir_typeinfo_consistent or ir_typeinfo_inconsistent.
84  */
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);
88
89 #include "end.h"
90
91 #endif