diff options
author | Song Gao <gaosong@loongson.cn> | 2023-09-14 10:26:09 +0800 |
---|---|---|
committer | Song Gao <gaosong@loongson.cn> | 2023-09-20 11:43:12 +0800 |
commit | ee7250d09171b3140e57671e79cd22770fed5106 (patch) | |
tree | 43bfca1a8dcbcf55ef5212dec0f93c63d96895fc /target/loongarch/vec_helper.c | |
parent | 85995f076aa89a43ddb80fc0f35793b4b6c06659 (diff) |
target/loongarch: Implement xavg/xvagr
This patch includes:
- XVAVG.{B/H/W/D/}[U];
- XVAVGR.{B/H/W/D}[U].
Signed-off-by: Song Gao <gaosong@loongson.cn>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Message-Id: <20230914022645.1151356-22-gaosong@loongson.cn>
Diffstat (limited to 'target/loongarch/vec_helper.c')
-rw-r--r-- | target/loongarch/vec_helper.c | 22 |
1 files changed, 12 insertions, 10 deletions
diff --git a/target/loongarch/vec_helper.c b/target/loongarch/vec_helper.c index fc3b07e8d2..35b207aae1 100644 --- a/target/loongarch/vec_helper.c +++ b/target/loongarch/vec_helper.c @@ -350,16 +350,18 @@ DO_ODD_U_S(vaddwod_d_wu_w, 64, D, UD, W, UW, DO_ADD) #define DO_VAVG(a, b) ((a >> 1) + (b >> 1) + (a & b & 1)) #define DO_VAVGR(a, b) ((a >> 1) + (b >> 1) + ((a | b) & 1)) -#define DO_3OP(NAME, BIT, E, DO_OP) \ -void HELPER(NAME)(void *vd, void *vj, void *vk, uint32_t v) \ -{ \ - int i; \ - VReg *Vd = (VReg *)vd; \ - VReg *Vj = (VReg *)vj; \ - VReg *Vk = (VReg *)vk; \ - for (i = 0; i < LSX_LEN/BIT; i++) { \ - Vd->E(i) = DO_OP(Vj->E(i), Vk->E(i)); \ - } \ +#define DO_3OP(NAME, BIT, E, DO_OP) \ +void HELPER(NAME)(void *vd, void *vj, void *vk, uint32_t desc) \ +{ \ + int i; \ + VReg *Vd = (VReg *)vd; \ + VReg *Vj = (VReg *)vj; \ + VReg *Vk = (VReg *)vk; \ + int oprsz = simd_oprsz(desc); \ + \ + for (i = 0; i < oprsz / (BIT / 8); i++) { \ + Vd->E(i) = DO_OP(Vj->E(i), Vk->E(i)); \ + } \ } DO_3OP(vavg_b, 8, B, DO_VAVG) |