fixed output
[libfirm] / ir / ana / irtypeinfo.h
1 /**
2  *
3  * @file irtypeinfo.h
4  *
5  * Project:     libFIRM
6  * File name:   ir/ana/irtypeinfo.h
7  * Purpose:     Data structure to hold type information for nodes.
8  * Author:      Goetz Lindenmaier
9  * Modified by:
10  * Created:     28.8.2003
11  * CVS-ID:      $Id$
12  * Copyright:   (c) 2003 Universität Karlsruhe
13  * Licence:     This file protected by GPL -  GNU GENERAL PUBLIC LICENSE.
14  *
15  * Data structure to hold type information for nodes.
16  *
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".
20  *
21  */
22 #ifndef _IRTYPEINFO_H_
23 #define _IRTYPEINFO_H_
24
25 #include "firm_types.h"
26
27 /* ------------ Auxiliary type. --------------------------------------- */
28
29 /** An auxiliary type used to express that a field is uninitialized.
30  *
31  *  This auxiliary type expresses that a field is uninitialized.  The
32  *  variable is set by init_irtypeinfo.  The type is freed by
33  *  free_irtypeinfo.
34  */
35 extern ir_type *initial_type;
36
37
38
39 /* ------------ Initializing this module. ----------------------------- */
40
41 /** Initializes the type information module.
42  *
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).
47  */
48 void init_irtypeinfo(void);
49 void free_irtypeinfo(void);
50
51 /* ------------ Irgraph state handling. ------------------------------- */
52
53 /*
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
58 */
59
60 typedef enum {
61   ir_typeinfo_none,         /**< No typeinfo computed, calls to set/get_irn_type
62                                   are invalid. */
63   ir_typeinfo_consistent,   /**< Type info valid, calls to set/get_irn_type return
64                                   the proper type. */
65   ir_typeinfo_inconsistent  /**< Type info can be accessed, but it can be invalid
66                                   because of other transformations. */
67 } ir_typeinfo_state;
68
69 void              set_irg_typeinfo_state(ir_graph *irg, ir_typeinfo_state s);
70 ir_typeinfo_state get_irg_typeinfo_state(ir_graph *irg);
71
72 /** Returns accumulated type information state information.
73  *
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.
77  */
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);
82
83 /* ------------ Irnode type information. ------------------------------ */
84
85 /** Accessing the type information.
86  *
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.
90  */
91 ir_type *get_irn_typeinfo_type(ir_node *n);
92 void    set_irn_typeinfo_type(ir_node *n, ir_type *tp);
93
94 #endif /* _IRTYPEINFO_H_ */