/* set param types and result types */
n_param = 0;
if (imode == env->params->high_signed) {
- set_method_param_type(mtd, n_param++, tp_s);
+ set_method_param_type(mtd, n_param++, tp_u);
set_method_param_type(mtd, n_param++, tp_s);
} else if (imode == env->params->high_unsigned) {
set_method_param_type(mtd, n_param++, tp_u);
n_res = 0;
if (omode == env->params->high_signed) {
- set_method_res_type(mtd, n_res++, tp_s);
+ set_method_res_type(mtd, n_res++, tp_u);
set_method_res_type(mtd, n_res++, tp_s);
} else if (omode == env->params->high_unsigned) {
set_method_res_type(mtd, n_res++, tp_u);
ir_node *block = get_nodes_block(node);
int idx;
ir_graph *irg = current_ir_graph;
+ ir_mode *low_mode = env->params->low_unsigned;
tv = get_Const_tarval(node);
- tv_l = tarval_convert_to(tv, mode);
- low = new_rd_Const(dbg, irg, block, mode, tv_l);
+ tv_l = tarval_convert_to(tv, low_mode);
+ low = new_rd_Const(dbg, irg, block, low_mode, tv_l);
tv_h = tarval_convert_to(tarval_shrs(tv, env->tv_mode_bits), mode);
high = new_rd_Const(dbg, irg, block, mode, tv_h);
* Translate a Load: create two.
*/
static void lower_Load(ir_node *node, ir_mode *mode, lower_env_t *env) {
+ ir_mode *low_mode = env->params->low_unsigned;
ir_graph *irg = current_ir_graph;
ir_node *adr = get_Load_ptr(node);
ir_node *mem = get_Load_mem(node);
/* create two loads */
dbg = get_irn_dbg_info(node);
- low = new_rd_Load(dbg, irg, block, mem, low, mode);
+ low = new_rd_Load(dbg, irg, block, mem, low, low_mode);
proj = new_r_Proj(irg, block, low, mode_M, pn_Load_M);
high = new_rd_Load(dbg, irg, block, proj, high, mode);
break;
case pn_Load_res: /* Result of load operation. */
assert(idx < env->n_entries);
- env->entries[idx]->low_word = new_r_Proj(irg, block, low, mode, pn_Load_res);
- env->entries[idx]->high_word = new_r_Proj(irg, block, high, mode, pn_Load_res);
+ env->entries[idx]->low_word = new_r_Proj(irg, block, low, low_mode, pn_Load_res);
+ env->entries[idx]->high_word = new_r_Proj(irg, block, high, mode, pn_Load_res);
break;
default:
assert(0 && "unexpected Proj number");
dbg_info *dbg;
int idx;
node_entry_t *entry;
+ (void) node;
+ (void) mode;
irn = get_Store_value(node);
entry = env->entries[get_irn_idx(irn)];
case pn_Div_res: /* Result of computation. */
idx = get_irn_idx(proj);
assert(idx < env->n_entries);
- env->entries[idx]->low_word = new_r_Proj(current_ir_graph, block, irn, mode, 0);
- env->entries[idx]->high_word = new_r_Proj(current_ir_graph, block, irn, mode, 1);
+ env->entries[idx]->low_word = new_r_Proj(current_ir_graph, block, irn, env->params->low_unsigned, 0);
+ env->entries[idx]->high_word = new_r_Proj(current_ir_graph, block, irn, mode, 1);
break;
default:
assert(0 && "unexpected Proj number");
case pn_Mod_res: /* Result of computation. */
idx = get_irn_idx(proj);
assert(idx < env->n_entries);
- env->entries[idx]->low_word = new_r_Proj(irg, block, irn, mode, 0);
- env->entries[idx]->high_word = new_r_Proj(irg, block, irn, mode, 1);
+ env->entries[idx]->low_word = new_r_Proj(irg, block, irn, env->params->low_unsigned, 0);
+ env->entries[idx]->high_word = new_r_Proj(irg, block, irn, mode, 1);
break;
default:
assert(0 && "unexpected Proj number");
case pn_DivMod_res_div: /* Result of Div. */
idx = get_irn_idx(proj);
assert(idx < env->n_entries);
- env->entries[idx]->low_word = new_r_Proj(irg, block, resDiv, mode, 0);
- env->entries[idx]->high_word = new_r_Proj(irg, block, resDiv, mode, 1);
+ env->entries[idx]->low_word = new_r_Proj(irg, block, resDiv, env->params->low_unsigned, 0);
+ env->entries[idx]->high_word = new_r_Proj(irg, block, resDiv, mode, 1);
break;
case pn_DivMod_res_mod: /* Result of Mod. */
idx = get_irn_idx(proj);
- env->entries[idx]->low_word = new_r_Proj(irg, block, resMod, mode, 0);
- env->entries[idx]->high_word = new_r_Proj(irg, block, resMod, mode, 1);
+ env->entries[idx]->low_word = new_r_Proj(irg, block, resMod, env->params->low_unsigned, 0);
+ env->entries[idx]->high_word = new_r_Proj(irg, block, resMod, mode, 1);
break;
default:
assert(0 && "unexpected Proj number");
idx = get_irn_idx(node);
assert(idx < env->n_entries);
- env->entries[idx]->low_word = new_r_Proj(irg, block, irn, mode, 0);
- env->entries[idx]->high_word = new_r_Proj(irg, block, irn, mode, 1);
+ env->entries[idx]->low_word = new_r_Proj(irg, block, irn, env->params->low_unsigned, 0);
+ env->entries[idx]->high_word = new_r_Proj(irg, block, irn, mode, 1);
} /* lower_Binop */
/**
idx = get_irn_idx(node);
assert(idx < env->n_entries);
- env->entries[idx]->low_word = new_r_Proj(irg, block, irn, mode, 0);
- env->entries[idx]->high_word = new_r_Proj(irg, block, irn, mode, 1);
+ env->entries[idx]->low_word = new_r_Proj(irg, block, irn, env->params->low_unsigned, 0);
+ env->entries[idx]->high_word = new_r_Proj(irg, block, irn, mode, 1);
} /* lower_Shiftop */
/**
idx = get_irn_idx(node);
assert(idx < env->n_entries);
- env->entries[idx]->low_word = new_r_Proj(irg, block, irn, mode, 0);
- env->entries[idx]->high_word = new_r_Proj(irg, block, irn, mode, 1);
+ env->entries[idx]->low_word = new_r_Proj(irg, block, irn, env->params->low_unsigned, 0);
+ env->entries[idx]->high_word = new_r_Proj(irg, block, irn, mode, 1);
} /* lower_Unop */
/**
idx = get_irn_idx(node);
assert(idx < env->n_entries);
irg = current_ir_graph;
- env->entries[idx]->low_word = constr_rd(dbg, irg, block, lop_l, rop_l, mode);
+ env->entries[idx]->low_word = constr_rd(dbg, irg, block, lop_l, rop_l, env->params->low_unsigned);
env->entries[idx]->high_word = constr_rd(dbg, irg, block, lop_h, rop_h, mode);
} /* lower_Binop_logical */
idx = get_irn_idx(node);
assert(idx < env->n_entries);
- env->entries[idx]->low_word = new_rd_Not(dbg, current_ir_graph, block, op_l, mode);
+ env->entries[idx]->low_word = new_rd_Not(dbg, current_ir_graph, block, op_l, env->params->low_unsigned);
env->entries[idx]->high_word = new_rd_Not(dbg, current_ir_graph, block, op_h, mode);
} /* lower_Not */
-/**
- * Translate a Minus.
- *
- * Create two Minus'.
- */
-static void lower_Minus(ir_node *node, ir_mode *mode, lower_env_t *env) {
- ir_node *block, *irn;
- ir_node *op_l, *op_h;
- dbg_info *dbg;
- int idx;
- ir_graph *irg;
- node_entry_t *entry;
-
- irn = get_Minus_op(node);
- entry = env->entries[get_irn_idx(irn)];
- assert(entry);
-
- if (! entry->low_word) {
- /* not ready yet, wait */
- pdeq_putr(env->waitq, node);
- return;
- } /* if */
-
- op_l = entry->low_word;
- op_h = entry->high_word;
-
- dbg = get_irn_dbg_info(node);
- block = get_nodes_block(node);
- irg = current_ir_graph;
-
- idx = get_irn_idx(node);
- assert(idx < env->n_entries);
- env->entries[idx]->low_word = new_rd_Minus(dbg, current_ir_graph, block, op_l, mode);
- env->entries[idx]->high_word = new_rd_Minus(dbg, current_ir_graph, block, op_h, mode);
-} /* lower_Minus */
-
/**
* Translate a Cond.
*/
ir_node *sel = get_Cond_selector(node);
ir_mode *m = get_irn_mode(sel);
int idx;
+ (void) mode;
if (m == mode_b) {
node_entry_t *lentry, *rentry;
pn_Cmp pnc;
dbg_info *dbg;
+ if(!is_Proj(sel))
+ return;
+
cmp = get_Proj_pred(sel);
+ if(!is_Cmp(cmp))
+ return;
+
left = get_Cmp_left(cmp);
idx = get_irn_idx(left);
lentry = env->entries[idx];
static void lower_Conv_to_Ls(ir_node *node, lower_env_t *env) {
ir_node *op = get_Conv_op(node);
ir_mode *imode = get_irn_mode(op);
- ir_mode *dst_mode = env->params->low_signed;
+ ir_mode *dst_mode_l = env->params->low_unsigned;
+ ir_mode *dst_mode_h = env->params->low_signed;
int idx = get_irn_idx(node);
ir_graph *irg = current_ir_graph;
ir_node *block = get_nodes_block(node);
pdeq_putr(env->waitq, node);
return;
} /* if */
- env->entries[idx]->low_word = new_rd_Conv(dbg, irg, block, env->entries[op_idx]->low_word, dst_mode);
- env->entries[idx]->high_word = new_rd_Conv(dbg, irg, block, env->entries[op_idx]->high_word, dst_mode);
+ env->entries[idx]->low_word = new_rd_Conv(dbg, irg, block, env->entries[op_idx]->low_word, dst_mode_l);
+ env->entries[idx]->high_word = new_rd_Conv(dbg, irg, block, env->entries[op_idx]->high_word, dst_mode_h);
} else {
/* simple case: create a high word */
- if (imode != dst_mode)
- op = new_rd_Conv(dbg, irg, block, op, dst_mode);
+ if (imode != dst_mode_l)
+ op = new_rd_Conv(dbg, irg, block, op, dst_mode_l);
env->entries[idx]->low_word = op;
- env->entries[idx]->high_word = new_rd_Shrs(dbg, irg, block, op,
- new_Const_long(mode_Iu, get_mode_size_bits(dst_mode) - 1), dst_mode);
+
+ if (mode_is_signed(imode)) {
+ ir_node *op_conv = new_rd_Conv(dbg, irg, block, op, dst_mode_h);
+ env->entries[idx]->high_word = new_rd_Shrs(dbg, irg, block, op_conv,
+ new_Const_long(mode_Iu, get_mode_size_bits(dst_mode_h) - 1), dst_mode_h);
+ } else {
+ env->entries[idx]->high_word = new_Const(dst_mode_h, get_mode_null(dst_mode_h));
+ } /* if */
} /* if */
} else {
ir_node *irn, *call;
set_irn_pinned(call, get_irn_pinned(node));
irn = new_r_Proj(irg, block, call, mode_T, pn_Call_T_result);
- env->entries[idx]->low_word = new_r_Proj(irg, block, irn, dst_mode, 0);
- env->entries[idx]->high_word = new_r_Proj(irg, block, irn, dst_mode, 1);
+ env->entries[idx]->low_word = new_r_Proj(irg, block, irn, dst_mode_l, 0);
+ env->entries[idx]->high_word = new_r_Proj(irg, block, irn, dst_mode_h, 1);
} /* if */
} /* lower_Conv_to_Ls */
op = new_rd_Conv(dbg, irg, block, op, dst_mode);
env->entries[idx]->low_word = op;
- env->entries[idx]->high_word = new_Const(dst_mode, get_mode_null(dst_mode));
+
+ if (mode_is_signed(imode)) {
+ env->entries[idx]->high_word = new_rd_Shrs(dbg, irg, block, op,
+ new_Const_long(mode_Iu, get_mode_size_bits(dst_mode) - 1), dst_mode);
+ } else {
+ env->entries[idx]->high_word = new_Const(dst_mode, get_mode_null(dst_mode));
+ } /* if */
} /* if */
} else {
ir_node *irn, *call;
assert(idx < env->n_entries);
+ if (! env->entries[idx]->low_word) {
+ /* not ready yet, wait */
+ pdeq_putr(env->waitq, node);
+ return;
+ } /* if */
+
if (mode_is_int(omode) || mode_is_reference(omode)) {
op = env->entries[idx]->low_word;
assert(idx < env->n_entries);
+ if (! env->entries[idx]->low_word) {
+ /* not ready yet, wait */
+ pdeq_putr(env->waitq, node);
+ return;
+ } /* if */
+
if (mode_is_int(omode) || mode_is_reference(omode)) {
op = env->entries[idx]->low_word;
ir_mode *mode = get_type_mode(tp);
if (mode == env->params->high_signed) {
- set_method_param_type(res, n_param++, tp_s);
+ set_method_param_type(res, n_param++, tp_u);
set_method_param_type(res, n_param++, tp_s);
} else if (mode == env->params->high_unsigned) {
set_method_param_type(res, n_param++, tp_u);
ir_mode *mode = get_type_mode(tp);
if (mode == env->params->high_signed) {
- set_method_res_type(res, n_res++, tp_s);
+ set_method_res_type(res, n_res++, tp_u);
set_method_res_type(res, n_res++, tp_s);
} else if (mode == env->params->high_unsigned) {
set_method_res_type(res, n_res++, tp_u);
ir_node **in;
int i, j, n, idx;
int need_conv = 0;
+ (void) mode;
/* check if this return must be lowered */
for (i = 0, n = get_Return_n_ress(node); i < n; ++i) {
long *new_projs;
int i, j, n_params, rem;
ir_node *proj, *args;
+ (void) mode;
if (is_lowered_type(tp)) {
mtp = get_associated_type(tp);
idx = get_irn_idx(proj);
if (env->entries[idx]) {
+ ir_mode *low_mode = env->params->low_unsigned;
+
mode = get_irn_mode(proj);
if (mode == env->params->high_signed) {
dbg = get_irn_dbg_info(proj);
env->entries[idx]->low_word =
- new_rd_Proj(dbg, irg, get_nodes_block(proj), args, mode, new_projs[proj_nr]);
+ new_rd_Proj(dbg, irg, get_nodes_block(proj), args, low_mode, new_projs[proj_nr]);
env->entries[idx]->high_word =
new_rd_Proj(dbg, irg, get_nodes_block(proj), args, mode, new_projs[proj_nr] + 1);
} /* if */
int n_params, n_res, need_lower = 0;
int i, j;
long *res_numbers = NULL;
+ (void) mode;
if (is_lowered_type(tp)) {
call_tp = get_associated_type(tp);
idx = get_irn_idx(proj);
if (env->entries[idx]) {
ir_mode *mode = get_irn_mode(proj);
+ ir_mode *low_mode = env->params->low_unsigned;
dbg_info *dbg;
if (mode == env->params->high_signed) {
dbg = get_irn_dbg_info(proj);
env->entries[idx]->low_word =
- new_rd_Proj(dbg, irg, get_nodes_block(proj), results, mode, res_numbers[proj_nr]);
+ new_rd_Proj(dbg, irg, get_nodes_block(proj), results, low_mode, res_numbers[proj_nr]);
env->entries[idx]->high_word =
new_rd_Proj(dbg, irg, get_nodes_block(proj), results, mode, res_numbers[proj_nr] + 1);
} /* if */
* First step: just create two templates
*/
static void lower_Phi(ir_node *phi, ir_mode *mode, lower_env_t *env) {
+ ir_mode *mode_l = env->params->low_unsigned;
ir_graph *irg = current_ir_graph;
- ir_node *block, *unk;
+ ir_node *block;
+ ir_node *unk_l;
+ ir_node *unk_h;
ir_node **inl, **inh;
dbg_info *dbg;
int idx, i, arity = get_Phi_n_preds(phi);
/* first create a new in array */
NEW_ARR_A(ir_node *, inl, arity);
NEW_ARR_A(ir_node *, inh, arity);
- unk = new_r_Unknown(irg, mode);
+ unk_l = new_r_Unknown(irg, mode_l);
+ unk_h = new_r_Unknown(irg, mode);
for (i = 0; i < arity; ++i) {
ir_node *pred = get_Phi_pred(phi, i);
inl[i] = env->entries[idx]->low_word;
inh[i] = env->entries[idx]->high_word;
} else {
- inl[i] = unk;
- inh[i] = unk;
+ inl[i] = unk_l;
+ inh[i] = unk_h;
enq = 1;
} /* if */
} /* for */
idx = get_irn_idx(phi);
assert(idx < env->n_entries);
- env->entries[idx]->low_word = new_rd_Phi(dbg, irg, block, arity, inl, mode);
+ env->entries[idx]->low_word = new_rd_Phi(dbg, irg, block, arity, inl, mode_l);
env->entries[idx]->high_word = new_rd_Phi(dbg, irg, block, arity, inh, mode);
if (enq) {
int idx = get_irn_idx(node);
ir_mode *mode = get_irn_mode(node);
- if (mode == mode_b || get_irn_op(node) == op_Psi) {
+ if (mode == mode_b || is_Psi(node)) {
int i;
for (i = get_irn_arity(node) - 1; i >= 0; --i) {
static int cmp_op_mode(const void *elt, const void *key, size_t size) {
const op_mode_entry_t *e1 = elt;
const op_mode_entry_t *e2 = key;
+ (void) size;
return (e1->op - e2->op) | (e1->imode - e2->imode) | (e1->omode - e2->omode);
} /* cmp_op_mode */
static int cmp_conv_tp(const void *elt, const void *key, size_t size) {
const conv_tp_entry_t *e1 = elt;
const conv_tp_entry_t *e2 = key;
+ (void) size;
return (e1->imode - e2->imode) | (e1->omode - e2->omode);
} /* static int cmp_conv_tp */
} /* if */
if (! binop_tp_s) {
binop_tp_s = new_type_method(IDENT("binop_s_intrinsic"), 4, 2);
- set_method_param_type(binop_tp_s, 0, tp_s);
+ set_method_param_type(binop_tp_s, 0, tp_u);
set_method_param_type(binop_tp_s, 1, tp_s);
- set_method_param_type(binop_tp_s, 2, tp_s);
+ set_method_param_type(binop_tp_s, 2, tp_u);
set_method_param_type(binop_tp_s, 3, tp_s);
- set_method_res_type(binop_tp_s, 0, tp_s);
+ set_method_res_type(binop_tp_s, 0, tp_u);
set_method_res_type(binop_tp_s, 1, tp_s);
} /* if */
if (! shiftop_tp_u) {
} /* if */
if (! shiftop_tp_s) {
shiftop_tp_s = new_type_method(IDENT("shiftop_s_intrinsic"), 3, 2);
- set_method_param_type(shiftop_tp_s, 0, tp_s);
+ set_method_param_type(shiftop_tp_s, 0, tp_u);
set_method_param_type(shiftop_tp_s, 1, tp_s);
/* beware: shift count is always mode_Iu */
set_method_param_type(shiftop_tp_s, 2, tp_u);
- set_method_res_type(shiftop_tp_s, 0, tp_s);
+ set_method_res_type(shiftop_tp_s, 0, tp_u);
set_method_res_type(shiftop_tp_s, 1, tp_s);
} /* if */
if (! unop_tp_u) {
} /* if */
if (! unop_tp_s) {
unop_tp_s = new_type_method(IDENT("unop_s_intrinsic"), 2, 2);
- set_method_param_type(unop_tp_s, 0, tp_s);
+ set_method_param_type(unop_tp_s, 0, tp_u);
set_method_param_type(unop_tp_s, 1, tp_s);
- set_method_res_type(unop_tp_s, 0, tp_s);
+ set_method_res_type(unop_tp_s, 0, tp_u);
set_method_res_type(unop_tp_s, 1, tp_s);
} /* if */
LOWER(Shr);
LOWER(Shrs);
LOWER(Rot);
- LOWER(Minus);
LOWER(DivMod);
LOWER(Div);
LOWER(Mod);
LOWER_UN(Abs);
+ LOWER_UN(Minus);
LOWER(Conv);
char buf[64];
ident *id;
ir_entity *ent;
+ (void) context;
if (imode == omode) {
snprintf(buf, sizeof(buf), "__l%s%s", get_op_name(op), get_mode_name(imode));