mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-04 08:13:54 -06:00
target/arm: Implement MVE VQDMULL scalar
Implement the MVE VQDMULL scalar insn. This multiplies the top or bottom half of each element by the scalar, doubles and saturates to a double-width result. Note that this encoding overlaps with VQADD and VQSUB; it uses what in VQADD and VQSUB would be the 'size=0b11' encoding. Signed-off-by: Peter Maydell <peter.maydell@linaro.org> Reviewed-by: Richard Henderson <richard.henderson@linaro.org> Message-id: 20210617121628.20116-30-peter.maydell@linaro.org
This commit is contained in:
parent
66c0576754
commit
a88903537d
4 changed files with 119 additions and 4 deletions
|
@ -610,6 +610,71 @@ DO_2OP_SAT_SCALAR(vqrdmulh_scalarb, 1, int8_t, DO_QRDMULH_B)
|
|||
DO_2OP_SAT_SCALAR(vqrdmulh_scalarh, 2, int16_t, DO_QRDMULH_H)
|
||||
DO_2OP_SAT_SCALAR(vqrdmulh_scalarw, 4, int32_t, DO_QRDMULH_W)
|
||||
|
||||
/*
|
||||
* Long saturating scalar ops. As with DO_2OP_L, TYPE and H are for the
|
||||
* input (smaller) type and LESIZE, LTYPE, LH for the output (long) type.
|
||||
* SATMASK specifies which bits of the predicate mask matter for determining
|
||||
* whether to propagate a saturation indication into FPSCR.QC -- for
|
||||
* the 16x16->32 case we must check only the bit corresponding to the T or B
|
||||
* half that we used, but for the 32x32->64 case we propagate if the mask
|
||||
* bit is set for either half.
|
||||
*/
|
||||
#define DO_2OP_SAT_SCALAR_L(OP, TOP, ESIZE, TYPE, LESIZE, LTYPE, FN, SATMASK) \
|
||||
void HELPER(glue(mve_, OP))(CPUARMState *env, void *vd, void *vn, \
|
||||
uint32_t rm) \
|
||||
{ \
|
||||
LTYPE *d = vd; \
|
||||
TYPE *n = vn; \
|
||||
TYPE m = rm; \
|
||||
uint16_t mask = mve_element_mask(env); \
|
||||
unsigned le; \
|
||||
bool qc = false; \
|
||||
for (le = 0; le < 16 / LESIZE; le++, mask >>= LESIZE) { \
|
||||
bool sat = false; \
|
||||
LTYPE r = FN((LTYPE)n[H##ESIZE(le * 2 + TOP)], m, &sat); \
|
||||
mergemask(&d[H##LESIZE(le)], r, mask); \
|
||||
qc |= sat && (mask & SATMASK); \
|
||||
} \
|
||||
if (qc) { \
|
||||
env->vfp.qc[0] = qc; \
|
||||
} \
|
||||
mve_advance_vpt(env); \
|
||||
}
|
||||
|
||||
static inline int32_t do_qdmullh(int16_t n, int16_t m, bool *sat)
|
||||
{
|
||||
int64_t r = ((int64_t)n * m) * 2;
|
||||
return do_sat_bhw(r, INT32_MIN, INT32_MAX, sat);
|
||||
}
|
||||
|
||||
static inline int64_t do_qdmullw(int32_t n, int32_t m, bool *sat)
|
||||
{
|
||||
/* The multiply can't overflow, but the doubling might */
|
||||
int64_t r = (int64_t)n * m;
|
||||
if (r > INT64_MAX / 2) {
|
||||
*sat = true;
|
||||
return INT64_MAX;
|
||||
} else if (r < INT64_MIN / 2) {
|
||||
*sat = true;
|
||||
return INT64_MIN;
|
||||
} else {
|
||||
return r * 2;
|
||||
}
|
||||
}
|
||||
|
||||
#define SATMASK16B 1
|
||||
#define SATMASK16T (1 << 2)
|
||||
#define SATMASK32 ((1 << 4) | 1)
|
||||
|
||||
DO_2OP_SAT_SCALAR_L(vqdmullb_scalarh, 0, 2, int16_t, 4, int32_t, \
|
||||
do_qdmullh, SATMASK16B)
|
||||
DO_2OP_SAT_SCALAR_L(vqdmullb_scalarw, 0, 4, int32_t, 8, int64_t, \
|
||||
do_qdmullw, SATMASK32)
|
||||
DO_2OP_SAT_SCALAR_L(vqdmullt_scalarh, 1, 2, int16_t, 4, int32_t, \
|
||||
do_qdmullh, SATMASK16T)
|
||||
DO_2OP_SAT_SCALAR_L(vqdmullt_scalarw, 1, 4, int32_t, 8, int64_t, \
|
||||
do_qdmullw, SATMASK32)
|
||||
|
||||
static inline uint32_t do_vbrsrb(uint32_t n, uint32_t m)
|
||||
{
|
||||
m &= 0xff;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue