ir_type *value_param_tp; /**< the old value param type */
};
+static void lower_node(lower_env_t *env, ir_node *node);
+
/**
* Create a method type for a Conv emulation from imode to omode.
*/
/* bad we can't really handle Switch with 64bit offsets */
panic("Cond with 64bit jumptable not supported");
}
+ lower_node(env, sel);
return;
}
- if (!is_Cmp(sel))
+ if (!is_Cmp(sel)) {
+ lower_node(env, sel);
return;
+ }
left = get_Cmp_left(sel);
cmp_mode = get_irn_mode(left);
- if (cmp_mode != env->high_signed && cmp_mode != env->high_unsigned)
+ if (cmp_mode != env->high_signed && cmp_mode != env->high_unsigned) {
+ lower_node(env, sel);
return;
+ }
right = get_Cmp_right(sel);
+ lower_node(env, left);
+ lower_node(env, right);
lentry = get_node_entry(env, left);
rentry = get_node_entry(env, right);
dbg = get_irn_dbg_info(sel);
relation = get_Cmp_relation(sel);
- if (is_Const(right) && is_Const_null(right)) {
- if (relation == ir_relation_equal || relation == ir_relation_less_greater) {
- /* x ==/!= 0 ==> or(low,high) ==/!= 0 */
- ir_mode *mode = env->low_unsigned;
- ir_node *low = new_r_Conv(block, lentry->low_word, mode);
- ir_node *high = new_r_Conv(block, lentry->high_word, mode);
- ir_node *ornode = new_rd_Or(dbg, block, low, high, mode);
- ir_node *cmp = new_rd_Cmp(dbg, block, ornode, new_r_Const_long(irg, mode, 0), relation);
- set_Cond_selector(node, cmp);
- return;
- }
+ if (ir_is_equality_cmp_0(sel)) {
+ /* x ==/!= 0 ==> or(low,high) ==/!= 0 */
+ ir_mode *mode = env->low_unsigned;
+ ir_node *low = new_r_Conv(block, lentry->low_word, mode);
+ ir_node *high = new_r_Conv(block, lentry->high_word, mode);
+ ir_node *ornode = new_rd_Or(dbg, block, low, high, mode);
+ ir_node *cmp = new_rd_Cmp(dbg, block, ornode, new_r_Const_long(irg, mode, 0), relation);
+ set_Cond_selector(node, cmp);
+ return;
}
if (relation == ir_relation_equal) {
ir_mode *mode = get_irn_mode(l);
ir_node *r, *low, *high, *t, *res;
ir_relation relation;
- ir_node *blk;
- dbg_info *db;
+ ir_node *block;
+ dbg_info *dbg;
const node_entry_t *lentry;
const node_entry_t *rentry;
(void) m;
- if (mode != env->high_signed && mode != env->high_unsigned) {
+ if (mode != env->high_signed && mode != env->high_unsigned)
return;
- }
r = get_Cmp_right(cmp);
lentry = get_node_entry(env, l);
rentry = get_node_entry(env, r);
relation = get_Cmp_relation(cmp);
- blk = get_nodes_block(cmp);
- db = get_irn_dbg_info(cmp);
+ block = get_nodes_block(cmp);
+ dbg = get_irn_dbg_info(cmp);
+
+ /* easy case for x ==/!= 0 (see lower_Cond for details) */
+ if (ir_is_equality_cmp_0(cmp)) {
+ ir_graph *irg = get_irn_irg(cmp);
+ ir_mode *mode = env->low_unsigned;
+ ir_node *low = new_r_Conv(block, lentry->low_word, mode);
+ ir_node *high = new_r_Conv(block, lentry->high_word, mode);
+ ir_node *ornode = new_rd_Or(dbg, block, low, high, mode);
+ ir_node *new_cmp = new_rd_Cmp(dbg, block, ornode, new_r_Const_long(irg, mode, 0), relation);
+ exchange(cmp, new_cmp);
+ return;
+ }
if (relation == ir_relation_equal) {
/* simple case:a == b <==> a_h == b_h && a_l == b_l */
- low = new_rd_Cmp(db, blk, lentry->low_word, rentry->low_word,
+ low = new_rd_Cmp(dbg, block, lentry->low_word, rentry->low_word,
relation);
- high = new_rd_Cmp(db, blk, lentry->high_word, rentry->high_word,
+ high = new_rd_Cmp(dbg, block, lentry->high_word, rentry->high_word,
relation);
- res = new_rd_And(db, blk, low, high, mode_b);
+ res = new_rd_And(dbg, block, low, high, mode_b);
} else if (relation == ir_relation_less_greater) {
/* simple case:a != b <==> a_h != b_h || a_l != b_l */
- low = new_rd_Cmp(db, blk, lentry->low_word, rentry->low_word,
+ low = new_rd_Cmp(dbg, block, lentry->low_word, rentry->low_word,
relation);
- high = new_rd_Cmp(db, blk, lentry->high_word, rentry->high_word,
+ high = new_rd_Cmp(dbg, block, lentry->high_word, rentry->high_word,
relation);
- res = new_rd_Or(db, blk, low, high, mode_b);
+ res = new_rd_Or(dbg, block, low, high, mode_b);
} else {
/* a rel b <==> a_h REL b_h || (a_h == b_h && a_l rel b_l) */
- ir_node *high1 = new_rd_Cmp(db, blk, lentry->high_word,
+ ir_node *high1 = new_rd_Cmp(dbg, block, lentry->high_word,
rentry->high_word, relation & ~ir_relation_equal);
- low = new_rd_Cmp(db, blk, lentry->low_word, rentry->low_word,
+ low = new_rd_Cmp(dbg, block, lentry->low_word, rentry->low_word,
relation);
- high = new_rd_Cmp(db, blk, lentry->high_word, rentry->high_word,
+ high = new_rd_Cmp(dbg, block, lentry->high_word, rentry->high_word,
ir_relation_equal);
- t = new_rd_And(db, blk, low, high, mode_b);
- res = new_rd_Or(db, blk, high1, t, mode_b);
+ t = new_rd_And(dbg, block, low, high, mode_b);
+ res = new_rd_Or(dbg, block, high1, t, mode_b);
}
exchange(cmp, res);
}
* @param ent the entity
* @param pos the argument index of this entity
*/
-static inline void set_entity_arg_idx(ir_entity *ent, int pos)
+static inline void set_entity_arg_idx(ir_entity *ent, size_t pos)
{
set_entity_link(ent, INT_TO_PTR(pos));
}
*
* @param ent the entity
*/
-static int get_entity_arg_idx(const ir_entity *ent) {
- return (int)PTR_TO_INT(get_entity_link(ent));
+static size_t get_entity_arg_idx(const ir_entity *ent) {
+ return PTR_TO_INT(get_entity_link(ent));
}
/**
static ir_type *lower_mtp(lower_env_t *env, ir_type *mtp)
{
pmap_entry *entry;
- ident *lid;
ir_type *res, *value_type;
if (is_lowered_type(mtp))
entry = pmap_find(lowered_type, mtp);
if (! entry) {
- int i, orig_n_params, orig_n_res, n_param, n_res;
+ size_t i, orig_n_params, orig_n_res, n_param, n_res;
/* count new number of params */
n_param = orig_n_params = get_method_n_params(mtp);
- for (i = orig_n_params - 1; i >= 0; --i) {
- ir_type *tp = get_method_param_type(mtp, i);
+ for (i = orig_n_params; i > 0;) {
+ ir_type *tp = get_method_param_type(mtp, --i);
if (is_Primitive_type(tp)) {
ir_mode *mode = get_type_mode(tp);
/* count new number of results */
n_res = orig_n_res = get_method_n_ress(mtp);
- for (i = orig_n_res - 1; i >= 0; --i) {
- ir_type *tp = get_method_res_type(mtp, i);
+ for (i = orig_n_res; i > 0;) {
+ ir_type *tp = get_method_res_type(mtp, --i);
if (is_Primitive_type(tp)) {
ir_mode *mode = get_type_mode(tp);
/* set new param positions for all entities of the value type */
for (i = n_param = 0; i < orig_n_params; ++i) {
ir_type *tp = get_method_param_type(mtp, i);
- ident *id = get_method_param_ident(mtp, i);
ir_entity *ent = get_method_value_param_ent(mtp, i);
set_entity_arg_idx(ent, n_param);
ir_mode *mode = get_type_mode(tp);
if (mode == env->high_signed || mode == env->high_unsigned) {
- if (id != NULL) {
- lid = id_mangle(id, env->first_id);
- set_method_param_ident(res, n_param, lid);
- set_entity_ident(get_method_value_param_ent(res, n_param), lid);
- lid = id_mangle(id, env->next_id);
- set_method_param_ident(res, n_param + 1, lid);
- set_entity_ident(get_method_value_param_ent(res, n_param + 1), lid);
- }
n_param += 2;
continue;
}
}
- if (id != NULL) {
- set_method_param_ident(res, n_param, id);
- set_entity_ident(get_method_value_param_ent(res, n_param), id);
- }
++n_param;
}
ir_entity *ent = get_irg_entity(irg);
ir_type *mtp = get_entity_type(ent);
ir_node **in;
- int i, j, n;
+ size_t i, j, n;
int need_conv = 0;
(void) mode;
ir_type *tp = get_entity_type(ent);
ir_type *mtp;
long *new_projs;
- int i, j, n_params, rem;
+ size_t i, j, n_params;
+ int rem;
ir_node *proj, *args;
(void) mode;
ir_type *tp = get_Call_type(node);
ir_type *call_tp;
ir_node **in, *proj, *results;
- int n_params, n_res;
+ size_t n_params, n_res;
bool need_lower = false;
- int i, j;
+ size_t i, j;
+ size_t p;
long *res_numbers = NULL;
(void) mode;
assert(! is_lowered_type(call_tp));
n_params = get_method_n_params(call_tp);
- for (i = 0; i < n_params; ++i) {
- ir_type *tp = get_method_param_type(call_tp, i);
+ for (p = 0; p < n_params; ++p) {
+ ir_type *tp = get_method_param_type(call_tp, p);
if (is_Primitive_type(tp)) {
ir_mode *mode = get_type_mode(tp);
/* switch off optimization for new Proj nodes or they might be CSE'ed
with not patched one's */
set_optimize(0);
- for (i = j = 0, proj = (ir_node*)get_irn_link(results); proj;
- proj = (ir_node*)get_irn_link(proj), ++i, ++j) {
+ for (proj = (ir_node*)get_irn_link(results); proj; proj = (ir_node*)get_irn_link(proj)) {
if (get_Proj_pred(proj) == results) {
long proj_nr = get_Proj_proj(proj);
ir_mode *proj_mode = get_irn_mode(proj);
if (env->value_param_tp != NULL) {
ir_entity *ent = get_Sel_entity(sel);
if (get_entity_owner(ent) == env->value_param_tp) {
- int pos = get_entity_arg_idx(ent);
+ size_t pos = get_entity_arg_idx(ent);
ent = get_method_value_param_ent(env->l_mtp, pos);
set_Sel_entity(sel, ent);
*/
static bool mtp_must_be_lowered(lower_env_t *env, ir_type *mtp)
{
- int n_params = get_method_n_params(mtp);
- int i;
+ size_t i, n_params = get_method_n_params(mtp);
/* first check if we have parameters that must be fixed */
for (i = 0; i < n_params; ++i) {
lower_node(env, block);
}
- arity = get_irn_arity(node);
- for (i = 0; i < arity; ++i) {
- ir_node *pred = get_irn_n(node, i);
- lower_node(env, pred);
+ if (!is_Cond(node)) {
+ arity = get_irn_arity(node);
+ for (i = 0; i < arity; ++i) {
+ ir_node *pred = get_irn_n(node, i);
+ lower_node(env, pred);
+ }
}
op = get_irn_op(node);