#include "xmalloc.h"
#include "debug.h"
#include "error.h"
+#include "opt_manage.h"
static unsigned get_vnum(const ir_node *node)
{
*
* @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);
* 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)