target/arm: Implement MVE VPSEL

Implement the MVE VPSEL insn, which sets each byte of the destination
vector Qd to the byte from either Qn or Qm depending on the value of
the corresponding bit in VPR.P0.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
This commit is contained in:
Peter Maydell 2021-08-13 17:11:51 +01:00
parent cce81873bc
commit c386443b16
4 changed files with 28 additions and 2 deletions

View file

@ -1842,3 +1842,22 @@ DO_VCMP_S(vcmpge, DO_GE)
DO_VCMP_S(vcmplt, DO_LT)
DO_VCMP_S(vcmpgt, DO_GT)
DO_VCMP_S(vcmple, DO_LE)
void HELPER(mve_vpsel)(CPUARMState *env, void *vd, void *vn, void *vm)
{
/*
* Qd[n] = VPR.P0[n] ? Qn[n] : Qm[n]
* but note that whether bytes are written to Qd is still subject
* to (all forms of) predication in the usual way.
*/
uint64_t *d = vd, *n = vn, *m = vm;
uint16_t mask = mve_element_mask(env);
uint16_t p0 = FIELD_EX32(env->v7m.vpr, V7M_VPR, P0);
unsigned e;
for (e = 0; e < 16 / 8; e++, mask >>= 8, p0 >>= 8) {
uint64_t r = m[H8(e)];
mergemask(&r, n[H8(e)], p0);
mergemask(&d[H8(e)], r, mask);
}
mve_advance_vpt(env);
}