-/**
- * Author: Daniel Grund
- * Date: 17.01.2006
- * Copyright: (c) Universitaet Karlsruhe
- * Licence: This file protected by GPL - GNU GENERAL PUBLIC LICENSE.
+/*
+ * Copyright (C) 1995-2007 University of Karlsruhe. All right reserved.
+ *
+ * This file is part of libFirm.
+ *
+ * This file may be distributed and/or modified under the terms of the
+ * GNU General Public License version 2 as published by the Free Software
+ * Foundation and appearing in the file LICENSE.GPL included in the
+ * packaging of this file.
+ *
+ * Licensees holding valid libFirm Professional Edition licenses may use
+ * this file in accordance with the libFirm Commercial License.
+ * Agreement provided with the Software.
*
+ * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
+ * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE.
*/
+/**
+ * @file
+ * @brief Simple SSA destruction.
+ * @author Daniel Grund
+ * @date 17.01.2006
+ * @version $Id$
+ */
+#ifdef NOT_PORTED
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
-#ifdef HAVE_MALLOC_H
- #include <malloc.h>
-#endif
-#ifdef HAVE_ALLOCA_H
- #include <alloca.h>
-#endif
-
#include <stdio.h>
#include <stdlib.h>
#include <limits.h>
-#ifdef WITH_LIBCORE
-#include <libcore/lc_opts.h>
-#include <libcore/lc_opts_enum.h>
-#endif
#include "set.h"
#include "pset.h"
#include "pmap.h"
#include "bitset.h"
+#include "xmalloc.h"
#include "irprintf_t.h"
#include "irnode_t.h"
#include "irdom_t.h"
#include "phiclass.h"
-#include "beraextern.h"
#include "beabi.h"
-#include "bearch.h"
+#include "bearch_t.h"
#include "benode_t.h"
#include "beirgmod.h"
#include "besched_t.h"
#define DBG_LEVEL 2
typedef struct _ssa_destr_env_t {
- ir_graph *irg;
+ ir_graph *irg;
const arch_register_class_t *cls;
- const arch_env_t *aenv;
- set *vars;
+ const arch_env_t *aenv;
+ set *vars;
} ssa_destr_env_t;
#define pset_foreach(pset, irn) for(irn=pset_first(pset); irn; irn=pset_next(pset))
#define set_foreach(set, e) for(e=set_first(set); e; e=set_next(set))
+static phi_classes_t *pc = NULL;
+
/******************************************************************************
__ __ _ ___ __ __
\ \ / / | | |__ \ \ \ / /
return vi->values;
}
-static INLINE ir_node *get_first_phi(pset *s) {
- ir_node *irn;
+static INLINE ir_node *get_first_phi(ir_node **s) {
+ int i;
- pset_foreach(s, irn)
- if (is_Phi(irn)) {
- pset_break(s);
- return irn;
- }
+ for (i = ARR_LEN(s) - 1; i >= 0; --i) {
+ if (is_Phi(s[i]))
+ return s[i];
+ }
assert(0 && "There must be a phi in this");
return NULL;
*/
static void values_to_vars(ir_node *irn, void *env) {
ssa_destr_env_t *sde = env;
- int nr;
- pset *vals;
+ int nr, i, build_vals = 0;
+ ir_node **vals;
- if(arch_get_irn_reg_class(sde->aenv, irn, -1) == NULL)
+ if (arch_get_irn_reg_class(sde->aenv, irn, -1) == NULL)
return;
- vals = get_phi_class(irn);
+ vals = get_phi_class(pc, irn);
if (vals) {
nr = get_irn_node_nr(get_first_phi(vals));
} else {
/* not a phi class member, value == var */
- nr = get_irn_node_nr(irn);
- vals = pset_new_ptr(1);
- pset_insert_ptr(vals, irn);
+ nr = get_irn_node_nr(irn);
+ vals = NEW_ARR_F(ir_node *, 1);
+ vals[0] = irn;
+ build_vals = 1;
}
/* values <--> var mapping */
- pset_foreach(vals, irn) {
- be_var_add_value(sde->vars, nr, irn);
+ for (i = ARR_LEN(vals) - 1; i >= 0; --i) {
+ be_var_add_value(sde->vars, nr, vals[i]);
}
+
+ if (build_vals)
+ DEL_ARR_F(vals);
}
/******************************************************************************
irg_block_walk_graph(irg, ssa_destr_simple_walker, NULL, &sde);
/* Mapping of SSA-Values <--> Variables */
- phi_class_compute(irg);
+ pc = phi_class_new_from_irg(irg, 0);
be_clear_links(irg);
irg_walk_graph(irg, values_to_vars, NULL, &sde);
del_pset(vi->values);
del_set(vars);
+ phi_class_free(pc);
}
+
+#endif /* NOT_PORTED */