From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37452) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZTuST-0002Xz-5y for qemu-devel@nongnu.org; Mon, 24 Aug 2015 12:18:54 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZTuSS-0002un-0y for qemu-devel@nongnu.org; Mon, 24 Aug 2015 12:18:53 -0400 Received: from mail-qg0-x234.google.com ([2607:f8b0:400d:c04::234]:36728) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZTuSR-0002uf-TD for qemu-devel@nongnu.org; Mon, 24 Aug 2015 12:18:51 -0400 Received: by qgeb6 with SMTP id b6so89605484qge.3 for ; Mon, 24 Aug 2015 09:18:51 -0700 (PDT) Sender: Richard Henderson From: Richard Henderson Date: Mon, 24 Aug 2015 09:17:36 -0700 Message-Id: <1440433079-14458-11-git-send-email-rth@twiddle.net> In-Reply-To: <1440433079-14458-1-git-send-email-rth@twiddle.net> References: <1440433079-14458-1-git-send-email-rth@twiddle.net> Subject: [Qemu-devel] [PATCH v14 10/33] target-tilegx: Add several helpers for instructions translation List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: walt@tilera.com, cmetcalf@ezchip.com, Chen Gang , xili_gchen_5257@hotmail.com, peter.maydell@linaro.org From: Chen Gang The related instructions are exception, cntlz, cnttz, shufflebytes. Signed-off-by: Chen Gang Message-Id: [rth: Remove incorrect implementation of add_saturate.] Signed-off-by: Richard Henderson --- 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..ea66da0 --- /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 + * + */ + +#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 |= ((src >> ((sel & 7) * 8)) & 0xff) << 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