e525e339d462aa8e550846a436861cdf41f2e55e
[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 "irmode.h"
20 #include "tv.h"
21
22 /* debugging aid */
23 enum reserved_id {
24   resid_tarval_bad       = 1,
25   resid_tarval_undefined = 2,
26   resid_tarval_b_false   = 3,
27   resid_tarval_b_true    = 4
28 };
29
30 /**
31  * Initialization of the tarval module.
32  *
33  * Call before init_mode().
34  *
35  * @param null_value  The reference mode NULL value, typical 0l
36  */
37 void init_tarval_1(long null_value);
38
39 /**
40  * Initialization of the tarval module.
41  *
42  * Call after init_mode().
43  */
44 void init_tarval_2(void);
45
46 /**
47  * Free all memory occupied by the tarval module.
48  */
49 void finish_tarval(void);
50
51 /**
52  * This struct represents the afore mentioned tarvals.
53  *
54  * A tarval struct consists of an internal representation of the
55  * value and some additional fields further describing the value.
56  *
57  * ATTRIBUTES:
58  *   - ir_mode *mode     The mode of the stored value
59  *   - void *value       The internal representation
60  *
61  * @sa
62  *   irmode.h for predefined modes
63  */
64 struct tarval {
65   firm_kind kind;         /**< must be k_tarval */
66   ir_mode   *mode;        /**< the mode of the stored value */
67   const void *value;      /**< the value stored in an internal way... */
68   unsigned int length;    /**< the length of the stored value */
69 };
70
71 /* inline functions */
72 /*
73  * Access routines for tarval fields ========================================
74  */
75 static INLINE ir_mode *
76 _get_tarval_mode(const tarval *tv) {
77   assert(tv);
78   return tv->mode;
79 }
80
81 static INLINE tarval *
82 _get_tarval_bad(void) {
83   return tarval_bad;
84 }
85
86 static INLINE tarval *
87 _get_tarval_undefined(void) {
88   return tarval_undefined;
89 }
90
91 static INLINE tarval *
92 _get_tarval_b_false(void) {
93   return tarval_b_false;
94 }
95
96 static INLINE tarval *
97 _get_tarval_b_true(void) {
98   return tarval_b_true;
99 }
100
101 #define get_tarval_mode(tv)     _get_tarval_mode(tv)
102 #define get_tarval_bad()        _get_tarval_bad()
103 #define get_tarval_undefined()  _get_tarval_undefined()
104 #define get_tarval_b_false()    _get_tarval_b_false()
105 #define get_tarval_b_true()     _get_tarval_b_true()
106 #define get_tarval_P_void()     _get_tarval_P_void()
107
108 #endif /* _TV_T_H_ */