* @author Michael Beck
* @version $Id$
*/
-#ifdef HAVE_CONFIG_H
-# include "config.h"
-#endif
+#include "config.h"
#ifdef HAVE_STRING_H
# include <string.h>
#include <assert.h>
+#include "error.h"
#include "lowering.h"
#include "irnode_t.h"
#include "irgraph_t.h"
#include "pmap.h"
#include "pdeq.h"
#include "irdump.h"
-#include "xmalloc.h"
+#include "array_t.h"
/** A map from mode to a primitive type. */
static pmap *prim_types;
if (tarval_is_long(tv) &&
get_tarval_long(tv) >= (long)get_mode_size_bits(mode)) {
- ir_node *block = get_nodes_block(node);
- ir_node *left = get_Shrs_left(node);
- long shf_cnt = get_tarval_long(tv) - get_mode_size_bits(mode);
+ ir_node *block = get_nodes_block(node);
+ ir_node *left = get_Shrs_left(node);
+ long shf_cnt = get_tarval_long(tv) - get_mode_size_bits(mode);
+ int idx = get_irn_idx(left);
+ ir_node *low;
ir_node *c;
- int idx = get_irn_idx(left);
left = env->entries[idx]->high_word;
idx = get_irn_idx(node);
if (shf_cnt > 0) {
- ir_node *tmp;
- c = new_r_Const_long(irg, block, mode_Iu, shf_cnt);
- tmp = new_r_Shrs(irg, block, left, c, mode);
- /* low word is expected to have mode_Iu */
- env->entries[idx]->low_word = new_r_Conv(irg, block, tmp, mode_Iu);
+ c = new_r_Const_long(irg, block, mode_Iu, shf_cnt);
+ low = new_r_Shrs(irg, block, left, c, mode);
} else {
- env->entries[idx]->low_word = left;
+ low = left;
} /* if */
+ /* low word is expected to have mode_Iu */
+ env->entries[idx]->low_word = new_r_Conv(irg, block, low, mode_Iu);
+
c = new_r_Const_long(irg, block, mode_Iu, get_mode_size_bits(mode) - 1);
env->entries[idx]->high_word = new_r_Shrs(irg, block, left, c, mode);
ir_node *left = get_Rotl_left(node);
ir_node *h, *l;
int idx = get_irn_idx(left);
+ (void) right;
+ (void) mode;
assert(get_mode_arithmetic(mode) == irma_twos_complement &&
is_Const(right) && tarval_is_long(get_Const_tarval(right)) &&
} /* lower_Phi */
/**
- * Translate a Psi.
+ * Translate a Mux.
*/
-static void lower_Psi(ir_node *psi, ir_mode *mode, lower_env_t *env) {
+static void lower_Mux(ir_node *mux, ir_mode *mode, lower_env_t *env) {
ir_graph *irg = current_ir_graph;
ir_node *block, *val;
- ir_node **valsl, **valsh, **conds;
+ ir_node *true_l, *true_h, *false_l, *false_h, *sel;
dbg_info *dbg;
- int idx, i, n_conds = get_Psi_n_conds(psi);
+ int idx;
- /* first create a new in array */
- NEW_ARR_A(ir_node *, valsl, n_conds + 1);
- NEW_ARR_A(ir_node *, valsh, n_conds + 1);
+ val = get_Mux_true(mux);
+ idx = get_irn_idx(val);
+ if (env->entries[idx]->low_word) {
+ /* Values already build */
+ true_l = env->entries[idx]->low_word;
+ true_h = env->entries[idx]->high_word;
+ } else {
+ /* still not ready */
+ pdeq_putr(env->waitq, mux);
+ return;
+ } /* if */
- for (i = 0; i < n_conds; ++i) {
- val = get_Psi_val(psi, i);
- idx = get_irn_idx(val);
- if (env->entries[idx]->low_word) {
- /* Values already build */
- valsl[i] = env->entries[idx]->low_word;
- valsh[i] = env->entries[idx]->high_word;
- } else {
- /* still not ready */
- pdeq_putr(env->waitq, psi);
- return;
- } /* if */
- } /* for */
- val = get_Psi_default(psi);
+ val = get_Mux_false(mux);
idx = get_irn_idx(val);
if (env->entries[idx]->low_word) {
/* Values already build */
- valsl[i] = env->entries[idx]->low_word;
- valsh[i] = env->entries[idx]->high_word;
+ false_l = env->entries[idx]->low_word;
+ false_h = env->entries[idx]->high_word;
} else {
/* still not ready */
- pdeq_putr(env->waitq, psi);
+ pdeq_putr(env->waitq, mux);
return;
} /* if */
- NEW_ARR_A(ir_node *, conds, n_conds);
- for (i = 0; i < n_conds; ++i) {
- conds[i] = get_Psi_cond(psi, i);
- } /* for */
+ sel = get_Mux_sel(mux);
- dbg = get_irn_dbg_info(psi);
- block = get_nodes_block(psi);
+ dbg = get_irn_dbg_info(mux);
+ block = get_nodes_block(mux);
- idx = get_irn_idx(psi);
+ idx = get_irn_idx(mux);
assert(idx < env->n_entries);
- env->entries[idx]->low_word = new_rd_Psi(dbg, irg, block, n_conds, conds, valsl, mode);
- env->entries[idx]->high_word = new_rd_Psi(dbg, irg, block, n_conds, conds, valsh, mode);
-} /* lower_Psi */
+ env->entries[idx]->low_word = new_rd_Mux(dbg, irg, block, sel, false_l, true_l, mode);
+ env->entries[idx]->high_word = new_rd_Mux(dbg, irg, block, sel, false_h, true_h, mode);
+} /* lower_Mux */
+
+static void lower_ASM(ir_node *asmn, ir_mode *mode, lower_env_t *env)
+{
+ ir_mode *his = env->params->high_signed;
+ ir_mode *hiu = env->params->high_unsigned;
+ int i;
+ ir_node *n;
+
+ (void)mode;
+
+ for (i = get_irn_arity(asmn) - 1; i >= 0; --i) {
+ ir_mode *op_mode = get_irn_mode(get_irn_n(asmn, i));
+ if (op_mode == his || op_mode == hiu) {
+ panic("lowering ASM unimplemented");
+ }
+ }
+
+ for (n = asmn;;) {
+ ir_mode *proj_mode;
+
+ n = get_irn_link(n);
+ if (n == NULL)
+ break;
+
+ proj_mode = get_irn_mode(n);
+ if (proj_mode == his || proj_mode == hiu) {
+ panic("lowering ASM unimplemented");
+ }
+ }
+}
/**
* check for opcodes that must always be lowered.
*/
static int always_lower(ir_opcode code) {
switch (code) {
+ case iro_ASM:
case iro_Proj:
case iro_Start:
case iro_Call:
int idx = get_irn_idx(node);
ir_mode *mode = get_irn_mode(node);
- if (mode == mode_b || is_Psi(node) || is_Conv(node)) {
+ if (mode == mode_b || is_Mux(node) || is_Conv(node)) {
int i;
for (i = get_irn_arity(node) - 1; i >= 0; --i) {
#define LOWER_UN(op) LOWER2(op, lower_Unop)
/* the table of all operations that must be lowered follows */
+ LOWER(ASM);
LOWER(Load);
LOWER(Store);
LOWER(Const);
LOWER(Call);
LOWER(Unknown);
LOWER(Phi);
- LOWER(Psi);
+ LOWER(Mux);
LOWER(Start);
LOWER_BIN(Add);