Skip to content

Commit

Permalink
target/hppa: Implement HSUB
Browse files Browse the repository at this point in the history
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
  • Loading branch information
rth7680 committed Nov 7, 2023
1 parent 0843563 commit 10c9e58
Show file tree
Hide file tree
Showing 4 changed files with 53 additions and 0 deletions.
2 changes: 2 additions & 0 deletions target/hppa/helper.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ DEF_HELPER_FLAGS_1(ldc_check, TCG_CALL_NO_RWG, void, tl)

DEF_HELPER_FLAGS_2(hadd_ss, TCG_CALL_NO_RWG_SE, i64, i64, i64)
DEF_HELPER_FLAGS_2(hadd_us, TCG_CALL_NO_RWG_SE, i64, i64, i64)
DEF_HELPER_FLAGS_2(hsub_ss, TCG_CALL_NO_RWG_SE, i64, i64, i64)
DEF_HELPER_FLAGS_2(hsub_us, TCG_CALL_NO_RWG_SE, i64, i64, i64)

DEF_HELPER_FLAGS_4(probe, TCG_CALL_NO_WG, tl, env, tl, i32, i32)

Expand Down
4 changes: 4 additions & 0 deletions target/hppa/insns.decode
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,10 @@ hadd 000010 ..... ..... 00000011 11 0 ..... @rrr
hadd_ss 000010 ..... ..... 00000011 01 0 ..... @rrr
hadd_us 000010 ..... ..... 00000011 00 0 ..... @rrr

hsub 000010 ..... ..... 00000001 11 0 ..... @rrr
hsub_ss 000010 ..... ..... 00000001 01 0 ..... @rrr
hsub_us 000010 ..... ..... 00000001 00 0 ..... @rrr

####
# Index Mem
####
Expand Down
32 changes: 32 additions & 0 deletions target/hppa/op_helper.c
Original file line number Diff line number Diff line change
Expand Up @@ -409,3 +409,35 @@ uint64_t HELPER(hadd_us)(uint64_t r1, uint64_t r2)
}
return ret;
}

uint64_t HELPER(hsub_ss)(uint64_t r1, uint64_t r2)
{
uint64_t ret = 0;

for (int i = 0; i < 64; i += 16) {
int f1 = sextract64(r1, i, 16);
int f2 = sextract64(r2, i, 16);
int fr = f1 - f2;

fr = MIN(fr, INT16_MAX);
fr = MAX(fr, INT16_MIN);
ret = deposit64(ret, i, 16, fr);
}
return ret;
}

uint64_t HELPER(hsub_us)(uint64_t r1, uint64_t r2)
{
uint64_t ret = 0;

for (int i = 0; i < 64; i += 16) {
int f1 = extract64(r1, i, 16);
int f2 = sextract64(r2, i, 16);
int fr = f1 - f2;

fr = MIN(fr, UINT16_MAX);
fr = MAX(fr, 0);
ret = deposit64(ret, i, 16, fr);
}
return ret;
}
15 changes: 15 additions & 0 deletions target/hppa/translate.c
Original file line number Diff line number Diff line change
Expand Up @@ -2804,6 +2804,21 @@ static bool trans_hadd_us(DisasContext *ctx, arg_rrr *a)
return do_multimedia(ctx, a, gen_helper_hadd_us);
}

static bool trans_hsub(DisasContext *ctx, arg_rrr *a)
{
return do_multimedia(ctx, a, tcg_gen_vec_sub16_i64);
}

static bool trans_hsub_ss(DisasContext *ctx, arg_rrr *a)
{
return do_multimedia(ctx, a, gen_helper_hsub_ss);
}

static bool trans_hsub_us(DisasContext *ctx, arg_rrr *a)
{
return do_multimedia(ctx, a, gen_helper_hsub_us);
}

static bool trans_ld(DisasContext *ctx, arg_ldst *a)
{
if (!ctx->is_pa20 && a->size > MO_32) {
Expand Down

0 comments on commit 10c9e58

Please sign in to comment.