diff options
author | Chih-Min Chao <chihmin.chao@sifive.com> | 2019-06-06 03:24:27 -0700 |
---|---|---|
committer | Chih-Min Chao <chihmin.chao@sifive.com> | 2019-06-18 08:56:11 -0700 |
commit | 655aedc0ebd2326d69d389bc714c2d622bf2cb08 (patch) | |
tree | aa2cf79905906cde9ff6d10c63d1499fb4a484a1 /riscv/insns/vmsof_m.h | |
parent | 235aa58bfb439c9782defe8bdd21f792e40aac31 (diff) | |
download | spike-655aedc0ebd2326d69d389bc714c2d622bf2cb08.zip spike-655aedc0ebd2326d69d389bc714c2d622bf2cb08.tar.gz spike-655aedc0ebd2326d69d389bc714c2d622bf2cb08.tar.bz2 |
rvv: add integer/fixed-point/mask/reduction/permutation instructions
based on v-spec 0.7.1, support
sections: 12/13/15.1 ~ 15.2/16/17
element size: 8/16/32/64
support ediv: 1
Signed-off-by: Bruce Hoult <bruce@hoult.org>
Signed-off-by: Chih-Min Chao <chihmin.chao@sifive.com>
Signed-off-by: Dave Wen <dave.wen@sifive.com>
Diffstat (limited to 'riscv/insns/vmsof_m.h')
-rw-r--r-- | riscv/insns/vmsof_m.h | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/riscv/insns/vmsof_m.h b/riscv/insns/vmsof_m.h new file mode 100644 index 0000000..b4cbbce --- /dev/null +++ b/riscv/insns/vmsof_m.h @@ -0,0 +1,32 @@ +// vmsof.m rd, vs2, vm +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 rs1_num = insn.rs1(); +reg_t rs2_num = insn.rs2(); + +bool has_one = false; +for (reg_t i = P.VU.vstart ; i < vl; ++i) { + const int mlen = P.VU.vmlen; + const int midx = (mlen * i) / 64; + const int mpos = (mlen * i) % 64; + const uint64_t mmask = (UINT64_MAX << (64 - mlen)) >> (64 - mlen - mpos); + + bool vs2_lsb = ((P.VU.elt<uint64_t>(rs2_num, midx ) >> mpos) & 0x1) == 1; + bool do_mask = (P.VU.elt<uint64_t>(0, midx) >> mpos) & 0x1; + uint64_t &vd = P.VU.elt<uint64_t>(rd_num, midx); + + if (insn.v_vm() == 1 || (insn.v_vm() == 0 && do_mask)) { + uint64_t res = 0; + if(!has_one && vs2_lsb) { + has_one = true; + res = 1; + } + vd = (vd & ~mmask) | ((res << mpos) & mmask); + } +} + +VI_TAIL_ZERO_MASK(rd_num); +P.VU.vstart = 0; |