Teach new_tarval_from_str_int() to parse binary numbers: 0[bB][01]+.
[libfirm] / include / libfirm / compound_path.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 Deprecated way to initialize compound entites! (use ir_initializer
23  *        stuff instead)
24  * Declarations for functions and datastructures to represent compound
25  * type initializers.
26  */
27 #ifndef FIRM_COMPOUND_PATHS_H
28 #define FIRM_COMPOUND_PATHS_H
29
30 #include "firm_types.h"
31 #include "begin.h"
32
33 /**
34  * path into compound types
35  * @deprecated
36  */
37 typedef struct compound_graph_path  compound_graph_path;
38
39 /**
40  * @deprecated
41  * Creates a new compound graph path of given length.
42  */
43 FIRM_API compound_graph_path *new_compound_graph_path(ir_type *tp, size_t length);
44
45 /**
46  * @deprecated
47  * Returns non-zero if an object is a compound graph path
48  */
49 FIRM_API int is_compound_graph_path(const void *thing);
50
51 /**
52  * @deprecated
53  * Frees a graph path object
54  */
55 FIRM_API void free_compound_graph_path(compound_graph_path *gr);
56
57 /**
58  * @deprecated
59  * Returns the length of a graph path
60  */
61 FIRM_API size_t get_compound_graph_path_length(const compound_graph_path *gr);
62
63 /**
64  * @deprecated
65  * Returns the entity node of an compound graph path at position pos.
66  */
67 ir_entity *get_compound_graph_path_node(const compound_graph_path *gr, size_t pos);
68
69 /**
70  * @deprecated
71  * Sets the entity node of an compound graph path at position pos.
72  */
73 FIRM_API void set_compound_graph_path_node(compound_graph_path *gr, size_t pos,
74                                            ir_entity *node);
75
76 /**
77  * @deprecated
78  * Returns the index of an compound graph path at position pos.
79  */
80 FIRM_API long get_compound_graph_path_array_index(const compound_graph_path *gr, size_t pos);
81
82 /**
83  * @deprecated
84  * Sets the index of an compound graph path at position pos.
85  */
86 FIRM_API void set_compound_graph_path_array_index(compound_graph_path *gr, size_t pos, long index);
87
88 /**
89  * @deprecated
90  * Returns the type of an compound graph path.
91  */
92 FIRM_API ir_type *get_compound_graph_path_type(const compound_graph_path *gr);
93
94 /**
95  * @deprecated
96  * Checks whether the path up to pos is correct. If the path contains a NULL,
97  *  assumes the path is not complete and returns non-zero.
98  */
99 FIRM_API int is_proper_compound_graph_path(compound_graph_path *gr, size_t pos);
100
101 /**
102  * @deprecated
103  * A value of a compound entity is a pair of a value and the description of the
104  * corresponding access path to the member of the compound.
105  */
106 FIRM_API void add_compound_ent_value_w_path(ir_entity *ent, ir_node *val, compound_graph_path *path);
107 /**
108  * @deprecated
109  * Sets initializer value for a compound ent path
110  */
111 FIRM_API void set_compound_ent_value_w_path(ir_entity *ent, ir_node *val, compound_graph_path *path, size_t pos);
112
113 /**
114  * @deprecated
115  * Returns the access path for value at position pos.
116  */
117 FIRM_API compound_graph_path *get_compound_ent_value_path(const ir_entity *ent, size_t pos);
118
119 /**
120  * @deprecated
121  * Returns a constant value given the access path.
122  *  The path must contain array indices for all array element entities.
123  */
124 FIRM_API ir_node *get_compound_ent_value_by_path(const ir_entity *ent,
125                                                  compound_graph_path *path);
126
127 /**
128  * @deprecated
129  * Removes all constant entries where the path ends at value_ent. Does not
130  * free the memory of the paths.  (The same path might be used for several
131  * constant entities.
132  */
133 FIRM_API void remove_compound_ent_value(ir_entity *ent, ir_entity *value_ent);
134
135 /**
136  * @deprecated
137  * Generates a Path with length 1.
138  *  Beware: Has a bad runtime for array elements (O(|array|) and should be
139  *  avoided there. Use add_compound_ent_value_w_path() instead and create
140  *  the path manually.
141  */
142 FIRM_API void add_compound_ent_value(ir_entity *ent, ir_node *val, ir_entity *member);
143
144 /**
145  * @deprecated
146  * Returns the last member in the path
147  */
148 FIRM_API ir_entity *get_compound_ent_value_member(const ir_entity *ent, size_t pos);
149
150 /**
151  * @deprecated
152  * Sets the path at pos 0
153  */
154 FIRM_API void set_compound_ent_value(ir_entity *ent, ir_node *val,
155                                      ir_entity *member, size_t pos);
156
157 /**
158  * @deprecated
159  * Initializes the entity ent which must be of a one dimensional
160  * array type with the values given in the values array.
161  * The array must have a lower and an upper bound.  Keeps the
162  * order of values. Does not test whether the number of values
163  * fits into the given array size.  Does not test whether the
164  * values have the proper mode for the array.
165  */
166 FIRM_API void set_array_entity_values(ir_entity *ent, ir_tarval **values, size_t num_vals);
167
168 /**
169  * @deprecated
170  * Returns the offset in bits from the last byte address.
171  *
172  * This requires that the layout of all concerned types is fixed.
173  *
174  * @param ent Any entity of compound type with at least pos initialization values.
175  * @param pos The position of the value for which the offset is requested.
176  */
177 FIRM_API unsigned get_compound_ent_value_offset_bit_remainder(const ir_entity *ent, size_t pos);
178
179 /**
180  * @deprecated
181  * Returns the overall offset of value at position pos in bytes.
182  *
183  * This requires that the layout of all concerned types is fixed.
184  * Asserts if bit offset is not byte aligned.
185  *
186  * @param ent Any entity of compound type with at least pos initialization values.
187  * @param pos The position of the value for which the offset is requested.
188  */
189 FIRM_API unsigned get_compound_ent_value_offset_bytes(const ir_entity *ent, size_t pos);
190
191 /**
192  * @deprecated
193  * Returns the number of constant values needed to initialize the entity.
194  * Asserts if the entity has variability_uninitialized.
195  */
196 FIRM_API size_t get_compound_ent_n_values(const ir_entity *ent);
197
198 /**
199  * @deprecated
200  * Returns a constant value given the position.
201  */
202 FIRM_API ir_node *get_compound_ent_value(const ir_entity *ent, size_t pos);
203
204 /**
205  * @deprecated
206  * return 1 if entity has a compound_graph-style initializer
207  */
208 FIRM_API int entity_has_compound_ent_values(const ir_entity *entity);
209
210 #include "end.h"
211
212 #endif