* @file
* @brief Scalar replacement of compounds.
* @author Beyhan Veliev, Michael Beck
- * @version $Id$
*/
#include "config.h"
#include "irgmod.h"
#include "irnode_t.h"
#include "irpass.h"
-#include "irtools.h"
+#include "util.h"
#include "xmalloc.h"
#include "debug.h"
#include "error.h"
if (ent_mode != mode) {
if (ent_mode == NULL ||
get_mode_size_bits(ent_mode) != get_mode_size_bits(mode) ||
- get_mode_sort(ent_mode) != get_mode_sort(mode) ||
get_mode_arithmetic(ent_mode) != irma_twos_complement ||
get_mode_arithmetic(mode) != irma_twos_complement)
return false;
ir_node *args;
int j;
- assure_irg_outs(inner_irg);
+ assure_irg_properties(inner_irg, IR_GRAPH_PROPERTY_CONSISTENT_OUTS);
args = get_irg_args(inner_irg);
for (j = get_irn_n_outs(args) - 1; j >= 0; --j) {
ir_node *arg = get_irn_out(args, j);
pset_insert_ptr(sels, sel);
key = find_path(sel, 0);
- path = (path_t*)set_find(pathes, key, path_size(key), path_hash(key));
+ path = set_find(path_t, pathes, key, path_size(key), path_hash(key));
if (path) {
set_vnum(sel, path->vnum);
} else {
key->vnum = vnum++;
- set_insert(pathes, key, path_size(key), path_hash(key));
+ set_insert(path_t, pathes, key, path_size(key), path_hash(key));
set_vnum(sel, key->vnum);
DB((dbg, SET_LEVEL_3, " %+F represents value %u\n", sel, key->vnum));
*
* @param irg The current ir graph.
*/
-int scalar_replacement_opt(ir_graph *irg)
+void scalar_replacement_opt(ir_graph *irg)
{
unsigned nvals;
int i;
- scalars_t key, *value;
+ scalars_t key;
ir_node *irg_frame;
ir_mode **modes;
set *set_ent;
pset *sels;
ir_type *ent_type, *frame_tp;
- int res = 0;
- /* Call algorithm that computes the out edges */
- assure_irg_outs(irg);
+ assure_irg_properties(irg,
+ IR_GRAPH_PROPERTY_NO_UNREACHABLE_CODE
+ | IR_GRAPH_PROPERTY_CONSISTENT_OUTS);
/* we use the link field to store the VNUM */
ir_reserve_resources(irg, IR_RESOURCE_IRN_LINK);
ent_type = get_entity_type(ent);
key.ent = ent;
- set_insert(set_ent, &key, sizeof(key), HASH_PTR(key.ent));
+ set_insert(scalars_t, set_ent, &key, sizeof(key), hash_ptr(key.ent));
#ifdef DEBUG_libfirm
if (is_Array_type(ent_type)) {
if (nvals > 0) {
do_scalar_replacements(irg, sels, nvals, modes);
- foreach_set(set_ent, scalars_t*, value) {
+ foreach_set(set_ent, scalars_t, value) {
free_entity(value->ent);
}
* neither changed control flow, cf-backedges should be still
* consistent.
*/
- res = 1;
}
del_pset(sels);
del_set(set_ent);
ir_free_resources(irg, IR_RESOURCE_IRN_LINK);
irp_free_resources(irp, IRP_RESOURCE_ENTITY_LINK);
- return res;
+ confirm_irg_properties(irg, IR_GRAPH_PROPERTIES_NONE);
}
ir_graph_pass_t *scalar_replacement_opt_pass(const char *name)
{
- return def_graph_pass_ret(name ? name : "scalar_rep",
- scalar_replacement_opt);
+ return def_graph_pass(name ? name : "scalar_rep", scalar_replacement_opt);
}
void firm_init_scalar_replace(void)