mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-03 15:53:54 -06:00
target/arm: Implement SVE2 bitwise permute
Reviewed-by: Peter Maydell <peter.maydell@linaro.org> Signed-off-by: Richard Henderson <richard.henderson@linaro.org> Message-id: 20210525010358.152808-18-richard.henderson@linaro.org Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
This commit is contained in:
parent
2df3ca5599
commit
cb9c33b817
5 changed files with 135 additions and 0 deletions
|
@ -1246,6 +1246,79 @@ DO_ZZZ_NTB(sve2_eoril_d, uint64_t, , DO_EOR)
|
|||
|
||||
#undef DO_ZZZ_NTB
|
||||
|
||||
#define DO_BITPERM(NAME, TYPE, OP) \
|
||||
void HELPER(NAME)(void *vd, void *vn, void *vm, uint32_t desc) \
|
||||
{ \
|
||||
intptr_t i, opr_sz = simd_oprsz(desc); \
|
||||
for (i = 0; i < opr_sz; i += sizeof(TYPE)) { \
|
||||
TYPE nn = *(TYPE *)(vn + i); \
|
||||
TYPE mm = *(TYPE *)(vm + i); \
|
||||
*(TYPE *)(vd + i) = OP(nn, mm, sizeof(TYPE) * 8); \
|
||||
} \
|
||||
}
|
||||
|
||||
static uint64_t bitextract(uint64_t data, uint64_t mask, int n)
|
||||
{
|
||||
uint64_t res = 0;
|
||||
int db, rb = 0;
|
||||
|
||||
for (db = 0; db < n; ++db) {
|
||||
if ((mask >> db) & 1) {
|
||||
res |= ((data >> db) & 1) << rb;
|
||||
++rb;
|
||||
}
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
DO_BITPERM(sve2_bext_b, uint8_t, bitextract)
|
||||
DO_BITPERM(sve2_bext_h, uint16_t, bitextract)
|
||||
DO_BITPERM(sve2_bext_s, uint32_t, bitextract)
|
||||
DO_BITPERM(sve2_bext_d, uint64_t, bitextract)
|
||||
|
||||
static uint64_t bitdeposit(uint64_t data, uint64_t mask, int n)
|
||||
{
|
||||
uint64_t res = 0;
|
||||
int rb, db = 0;
|
||||
|
||||
for (rb = 0; rb < n; ++rb) {
|
||||
if ((mask >> rb) & 1) {
|
||||
res |= ((data >> db) & 1) << rb;
|
||||
++db;
|
||||
}
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
DO_BITPERM(sve2_bdep_b, uint8_t, bitdeposit)
|
||||
DO_BITPERM(sve2_bdep_h, uint16_t, bitdeposit)
|
||||
DO_BITPERM(sve2_bdep_s, uint32_t, bitdeposit)
|
||||
DO_BITPERM(sve2_bdep_d, uint64_t, bitdeposit)
|
||||
|
||||
static uint64_t bitgroup(uint64_t data, uint64_t mask, int n)
|
||||
{
|
||||
uint64_t resm = 0, resu = 0;
|
||||
int db, rbm = 0, rbu = 0;
|
||||
|
||||
for (db = 0; db < n; ++db) {
|
||||
uint64_t val = (data >> db) & 1;
|
||||
if ((mask >> db) & 1) {
|
||||
resm |= val << rbm++;
|
||||
} else {
|
||||
resu |= val << rbu++;
|
||||
}
|
||||
}
|
||||
|
||||
return resm | (resu << rbm);
|
||||
}
|
||||
|
||||
DO_BITPERM(sve2_bgrp_b, uint8_t, bitgroup)
|
||||
DO_BITPERM(sve2_bgrp_h, uint16_t, bitgroup)
|
||||
DO_BITPERM(sve2_bgrp_s, uint32_t, bitgroup)
|
||||
DO_BITPERM(sve2_bgrp_d, uint64_t, bitgroup)
|
||||
|
||||
#undef DO_BITPERM
|
||||
|
||||
#define DO_ZZI_SHLL(NAME, TYPEW, TYPEN, HW, HN) \
|
||||
void HELPER(NAME)(void *vd, void *vn, uint32_t desc) \
|
||||
{ \
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue