becopyheur: Avoid unnecessary bitset copying.
[libfirm] / ir / tv / tv_t.h
1 /*
2  * This file is part of libFirm.
3  * Copyright (C) 2012 University of Karlsruhe.
4  */
5
6 /**
7  * @file
8  * @brief    Representation of and static computations on target machine
9  *           values -- private header.
10  * @date     2003
11  * @author   Mathias Heil
12  */
13 #ifndef FIRM_TV_TV_T_H
14 #define FIRM_TV_TV_T_H
15
16 #include "firm_common.h"
17
18 #include <assert.h>
19 #include "irmode.h"
20 #include "tv.h"
21
22 /**
23  * Initialization of the tarval module.
24  *
25  * Call before init_mode().
26  *
27  * @param null_value
28  *            The reference mode NULL value, typical 0l
29  * @param support_quad_precision
30  *            If non-zero, activate support for quad precision
31  */
32 void init_tarval_1(long null_value, int support_quad_precision);
33
34 /**
35  * Initialization of the tarval module.
36  *
37  * Call after init_mode().
38  */
39 void init_tarval_2(void);
40
41 /**
42  * Free all memory occupied by the tarval module.
43  */
44 void finish_tarval(void);
45
46 /**
47  * This struct represents the afore mentioned tarvals.
48  *
49  * A tarval struct consists of an internal representation of the
50  * value and some additional fields further describing the value.
51  *
52  * ATTRIBUTES:
53  *   - ir_mode *mode     The mode of the stored value
54  *   - void *value       The internal representation
55  *
56  * @sa
57  *   irmode.h for predefined modes
58  */
59 struct ir_tarval {
60         firm_kind  kind;    /**< must be k_tarval */
61         ir_mode    *mode;   /**< the mode of the stored value */
62         const void *value;  /**< the value stored in an internal way... */
63         size_t     length;  /**< the length of the stored value */
64 };
65
66 /* inline functions */
67 /*
68  * Access routines for tarval fields ========================================
69  */
70 static inline ir_mode *_get_tarval_mode(const ir_tarval *tv)
71 {
72         assert(tv);
73         return tv->mode;
74 }
75
76 static inline ir_tarval *_get_tarval_bad(void)
77 {
78         return tarval_bad;
79 }
80
81 static inline ir_tarval *_get_tarval_undefined(void)
82 {
83         return tarval_undefined;
84 }
85
86 static inline ir_tarval *_get_tarval_b_false(void)
87 {
88         return tarval_b_false;
89 }
90
91 static inline ir_tarval *_get_tarval_b_true(void)
92 {
93         return tarval_b_true;
94 }
95
96 static inline ir_tarval *_get_tarval_reachable(void)
97 {
98         return tarval_reachable;
99 }
100
101 static inline ir_tarval *_get_tarval_unreachable(void)
102 {
103         return tarval_unreachable;
104 }
105
106 static inline int _is_tarval(const void *thing)
107 {
108         return get_kind(thing) == k_tarval;
109 }
110
111 #define get_tarval_mode(tv)      _get_tarval_mode(tv)
112 #define get_tarval_bad()         _get_tarval_bad()
113 #define get_tarval_undefined()   _get_tarval_undefined()
114 #define get_tarval_b_false()     _get_tarval_b_false()
115 #define get_tarval_b_true()      _get_tarval_b_true()
116 #define get_tarval_unreachable() _get_tarval_unreachable()
117 #define get_tarval_reachable()   _get_tarval_reachable()
118 #define is_tarval(thing)         _is_tarval(thing)
119
120 #endif /* FIRM_TV_TV_T_H */