From 2166a6d81e16179aa437dac98b0538732bec675e Mon Sep 17 00:00:00 2001 From: Eyck-Alexander Jentzsch Date: Thu, 6 Mar 2025 16:20:35 +0100 Subject: [PATCH] makes widenning function types more explicit --- src/vm/vector_functions.hpp | 59 ++++++++++++++++++++++++------------- 1 file changed, 38 insertions(+), 21 deletions(-) diff --git a/src/vm/vector_functions.hpp b/src/vm/vector_functions.hpp index ac47eca..0d5fe89 100644 --- a/src/vm/vector_functions.hpp +++ b/src/vm/vector_functions.hpp @@ -276,60 +276,77 @@ std::function get_funct(unsi case 0b101111: // VNMSAC return [](dest_elem_t vd, src2_elem_t vs2, src1_elem_t vs1) { return -1 * (vs1 * vs2) + vd; }; case 0b110000: // VWADDU - return [](dest_elem_t vd, src2_elem_t vs2, src1_elem_t vs1) { return vs2 + vs1; }; + return [](dest_elem_t vd, src2_elem_t vs2, src1_elem_t vs1) { + return static_cast(vs2) + static_cast(vs1); + }; case 0b110001: // VWADD return [](dest_elem_t vd, src2_elem_t vs2, src1_elem_t vs1) { - return static_cast>(static_cast>(vs2) + - static_cast>(vs1)); + return static_cast>(static_cast>(vs2)) + + static_cast>(static_cast>(vs1)); }; case 0b110010: // VWSUBU - return [](dest_elem_t vd, src2_elem_t vs2, src1_elem_t vs1) { return vs2 - vs1; }; + return [](dest_elem_t vd, src2_elem_t vs2, src1_elem_t vs1) { + return static_cast(vs2) - static_cast(vs1); + }; case 0b110011: // VWSUB return [](dest_elem_t vd, src2_elem_t vs2, src1_elem_t vs1) { - return static_cast>(static_cast>(vs2) - - static_cast>(vs1)); + return static_cast>(static_cast>(vs2)) - + static_cast>(static_cast>(vs1)); }; case 0b110100: // VWADDU.W - return [](dest_elem_t vd, src2_elem_t vs2, src1_elem_t vs1) { return vs2 + vs1; }; + return [](dest_elem_t vd, src2_elem_t vs2, src1_elem_t vs1) { + return static_cast(vs2) + static_cast(vs1); + }; case 0b110101: // VWADD.W return [](dest_elem_t vd, src2_elem_t vs2, src1_elem_t vs1) { - return static_cast>(static_cast>(vs2) + - static_cast>(vs1)); + return static_cast>(static_cast>(vs2)) + + static_cast>(static_cast>(vs1)); }; case 0b110110: // VWSUBU.W - return [](dest_elem_t vd, src2_elem_t vs2, src1_elem_t vs1) { return vs2 - vs1; }; + return [](dest_elem_t vd, src2_elem_t vs2, src1_elem_t vs1) { + return static_cast(vs2) - static_cast(vs1); + }; case 0b110111: // VWSUB.W return [](dest_elem_t vd, src2_elem_t vs2, src1_elem_t vs1) { - return static_cast>(static_cast>(vs2) - - static_cast>(vs1)); + return static_cast>(static_cast>(vs2)) - + static_cast>(static_cast>(vs1)); }; case 0b111000: // VWMULU return [](dest_elem_t vd, src2_elem_t vs2, src1_elem_t vs1) { - return (static_cast>(vs2) * static_cast>(vs1)); + return (static_cast(vs2) * static_cast(vs1)); }; case 0b111010: // VWMULSU return [](dest_elem_t vd, src2_elem_t vs2, src1_elem_t vs1) { - return (static_cast>>(static_cast>(vs2)) * - static_cast>(vs1)); + return static_cast>( + static_cast>(static_cast>(vs2))) * + static_cast(vs1); }; case 0b111011: // VWMUL return [](dest_elem_t vd, src2_elem_t vs2, src1_elem_t vs1) { - return (static_cast>>(static_cast>(vs2)) * - static_cast>>(static_cast>(vs1))); + return (static_cast>(static_cast>(vs2)) * + static_cast>(static_cast>(vs1))); }; case 0b111100: // VWMACCU - return [](dest_elem_t vd, src2_elem_t vs2, src1_elem_t vs1) { return vs1 * vs2 + vd; }; + return [](dest_elem_t vd, src2_elem_t vs2, src1_elem_t vs1) { + return static_cast(vs1) * static_cast(vs2) + vd; + }; case 0b111101: // VWMACC return [](dest_elem_t vd, src2_elem_t vs2, src1_elem_t vs1) { - return static_cast>(vs1) * static_cast>(vs2) + vd; + return static_cast>(static_cast>(vs1)) * + static_cast>(static_cast>(vs2)) + + vd; }; case 0b111110: // VWMACCUS return [](dest_elem_t vd, src2_elem_t vs2, src1_elem_t vs1) { - return vs1 * static_cast>(vs2) + vd; + return static_cast(vs1) * + static_cast>(static_cast>(vs2)) + + vd; }; case 0b111111: // VWMACCSU return [](dest_elem_t vd, src2_elem_t vs2, src1_elem_t vs1) { - return static_cast>(vs1) * vs2 + vd; + return static_cast>(static_cast>(vs1)) * + static_cast(vs2) + + vd; }; default: throw new std::runtime_error("Unknown funct6 in get_funct");