[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL 10/35] target-tilegx: Add several helpers for instruc
From: |
Richard Henderson |
Subject: |
[Qemu-devel] [PULL 10/35] target-tilegx: Add several helpers for instructions translation |
Date: |
Tue, 15 Sep 2015 08:03:48 -0700 |
From: Chen Gang <address@hidden>
The related instructions are exception, cntlz, cnttz, shufflebytes.
Reviewed-by: Peter Maydell <address@hidden>
Signed-off-by: Chen Gang <address@hidden>
Message-Id: <address@hidden>
[rth: Remove incorrect implementation of add_saturate.]
Signed-off-by: Richard Henderson <address@hidden>
---
target-tilegx/helper.c | 70 ++++++++++++++++++++++++++++++++++++++++++++++++++
target-tilegx/helper.h | 4 +++
2 files changed, 74 insertions(+)
create mode 100644 target-tilegx/helper.c
create mode 100644 target-tilegx/helper.h
diff --git a/target-tilegx/helper.c b/target-tilegx/helper.c
new file mode 100644
index 0000000..5b37a8c
--- /dev/null
+++ b/target-tilegx/helper.c
@@ -0,0 +1,70 @@
+/*
+ * QEMU TILE-Gx helpers
+ *
+ * Copyright (c) 2015 Chen Gang
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, see
+ * <http://www.gnu.org/licenses/lgpl-2.1.html>
+ */
+
+#include "cpu.h"
+#include "qemu-common.h"
+#include "exec/helper-proto.h"
+
+void helper_exception(CPUTLGState *env, uint32_t excp)
+{
+ CPUState *cs = CPU(tilegx_env_get_cpu(env));
+
+ cs->exception_index = excp;
+ cpu_loop_exit(cs);
+}
+
+uint64_t helper_cntlz(uint64_t arg)
+{
+ return clz64(arg);
+}
+
+uint64_t helper_cnttz(uint64_t arg)
+{
+ return ctz64(arg);
+}
+
+/*
+ * Functional Description
+ * uint64_t a = rf[SrcA];
+ * uint64_t b = rf[SrcB];
+ * uint64_t d = rf[Dest];
+ * uint64_t output = 0;
+ * unsigned int counter;
+ * for (counter = 0; counter < (WORD_SIZE / BYTE_SIZE); counter++)
+ * {
+ * int sel = getByte (b, counter) & 0xf;
+ * uint8_t byte = (sel < 8) ? getByte (d, sel) : getByte (a, (sel -
8));
+ * output = setByte (output, counter, byte);
+ * }
+ * rf[Dest] = output;
+ */
+uint64_t helper_shufflebytes(uint64_t dest, uint64_t srca, uint64_t srcb)
+{
+ uint64_t vdst = 0;
+ int count;
+
+ for (count = 0; count < 64; count += 8) {
+ uint64_t sel = srcb >> count;
+ uint64_t src = (sel & 8) ? srca : dest;
+ vdst |= extract64(src, (sel & 7) * 8, 8) << count;
+ }
+
+ return vdst;
+}
diff --git a/target-tilegx/helper.h b/target-tilegx/helper.h
new file mode 100644
index 0000000..fd5517e
--- /dev/null
+++ b/target-tilegx/helper.h
@@ -0,0 +1,4 @@
+DEF_HELPER_2(exception, noreturn, env, i32)
+DEF_HELPER_FLAGS_1(cntlz, TCG_CALL_NO_RWG_SE, i64, i64)
+DEF_HELPER_FLAGS_1(cnttz, TCG_CALL_NO_RWG_SE, i64, i64)
+DEF_HELPER_FLAGS_3(shufflebytes, TCG_CALL_NO_RWG_SE, i64, i64, i64, i64)
--
2.4.3
- [Qemu-devel] [PULL 03/35] linux-user: Conditionalize syscalls which are not defined in tilegx, (continued)
- [Qemu-devel] [PULL 03/35] linux-user: Conditionalize syscalls which are not defined in tilegx, Richard Henderson, 2015/09/15
- [Qemu-devel] [PULL 04/35] target-tilegx: Add opcode basic implementation from Tilera Corporation, Richard Henderson, 2015/09/15
- [Qemu-devel] [PULL 07/35] target-tilegx: Fix LDNA_ADD_IMM8_OPCODE_X1, Richard Henderson, 2015/09/15
- [Qemu-devel] [PULL 01/35] linux-user: tilegx: Add architecture related features, Richard Henderson, 2015/09/15
- [Qemu-devel] [PULL 06/35] target-tilegx: Modify _SPECIAL_ opcodes, Richard Henderson, 2015/09/15
- [Qemu-devel] [PULL 05/35] target-tilegx: Modify opcode_tilegx.h to fit QEMU usage, Richard Henderson, 2015/09/15
- [Qemu-devel] [PULL 09/35] target-tilegx: Add cpu basic features for linux-user, Richard Henderson, 2015/09/15
- [Qemu-devel] [PULL 12/35] target-tilegx: Generate SEGV properly, Richard Henderson, 2015/09/15
- [Qemu-devel] [PULL 08/35] target-tilegx: Add special register information from Tilera Corporation, Richard Henderson, 2015/09/15
- [Qemu-devel] [PULL 13/35] target-tilegx: Add TILE-Gx building files, Richard Henderson, 2015/09/15
- [Qemu-devel] [PULL 10/35] target-tilegx: Add several helpers for instructions translation,
Richard Henderson <=
- [Qemu-devel] [PULL 17/35] target-arm: Use new revbit functions, Richard Henderson, 2015/09/15
- [Qemu-devel] [PULL 16/35] host-utils: Add revbit functions, Richard Henderson, 2015/09/15
- [Qemu-devel] [PULL 15/35] target-tilegx: Handle arithmetic instructions, Richard Henderson, 2015/09/15
- [Qemu-devel] [PULL 22/35] target-tilegx: Handle conditional branch instructions, Richard Henderson, 2015/09/15
- [Qemu-devel] [PULL 18/35] target-tilegx: Handle most bit manipulation instructions, Richard Henderson, 2015/09/15
- [Qemu-devel] [PULL 20/35] target-tilegx: Handle post-increment load and store instructions, Richard Henderson, 2015/09/15
- [Qemu-devel] [PULL 11/35] target-tilegx: Framework for decoding bundles, Richard Henderson, 2015/09/15
- [Qemu-devel] [PULL 23/35] target-tilegx: Handle comparison instructions, Richard Henderson, 2015/09/15
- [Qemu-devel] [PULL 19/35] target-tilegx: Handle basic load and store instructions, Richard Henderson, 2015/09/15