target/arm: Implement BFMOPA, BFMOPS

Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
Message-id: 20220708151540.18136-26-richard.henderson@linaro.org
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
This commit is contained in:
Richard Henderson 2022-07-08 20:45:20 +05:30 committed by Peter Maydell
parent 558e956c71
commit 920f640d39
4 changed files with 90 additions and 0 deletions

View file

@ -987,3 +987,59 @@ void HELPER(sme_fmopa_d)(void *vza, void *vzn, void *vzm, void *vpn,
}
}
}
/*
* Alter PAIR as needed for controlling predicates being false,
* and for NEG on an enabled row element.
*/
static inline uint32_t f16mop_adj_pair(uint32_t pair, uint32_t pg, uint32_t neg)
{
/*
* The pseudocode uses a conditional negate after the conditional zero.
* It is simpler here to unconditionally negate before conditional zero.
*/
pair ^= neg;
if (!(pg & 1)) {
pair &= 0xffff0000u;
}
if (!(pg & 4)) {
pair &= 0x0000ffffu;
}
return pair;
}
void HELPER(sme_bfmopa)(void *vza, void *vzn, void *vzm, void *vpn,
void *vpm, uint32_t desc)
{
intptr_t row, col, oprsz = simd_maxsz(desc);
uint32_t neg = simd_data(desc) * 0x80008000u;
uint16_t *pn = vpn, *pm = vpm;
for (row = 0; row < oprsz; ) {
uint16_t prow = pn[H2(row >> 4)];
do {
void *vza_row = vza + tile_vslice_offset(row);
uint32_t n = *(uint32_t *)(vzn + H1_4(row));
n = f16mop_adj_pair(n, prow, neg);
for (col = 0; col < oprsz; ) {
uint16_t pcol = pm[H2(col >> 4)];
do {
if (prow & pcol & 0b0101) {
uint32_t *a = vza_row + H1_4(col);
uint32_t m = *(uint32_t *)(vzm + H1_4(col));
m = f16mop_adj_pair(m, pcol, 0);
*a = bfdotadd(*a, n, m);
col += 4;
pcol >>= 4;
}
} while (col & 15);
}
row += 4;
prow >>= 4;
} while (row & 15);
}
}