e2k: Add pcmp{eq,gt}{b,h,w,d} instrs.

This commit is contained in:
Denis Drakhnia 2021-01-15 21:30:02 +02:00 committed by Denis Drakhnia
parent e4e22e089c
commit 3fb4bcec13
3 changed files with 47 additions and 43 deletions

View File

@ -26,7 +26,6 @@ DEF_HELPER_2(setwd, void, env, i32)
DEF_HELPER_2(probe_read_access, int, env, tl)
DEF_HELPER_2(probe_write_access, int, env, tl)
DEF_HELPER_3(packed_shuffle_i64, i64, i64, i64, i64)
DEF_HELPER_2(pcmpeqb, i64, i64, i64)
DEF_HELPER_2(pmovmskb, i64, i64, i64)
DEF_HELPER_1(aau_load_program, void, env)
@ -49,6 +48,16 @@ DEF_HELPER_2(pmaxsh, i64, i64, i64)
DEF_HELPER_2(pmaxuw, i64, i64, i64)
DEF_HELPER_2(pmaxsw, i64, i64, i64)
/* Packed Cmp */
DEF_HELPER_2(pcmpeqb, i64, i64, i64)
DEF_HELPER_2(pcmpeqh, i64, i64, i64)
DEF_HELPER_2(pcmpeqw, i64, i64, i64)
DEF_HELPER_2(pcmpeqd, i64, i64, i64)
DEF_HELPER_2(pcmpgtb, i64, i64, i64)
DEF_HELPER_2(pcmpgth, i64, i64, i64)
DEF_HELPER_2(pcmpgtw, i64, i64, i64)
DEF_HELPER_2(pcmpgtd, 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

@ -17,22 +17,22 @@ static uint8_t reverse_bits(uint8_t b)
#define vec64_ub 8
#define vec64_uh 4
#define vec64_uw 2
#define vec64_uq 1
#define vec64_ud 1
#define vec64_sb vec64_ub
#define vec64_sh vec64_uh
#define vec64_sw vec64_uw
#define vec64_sq vec64_uq
#define vec64_sd vec64_ud
typedef union {
uint8_t ub[vec64_ub];
uint16_t uh[vec64_uh];
uint32_t uw[vec64_uw];
uint64_t uq;
uint64_t ud[vec64_ud];
int8_t sb[vec64_ub];
int16_t sh[vec64_uh];
int32_t sw[vec64_uw];
int64_t sq;
int64_t sd[vec64_ud];
} vec64;
uint64_t HELPER(packed_shuffle_i64)(uint64_t src1, uint64_t src2, uint64_t src3)
@ -40,9 +40,9 @@ uint64_t HELPER(packed_shuffle_i64)(uint64_t src1, uint64_t src2, uint64_t src3)
vec64 ret, s1, s2, s3;
unsigned int i;
s1.uq = src1;
s2.uq = src2;
s3.uq = src3;
s1.ud[0] = src1;
s2.ud[0] = src2;
s3.ud[0] = src3;
for (i = 0; i < 8; i++) {
uint8_t desc = s3.ub[i];
@ -101,44 +101,24 @@ uint64_t HELPER(packed_shuffle_i64)(uint64_t src1, uint64_t src2, uint64_t src3)
ret.ub[i] = byte;
}
return ret.uq;
return ret.ud[0];
}
#define GEN_HELPER_PACKED(name, type, code) \
uint64_t HELPER(glue(name, type))(uint64_t src1, uint64_t src2) \
uint64_t HELPER(name)(uint64_t src1, uint64_t src2) \
{ \
size_t i = 0; \
vec64 s1 = { .uq = src1 }, s2 = { .uq = src2 }, dst; \
vec64 s1 = { .ud[0] = src1 }, s2 = { .ud[0] = src2 }, dst; \
for (; i < glue(vec64_, type); i++) { \
code \
} \
return dst.uq; \
return dst.ud[0]; \
}
#define GEN_HELPER_PACKED_MINMAX(name, type, op) \
GEN_HELPER_PACKED(name, type, { \
GEN_HELPER_PACKED(glue(name, type), type, { \
dst.type[i] = op(s1.type[i], s2.type[i]); \
})
// FIXME: not tested
uint64_t HELPER(pcmpeqb)(uint64_t src1, uint64_t src2)
{
unsigned int i;
vec64 s1, s2, ret;
s1.uq = src1;
s2.uq = src2;
for (i = 0; i < 8; i++) {
if (s1.ub[i] == s2.ub[i]) {
ret.ub[i] = 0xff;
} else {
ret.ub[i] = 0;
}
}
return ret.uq;
}
GEN_HELPER_PACKED_MINMAX(pmin, ub, MIN)
GEN_HELPER_PACKED_MINMAX(pmin, sb, MIN)
GEN_HELPER_PACKED_MINMAX(pmin, uh, MIN)
@ -153,14 +133,29 @@ GEN_HELPER_PACKED_MINMAX(pmax, sh, MAX)
GEN_HELPER_PACKED_MINMAX(pmax, uw, MAX)
GEN_HELPER_PACKED_MINMAX(pmax, sw, MAX)
#define GEN_HELPER_PACKED_CMP(name, type, op) \
GEN_HELPER_PACKED(name, type, { \
dst.type[i] = s1.type[i] op s2.type[i] ? -1UL : 0; \
})
GEN_HELPER_PACKED_CMP(pcmpeqb, ub, ==)
GEN_HELPER_PACKED_CMP(pcmpeqh, uh, ==)
GEN_HELPER_PACKED_CMP(pcmpeqw, uw, ==)
GEN_HELPER_PACKED_CMP(pcmpeqd, ud, ==)
GEN_HELPER_PACKED_CMP(pcmpgtb, sb, >)
GEN_HELPER_PACKED_CMP(pcmpgth, sh, >)
GEN_HELPER_PACKED_CMP(pcmpgtw, sw, >)
GEN_HELPER_PACKED_CMP(pcmpgtd, sd, >)
uint64_t HELPER(pmovmskb)(uint64_t src1, uint64_t src2)
{
unsigned int i;
vec64 s1, s2;
uint16_t ret = 0;
s1.uq = src1;
s2.uq = src2;
s1.ud[0] = src1;
s2.ud[0] = src2;
for (i = 0; i < 8; i++) {
if (s1.sb[i] < 0) {

View File

@ -2945,6 +2945,14 @@ static void gen_op(DisasContext *ctx, Instr *instr)
case OP_PMAXSH: gen_alopf1_ddd(instr, gen_helper_pmaxsh); break;
case OP_PMAXUW: gen_alopf1_ddd(instr, gen_helper_pmaxuw); break;
case OP_PMAXSW: gen_alopf1_ddd(instr, gen_helper_pmaxsw); break;
case OP_PCMPEQB: gen_alopf1_ddd(instr, gen_helper_pcmpeqb); break;
case OP_PCMPEQH: gen_alopf1_ddd(instr, gen_helper_pcmpeqh); break;
case OP_PCMPEQW: gen_alopf1_ddd(instr, gen_helper_pcmpeqw); break;
case OP_PCMPEQD: gen_alopf1_ddd(instr, gen_helper_pcmpeqd); break;
case OP_PCMPGTB: gen_alopf1_ddd(instr, gen_helper_pcmpgtb); break;
case OP_PCMPGTH: gen_alopf1_ddd(instr, gen_helper_pcmpgth); break;
case OP_PCMPGTW: gen_alopf1_ddd(instr, gen_helper_pcmpgtw); break;
case OP_PCMPGTD: gen_alopf1_ddd(instr, gen_helper_pcmpgtd); 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;
@ -2952,7 +2960,6 @@ static void gen_op(DisasContext *ctx, Instr *instr)
case OP_PMOVMSKB: gen_alopf1_ddd(instr, gen_helper_pmovmskb); break;
case OP_PADDD: gen_alopf1_ddd(instr, tcg_gen_add_i64); break;
case OP_PSUBD: gen_alopf1_ddd(instr, tcg_gen_sub_i64); break;
case OP_PCMPEQB: gen_alopf1_ddd(instr, gen_helper_pcmpeqb); break;
case OP_STAAB: gen_staa_i32(instr, MO_8); break;
case OP_STAAH: gen_staa_i32(instr, MO_16); break;
case OP_STAAW: gen_staa_i32(instr, MO_32); break;
@ -3192,11 +3199,6 @@ static void gen_op(DisasContext *ctx, Instr *instr)
case OP_PFCMPNLTD:
case OP_PFCMPNLED:
case OP_PFCMPODD:
case OP_PCMPEQH:
case OP_PCMPEQW:
case OP_PCMPGTB:
case OP_PCMPGTH:
case OP_PCMPGTW:
case OP_PMOVMSKPS:
case OP_PMOVMSKPD:
case OP_PACKSSHB:
@ -3299,8 +3301,6 @@ static void gen_op(DisasContext *ctx, Instr *instr)
case OP_PMULUBHH:
case OP_MPSADBH:
case OP_PACKUSWH:
case OP_PCMPEQD:
case OP_PCMPGTD:
case OP_PFHADDS:
case OP_PFHSUBS:
case OP_PFADDSUBS: