Fix signed/unsigned errors in %shiftl/x0 and %shiftr/x0

Fix these warnings once and for all. Just use only signed integers
for all the variables and arithmetic.
This commit is contained in:
Stephen Williams 2009-11-26 09:43:35 -08:00
parent c73925e775
commit 1ada697e45
1 changed files with 13 additions and 9 deletions

View File

@ -4205,9 +4205,9 @@ bool of_SET_X0(vthread_t thr, vvp_code_t cp)
bool of_SHIFTL_I0(vthread_t thr, vvp_code_t cp)
{
unsigned base = cp->bit_idx[0];
unsigned wid = cp->number;
long shift = thr->words[0].w_int;
int base = cp->bit_idx[0];
int wid = cp->number;
int shift = thr->words[0].w_int;
assert(base >= 4);
thr_check_addr(thr, base+wid-1);
@ -4217,7 +4217,7 @@ bool of_SHIFTL_I0(vthread_t thr, vvp_code_t cp)
vvp_vector4_t tmp (wid, BIT4_X);
thr->bits4.set_vec(base, tmp);
} else if (shift >= (long)wid) {
} else if (shift >= wid) {
// Shift is so far that all value is shifted out. Write
// in a constant 0 result.
vvp_vector4_t tmp (wid, BIT4_0);
@ -4231,9 +4231,13 @@ bool of_SHIFTL_I0(vthread_t thr, vvp_code_t cp)
vvp_vector4_t fil (shift, BIT4_0);
thr->bits4.set_vec(base, fil);
} else if (shift <= -wid) {
vvp_vector4_t tmp (wid, BIT4_X);
thr->bits4.set_vec(base, tmp);
} else if (shift < 0) {
// For a negative shift we pad with 'bx.
unsigned idx;
int idx;
for (idx = 0 ; (idx-shift) < wid ; idx += 1) {
unsigned src = base + idx - shift;
unsigned dst = base + idx;
@ -4255,9 +4259,9 @@ bool of_SHIFTL_I0(vthread_t thr, vvp_code_t cp)
*/
bool of_SHIFTR_I0(vthread_t thr, vvp_code_t cp)
{
unsigned base = cp->bit_idx[0];
unsigned wid = cp->number;
long shift = thr->words[0].w_int;
int base = cp->bit_idx[0];
int wid = cp->number;
int shift = thr->words[0].w_int;
assert(base >= 4);
thr_check_addr(thr, base+wid-1);
@ -4279,7 +4283,7 @@ bool of_SHIFTR_I0(vthread_t thr, vvp_code_t cp)
vvp_vector4_t tmp (shift, BIT4_0);
thr->bits4.set_vec(base+wid-shift, tmp);
} else if (shift < -(long)wid) {
} else if (shift < -wid) {
// Negative shift is so far that all the value is shifted out.
// Write in a constant 'bx result.
vvp_vector4_t tmp (wid, BIT4_X);