2 * Copyright (C) 1995-2008 University of Karlsruhe. All right reserved.
4 * This file is part of libFirm.
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.
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.
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
22 * @brief Deprecated way to initialize compound entites! (use ir_initializer
24 * Declarations for functions and datastructures to represent compound
27 #ifndef FIRM_COMPOUND_PATHS_H
28 #define FIRM_COMPOUND_PATHS_H
30 #include "firm_types.h"
34 * path into compound types
37 typedef struct compound_graph_path compound_graph_path;
41 * Creates a new compound graph path of given length.
43 FIRM_API compound_graph_path *new_compound_graph_path(ir_type *tp, size_t length);
47 * Returns non-zero if an object is a compound graph path
49 FIRM_API int is_compound_graph_path(const void *thing);
53 * Frees a graph path object
55 FIRM_API void free_compound_graph_path(compound_graph_path *gr);
59 * Returns the length of a graph path
61 FIRM_API size_t get_compound_graph_path_length(const compound_graph_path *gr);
65 * Returns the entity node of an compound graph path at position pos.
67 ir_entity *get_compound_graph_path_node(const compound_graph_path *gr, size_t pos);
71 * Sets the entity node of an compound graph path at position pos.
73 FIRM_API void set_compound_graph_path_node(compound_graph_path *gr, size_t pos,
78 * Returns the index of an compound graph path at position pos.
80 FIRM_API long get_compound_graph_path_array_index(const compound_graph_path *gr, size_t pos);
84 * Sets the index of an compound graph path at position pos.
86 FIRM_API void set_compound_graph_path_array_index(compound_graph_path *gr, size_t pos, long index);
90 * Returns the type of an compound graph path.
92 FIRM_API ir_type *get_compound_graph_path_type(const compound_graph_path *gr);
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.
99 FIRM_API int is_proper_compound_graph_path(compound_graph_path *gr, size_t pos);
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.
106 FIRM_API void add_compound_ent_value_w_path(ir_entity *ent, ir_node *val, compound_graph_path *path);
109 * Sets initializer value for a compound ent path
111 FIRM_API void set_compound_ent_value_w_path(ir_entity *ent, ir_node *val, compound_graph_path *path, size_t pos);
115 * Returns the access path for value at position pos.
117 FIRM_API compound_graph_path *get_compound_ent_value_path(const ir_entity *ent, size_t pos);
121 * Returns a constant value given the access path.
122 * The path must contain array indices for all array element entities.
124 FIRM_API ir_node *get_compound_ent_value_by_path(const ir_entity *ent,
125 compound_graph_path *path);
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
133 FIRM_API void remove_compound_ent_value(ir_entity *ent, ir_entity *value_ent);
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
142 FIRM_API void add_compound_ent_value(ir_entity *ent, ir_node *val, ir_entity *member);
146 * Returns the last member in the path
148 FIRM_API ir_entity *get_compound_ent_value_member(const ir_entity *ent, size_t pos);
152 * Sets the path at pos 0
154 FIRM_API void set_compound_ent_value(ir_entity *ent, ir_node *val,
155 ir_entity *member, size_t pos);
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.
166 FIRM_API void set_array_entity_values(ir_entity *ent, ir_tarval **values, size_t num_vals);
170 * Returns the offset in bits from the last byte address.
172 * This requires that the layout of all concerned types is fixed.
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.
177 FIRM_API unsigned get_compound_ent_value_offset_bit_remainder(const ir_entity *ent, size_t pos);
181 * Returns the overall offset of value at position pos in bytes.
183 * This requires that the layout of all concerned types is fixed.
184 * Asserts if bit offset is not byte aligned.
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.
189 FIRM_API unsigned get_compound_ent_value_offset_bytes(const ir_entity *ent, size_t pos);
193 * Returns the number of constant values needed to initialize the entity.
194 * Asserts if the entity has variability_uninitialized.
196 FIRM_API size_t get_compound_ent_n_values(const ir_entity *ent);
200 * Returns a constant value given the position.
202 FIRM_API ir_node *get_compound_ent_value(const ir_entity *ent, size_t pos);
206 * return 1 if entity has a compound_graph-style initializer
208 FIRM_API int entity_has_compound_ent_values(const ir_entity *entity);