Open Timmmm opened 2 months ago
There are many uses of var and undefined that are unnecessary and dodgy, especially in the vector code. For example this:
var
undefined
var result : vector('n, dec, bits('o)) = undefined; var mask : vector('n, dec, bool) = undefined; (result, mask) = init_masked_result(num_elem, SEW_widen, LMUL_pow_widen, vd_val, vm_val); foreach (i from 0 to (num_elem - 1)) { if mask[i] then { result[i] = match funct6 { FWVV_VMACC => fp_muladd(rm_3b, fp_widen(vs1_val[i]), fp_widen(vs2_val[i]), vd_val[i]), FWVV_VNMACC => fp_nmulsub(rm_3b, fp_widen(vs1_val[i]), fp_widen(vs2_val[i]), vd_val[i]), FWVV_VMSAC => fp_mulsub(rm_3b, fp_widen(vs1_val[i]), fp_widen(vs2_val[i]), vd_val[i]), FWVV_VNMSAC => fp_nmuladd(rm_3b, fp_widen(vs1_val[i]), fp_widen(vs2_val[i]), vd_val[i]) } } }; write_vreg(num_elem, SEW_widen, LMUL_pow_widen, vd, result);
Would probably be better like
let (result_, mask) = init_masked_result(num_elem, SEW_widen, LMUL_pow_widen, vd_val, vm_val); var result = result_; foreach (i from 0 to (num_elem - 1)) { if mask[i] then { result[i] = match funct6 { FWVV_VMACC => fp_muladd(rm_3b, fp_widen(vs1_val[i]), fp_widen(vs2_val[i]), vd_val[i]), FWVV_VNMACC => fp_nmulsub(rm_3b, fp_widen(vs1_val[i]), fp_widen(vs2_val[i]), vd_val[i]), FWVV_VMSAC => fp_mulsub(rm_3b, fp_widen(vs1_val[i]), fp_widen(vs2_val[i]), vd_val[i]), FWVV_VNMSAC => fp_nmuladd(rm_3b, fp_widen(vs1_val[i]), fp_widen(vs2_val[i]), vd_val[i]) } } }; write_vreg(num_elem, SEW_widen, LMUL_pow_widen, vd, result);
(unfortunately var result = result; doesn't work)
var result = result;
I think I would do let (initial_result, mask) = ... and var result = initial_result as might be easier to understand what's going on for those less familiar with the language.
let (initial_result, mask) = ...
var result = initial_result
There are many uses of
var
andundefined
that are unnecessary and dodgy, especially in the vector code. For example this:Would probably be better like
(unfortunately
var result = result;
doesn't work)