From 0a7e3625e9a61866a8e42457f83c945a334f37fc Mon Sep 17 00:00:00 2001 From: Denis Drakhnya Date: Sat, 16 Jan 2021 01:00:47 +0200 Subject: [PATCH] e2k: Add pmadd{h,ubsh} instrs. --- target/e2k/helper.h | 4 ++++ target/e2k/helper_vec.c | 18 ++++++++++++++++++ target/e2k/translate/alc.c | 4 ++-- 3 files changed, 24 insertions(+), 2 deletions(-) diff --git a/target/e2k/helper.h b/target/e2k/helper.h index 20af829992..e70a86f8a4 100644 --- a/target/e2k/helper.h +++ b/target/e2k/helper.h @@ -80,6 +80,10 @@ DEF_HELPER_2(psrlw, i64, i64, i64) DEF_HELPER_2(psrah, i64, i64, i64) DEF_HELPER_2(psraw, i64, i64, i64) +/* Packed Mul */ +DEF_HELPER_2(pmaddh, i64, i64, i64) +DEF_HELPER_2(pmaddubsh, i64, i64, i64) + /* Float 32/64 Ops */ #define DEF_HELPER_3_32_64(name) \ DEF_HELPER_3(name##s, i32, env, i32, i32) \ diff --git a/target/e2k/helper_vec.c b/target/e2k/helper_vec.c index ab54d61fd5..0af583cdf6 100644 --- a/target/e2k/helper_vec.c +++ b/target/e2k/helper_vec.c @@ -191,6 +191,24 @@ GEN_HELPER_PACKED_SCALAR_BINOP(psrlw, uw, >>) GEN_HELPER_PACKED_SRA(psrah, sh, int32_t) GEN_HELPER_PACKED_SRA(psraw, sw, int64_t) +#define GEN_HELPER_PACKED_MAD(name, dst_type, type, cast, op) \ + uint64_t HELPER(name)(uint64_t src1, uint64_t src2) \ + { \ + size_t i = 0; \ + vec64 s1 = { .ud[0] = src1 }, s2 = { .ud[0] = src2 }, dst; \ + for (; i < glue(vec64_, type); i += 2) { \ + dst.dst_type[i >> 1] = op((cast) s1.type[i + 1] * s2.type[i + 1] +\ + (cast) s1.type[i ] * s2.type[i ]); \ + } \ + return dst.ud[0]; \ + } + +#define ident(x) x +#define satsh(x) MIN(MAX(x, -32768), 32767) + +GEN_HELPER_PACKED_MAD(pmaddh, sw, sh, int32_t, ident) +GEN_HELPER_PACKED_MAD(pmaddubsh, sh, ub, int16_t, satsh) + uint64_t HELPER(pmovmskb)(uint64_t src1, uint64_t src2) { unsigned int i; diff --git a/target/e2k/translate/alc.c b/target/e2k/translate/alc.c index e490615583..19b5614aa9 100644 --- a/target/e2k/translate/alc.c +++ b/target/e2k/translate/alc.c @@ -3053,6 +3053,8 @@ static void gen_op(DisasContext *ctx, Instr *instr) case OP_PSUBSH: gen_alopf1_ddd(instr, gen_helper_psubsh); break; case OP_PSUBUSB: gen_alopf1_ddd(instr, gen_helper_psubusb); break; case OP_PSUBUSH: gen_alopf1_ddd(instr, gen_helper_psubush); break; + case OP_PMADDH: gen_alopf1_ddd(instr, gen_helper_pmaddh); break; + case OP_PMADDUBSH: gen_alopf1_ddd(instr, gen_helper_pmaddubsh); 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; @@ -3223,7 +3225,6 @@ static void gen_op(DisasContext *ctx, Instr *instr) case OP_PMULHUH: case OP_PMULHH: case OP_PMULLH: - case OP_PMADDH: case OP_PFADDS: case OP_PFADDD: case OP_PFSUBS: @@ -3399,7 +3400,6 @@ static void gen_op(DisasContext *ctx, Instr *instr) case OP_PSIGNB: case OP_PSIGNH: case OP_PSIGNW: - case OP_PMADDUBSH: case OP_PMULHRSH: case OP_PHMINPOSUH: case OP_PUTTST: