diff options
author | Alasdair Armstrong <alasdair.armstrong@cl.cam.ac.uk> | 2024-09-20 18:19:30 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-09-20 18:19:30 +0100 |
commit | 6dd64644405a7c387c98bb1482dc2bfcba0b3899 (patch) | |
tree | 39b63209837778c714385707176aad61ab49b473 /model/riscv_insts_vext_fp_vm.sail | |
parent | bdf95b07c4574c018ca64a93ba29aa78c7f8ca5d (diff) | |
download | sail-riscv-6dd64644405a7c387c98bb1482dc2bfcba0b3899.zip sail-riscv-6dd64644405a7c387c98bb1482dc2bfcba0b3899.tar.gz sail-riscv-6dd64644405a7c387c98bb1482dc2bfcba0b3899.tar.bz2 |
Vector: Remove now unnecessary uses of undefined
Sail 0.18 contains the vector_init primitive, to make initialising
vectors with defined values easier. We can use this in some places
where the vector code was creating an uninitalised vector, only to
then initialize it later.
Second, we can remove some uses of undefined by refactoring slightly
how init_masked_result is used, which has the added benefit of making
mask immutable.
Some additional constraints need to be added to use the vector_init
primitive.
Sail's pattern completeness checker is now smarter than before, so
some wildcard cases can also be safely removed.
Diffstat (limited to 'model/riscv_insts_vext_fp_vm.sail')
-rwxr-xr-x | model/riscv_insts_vext_fp_vm.sail | 10 |
1 files changed, 4 insertions, 6 deletions
diff --git a/model/riscv_insts_vext_fp_vm.sail b/model/riscv_insts_vext_fp_vm.sail index 1914ed7..6d578fa 100755 --- a/model/riscv_insts_vext_fp_vm.sail +++ b/model/riscv_insts_vext_fp_vm.sail @@ -41,10 +41,9 @@ function clause execute(FVVMTYPE(funct6, vm, vs2, vs1, vd)) = { let vs1_val : vector('n, dec, bits('m)) = read_vreg(num_elem, SEW, LMUL_pow, vs1); let vs2_val : vector('n, dec, bits('m)) = read_vreg(num_elem, SEW, LMUL_pow, vs2); let vd_val : vector('n, dec, bool) = read_vmask(num_elem, 0b0, vd); - var result : vector('n, dec, bool) = undefined; - var mask : vector('n, dec, bool) = undefined; - (result, mask) = init_masked_result_cmp(num_elem, SEW, LMUL_pow, vd_val, vm_val); + let (initial_result, mask) = init_masked_result_cmp(num_elem, SEW, LMUL_pow, vd_val, vm_val); + var result = initial_result; foreach (i from 0 to (num_elem - 1)) { if mask[i] then { @@ -105,10 +104,9 @@ function clause execute(FVFMTYPE(funct6, vm, vs2, rs1, vd)) = { let rs1_val : bits('m) = get_scalar_fp(rs1, 'm); let vs2_val : vector('n, dec, bits('m)) = read_vreg(num_elem, SEW, LMUL_pow, vs2); let vd_val : vector('n, dec, bool) = read_vmask(num_elem, 0b0, vd); - var result : vector('n, dec, bool) = undefined; - var mask : vector('n, dec, bool) = undefined; - (result, mask) = init_masked_result_cmp(num_elem, SEW, LMUL_pow, vd_val, vm_val); + let (initial_result, mask) = init_masked_result_cmp(num_elem, SEW, LMUL_pow, vd_val, vm_val); + var result = initial_result; foreach (i from 0 to (num_elem - 1)) { if mask[i] then { |