From 222b6838496b6c4f7b4834e23e9c892eb64c2159 Mon Sep 17 00:00:00 2001 From: Stephen Williams Date: Thu, 25 Oct 2012 09:13:09 -0700 Subject: [PATCH] Clean up invokations of the vector4_to_value template. --- vvp/arith.cc | 8 ++++---- vvp/part.cc | 8 +++++--- vvp/vpi_signal.cc | 18 +++++++++++++++--- 3 files changed, 24 insertions(+), 10 deletions(-) diff --git a/vvp/arith.cc b/vvp/arith.cc index f69b3c4e3..e348fefa7 100644 --- a/vvp/arith.cc +++ b/vvp/arith.cc @@ -403,24 +403,24 @@ void vvp_arith_mult::recv_vec4(vvp_net_ptr_t ptr, const vvp_vector4_t&bit, { dispatch_operand_(ptr, bit); - if (wid_ > 8 * sizeof(long)) { + if (wid_ > 8 * sizeof(int64_t)) { wide_(ptr); return ; } - long a; + int64_t a; if (! vector4_to_value(op_a_, a, false, true)) { ptr.ptr()->send_vec4(x_val_, 0); return; } - long b; + int64_t b; if (! vector4_to_value(op_b_, b, false, true)) { ptr.ptr()->send_vec4(x_val_, 0); return; } - long val = a * b; + int64_t val = a * b; assert(wid_ <= 8*sizeof(val)); vvp_vector4_t vval (wid_); diff --git a/vvp/part.cc b/vvp/part.cc index cddc96f0c..e34b02c74 100644 --- a/vvp/part.cc +++ b/vvp/part.cc @@ -17,10 +17,12 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ +# define __STDC_LIMIT_MACROS # include "compile.h" # include "part.h" # include # include +# include # include # include @@ -238,7 +240,7 @@ bool vvp_fun_part_var::recv_vec4_(vvp_net_ptr_t port, const vvp_vector4_t&bit, int&base, vvp_vector4_t&source, vvp_vector4_t&ref) { - long tmp; + int32_t tmp; switch (port.port()) { case 0: source = bit; @@ -246,9 +248,9 @@ bool vvp_fun_part_var::recv_vec4_(vvp_net_ptr_t port, const vvp_vector4_t&bit, case 1: // INT_MIN is before the vector and is used to // represent a 'bx value on the select input. - tmp = INT_MIN; + tmp = INT32_MIN; vector4_to_value(bit, tmp, is_signed_); - if ((int)tmp == base) return false; + if (static_cast(tmp) == base) return false; base = tmp; break; default: diff --git a/vvp/vpi_signal.cc b/vvp/vpi_signal.cc index 468f211d3..eb8903d8c 100644 --- a/vvp/vpi_signal.cc +++ b/vvp/vpi_signal.cc @@ -327,9 +327,21 @@ static void format_vpiIntVal(vvp_signal_value*sig, int base, unsigned wid, vvp_vector4_t tmp; sig->vec4_value(tmp); vvp_vector4_t sub = tmp.subvalue(base, wid); - long val = 0; - vector4_to_value(sub, val, signed_flag, false); - vp->value.integer = val; + + // Normally, we'd be OK with just using long in the call to + // vector4_to_value, but some compilers seem to take long as + // distinct from int32_t AND int64_t. Since the condition is + // constant, the compiler should eliminate the dead code. + if (sizeof(vp->value.integer) == sizeof(int32_t)) { + int32_t val = 0; + vector4_to_value(sub, val, signed_flag, false); + vp->value.integer = val; + } else { + assert(sizeof(vp->value.integer) == sizeof(int64_t)); + int64_t val = 0; + vector4_to_value(sub, val, signed_flag, false); + vp->value.integer = val; + } } static void format_vpiRealVal(vvp_signal_value*sig, int base, unsigned wid,