From patchwork Thu Sep 3 01:31:02 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 513761 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 01B791402A9 for ; Thu, 3 Sep 2015 11:41:48 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b=EkXYg0X/; dkim-atps=neutral Received: from localhost ([::1]:43269 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZXJX7-0005iV-HX for incoming@patchwork.ozlabs.org; Wed, 02 Sep 2015 21:41:45 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:47986) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZXJNO-0005zH-T2 for qemu-devel@nongnu.org; Wed, 02 Sep 2015 21:31:43 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZXJNK-0002JL-Qs for qemu-devel@nongnu.org; Wed, 02 Sep 2015 21:31:42 -0400 Received: from mail-pa0-x22c.google.com ([2607:f8b0:400e:c03::22c]:33882) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZXJNK-0002Iz-JT for qemu-devel@nongnu.org; Wed, 02 Sep 2015 21:31:38 -0400 Received: by padhy1 with SMTP id hy1so28877853pad.1 for ; Wed, 02 Sep 2015 18:31:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=QmddycUEw1V8tXc8KqLFGNDOvufTd1q0MRwFmsX326I=; b=EkXYg0X/+4bbt7HeJQLD38idS4ZCOY2cFjQ/dh0dvRgHGJvU9akntrjJF5pO686Alh Md8idMtwKTS7TrcMigbMPgzefK5XNej7u66IiCVl1+/OomS7IRDtR+wfuVtV0rUQQl8v R6D9b8GiaCbqCygqDBvrYE+rubK+eADw03rOcz4rqdJKEYG4F3+oUDSgxujbO0UCBWnK t5BZ0C7HYZSQaV+0mhk+22PHrTG41D5K0th8Po6zmxa8OQJCcOVXUN1Dycl39d7HhQMI rxaJvcpNtMO+3ZKp+DDoiX8v9S6mXgi2nOO+1TFky5xU2blZ/Tt6X3InF8UGZNkXHpze Mb6A== X-Received: by 10.68.248.102 with SMTP id yl6mr62508456pbc.66.1441243897921; Wed, 02 Sep 2015 18:31:37 -0700 (PDT) Received: from bigtime.twiddle.net (50-194-63-110-static.hfc.comcastbusiness.net. [50.194.63.110]) by smtp.gmail.com with ESMTPSA id kz8sm23209851pab.6.2015.09.02.18.31.37 (version=TLSv1/SSLv3 cipher=OTHER); Wed, 02 Sep 2015 18:31:37 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Wed, 2 Sep 2015 18:31:02 -0700 Message-Id: <1441243885-7495-11-git-send-email-rth@twiddle.net> X-Mailer: git-send-email 2.4.3 In-Reply-To: <1441243885-7495-1-git-send-email-rth@twiddle.net> References: <1441243885-7495-1-git-send-email-rth@twiddle.net> X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2607:f8b0:400e:c03::22c Cc: peter.maydell@linaro.org, Chen Gang , Chen Gang Subject: [Qemu-devel] [PATCH v15 10/33] target-tilegx: Add several helpers for instructions translation X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org From: Chen Gang The related instructions are exception, cntlz, cnttz, shufflebytes. Reviewed-by: Peter Maydell 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..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 + * + */ + +#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)