Skip to contentSkip to conversation

target-tilegx: Implement v*add and v*sub instructions

PATCH New [email protected] 1 participant 1 message Sep 22, 2015

lore
Share & tools
lore
#0 lore raw

PATCH v3 1/1 target-tilegx: Implement v*add and v*sub instructions

From: Chen Gang <[email protected]>

v4* are implemented in normal code, another are implemented in helper functions.

---
 target-tilegx/helper.h      |  5 +++++
 target-tilegx/simd_helper.c | 23 +++++++++++++++++++++++
 target-tilegx/translate.c   | 46 +++++++++++++++++++++++++++++++++++++++++++--
 3 files changed, 72 insertions(+), 2 deletions(-)
target-tilegx/helper.h +5 -0
index b253722..6d98f3a 100644
@@ -11,3 +11,8 @@ DEF_HELPER_FLAGS_2(v1shrs, TCG_CALL_NO_RWG_SE, i64, i64, i64)
 DEF_HELPER_FLAGS_2(v2shl, TCG_CALL_NO_RWG_SE, i64, i64, i64)
 DEF_HELPER_FLAGS_2(v2shru, TCG_CALL_NO_RWG_SE, i64, i64, i64)
 DEF_HELPER_FLAGS_2(v2shrs, TCG_CALL_NO_RWG_SE, i64, i64, i64)
+
+DEF_HELPER_FLAGS_2(v1add, TCG_CALL_NO_RWG_SE, i64, i64, i64)
+DEF_HELPER_FLAGS_2(v1sub, TCG_CALL_NO_RWG_SE, i64, i64, i64)
+DEF_HELPER_FLAGS_2(v2add, TCG_CALL_NO_RWG_SE, i64, i64, i64)
+DEF_HELPER_FLAGS_2(v2sub, TCG_CALL_NO_RWG_SE, i64, i64, i64)
target-tilegx/simd_helper.c +23 -0
index c03e31a..1cc9620 100644
@@ -22,6 +22,29 @@
 #include "qemu-common.h"
 #include "exec/helper-proto.h"
 
+uint64_t helper_v1add(uint64_t a, uint64_t b)
+{
+    return ((a & 0x7f7f7f7f7f7f7f7fULL) + (b & 0x7f7f7f7f7f7f7f7fULL))
+           ^ ((a ^ b) & 0x8080808080808080ULL);
+}
+
+uint64_t helper_v1sub(uint64_t a, uint64_t b)
+{
+    return ((a | 0x8080808080808080ULL) - (b & 0x7f7f7f7f7f7f7f7fULL))
+           ^ ((a ^ ~b) & 0x8080808080808080ULL);
+}
+
+uint64_t helper_v2add(uint64_t a, uint64_t b)
+{
+    return ((a & 0x7fff7fff7fff7fffULL) + (b & 0x7fff7fff7fff7fffULL))
+           ^ ((a ^ b) & 0x8000800080008000ULL);
+}
+
+uint64_t helper_v2sub(uint64_t a, uint64_t b)
+{
+    return ((a | 0x8000800080008000ULL) - (b & 0x7fff7fff7fff7fffULL))
+           ^ ((a ^ ~b) & 0x8000800080008000ULL);
+}
 
 uint64_t helper_v1shl(uint64_t a, uint64_t b)
 {
target-tilegx/translate.c +44 -2

92 lines not on this page · raw message

Signature · 1 line
1.9.3