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