BugFix: add missing copy
[libfirm] / ir / tv / tv_t.h
1 /*
2  * Copyright (C) 1995-2008 University of Karlsruhe.  All right reserved.
3  *
4  * This file is part of libFirm.
5  *
6  * This file may be distributed and/or modified under the terms of the
7  * GNU General Public License version 2 as published by the Free Software
8  * Foundation and appearing in the file LICENSE.GPL included in the
9  * packaging of this file.
10  *
11  * Licensees holding valid libFirm Professional Edition licenses may use
12  * this file in accordance with the libFirm Commercial License.
13  * Agreement provided with the Software.
14  *
15  * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
16  * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
17  * PURPOSE.
18  */
19
20 /**
21  * @file
22  * @brief    Representation of and static computations on target machine
23  *           values -- private header.
24  * @date     2003
25  * @author   Mathias Heil
26  * @version  $Id$
27  */
28 #ifndef FIRM_TV_TV_T_H
29 #define FIRM_TV_TV_T_H
30
31 #include "firm_config.h"
32
33 #include <assert.h>
34 #include "irmode.h"
35 #include "tv.h"
36
37 /** Debugging aid for the firmEvaluator: Marks for reserved tarvals values. */
38 enum reserved_id {
39   resid_tarval_bad       = 1,  /**< tarval_bad marker. */
40   resid_tarval_undefined = 2,  /**< tarval_undefined marker. */
41   resid_tarval_b_false   = 3,  /**< tarval_b_false marker. */
42   resid_tarval_b_true    = 4   /**< tarval_b_true marker. */
43 };
44
45 /**
46  * Initialization of the tarval module.
47  *
48  * Call before init_mode().
49  *
50  * @param null_value  The reference mode NULL value, typical 0l
51  */
52 void init_tarval_1(long null_value);
53
54 /**
55  * Initialization of the tarval module.
56  *
57  * Call after init_mode().
58  */
59 void init_tarval_2(void);
60
61 /**
62  * Free all memory occupied by the tarval module.
63  */
64 void finish_tarval(void);
65
66 /**
67  * This struct represents the afore mentioned tarvals.
68  *
69  * A tarval struct consists of an internal representation of the
70  * value and some additional fields further describing the value.
71  *
72  * ATTRIBUTES:
73  *   - ir_mode *mode     The mode of the stored value
74  *   - void *value       The internal representation
75  *
76  * @sa
77  *   irmode.h for predefined modes
78  */
79 struct tarval {
80   firm_kind kind;         /**< must be k_tarval */
81   ir_mode   *mode;        /**< the mode of the stored value */
82   const void *value;      /**< the value stored in an internal way... */
83   unsigned int length;    /**< the length of the stored value */
84 };
85
86 /* inline functions */
87 /*
88  * Access routines for tarval fields ========================================
89  */
90 static INLINE ir_mode *
91 _get_tarval_mode(const tarval *tv) {
92   assert(tv);
93   return tv->mode;
94 }
95
96 static INLINE tarval *
97 _get_tarval_bad(void) {
98   return tarval_bad;
99 }
100
101 static INLINE tarval *
102 _get_tarval_undefined(void) {
103   return tarval_undefined;
104 }
105
106 static INLINE tarval *
107 _get_tarval_b_false(void) {
108   return tarval_b_false;
109 }
110
111 static INLINE tarval *
112 _get_tarval_b_true(void) {
113   return tarval_b_true;
114 }
115
116 #define get_tarval_mode(tv)     _get_tarval_mode(tv)
117 #define get_tarval_bad()        _get_tarval_bad()
118 #define get_tarval_undefined()  _get_tarval_undefined()
119 #define get_tarval_b_false()    _get_tarval_b_false()
120 #define get_tarval_b_true()     _get_tarval_b_true()
121 #define get_tarval_P_void()     _get_tarval_P_void()
122
123 #endif /* FIRM_TV_TV_T_H */