From 9440e28b68b50f537f2b95cc8e1cf74a02f2cadd Mon Sep 17 00:00:00 2001 From: Denis Drakhnya Date: Sat, 16 Jan 2021 16:19:56 +0200 Subject: [PATCH] e2k: Add psign{b,h,w} instrs. --- target/e2k/helper.h | 5 +++++ target/e2k/helper_vec.c | 10 ++++++++++ target/e2k/translate/alc.c | 6 +++--- 3 files changed, 18 insertions(+), 3 deletions(-) diff --git a/target/e2k/helper.h b/target/e2k/helper.h index 989589afc7..ac4fc55289 100644 --- a/target/e2k/helper.h +++ b/target/e2k/helper.h @@ -96,6 +96,11 @@ DEF_HELPER_2(pmullh, i64, i64, i64) DEF_HELPER_2(pmulhuh, i64, i64, i64) DEF_HELPER_2(pmulubhh, i64, i64, i64) +/* Packed Sign Mul */ +DEF_HELPER_2(psignb, i64, i64, i64) +DEF_HELPER_2(psignh, i64, i64, i64) +DEF_HELPER_2(psignw, i64, i64, i64) + /* Packed Move Mask */ DEF_HELPER_2(pmovmskb, i64, i64, i64) DEF_HELPER_2(pmovmskps, i64, i64, i64) diff --git a/target/e2k/helper_vec.c b/target/e2k/helper_vec.c index d42a12137f..e32714f67d 100644 --- a/target/e2k/helper_vec.c +++ b/target/e2k/helper_vec.c @@ -63,6 +63,10 @@ typedef union { } #define GEN_HELPER_PACKED(name, type, code) \ GEN_HELPER_PACKED_N(name, vec64_len(type), code) +#define GEN_HELPER_PACKED_OP(name, type, op) \ + GEN_HELPER_PACKED_N(name, vec64_len(type), { \ + dst.type[i] = op(s1.type[i], s2.type[i]); \ + }) #define GEN_HELPER_PACKED_SCALAR(name, type, code) \ uint64_t HELPER(name)(uint64_t src1, uint64_t s2) \ { \ @@ -184,6 +188,12 @@ GEN_HELPER_PACKED(pmulubhh, uh, { \ dst.uh[i] = (((int16_t) s1.ub[i] * s2.sh[i]) + s1.ub[i]) >> 8; \ }) +#define mul_sign(a, b) ((b) < 0 ? -(a) : ((b) > 0 ? (a) : 0)) + +GEN_HELPER_PACKED_OP(psignb, sb, mul_sign) +GEN_HELPER_PACKED_OP(psignh, sh, mul_sign) +GEN_HELPER_PACKED_OP(psignw, sw, mul_sign) + #define MOVMASK(mask_type, type) { \ dst.mask_type[0] |= (s1.type[i] < 0) << (i + glue(vec64_, type)); \ dst.mask_type[0] |= (s2.type[i] < 0) << (i ); \ diff --git a/target/e2k/translate/alc.c b/target/e2k/translate/alc.c index eb39671f1b..2083b5193f 100644 --- a/target/e2k/translate/alc.c +++ b/target/e2k/translate/alc.c @@ -3113,6 +3113,9 @@ static void gen_op(DisasContext *ctx, Instr *instr) case OP_PMADDH: gen_alopf1_ddd(instr, gen_helper_pmaddh); break; case OP_PMADDUBSH: gen_alopf1_ddd(instr, gen_helper_pmaddubsh); break; case OP_PSADBW: gen_alopf1_ddd(instr, gen_helper_psadbw); break; + case OP_PSIGNB: gen_alopf1_ddd(instr, gen_helper_psignb); break; + case OP_PSIGNH: gen_alopf1_ddd(instr, gen_helper_psignh); break; + case OP_PSIGNW: gen_alopf1_ddd(instr, gen_helper_psignw); break; case OP_PSLLH: gen_alopf1_ddd(instr, gen_helper_psllh); break; case OP_PSLLW: gen_alopf1_ddd(instr, gen_helper_psllw); break; case OP_PSLLD: gen_alopf1_ddd(instr, tcg_gen_shl_i64); break; @@ -3440,9 +3443,6 @@ static void gen_op(DisasContext *ctx, Instr *instr) case OP_PFADDSUBS: case OP_PFSTOIFS: case OP_PFDTOIFD: - case OP_PSIGNB: - case OP_PSIGNH: - case OP_PSIGNW: case OP_PMULHRSH: case OP_PHMINPOSUH: case OP_PUTTST: