Skip to content

Commit

Permalink
Modularize single-width vector instruction
Browse files Browse the repository at this point in the history
To emulate vector registers of length VLEN using an array of uint32_t,
we first handle different SEW values (8, 16, 32) using sew_*b_handler.
Inside the handler, the V*_LOOP macro expands to process different VL
values and operand types, along with its corresponding V*_LOOP_LEFT.

The goal is to maximize code reuse by defining individual operations
next to their respective vector instructions, which can be easily
applied using the OPT() macro.

V*_LOOP execution steps:
1. Copy the operand op1 (op2).
2. Align op1 to the right.
3. Perform the specified operation between op1 and op2.
4. Mask the result according to the corresponding SEW.
5. Shift the result left to align with the corresponding position.
6. Accumulate the result.

In vector register groups, registers should follow the pattern v2*n,
v2*n+1 when lmul = 2, etc. The current implementation allows using any
vector registers except those exceeding v31.

For vector masking, if the corresponding mask bit is 0, the value of the
destination vector register is preserved. The process is as follows:
1. Copy the destination register.
2. Clear the bits corresponding to VL.
3. Store the computed result in ans.
4. Update the destination register with ans.

If ir->vm == 0, vector masking is activated.
  • Loading branch information
vestata committed Feb 12, 2025
1 parent 7f8bdf2 commit 7e23801
Show file tree
Hide file tree
Showing 2 changed files with 356 additions and 147 deletions.
1 change: 0 additions & 1 deletion src/rv32_constopt.c
Original file line number Diff line number Diff line change
Expand Up @@ -1827,5 +1827,4 @@ CONSTOPT(vfwmsac_vv, {})
CONSTOPT(vfwmsac_vf, {})
CONSTOPT(vfwnmsac_vv, {})
CONSTOPT(vfwnmsac_vf, {})

#endif
Loading

0 comments on commit 7e23801

Please sign in to comment.