From 1ada697e4527a161da7bacb436f9a5e6f6c6d416 Mon Sep 17 00:00:00 2001 From: Stephen Williams Date: Thu, 26 Nov 2009 09:43:35 -0800 Subject: [PATCH] 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. --- vvp/vthread.cc | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/vvp/vthread.cc b/vvp/vthread.cc index 6ff26126e..d15e61cd2 100644 --- a/vvp/vthread.cc +++ b/vvp/vthread.cc @@ -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);