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"
33 typedef struct compound_graph_path compound_graph_path, *ir_compound_graph_path_ptr;
37 * Creates a new compound graph path of given length.
39 FIRM_API compound_graph_path *new_compound_graph_path(ir_type *tp, int length);
43 * Returns non-zero if an object is a compound graph path
45 FIRM_API int is_compound_graph_path(const void *thing);
49 * Frees a graph path object
51 FIRM_API void free_compound_graph_path(compound_graph_path *gr);
55 * Returns the length of a graph path
57 FIRM_API int get_compound_graph_path_length(const compound_graph_path *gr);
61 * Get the entity node of an compound graph path at position pos.
63 ir_entity *get_compound_graph_path_node(const compound_graph_path *gr, int pos);
67 * Set the entity node of an compound graph path at position pos.
69 FIRM_API void set_compound_graph_path_node(compound_graph_path *gr, int pos,
74 * Get the index of an compound graph path at position pos.
76 FIRM_API int get_compound_graph_path_array_index(const compound_graph_path *gr, int pos);
80 * Set the index of an compound graph path at position pos.
82 FIRM_API void set_compound_graph_path_array_index(compound_graph_path *gr, int pos, int index);
86 * Get the type of an compound graph path.
88 FIRM_API ir_type *get_compound_graph_path_type(const compound_graph_path *gr);
92 * Checks whether the path up to pos is correct. If the path contains a NULL,
93 * assumes the path is not complete and returns non-zero.
95 FIRM_API int is_proper_compound_graph_path(compound_graph_path *gr, int pos);
99 * A value of a compound entity is a pair of a value and the description of the
100 * corresponding access path to the member of the compound.
102 FIRM_API void add_compound_ent_value_w_path(ir_entity *ent, ir_node *val, compound_graph_path *path);
103 FIRM_API void set_compound_ent_value_w_path(ir_entity *ent, ir_node *val, compound_graph_path *path, int pos);
107 * Returns the access path for value at position pos.
109 FIRM_API compound_graph_path *get_compound_ent_value_path(const ir_entity *ent, int pos);
113 * Returns a constant value given the access path.
114 * The path must contain array indices for all array element entities.
116 FIRM_API ir_node *get_compound_ent_value_by_path(const ir_entity *ent,
117 compound_graph_path *path);
121 * Removes all constant entries where the path ends at value_ent. Does not
122 * free the memory of the paths. (The same path might be used for several
125 FIRM_API void remove_compound_ent_value(ir_entity *ent, ir_entity *value_ent);
129 * Generates a Path with length 1.
130 * Beware: Has a bad runtime for array elements (O(|array|) and should be
131 * avoided there. Use add_compound_ent_value_w_path() instead and create
134 FIRM_API void add_compound_ent_value(ir_entity *ent, ir_node *val, ir_entity *member);
138 * Returns the last member in the path
140 FIRM_API ir_entity *get_compound_ent_value_member(const ir_entity *ent, int pos);
144 * Sets the path at pos 0
146 FIRM_API void set_compound_ent_value(ir_entity *ent, ir_node *val,
147 ir_entity *member, int pos);
151 * Initializes the entity ent which must be of a one dimensional
152 * array type with the values given in the values array.
153 * The array must have a lower and an upper bound. Keeps the
154 * order of values. Does not test whether the number of values
155 * fits into the given array size. Does not test whether the
156 * values have the proper mode for the array.
158 FIRM_API void set_array_entity_values(ir_entity *ent, ir_tarval **values, int num_vals);
162 * Return the offset in bits from the last byte address.
164 * This requires that the layout of all concerned types is fixed.
166 * @param ent Any entity of compound type with at least pos initialization values.
167 * @param pos The position of the value for which the offset is requested.
169 FIRM_API unsigned get_compound_ent_value_offset_bit_remainder(const ir_entity *ent, int pos);
173 * Return the overall offset of value at position pos in bytes.
175 * This requires that the layout of all concerned types is fixed.
176 * Asserts if bit offset is not byte aligned.
178 * @param ent Any entity of compound type with at least pos initialization values.
179 * @param pos The position of the value for which the offset is requested.
181 FIRM_API unsigned get_compound_ent_value_offset_bytes(const ir_entity *ent, int pos);
185 * Returns the number of constant values needed to initialize the entity.
186 * Asserts if the entity has variability_uninitialized.
188 FIRM_API int get_compound_ent_n_values(const ir_entity *ent);
192 * Returns a constant value given the position.
194 FIRM_API ir_node *get_compound_ent_value(const ir_entity *ent, int pos);
198 * return 1 if entity has a compound_graph-style initializer
200 FIRM_API int entity_has_compound_ent_values(const ir_entity *entity);