e2k: Add packed add and sub using saturation.

This commit is contained in:
Denis Drakhnia 2021-01-15 22:49:11 +02:00 committed by Denis Drakhnia
parent 034ceec4e7
commit d233d8afa5
3 changed files with 35 additions and 8 deletions

View File

@ -58,6 +58,18 @@ DEF_HELPER_2(pcmpgth, i64, i64, i64)
DEF_HELPER_2(pcmpgtw, i64, i64, i64)
DEF_HELPER_2(pcmpgtd, i64, i64, i64)
/* Packed Add using saturation */
DEF_HELPER_2(paddsb, i64, i64, i64)
DEF_HELPER_2(paddsh, i64, i64, i64)
DEF_HELPER_2(paddusb, i64, i64, i64)
DEF_HELPER_2(paddush, i64, i64, i64)
/* Packed Sub using saturation */
DEF_HELPER_2(psubsb, i64, i64, i64)
DEF_HELPER_2(psubsh, i64, i64, i64)
DEF_HELPER_2(psubusb, i64, i64, i64)
DEF_HELPER_2(psubush, i64, i64, i64)
/* Float 32/64 Ops */
#define DEF_HELPER_3_32_64(name) \
DEF_HELPER_3(name##s, i32, env, i32, i32) \

View File

@ -148,6 +148,21 @@ GEN_HELPER_PACKED_CMP(pcmpgth, sh, >)
GEN_HELPER_PACKED_CMP(pcmpgtw, sw, >)
GEN_HELPER_PACKED_CMP(pcmpgtd, sd, >)
#define GEN_HELPER_PACKED_BINOP_SATURATE(name, type, op, t, min, max) \
GEN_HELPER_PACKED(name, type, { \
dst.type[i] = MIN(MAX(s1.type[i] op s2.type[i], min), max); \
})
GEN_HELPER_PACKED_BINOP_SATURATE(paddsb, sb, +, int, -128, 127)
GEN_HELPER_PACKED_BINOP_SATURATE(paddsh, sh, +, int, -32768, 32767)
GEN_HELPER_PACKED_BINOP_SATURATE(paddusb, ub, +, int, 0, 255)
GEN_HELPER_PACKED_BINOP_SATURATE(paddush, uh, +, int, 0, 65535)
GEN_HELPER_PACKED_BINOP_SATURATE(psubsb, sb, -, int, -128, 127)
GEN_HELPER_PACKED_BINOP_SATURATE(psubsh, sh, -, int, -32768, 32767)
GEN_HELPER_PACKED_BINOP_SATURATE(psubusb, ub, -, int, 0, 255)
GEN_HELPER_PACKED_BINOP_SATURATE(psubush, uh, -, int, 0, 65535)
uint64_t HELPER(pmovmskb)(uint64_t src1, uint64_t src2)
{
unsigned int i;

View File

@ -2958,10 +2958,18 @@ static void gen_op(DisasContext *ctx, Instr *instr)
case OP_PADDH: gen_alopf1_ddd(instr, tcg_gen_vec_add16_i64); break;
case OP_PADDW: gen_alopf1_ddd(instr, tcg_gen_vec_add32_i64); break;
case OP_PADDD: gen_alopf1_ddd(instr, tcg_gen_add_i64); break;
case OP_PADDSB: gen_alopf1_ddd(instr, gen_helper_paddsb); break;
case OP_PADDSH: gen_alopf1_ddd(instr, gen_helper_paddsh); break;
case OP_PADDUSB: gen_alopf1_ddd(instr, gen_helper_paddusb); break;
case OP_PADDUSH: gen_alopf1_ddd(instr, gen_helper_paddush); break;
case OP_PSUBB: gen_alopf1_ddd(instr, tcg_gen_vec_sub8_i64); break;
case OP_PSUBH: gen_alopf1_ddd(instr, tcg_gen_vec_sub16_i64); break;
case OP_PSUBW: gen_alopf1_ddd(instr, tcg_gen_vec_sub32_i64); break;
case OP_PSUBD: gen_alopf1_ddd(instr, tcg_gen_sub_i64); break;
case OP_PSUBSB: gen_alopf1_ddd(instr, gen_helper_psubsb); break;
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_GETTAGS: gen_gettag_i32(instr); break;
case OP_GETTAGD: gen_gettag_i64(instr); break;
case OP_PUTTAGS: gen_puttag_i32(instr); break;
@ -3116,14 +3124,6 @@ static void gen_op(DisasContext *ctx, Instr *instr)
case OP_FSQRTTD:
case OP_PFMULS:
case OP_PFMULD:
case OP_PADDSB:
case OP_PADDSH:
case OP_PADDUSB:
case OP_PADDUSH:
case OP_PSUBSB:
case OP_PSUBSH:
case OP_PSUBUSB:
case OP_PSUBUSH:
case OP_PSADBW:
case OP_PMULHUH:
case OP_PMULHH: