/*
- * Project: libFIRM
- * File name: ir/opt/scalar_replace.c
- * Purpose: scalar replacement of arrays and compounds
- * Author: Beyhan Veliev
- * Modified by: Michael Beck
- * Created:
- * CVS-ID: $Id$
- * Copyright: (c) 1998-2005 Universität 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 Scalar replacement of compounds.
+ * @author Beyhan Veliev, Michael Beck
+ * @version $Id$
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
-#ifdef HAVE_ALLOCA_H
-#include <alloca.h>
-#endif
-
-#ifdef HAVE_MALLOC_H
-#include <malloc.h>
-#endif
-
-#ifdef HAVE_STRING_H
#include <string.h>
-#endif
+#include "iroptimize.h"
#include "scalar_replace.h"
#include "irflag_t.h"
#include "irouts.h"
#include "irgmod.h"
#include "irnode_t.h"
#include "irtools.h"
+#include "xmalloc.h"
#define SET_VNUM(node, vnum) set_irn_link(node, INT_TO_PTR(vnum))
#define GET_VNUM(node) (unsigned)PTR_TO_INT(get_irn_link(node))
* accesses like a.b.c[8].d
*/
typedef union {
- entity *ent;
+ ir_entity *ent;
tarval *tv;
} path_elem_t;
#define PATH_SIZE(p) (sizeof(*(p)) + sizeof((p)->path[0]) * ((p)->path_len - 1))
typedef struct _scalars_t {
- entity *ent; /**< A entity for scalar replacement. */
+ ir_entity *ent; /**< A entity for scalar replacement. */
ir_type *ent_owner; /**< The owner of this entity. */
} scalars_t;
int i;
ir_mode *emode, *mode;
ir_node *value;
- entity *ent;
+ ir_entity *ent;
if (! is_const_sel(sel))
return 1;
* @param ent the entity that will be scalar replaced
* @param sel a Sel node that selects some fields of this entity
*/
-static void link_all_leave_sels(entity *ent, ir_node *sel)
+static void link_all_leave_sels(ir_entity *ent, ir_node *sel)
{
int i, n, flag = 1;
ir_node *succ = get_irn_out(irg_frame, i);
if (is_Sel(succ)) {
- entity *ent = get_Sel_entity(succ);
+ ir_entity *ent = get_Sel_entity(succ);
set_entity_link(ent, NULL);
}
}
ir_node *succ = get_irn_out(irg_frame, i);
if (is_Sel(succ)) {
- entity *ent = get_Sel_entity(succ);
+ ir_entity *ent = get_Sel_entity(succ);
ir_type *ent_type;
if (get_entity_link(ent) == ADDRESS_TAKEN)
*
* @return the next free value number
*/
-static unsigned allocate_value_numbers(pset *sels, entity *ent, unsigned vnum, ir_mode ***modes)
+static unsigned allocate_value_numbers(pset *sels, ir_entity *ent, unsigned vnum, ir_mode ***modes)
{
ir_node *sel, *next;
path_t *key, *path;
set_insert(pathes, key, PATH_SIZE(key), path_hash(key));
SET_VNUM(sel, key->vnum);
- ARR_EXTO(ir_mode *, *modes, (key->vnum + 15) & ~15);
+ ARR_EXTO(ir_mode *, *modes, (int)((key->vnum + 15) & ~15));
(*modes)[key->vnum] = get_type_mode(get_entity_type(get_Sel_entity(sel)));
val = new_d_Conv(get_irn_dbg_info(node), val, mode);
turn_into_tuple(node, pn_Load_max);
- set_Tuple_pred(node, pn_Load_M, mem);
- set_Tuple_pred(node, pn_Load_res, val);
- set_Tuple_pred(node, pn_Load_X_except, new_Bad());
+ set_Tuple_pred(node, pn_Load_M, mem);
+ set_Tuple_pred(node, pn_Load_res, val);
+ set_Tuple_pred(node, pn_Load_X_regular, new_r_Jmp(current_ir_graph, block));
+ set_Tuple_pred(node, pn_Load_X_except, new_Bad());
} else {
l = obstack_alloc(&env->obst, sizeof(*l));
l->node = node;
value_arr[vnum] = val;
mem = get_Store_mem(node);
+ block = get_nodes_block(node);
turn_into_tuple(node, pn_Store_max);
- set_Tuple_pred(node, pn_Store_M, mem);
- set_Tuple_pred(node, pn_Store_X_except, new_Bad());
+ set_Tuple_pred(node, pn_Store_M, mem);
+ set_Tuple_pred(node, pn_Store_X_regular, new_r_Jmp(current_ir_graph, block));
+ set_Tuple_pred(node, pn_Store_X_except, new_Bad());
} else if (op == op_Phi && get_irn_mode(node) == mode_M) {
/*
* found a memory Phi: Here, we must create new Phi nodes
val = new_Unknown(env->modes[l->vnum]);
}
- mem = get_Load_mem(load);
/* Beware: A Load can contain a hidden conversion in Firm.
Handle this here. */
mode = get_Load_mode(load);
if (mode != get_irn_mode(val))
val = new_d_Conv(get_irn_dbg_info(load), val, mode);
+ mem = get_Load_mem(load);
+
turn_into_tuple(load, pn_Load_max);
- set_Tuple_pred(load, pn_Load_M, mem);
- set_Tuple_pred(load, pn_Load_res, val);
- set_Tuple_pred(load, pn_Load_X_except, new_Bad());
+ set_Tuple_pred(load, pn_Load_M, mem);
+ set_Tuple_pred(load, pn_Load_res, val);
+ set_Tuple_pred(load, pn_Load_X_regular, new_r_Jmp(current_ir_graph, block));
+ set_Tuple_pred(load, pn_Load_X_except, new_Bad());
}
}
ir_node *succ = get_irn_out(irg_frame, i);
if (is_Sel(succ)) {
- entity *ent = get_Sel_entity(succ);
+ ir_entity *ent = get_Sel_entity(succ);
if (get_entity_link(ent) == NULL || get_entity_link(ent) == ADDRESS_TAKEN)
continue;