cba32a02a0a38b0de1029b7cc1eff90314a4a9f4
[libfirm] / ir / tv / tv_t.h
1 /*
2  * Project:     libFIRM
3  * File name:   ir/tv/tv_t.h
4  * Purpose:     Representation of and static computations on target machine
5  *              values -- private header.
6  * Author:      Mathias Heil
7  * Modified by:
8  * Created:
9  * CVS-ID:      $Id$
10  * Copyright:   (c) 2003 Universität Karlsruhe
11  * Licence:     This file protected by GPL -  GNU GENERAL PUBLIC LICENSE.
12  */
13 #ifndef _TV_T_H_
14 #define _TV_T_H_
15
16 #include "firm_config.h"
17
18 #include <assert.h>
19 #include "entity.h"
20 #include "irmode.h"
21 #include "tv.h"
22
23 /* debugging aid */
24 enum reserved_id {
25   resid_tarval_bad       = 1,
26   resid_tarval_undefined = 2,
27   resid_tarval_b_false   = 3,
28   resid_tarval_b_true    = 4
29 };
30
31 /**
32  * Initialization of the tarval module.
33  *
34  * Call before init_mode().
35  *
36  * @param null_value  The reference mode NULL value, typical 0l
37  */
38 void init_tarval_1(long null_value);
39
40 /**
41  * Initialization of the tarval module.
42  *
43  * Call after init_mode().
44  */
45 void init_tarval_2(void);
46
47 /**
48  * Free all memory occupied by the tarval module.
49  */
50 void finish_tarval(void);
51
52 /**
53  * This struct represents the afore mentioned tarvals.
54  *
55  * A tarval struct consists of an internal representation of the
56  * value and some additional fields further describing the value.
57  *
58  * ATTRIBUTES:
59  *   - ir_mode *mode     The mode of the stored value
60  *   - void *value       The internal representation
61  *
62  * @sa
63  *   irmode.h for predefined modes
64  */
65 struct tarval {
66   firm_kind kind;         /**< must be k_tarval */
67   ir_mode   *mode;        /**< the mode of the stored value */
68   const void *value;      /**< the value stored in an internal way... */
69   unsigned int length;    /**< the length of the stored value */
70 };
71
72 /** remove tarval representing an entity that is about to be destroyed */
73 void free_tarval_entity(ir_entity *ent);
74
75 /* inline functions */
76 /*
77  * Access routines for tarval fields ========================================
78  */
79 static INLINE ir_mode *
80 _get_tarval_mode(const tarval *tv) {
81   assert(tv);
82   return tv->mode;
83 }
84
85 static INLINE tarval *
86 _get_tarval_bad(void) {
87   return tarval_bad;
88 }
89
90 static INLINE tarval *
91 _get_tarval_undefined(void) {
92   return tarval_undefined;
93 }
94
95 static INLINE tarval *
96 _get_tarval_b_false(void) {
97   return tarval_b_false;
98 }
99
100 static INLINE tarval *
101 _get_tarval_b_true(void) {
102   return tarval_b_true;
103 }
104
105 #define get_tarval_mode(tv)     _get_tarval_mode(tv)
106 #define get_tarval_bad()        _get_tarval_bad()
107 #define get_tarval_undefined()  _get_tarval_undefined()
108 #define get_tarval_b_false()    _get_tarval_b_false()
109 #define get_tarval_b_true()     _get_tarval_b_true()
110 #define get_tarval_P_void()     _get_tarval_P_void()
111
112 #endif /* _TV_T_H_ */