* @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"
+#include "opt_manage.h"
static unsigned get_vnum(const ir_node *node)
{
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;
*
* @param irg The current ir graph.
*/
-int scalar_replacement_opt(ir_graph *irg)
+static ir_graph_state_t do_scalar_replacement(ir_graph *irg)
{
unsigned nvals;
int i;
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);
/* 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(set_ent, &key, sizeof(key), hash_ptr(key.ent));
#ifdef DEBUG_libfirm
if (is_Array_type(ent_type)) {
* 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;
+ return 0;
+}
+
+static optdesc_t opt_scalar_rep = {
+ "scalar-replace",
+ IR_GRAPH_STATE_NO_UNREACHABLE_CODE | IR_GRAPH_STATE_CONSISTENT_OUTS,
+ do_scalar_replacement,
+};
+
+int scalar_replacement_opt(ir_graph *irg)
+{
+ perform_irg_optimization(irg, &opt_scalar_rep);
+ return 1;
}
ir_graph_pass_t *scalar_replacement_opt_pass(const char *name)