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"
32 typedef struct compound_graph_path compound_graph_path, *ir_compound_graph_path_ptr;
36 * Creates a new compound graph path of given length.
38 compound_graph_path *new_compound_graph_path(ir_type *tp, int length);
42 * Returns non-zero if an object is a compound graph path
44 int is_compound_graph_path(const void *thing);
48 * Frees a graph path object
50 void free_compound_graph_path(compound_graph_path *gr);
54 * Returns the length of a graph path
56 int get_compound_graph_path_length(const compound_graph_path *gr);
60 * Get the entity node of an compound graph path at position pos.
62 ir_entity *get_compound_graph_path_node(const compound_graph_path *gr, int pos);
66 * Set the entity node of an compound graph path at position pos.
68 void set_compound_graph_path_node(compound_graph_path *gr, int pos, ir_entity *node);
72 * Get the index of an compound graph path at position pos.
74 int get_compound_graph_path_array_index(const compound_graph_path *gr, int pos);
78 * Set the index of an compound graph path at position pos.
80 void set_compound_graph_path_array_index(compound_graph_path *gr, int pos, int index);
84 * Get the type of an compound graph path.
86 ir_type *get_compound_graph_path_type(const compound_graph_path *gr);
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.
93 int is_proper_compound_graph_path(compound_graph_path *gr, int pos);
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.
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);
105 * Returns the access path for value at position pos.
107 compound_graph_path *get_compound_ent_value_path(const ir_entity *ent, int pos);
111 * Returns a constant value given the access path.
112 * The path must contain array indices for all array element entities.
114 ir_node *get_compound_ent_value_by_path(const ir_entity *ent,
115 compound_graph_path *path);
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
123 void remove_compound_ent_value(ir_entity *ent, ir_entity *value_ent);
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
132 void add_compound_ent_value(ir_entity *ent, ir_node *val, ir_entity *member);
136 * Returns the last member in the path
138 ir_entity *get_compound_ent_value_member(const ir_entity *ent, int pos);
142 * Sets the path at pos 0
144 void set_compound_ent_value(ir_entity *ent, ir_node *val, ir_entity *member,
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.
156 void set_array_entity_values(ir_entity *ent, tarval **values, int num_vals);
160 * Return the offset in bits from the last byte address.
162 * This requires that the layout of all concerned types is fixed.
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.
167 unsigned get_compound_ent_value_offset_bit_remainder(const ir_entity *ent, int pos);
171 * Return the overall offset of value at position pos in bytes.
173 * This requires that the layout of all concerned types is fixed.
174 * Asserts if bit offset is not byte aligned.
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.
179 unsigned get_compound_ent_value_offset_bytes(const ir_entity *ent, int pos);
183 * Returns the number of constant values needed to initialize the entity.
184 * Asserts if the entity has variability_uninitialized.
186 int get_compound_ent_n_values(const ir_entity *ent);
190 * Returns a constant value given the position.
192 ir_node *get_compound_ent_value(const ir_entity *ent, int pos);
196 * return 1 if entity has a compound_graph-style initializer
198 int entity_has_compound_ent_values(const ir_entity *entity);