diff options
Diffstat (limited to 'riscv/insns/vrgather_vi.h')
-rw-r--r-- | riscv/insns/vrgather_vi.h | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/riscv/insns/vrgather_vi.h b/riscv/insns/vrgather_vi.h new file mode 100644 index 0000000..a9be102 --- /dev/null +++ b/riscv/insns/vrgather_vi.h @@ -0,0 +1,29 @@ +// vrgather.vi vd, vs2, zimm5 vm # vd[i] = (zimm5 >= VLMAX) ? 0 : vs2[zimm5]; +require(P.VU.vsew >= e8 && P.VU.vsew <= e64); +require(!P.VU.vill); +reg_t vl = P.VU.vl; +reg_t sew = P.VU.vsew; +reg_t rd_num = insn.rd(); +reg_t rs2_num = insn.rs2(); +reg_t zimm5 = insn.v_zimm5(); +for (reg_t i = P.VU.vstart; i < vl; ++i) { + VI_LOOP_ELEMENT_SKIP(); + + switch (sew) { + case e8: + P.VU.elt<uint8_t>(rd_num, i) = zimm5 >= P.VU.vlmax ? 0 : P.VU.elt<uint8_t>(rs2_num, zimm5); + break; + case e16: + P.VU.elt<uint16_t>(rd_num, i) = zimm5 >= P.VU.vlmax ? 0 : P.VU.elt<uint16_t>(rs2_num, zimm5); + break; + case e32: + P.VU.elt<uint32_t>(rd_num, i) = zimm5 >= P.VU.vlmax ? 0 : P.VU.elt<uint32_t>(rs2_num, zimm5); + break; + default: + P.VU.elt<uint64_t>(rd_num, i) = zimm5 >= P.VU.vlmax ? 0 : P.VU.elt<uint64_t>(rs2_num, zimm5); + break; + } +} + +VI_TAIL_ZERO(1); +P.VU.vstart = 0; |