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