[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v3 41/81] target/arm: Implement SVE2 ADDHNB, ADDHNT
From: |
Richard Henderson |
Subject: |
[PATCH v3 41/81] target/arm: Implement SVE2 ADDHNB, ADDHNT |
Date: |
Fri, 18 Sep 2020 11:37:11 -0700 |
From: Stephen Long <steplong@quicinc.com>
Signed-off-by: Stephen Long <steplong@quicinc.com>
Message-Id: <20200417162231.10374-2-steplong@quicinc.com>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
---
target/arm/helper-sve.h | 8 ++++++++
target/arm/sve.decode | 5 +++++
target/arm/sve_helper.c | 36 ++++++++++++++++++++++++++++++++++++
target/arm/translate-sve.c | 13 +++++++++++++
4 files changed, 62 insertions(+)
diff --git a/target/arm/helper-sve.h b/target/arm/helper-sve.h
index 4cd43d3ecc..5cf5473487 100644
--- a/target/arm/helper-sve.h
+++ b/target/arm/helper-sve.h
@@ -2509,6 +2509,14 @@ DEF_HELPER_FLAGS_3(sve2_uqrshrnt_h, TCG_CALL_NO_RWG,
void, ptr, ptr, i32)
DEF_HELPER_FLAGS_3(sve2_uqrshrnt_s, TCG_CALL_NO_RWG, void, ptr, ptr, i32)
DEF_HELPER_FLAGS_3(sve2_uqrshrnt_d, TCG_CALL_NO_RWG, void, ptr, ptr, i32)
+DEF_HELPER_FLAGS_4(sve2_addhnb_h, TCG_CALL_NO_RWG, void, ptr, ptr, ptr, i32)
+DEF_HELPER_FLAGS_4(sve2_addhnb_s, TCG_CALL_NO_RWG, void, ptr, ptr, ptr, i32)
+DEF_HELPER_FLAGS_4(sve2_addhnb_d, TCG_CALL_NO_RWG, void, ptr, ptr, ptr, i32)
+
+DEF_HELPER_FLAGS_4(sve2_addhnt_h, TCG_CALL_NO_RWG, void, ptr, ptr, ptr, i32)
+DEF_HELPER_FLAGS_4(sve2_addhnt_s, TCG_CALL_NO_RWG, void, ptr, ptr, ptr, i32)
+DEF_HELPER_FLAGS_4(sve2_addhnt_d, TCG_CALL_NO_RWG, void, ptr, ptr, ptr, i32)
+
DEF_HELPER_FLAGS_5(sve2_match_ppzz_b, TCG_CALL_NO_RWG,
i32, ptr, ptr, ptr, ptr, i32)
DEF_HELPER_FLAGS_5(sve2_match_ppzz_h, TCG_CALL_NO_RWG,
diff --git a/target/arm/sve.decode b/target/arm/sve.decode
index a03d6107da..af9e87e88d 100644
--- a/target/arm/sve.decode
+++ b/target/arm/sve.decode
@@ -1320,6 +1320,11 @@ UQSHRNT 01000101 .. 1 ..... 00 1101 ..... .....
@rd_rn_tszimm_shr
UQRSHRNB 01000101 .. 1 ..... 00 1110 ..... ..... @rd_rn_tszimm_shr
UQRSHRNT 01000101 .. 1 ..... 00 1111 ..... ..... @rd_rn_tszimm_shr
+## SVE2 integer add/subtract narrow high part
+
+ADDHNB 01000101 .. 1 ..... 011 000 ..... ..... @rd_rn_rm
+ADDHNT 01000101 .. 1 ..... 011 001 ..... ..... @rd_rn_rm
+
### SVE2 Character Match
MATCH 01000101 .. 1 ..... 100 ... ..... 0 .... @pd_pg_rn_rm
diff --git a/target/arm/sve_helper.c b/target/arm/sve_helper.c
index 10e3bd8415..6b1c0ad266 100644
--- a/target/arm/sve_helper.c
+++ b/target/arm/sve_helper.c
@@ -2111,6 +2111,42 @@ DO_SHRNT(sve2_uqrshrnt_d, uint64_t, uint32_t, ,
H1_4, DO_UQRSHRN_D)
#undef DO_SHRNB
#undef DO_SHRNT
+#define DO_BINOPNB(NAME, TYPEW, TYPEN, SHIFT, 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(TYPEW)) { \
+ TYPEW nn = *(TYPEW *)(vn + i); \
+ TYPEW mm = *(TYPEW *)(vm + i); \
+ *(TYPEW *)(vd + i) = (TYPEN)OP(nn, mm, SHIFT); \
+ } \
+}
+
+#define DO_BINOPNT(NAME, TYPEW, TYPEN, SHIFT, HW, HN, 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(TYPEW)) { \
+ TYPEW nn = *(TYPEW *)(vn + HW(i)); \
+ TYPEW mm = *(TYPEW *)(vm + HW(i)); \
+ *(TYPEN *)(vd + HN(i + sizeof(TYPEN))) = OP(nn, mm, SHIFT); \
+ } \
+}
+
+#define DO_ADDHN(N, M, SH) ((N + M) >> SH)
+
+DO_BINOPNB(sve2_addhnb_h, uint16_t, uint8_t, 8, DO_ADDHN)
+DO_BINOPNB(sve2_addhnb_s, uint32_t, uint16_t, 16, DO_ADDHN)
+DO_BINOPNB(sve2_addhnb_d, uint64_t, uint32_t, 32, DO_ADDHN)
+
+DO_BINOPNT(sve2_addhnt_h, uint16_t, uint8_t, 8, H1_2, H1, DO_ADDHN)
+DO_BINOPNT(sve2_addhnt_s, uint32_t, uint16_t, 16, H1_4, H1_2, DO_ADDHN)
+DO_BINOPNT(sve2_addhnt_d, uint64_t, uint32_t, 32, , H1_4, DO_ADDHN)
+
+#undef DO_ADDHN
+
+#undef DO_BINOPNB
+
/* Fully general four-operand expander, controlled by a predicate.
*/
#define DO_ZPZZZ(NAME, TYPE, H, OP) \
diff --git a/target/arm/translate-sve.c b/target/arm/translate-sve.c
index 5f4d879193..aa21aa49d0 100644
--- a/target/arm/translate-sve.c
+++ b/target/arm/translate-sve.c
@@ -7467,6 +7467,19 @@ static bool trans_UQRSHRNT(DisasContext *s, arg_rri_esz
*a)
return do_sve2_shr_narrow(s, a, ops);
}
+#define DO_SVE2_ZZZ_NARROW(NAME, name) \
+static bool trans_##NAME(DisasContext *s, arg_rrr_esz *a) \
+{ \
+ static gen_helper_gvec_3 * const fns[4] = { \
+ NULL, gen_helper_sve2_##name##_h, \
+ gen_helper_sve2_##name##_s, gen_helper_sve2_##name##_d, \
+ }; \
+ return do_sve2_zzz_ool(s, a, fns[a->esz]); \
+}
+
+DO_SVE2_ZZZ_NARROW(ADDHNB, addhnb)
+DO_SVE2_ZZZ_NARROW(ADDHNT, addhnt)
+
static bool do_sve2_ppzz_flags(DisasContext *s, arg_rprr_esz *a,
gen_helper_gvec_flags_4 *fn)
{
--
2.25.1
- [PATCH v3 29/81] target/arm: Implement SVE2 SHRN, RSHRN, (continued)
- [PATCH v3 29/81] target/arm: Implement SVE2 SHRN, RSHRN, Richard Henderson, 2020/09/18
- [PATCH v3 30/81] target/arm: Implement SVE2 SQSHRUN, SQRSHRUN, Richard Henderson, 2020/09/18
- [PATCH v3 31/81] target/arm: Implement SVE2 UQSHRN, UQRSHRN, Richard Henderson, 2020/09/18
- [PATCH v3 33/81] target/arm: Implement SVE2 WHILEGT, WHILEGE, WHILEHI, WHILEHS, Richard Henderson, 2020/09/18
- [PATCH v3 32/81] target/arm: Implement SVE2 SQSHRN, SQRSHRN, Richard Henderson, 2020/09/18
- [PATCH v3 34/81] target/arm: Implement SVE2 WHILERW, WHILEWR, Richard Henderson, 2020/09/18
- [PATCH v3 35/81] target/arm: Implement SVE2 bitwise ternary operations, Richard Henderson, 2020/09/18
- [PATCH v3 36/81] target/arm: Implement SVE2 MATCH, NMATCH, Richard Henderson, 2020/09/18
- [PATCH v3 37/81] target/arm: Implement SVE2 saturating multiply-add long, Richard Henderson, 2020/09/18
- [PATCH v3 40/81] target/arm: Implement SVE2 complex integer multiply-add, Richard Henderson, 2020/09/18
- [PATCH v3 41/81] target/arm: Implement SVE2 ADDHNB, ADDHNT,
Richard Henderson <=
- [PATCH v3 45/81] target/arm: Implement SVE2 HISTCNT, HISTSEG, Richard Henderson, 2020/09/18
- [PATCH v3 39/81] target/arm: Implement SVE2 integer multiply-add long, Richard Henderson, 2020/09/18
- [PATCH v3 38/81] target/arm: Implement SVE2 saturating multiply-add high, Richard Henderson, 2020/09/18
- [PATCH v3 42/81] target/arm: Implement SVE2 RADDHNB, RADDHNT, Richard Henderson, 2020/09/18
- [PATCH v3 46/81] target/arm: Implement SVE2 XAR, Richard Henderson, 2020/09/18
- [PATCH v3 47/81] target/arm: Implement SVE2 scatter store insns, Richard Henderson, 2020/09/18
- [PATCH v3 43/81] target/arm: Implement SVE2 SUBHNB, SUBHNT, Richard Henderson, 2020/09/18
- [PATCH v3 52/81] target/arm: Pass separate addend to FCMLA helpers, Richard Henderson, 2020/09/18
- [PATCH v3 56/81] target/arm: Implement SVE2 integer multiply-add (indexed), Richard Henderson, 2020/09/18
- [PATCH v3 48/81] target/arm: Implement SVE2 gather load insns, Richard Henderson, 2020/09/18