diff options
author | ChunPing Chung <cpchung@pllab.cs.nthu.edu.tw> | 2021-04-16 22:31:24 +0800 |
---|---|---|
committer | Chun-Ping Chung <cpchung@pllab.cs.nthu.edu.tw> | 2021-04-16 23:02:23 +0800 |
commit | deb2cfe9ef9ab85b0b2111d82b98c533f9116b04 (patch) | |
tree | fd1a65cc8b27a6744f9369a694093f8d91ba6551 | |
parent | e8b0cf83d965b10947d568f532bfd3bc4b480077 (diff) | |
download | riscv-isa-sim-p-ext-0.5.2.zip riscv-isa-sim-p-ext-0.5.2.tar.gz riscv-isa-sim-p-ext-0.5.2.tar.bz2 |
Merge pull request #694 from marcfedorow/p-extp-ext-0.5.2
rvp: insns fixes
-rw-r--r-- | riscv/decode.h | 38 | ||||
-rw-r--r-- | riscv/insns/bpick.h | 2 | ||||
-rw-r--r-- | riscv/insns/insb.h | 2 | ||||
-rw-r--r-- | riscv/insns/uclip16.h | 4 | ||||
-rw-r--r-- | riscv/insns/uclip32.h | 4 | ||||
-rw-r--r-- | riscv/insns/uclip8.h | 4 |
6 files changed, 24 insertions, 30 deletions
diff --git a/riscv/decode.h b/riscv/decode.h index 1141e1c..99f274e 100644 --- a/riscv/decode.h +++ b/riscv/decode.h @@ -2418,8 +2418,13 @@ for (reg_t i = 0; i < P.VU.vlmax && P.VU.vl != 0; ++i) { \ rd_tmp = set_field(rd_tmp, make_mask64((i * sizeof(pd) * 8), sizeof(pd) * 8), pd); #define WRITE_RD_PAIR(value) \ - WRITE_REG(insn.rd(), zext32(value)); \ - WRITE_REG(insn.rd() + 1, ((reg_t)value) >> 32); + if (MMU.is_target_big_endian()) { \ + WRITE_REG(insn.rd() + 1, sext32(value)); \ + WRITE_REG(insn.rd(), ((sreg_t)value) >> 32); \ + } else { \ + WRITE_REG(insn.rd(), sext32(value)); \ + WRITE_REG(insn.rd() + 1, ((sreg_t)value) >> 32); \ + } #define P_SET_OV(ov) \ auto old = p->get_csr(CSR_UCODE); \ @@ -2440,6 +2445,7 @@ for (reg_t i = 0; i < P.VU.vlmax && P.VU.vl != 0; ++i) { \ R = UINT##BIT##_MAX; \ P_SET_OV(1); \ } else if (R < 0) { \ + P_SET_OV(1); \ R = 0; \ } @@ -2491,10 +2497,10 @@ for (reg_t i = 0; i < P.VU.vlmax && P.VU.vl != 0; ++i) { \ #define P_REDUCTION_LOOP_BASE(BIT, BIT_INNER, USE_RD) \ require_extension('P'); \ require(BIT == e16 || BIT == e32 || BIT == e64); \ - reg_t rd_tmp = USE_RD ? RD : 0; \ - reg_t rs1 = RS1; \ - reg_t rs2 = RS2; \ - sreg_t len = xlen / BIT; \ + reg_t rd_tmp = USE_RD ? zext_xlen(RD) : 0; \ + reg_t rs1 = zext_xlen(RS1); \ + reg_t rs2 = zext_xlen(RS2); \ + sreg_t len = 64 / BIT; \ sreg_t len_inner = BIT / BIT_INNER; \ for (sreg_t i = len - 1; i >= 0; --i) { \ sreg_t pd_res = P_FIELD(rd_tmp, i, BIT); \ @@ -2503,10 +2509,10 @@ for (reg_t i = 0; i < P.VU.vlmax && P.VU.vl != 0; ++i) { \ #define P_REDUCTION_ULOOP_BASE(BIT, BIT_INNER, USE_RD) \ require_extension('P'); \ require(BIT == e16 || BIT == e32 || BIT == e64); \ - reg_t rd_tmp = USE_RD ? RD : 0; \ - reg_t rs1 = RS1; \ - reg_t rs2 = RS2; \ - sreg_t len = xlen / BIT; \ + reg_t rd_tmp = USE_RD ? zext_xlen(RD) : 0; \ + reg_t rs1 = zext_xlen(RS1); \ + reg_t rs2 = zext_xlen(RS2); \ + sreg_t len = 64 / BIT; \ sreg_t len_inner = BIT / BIT_INNER; \ for (sreg_t i = len - 1; i >=0; --i) { \ reg_t pd_res = P_UFIELD(rd_tmp, i, BIT); \ @@ -2616,13 +2622,6 @@ for (reg_t i = 0; i < P.VU.vlmax && P.VU.vl != 0; ++i) { \ WRITE_PD(); \ } -#define P_ONE_SULOOP_BODY(BIT, BODY) { \ - P_ONE_SUPARAMS(BIT) \ - BODY \ - WRITE_PD(); \ -} - - #define P_MUL_LOOP_BODY(BIT, BODY) { \ P_MUL_PARAMS(BIT) \ BODY \ @@ -2715,11 +2714,6 @@ for (reg_t i = 0; i < P.VU.vlmax && P.VU.vl != 0; ++i) { \ P_ONE_ULOOP_BODY(BIT, BODY) \ P_LOOP_END() -#define P_I_SULOOP(BIT, IMMBIT, BODY) \ - P_I_LOOP_BASE(BIT, IMMBIT) \ - P_ONE_SULOOP_BODY(BIT, BODY) \ - P_LOOP_END() - #define P_MUL_LOOP(BIT, BODY) \ P_MUL_LOOP_BASE(BIT) \ P_MUL_LOOP_BODY(BIT, BODY) \ diff --git a/riscv/insns/bpick.h b/riscv/insns/bpick.h index ece0271..c52d4dd 100644 --- a/riscv/insns/bpick.h +++ b/riscv/insns/bpick.h @@ -3,4 +3,4 @@ reg_t rc = READ_REG(insn.p_rc()); reg_t rs1 = RS1; reg_t rs2 = RS2; -WRITE_RD(zext_xlen((rs1 & rc) | (rs2 & ~rc)));
\ No newline at end of file +WRITE_RD(sext_xlen((rs1 & rc) | (rs2 & ~rc)));
\ No newline at end of file diff --git a/riscv/insns/insb.h b/riscv/insns/insb.h index 2a78ec1..199a8c6 100644 --- a/riscv/insns/insb.h +++ b/riscv/insns/insb.h @@ -1,3 +1,3 @@ require_extension('P'); reg_t bpos = (xlen == 32) ? insn.p_imm2() : insn.p_imm3(); -WRITE_RD(set_field(RD, make_mask64(bpos * 8, 8), P_B(RS1, 0)));
\ No newline at end of file +WRITE_RD(sext_xlen(set_field(RD, make_mask64(bpos * 8, 8), P_B(RS1, 0))));
\ No newline at end of file diff --git a/riscv/insns/uclip16.h b/riscv/insns/uclip16.h index 792ec73..faf57ca 100644 --- a/riscv/insns/uclip16.h +++ b/riscv/insns/uclip16.h @@ -1,5 +1,5 @@ -P_I_SULOOP(16, 4, { - int64_t uint_max = UINT64_MAX >> (64 - imm4u); +P_I_LOOP(16, 4, { + int64_t uint_max = imm4u ? UINT64_MAX >> (64 - imm4u) : 0; pd = ps1; if (ps1 > uint_max) { diff --git a/riscv/insns/uclip32.h b/riscv/insns/uclip32.h index d71865a..f5d89ad 100644 --- a/riscv/insns/uclip32.h +++ b/riscv/insns/uclip32.h @@ -1,5 +1,5 @@ -P_I_SULOOP(32, 5, { - int64_t uint_max = UINT64_MAX >> (64 - imm5u); +P_I_LOOP(32, 5, { + int64_t uint_max = imm5u ? UINT64_MAX >> (64 - imm5u) : 0; pd = ps1; if (ps1 > uint_max) { diff --git a/riscv/insns/uclip8.h b/riscv/insns/uclip8.h index 0ac2962..e2978a6 100644 --- a/riscv/insns/uclip8.h +++ b/riscv/insns/uclip8.h @@ -1,5 +1,5 @@ -P_I_SULOOP(8, 3, { - int64_t uint_max = UINT64_MAX >> (64 - imm3u); +P_I_LOOP(8, 3, { + int64_t uint_max = imm3u ? UINT64_MAX >> (64 - imm3u) : 0; pd = ps1; if (ps1 > uint_max) { |