Commit a999e1ba authored by Matthias Braun's avatar Matthias Braun
Browse files

fix some warnings, represent mode size as unsigned value

[r17158]
parent 34ba4cf5
......@@ -59,7 +59,7 @@ typedef int (*evaluate_costs_func)(insn_kind kind, tarval *tv);
struct ir_settings_arch_dep_t {
/* Mul optimization */
unsigned also_use_subs : 1; /**< Use also Subs when resolving Muls to shifts */
int maximum_shifts; /**< The maximum number of shifts that shall be inserted for a mul. */
unsigned maximum_shifts; /**< The maximum number of shifts that shall be inserted for a mul. */
unsigned highest_shift_amount; /**< The highest shift amount you want to
tolerate. Muls which would require a higher
shift constant are left. */
......@@ -68,7 +68,7 @@ struct ir_settings_arch_dep_t {
/* Div/Mod optimization */
unsigned allow_mulhs : 1; /**< Use the Mulhs operation for division by constant */
unsigned allow_mulhu : 1; /**< Use the Mulhu operation for division by constant */
int max_bits_for_mulh; /**< Maximum number of bits the Mulh operation can take.
unsigned max_bits_for_mulh; /**< Maximum number of bits the Mulh operation can take.
Modes with higher amount of bits will use Mulh */
};
......
......@@ -183,11 +183,11 @@ const char *get_mode_name(const ir_mode *mode);
mode_sort get_mode_sort(const ir_mode *mode);
/** Returns the size of values of the mode in bits. */
int get_mode_size_bits(const ir_mode *mode);
unsigned get_mode_size_bits(const ir_mode *mode);
/** Returns the size of values of the mode in bytes.
* If the size is not dividable by 8 returns -1. */
int get_mode_size_bytes(const ir_mode *mode);
unsigned get_mode_size_bytes(const ir_mode *mode);
/** Returns the signess of a mode.
*
......
......@@ -53,7 +53,7 @@
*/
_arr_descr arr_mt_descr
#ifndef NDEBUG
= { ARR_D_MAGIC, 0, {0}, 0, {{0}} }
= { ARR_D_MAGIC, 0, {0}, 0, {{{0}}} }
#endif
;
......
......@@ -97,7 +97,7 @@ static unsigned *get_backarray(ir_node *n) {
*/
static int legal_backarray(ir_node *n) {
unsigned *ba = mere_get_backarray(n);
if (ba && (rbitset_size(ba) != get_irn_arity(n)))
if (ba && (rbitset_size(ba) != (unsigned) get_irn_arity(n)))
return 0;
return 1;
}
......@@ -111,7 +111,7 @@ void fix_backedges(struct obstack *obst, ir_node *n) {
return;
arity = get_irn_arity(n);
if (rbitset_size(arr) != arity) {
if (rbitset_size(arr) != (unsigned) arity) {
arr = new_backedge_arr(obst, arity);
opc = get_irn_opcode(n);
......
......@@ -282,6 +282,8 @@ static ir_alias_relation different_index(ir_node *idx1, ir_node *idx2, int size)
*/
static ir_alias_relation different_sel_offsets(ir_node *sel1, ir_node *sel2) {
/* seems to be broken */
(void) sel1;
(void) sel2;
#if 0
ir_entity *ent1 = get_Sel_entity(sel1);
ir_entity *ent2 = get_Sel_entity(sel2);
......
......@@ -187,7 +187,7 @@ static ir_type **get_type_arraytype_array(const ir_type *tp) {
return res;
}
const void set_type_arraytype_array(const ir_type *tp, ir_type **pts) {
void set_type_arraytype_array(const ir_type *tp, ir_type **pts) {
ir_type **old = pmap_get(type_arraytype_map, tp);
if (old != pts)
pmap_insert(type_arraytype_map, tp, (void *)pts);
......
......@@ -177,7 +177,7 @@ static int _node_cmp_attr(const be_node_attr_t *a, const be_node_attr_t *b) {
*
* @return zero if both nodes have identically attributes
*/
static int node_cmp_attr(const ir_node *a, const ir_node *b) {
static int node_cmp_attr(ir_node *a, ir_node *b) {
const be_node_attr_t *a_attr = get_irn_attr_const(a);
const be_node_attr_t *b_attr = get_irn_attr_const(b);
......@@ -189,7 +189,7 @@ static int node_cmp_attr(const ir_node *a, const ir_node *b) {
*
* @return zero if both nodes have identically attributes
*/
static int FrameAddr_cmp_attr(const ir_node *a, const ir_node *b) {
static int FrameAddr_cmp_attr(ir_node *a, ir_node *b) {
const be_frame_attr_t *a_attr = get_irn_attr_const(a);
const be_frame_attr_t *b_attr = get_irn_attr_const(b);
......@@ -204,7 +204,7 @@ static int FrameAddr_cmp_attr(const ir_node *a, const ir_node *b) {
*
* @return zero if both nodes have identically attributes
*/
static int Return_cmp_attr(const ir_node *a, const ir_node *b) {
static int Return_cmp_attr(ir_node *a, ir_node *b) {
const be_return_attr_t *a_attr = get_irn_attr_const(a);
const be_return_attr_t *b_attr = get_irn_attr_const(b);
......@@ -221,7 +221,7 @@ static int Return_cmp_attr(const ir_node *a, const ir_node *b) {
*
* @return zero if both nodes have identically attributes
*/
static int IncSP_cmp_attr(const ir_node *a, const ir_node *b) {
static int IncSP_cmp_attr(ir_node *a, ir_node *b) {
const be_incsp_attr_t *a_attr = get_irn_attr_const(a);
const be_incsp_attr_t *b_attr = get_irn_attr_const(b);
......@@ -236,7 +236,7 @@ static int IncSP_cmp_attr(const ir_node *a, const ir_node *b) {
*
* @return zero if both nodes have identically attributes
*/
static int Call_cmp_attr(const ir_node *a, const ir_node *b) {
static int Call_cmp_attr(ir_node *a, ir_node *b) {
const be_call_attr_t *a_attr = get_irn_attr_const(a);
const be_call_attr_t *b_attr = get_irn_attr_const(b);
......
......@@ -2025,7 +2025,7 @@ static ir_node *try_create_dest_am(ir_node *node) {
ir_node *mem = get_Store_mem(node);
ir_node *ptr = get_Store_ptr(node);
ir_mode *mode = get_irn_mode(val);
int bits = get_mode_size_bits(mode);
unsigned bits = get_mode_size_bits(mode);
ir_node *op1;
ir_node *op2;
ir_node *new_node;
......
......@@ -375,43 +375,35 @@ ir_mode *new_ir_vector_mode(const char *name, mode_sort sort, int bit_size, unsi
}
/* Functions for the direct access to all attributes of an ir_mode */
modecode
(get_mode_modecode)(const ir_mode *mode) {
modecode (get_mode_modecode)(const ir_mode *mode) {
return _get_mode_modecode(mode);
}
ident *
(get_mode_ident)(const ir_mode *mode) {
ident *(get_mode_ident)(const ir_mode *mode) {
return _get_mode_ident(mode);
}
const char *
get_mode_name(const ir_mode *mode) {
const char *get_mode_name(const ir_mode *mode) {
return get_id_str(mode->name);
}
mode_sort
(get_mode_sort)(const ir_mode* mode) {
mode_sort (get_mode_sort)(const ir_mode* mode) {
return _get_mode_sort(mode);
}
int
(get_mode_size_bits)(const ir_mode *mode) {
unsigned (get_mode_size_bits)(const ir_mode *mode) {
return _get_mode_size_bits(mode);
}
int
(get_mode_size_bytes)(const ir_mode *mode) {
unsigned (get_mode_size_bytes)(const ir_mode *mode) {
return _get_mode_size_bytes(mode);
}
int
(get_mode_sign)(const ir_mode *mode) {
int (get_mode_sign)(const ir_mode *mode) {
return _get_mode_sign(mode);
}
mode_arithmetic
(get_mode_arithmetic)(const ir_mode *mode) {
mode_arithmetic (get_mode_arithmetic)(const ir_mode *mode) {
return get_mode_arithmetic(mode);
}
......@@ -420,28 +412,23 @@ mode_arithmetic
* whether shift applies modulo to value of bits to shift. Asserts
* if mode is not irms_int_number.
*/
unsigned int
(get_mode_modulo_shift)(const ir_mode *mode) {
unsigned int (get_mode_modulo_shift)(const ir_mode *mode) {
return _get_mode_modulo_shift(mode);
}
unsigned int
(get_mode_n_vector_elems)(const ir_mode *mode) {
unsigned int (get_mode_n_vector_elems)(const ir_mode *mode) {
return _get_mode_vector_elems(mode);
}
void *
(get_mode_link)(const ir_mode *mode) {
void *(get_mode_link)(const ir_mode *mode) {
return _get_mode_link(mode);
}
void
(set_mode_link)(ir_mode *mode, void *l) {
void (set_mode_link)(ir_mode *mode, void *l) {
_set_mode_link(mode, l);
}
tarval *
get_mode_min(ir_mode *mode) {
tarval *get_mode_min(ir_mode *mode) {
assert(mode);
assert(get_mode_modecode(mode) < (modecode) num_modes);
assert(mode_is_data(mode));
......@@ -449,8 +436,7 @@ get_mode_min(ir_mode *mode) {
return mode->min;
}
tarval *
get_mode_max(ir_mode *mode) {
tarval *get_mode_max(ir_mode *mode) {
assert(mode);
assert(get_mode_modecode(mode) < (modecode) num_modes);
assert(mode_is_data(mode));
......@@ -458,8 +444,7 @@ get_mode_max(ir_mode *mode) {
return mode->max;
}
tarval *
get_mode_null(ir_mode *mode) {
tarval *get_mode_null(ir_mode *mode) {
assert(mode);
assert(get_mode_modecode(mode) < (modecode) num_modes);
assert(mode_is_datab(mode));
......@@ -467,8 +452,7 @@ get_mode_null(ir_mode *mode) {
return mode->null;
}
tarval *
get_mode_one(ir_mode *mode) {
tarval *get_mode_one(ir_mode *mode) {
assert(mode);
assert(get_mode_modecode(mode) < (modecode) num_modes);
assert(mode_is_data(mode));
......@@ -476,8 +460,7 @@ get_mode_one(ir_mode *mode) {
return mode->one;
}
tarval *
get_mode_minus_one(ir_mode *mode) {
tarval *get_mode_minus_one(ir_mode *mode) {
assert(mode);
assert(get_mode_modecode(mode) < (modecode) num_modes);
assert(mode_is_data(mode));
......@@ -485,16 +468,14 @@ get_mode_minus_one(ir_mode *mode) {
return mode->minus_one;
}
tarval *
get_mode_all_one(ir_mode *mode) {
tarval *get_mode_all_one(ir_mode *mode) {
assert(mode);
assert(get_mode_modecode(mode) < (modecode) num_modes);
assert(mode_is_data(mode) || mode == mode_b);
return mode->all_one;
}
tarval *
get_mode_infinite(ir_mode *mode) {
tarval *get_mode_infinite(ir_mode *mode) {
assert(mode);
assert(get_mode_modecode(mode) < (modecode) num_modes);
assert(mode_is_float(mode));
......@@ -502,8 +483,7 @@ get_mode_infinite(ir_mode *mode) {
return get_tarval_plus_inf(mode);
}
tarval *
get_mode_NAN(ir_mode *mode) {
tarval *get_mode_NAN(ir_mode *mode) {
assert(mode);
assert(get_mode_modecode(mode) < (modecode) num_modes);
assert(mode_is_float(mode));
......@@ -511,67 +491,55 @@ get_mode_NAN(ir_mode *mode) {
return get_tarval_nan(mode);
}
int
is_mode(void *thing) {
int is_mode(void *thing) {
if (get_kind(thing) == k_ir_mode)
return 1;
else
return 0;
}
int
(mode_is_signed)(const ir_mode *mode) {
int (mode_is_signed)(const ir_mode *mode) {
return _mode_is_signed(mode);
}
int
(mode_is_float)(const ir_mode *mode) {
int (mode_is_float)(const ir_mode *mode) {
return _mode_is_float(mode);
}
int
(mode_is_int)(const ir_mode *mode) {
int (mode_is_int)(const ir_mode *mode) {
return _mode_is_int(mode);
}
int
(mode_is_reference)(const ir_mode *mode) {
int (mode_is_reference)(const ir_mode *mode) {
return _mode_is_reference(mode);
}
int
(mode_is_num)(const ir_mode *mode) {
int (mode_is_num)(const ir_mode *mode) {
return _mode_is_num(mode);
}
int
(mode_is_data)(const ir_mode *mode) {
int (mode_is_data)(const ir_mode *mode) {
return _mode_is_data(mode);
}
int
(mode_is_datab)(const ir_mode *mode) {
int (mode_is_datab)(const ir_mode *mode) {
return _mode_is_datab(mode);
}
int
(mode_is_dataM)(const ir_mode *mode) {
int (mode_is_dataM)(const ir_mode *mode) {
return _mode_is_dataM(mode);
}
int
(mode_is_float_vector)(const ir_mode *mode) {
int (mode_is_float_vector)(const ir_mode *mode) {
return _mode_is_float_vector(mode);
}
int
(mode_is_int_vector)(const ir_mode *mode) {
int (mode_is_int_vector)(const ir_mode *mode) {
return _mode_is_int_vector(mode);
}
/* Returns true if sm can be converted to lm without loss. */
int
smaller_mode(const ir_mode *sm, const ir_mode *lm) {
int smaller_mode(const ir_mode *sm, const ir_mode *lm) {
int sm_bits, lm_bits;
assert(sm);
......@@ -669,8 +637,7 @@ void set_reference_mode_unsigned_eq(ir_mode *ref_mode, ir_mode *int_mode) {
}
/* initialization, build the default modes */
void
init_mode(void) {
void init_mode(void) {
ir_mode newmode;
obstack_init(&modes);
......
......@@ -51,13 +51,13 @@ _get_mode_ident(const ir_mode *mode) { return mode->name; }
static INLINE mode_sort
_get_mode_sort(const ir_mode* mode) { return mode->sort; }
static INLINE int
static INLINE unsigned
_get_mode_size_bits(const ir_mode *mode) { return mode->size; }
static INLINE int
static INLINE unsigned
_get_mode_size_bytes(const ir_mode *mode) {
int size = _get_mode_size_bits(mode);
if ((size & 7) != 0) return -1;
unsigned size = _get_mode_size_bits(mode);
if ((size & 7) != 0) return (unsigned) -1;
return size >> 3;
}
......
......@@ -1286,6 +1286,10 @@ get_Sel_entity(const ir_node *node) {
return node->attr.sel.ent;
}
ir_entity *_get_Sel_entity(ir_node *node) {
return get_Sel_entity(node);
}
void
set_Sel_entity(ir_node *node, ir_entity *ent) {
assert(node->op == op_Sel);
......@@ -3058,7 +3062,7 @@ static ir_entity *get_Null_ent(ir_node *n) {
ir_op_ops *firm_set_default_get_entity_attr(ir_opcode code, ir_op_ops *ops) {
switch (code) {
case iro_SymConst: ops->get_entity_attr = get_SymConst_attr_entity; break;
case iro_Sel: ops->get_entity_attr = get_Sel_entity; break;
case iro_Sel: ops->get_entity_attr = _get_Sel_entity; break;
default:
/* not allowed to be NULL */
if (! ops->get_entity_attr)
......
......@@ -1882,13 +1882,13 @@ static ir_node *transform_node_AddSub(ir_node *n) {
ir_mode *mode = get_irn_mode(n);
if (mode_is_reference(mode)) {
ir_node *left = get_binop_left(n);
ir_node *right = get_binop_right(n);
int ref_bits = get_mode_size_bits(mode);
ir_node *left = get_binop_left(n);
ir_node *right = get_binop_right(n);
unsigned ref_bits = get_mode_size_bits(mode);
if (is_Conv(left)) {
ir_mode *mode = get_irn_mode(left);
int bits = get_mode_size_bits(mode);
unsigned bits = get_mode_size_bits(mode);
if (ref_bits == bits &&
mode_is_int(mode) &&
......@@ -1911,7 +1911,7 @@ static ir_node *transform_node_AddSub(ir_node *n) {
if (is_Conv(right)) {
ir_mode *mode = get_irn_mode(right);
int bits = get_mode_size_bits(mode);
unsigned bits = get_mode_size_bits(mode);
if (ref_bits == bits &&
mode_is_int(mode) &&
......@@ -3295,7 +3295,7 @@ static ir_node *transform_node_Minus(ir_node *n) {
if (is_Const(c)) {
tarval *tv = get_Const_tarval(c);
if (tarval_is_long(tv) && get_tarval_long(tv) == get_mode_size_bits(mode) - 1) {
if (tarval_is_long(tv) && get_tarval_long(tv) == (int) get_mode_size_bits(mode) - 1) {
/* -(a >>u (size-1)) = a >>s (size-1) */
ir_node *v = get_Shr_left(a);
......@@ -3311,7 +3311,7 @@ static ir_node *transform_node_Minus(ir_node *n) {
if (is_Const(c)) {
tarval *tv = get_Const_tarval(c);
if (tarval_is_long(tv) && get_tarval_long(tv) == get_mode_size_bits(mode) - 1) {
if (tarval_is_long(tv) && get_tarval_long(tv) == (int) get_mode_size_bits(mode) - 1) {
/* -(a >>s (size-1)) = a >>u (size-1) */
ir_node *v = get_Shrs_left(a);
......@@ -4438,7 +4438,7 @@ static ir_node *transform_node_Or_Rot(ir_node *or) {
return or;
if (get_tarval_long(tv1) + get_tarval_long(tv2)
!= get_mode_size_bits(mode))
!= (int) get_mode_size_bits(mode))
return or;
/* yet, condition met */
......@@ -4463,7 +4463,7 @@ static ir_node *transform_node_Or_Rot(ir_node *or) {
if (! tarval_is_long(tv1))
return or;
if (get_tarval_long(tv1) != get_mode_size_bits(mode))
if (get_tarval_long(tv1) != (int) get_mode_size_bits(mode))
return or;
/* yet, condition met */
......@@ -4486,7 +4486,7 @@ static ir_node *transform_node_Or_Rot(ir_node *or) {
if (! tarval_is_long(tv1))
return or;
if (get_tarval_long(tv1) != get_mode_size_bits(mode))
if (get_tarval_long(tv1) != (int) get_mode_size_bits(mode))
return or;
/* yet, condition met */
......
......@@ -93,7 +93,7 @@ struct ir_mode {
int, float, reference ...
(see irmode.h) */
mode_arithmetic arithmetic; /**< different arithmetic operations possible with a mode */
int size; /**< size of the mode in Bits. */
unsigned size; /**< size of the mode in Bits. */
unsigned sign:1; /**< signedness of this mode */
unsigned int modulo_shift; /**< number of bits a values of this mode will be shifted */
unsigned vector_elem; /**< if this is not equal 1, this is a vector mode with
......
......@@ -30,6 +30,8 @@
#include "irvrfy.h"
#include "irdump.h"
#include "beutil.h"
extern const char *firm_vrfy_failure_msg;
#ifdef NDEBUG
......
......@@ -915,7 +915,7 @@ static void lower_Shr(ir_node *node, ir_mode *mode, lower_env_t *env) {
tarval *tv = get_Const_tarval(right);
if (tarval_is_long(tv) &&
get_tarval_long(tv) >= get_mode_size_bits(mode)) {
get_tarval_long(tv) >= (int) get_mode_size_bits(mode)) {
ir_node *block = get_nodes_block(node);
ir_node *left = get_Shr_left(node);
ir_node *c;
......@@ -950,7 +950,7 @@ static void lower_Shl(ir_node *node, ir_mode *mode, lower_env_t *env) {
tarval *tv = get_Const_tarval(right);
if (tarval_is_long(tv) &&
get_tarval_long(tv) >= get_mode_size_bits(mode)) {
get_tarval_long(tv) >= (int) get_mode_size_bits(mode)) {
ir_mode *mode_l;
ir_node *block = get_nodes_block(node);
ir_node *left = get_Shl_left(node);
......@@ -987,7 +987,7 @@ static void lower_Shrs(ir_node *node, ir_mode *mode, lower_env_t *env) {
tarval *tv = get_Const_tarval(right);
if (tarval_is_long(tv) &&
get_tarval_long(tv) >= get_mode_size_bits(mode)) {
get_tarval_long(tv) >= (int) 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);
......@@ -1022,7 +1022,7 @@ static void lower_Rot(ir_node *node, ir_mode *mode, lower_env_t *env) {
tarval *tv = get_Const_tarval(right);
if (tarval_is_long(tv) &&
get_tarval_long(tv) == get_mode_size_bits(mode)) {
get_tarval_long(tv) == (int) get_mode_size_bits(mode)) {
ir_node *left = get_Rot_left(node);
ir_node *h, *l;
int idx = get_irn_idx(left);
......
......@@ -97,7 +97,7 @@ static void lower_sel(ir_node *sel) {
basemode = mode_P_data;
assert(basemode && "no mode for lowering Sel");
assert((get_mode_size_bytes(basemode) != -1) && "can not deal with unorthodox modes");
assert((get_mode_size_bits(basemode) % 8 != 0) && "can not deal with unorthodox modes");
index = get_Sel_index(sel, 0);
if (is_Array_type(owner)) {
......
......@@ -722,7 +722,7 @@ static unsigned check_nothrow_or_malloc(ir_graph *irg, int top) {
/* check, if malloc is called here */
for (j = get_Return_n_ress(pred) - 1; j >= 0; --j) {
const ir_node *res = get_Return_res(pred, j);
const ir_node *irn = skip_Proj_const(res);
//const ir_node *irn = skip_Proj_const(res);
if (is_malloc_call_result(res)) {
/* ok, this is a malloc */
} else if (is_Call(res)) {
......
......@@ -1184,7 +1184,7 @@ build_value_type(ident *name, int len, tp_ent_pair *tps) {
ir_type *new_d_type_method(ident *name, int n_param, int n_res, dbg_info *db) {
ir_type *res;
assert((get_mode_size_bytes(mode_P_code) != -1) && "unorthodox modes not implemented");
assert((get_mode_size_bits(mode_P_code) % 8 != 0) && "unorthodox modes not implemented");
res = new_type(type_method, mode_P_code, name, db);
res->flags |= tf_layout_fixed;
res->size = get_mode_size_bytes(mode_P_code);
......@@ -1874,7 +1874,7 @@ ir_type *new_d_type_pointer(ident *name, ir_type *points_to, ir_mode *ptr_mode,
assert(mode_is_reference(ptr_mode));
res = new_type(type_pointer, ptr_mode, name, db);
res->attr.pa.points_to = points_to;
assert((get_mode_size_bytes(res->mode) != -1) && "unorthodox modes not implemented");
assert((get_mode_size_bits(res->mode) % 8 != 0) && "unorthodox modes not implemented");
res->size = get_mode_size_bytes(res->mode);
res->flags |= tf_layout_fixed;
hook_new_type(res);
......
......@@ -1669,18 +1669,18 @@ int fc_flt2int(const fp_value *a, void *result, ir_mode *dst_mode) {
if (mode_is_signed(dst_mode)) {
if (highest == sc_get_lowest_set_bit(result)) {
/* need extra test for MIN_INT */
if (highest >= get_mode_size_bits(dst_mode)) {
if (highest >= (int) get_mode_size_bits(dst_mode)) {
/* FIXME: handle overflow */
return 0;
}
} else {
if (highest >= get_mode_size_bits(dst_mode) - 1) {
if (highest >= (int) get_mode_size_bits(dst_mode) - 1) {
/* FIXME: handle overflow */
return 0;
}
}
} else {
if (highest >= get_mode_size_bits(dst_mode)) {
if (highest >= (int) get_mode_size_bits(dst_mode)) {
/* FIXME: handle overflow */
return 0;
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment