target/arm: Implement SVE vector splice (predicated)

Backports commit b48ff24098c72f86e187e6abb7e9ca4de40a7fb4 from qemu
This commit is contained in:
Richard Henderson 2018-06-15 13:14:30 -04:00 committed by Lioncash
parent 7d930e8515
commit 7698c1634e
No known key found for this signature in database
GPG key ID: 4E3C3CC1031BA9C7
7 changed files with 59 additions and 0 deletions

View file

@ -3489,6 +3489,7 @@
#define helper_sve_smulh_zpzz_d helper_sve_smulh_zpzz_d_aarch64
#define helper_sve_smulh_zpzz_h helper_sve_smulh_zpzz_h_aarch64
#define helper_sve_smulh_zpzz_s helper_sve_smulh_zpzz_s_aarch64
#define helper_sve_splice helper_sve_splice_aarch64
#define helper_sve_sqaddi_b helper_sve_sqaddi_b_aarch64
#define helper_sve_sqaddi_d helper_sve_sqaddi_d_aarch64
#define helper_sve_sqaddi_h helper_sve_sqaddi_h_aarch64

View file

@ -3489,6 +3489,7 @@
#define helper_sve_smulh_zpzz_d helper_sve_smulh_zpzz_d_aarch64eb
#define helper_sve_smulh_zpzz_h helper_sve_smulh_zpzz_h_aarch64eb
#define helper_sve_smulh_zpzz_s helper_sve_smulh_zpzz_s_aarch64eb
#define helper_sve_splice helper_sve_splice_aarch64eb
#define helper_sve_sqaddi_b helper_sve_sqaddi_b_aarch64eb
#define helper_sve_sqaddi_d helper_sve_sqaddi_d_aarch64eb
#define helper_sve_sqaddi_h helper_sve_sqaddi_h_aarch64eb

View file

@ -3510,6 +3510,7 @@ aarch64_symbols = (
'helper_sve_smulh_zpzz_d',
'helper_sve_smulh_zpzz_h',
'helper_sve_smulh_zpzz_s',
'helper_sve_splice',
'helper_sve_sqaddi_b',
'helper_sve_sqaddi_d',
'helper_sve_sqaddi_h',

View file

@ -479,6 +479,8 @@ DEF_HELPER_FLAGS_4(sve_rbit_h, TCG_CALL_NO_RWG, void, ptr, ptr, ptr, i32)
DEF_HELPER_FLAGS_4(sve_rbit_s, TCG_CALL_NO_RWG, void, ptr, ptr, ptr, i32)
DEF_HELPER_FLAGS_4(sve_rbit_d, TCG_CALL_NO_RWG, void, ptr, ptr, ptr, i32)
DEF_HELPER_FLAGS_5(sve_splice, TCG_CALL_NO_RWG, void, ptr, ptr, ptr, ptr, i32)
DEF_HELPER_FLAGS_5(sve_and_pppp, TCG_CALL_NO_RWG, void, ptr, ptr, ptr, ptr, i32)
DEF_HELPER_FLAGS_5(sve_bic_pppp, TCG_CALL_NO_RWG, void, ptr, ptr, ptr, ptr, i32)
DEF_HELPER_FLAGS_5(sve_eor_pppp, TCG_CALL_NO_RWG, void, ptr, ptr, ptr, ptr, i32)

View file

@ -463,6 +463,9 @@ REVH 00000101 .. 1001 01 100 ... ..... ..... @rd_pg_rn
REVW 00000101 .. 1001 10 100 ... ..... ..... @rd_pg_rn
RBIT 00000101 .. 1001 11 100 ... ..... ..... @rd_pg_rn
# SVE vector splice (predicated)
SPLICE 00000101 .. 101 100 100 ... ..... ..... @rdn_pg_rm
### SVE Predicate Logical Operations Group
# SVE predicate logical operations

View file

@ -2108,3 +2108,40 @@ int32_t HELPER(sve_last_active_element)(void *vg, uint32_t pred_desc)
return last_active_element(vg, DIV_ROUND_UP(oprsz, 8), esz);
}
void HELPER(sve_splice)(void *vd, void *vn, void *vm, void *vg, uint32_t desc)
{
intptr_t opr_sz = simd_oprsz(desc) / 8;
int esz = simd_data(desc);
uint64_t pg, first_g, last_g, len, mask = pred_esz_masks[esz];
intptr_t i, first_i, last_i;
ARMVectorReg tmp;
first_i = last_i = 0;
first_g = last_g = 0;
/* Find the extent of the active elements within VG. */
for (i = QEMU_ALIGN_UP(opr_sz, 8) - 8; i >= 0; i -= 8) {
pg = *(uint64_t *)(vg + i) & mask;
if (pg) {
if (last_g == 0) {
last_g = pg;
last_i = i;
}
first_g = pg;
first_i = i;
}
}
len = 0;
if (first_g != 0) {
first_i = first_i * 8 + ctz64(first_g);
last_i = last_i * 8 + 63 - clz64(last_g);
len = last_i - first_i + (1 << esz);
if (vd == vm) {
vm = memcpy(&tmp, vm, opr_sz * 8);
}
swap_memmove(vd, vn + first_i, len);
}
swap_memmove(vd + len, vm, opr_sz * 8 - len);
}

View file

@ -2782,6 +2782,20 @@ static bool trans_RBIT(DisasContext *s, arg_rpr_esz *a, uint32_t insn)
return do_zpz_ool(s, a, fns[a->esz]);
}
static bool trans_SPLICE(DisasContext *s, arg_rprr_esz *a, uint32_t insn)
{
if (sve_access_check(s)) {
TCGContext *tcg_ctx = s->uc->tcg_ctx;
unsigned vsz = vec_full_reg_size(s);
tcg_gen_gvec_4_ool(tcg_ctx, vec_full_reg_offset(s, a->rd),
vec_full_reg_offset(s, a->rn),
vec_full_reg_offset(s, a->rm),
pred_full_reg_offset(s, a->pg),
vsz, vsz, a->esz, gen_helper_sve_splice);
}
return true;
}
/*
*** SVE Memory - 32-bit Gather and Unsized Contiguous Group
*/