From patchwork Tue Feb 12 04:57:06 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 158071 Delivered-To: patch@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp3415168jaa; Mon, 11 Feb 2019 21:03:52 -0800 (PST) X-Google-Smtp-Source: AHgI3IbrthWreZkZhcaBDvrURW4ij4yfY4W+tekACLlBSTH6v0pN+7jvHK45ftLu0kgd+WFlrG6G X-Received: by 2002:a81:7852:: with SMTP id t79mr1338990ywc.432.1549947832058; Mon, 11 Feb 2019 21:03:52 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1549947832; cv=none; d=google.com; s=arc-20160816; b=am5hqD/GcR2XMOhMKmVIVSdPuJvHnRujfGtcoCOxnylVQkt2f4r/PdjkIDe9s1dxAK /IPn+ESD9meSbImsDRSkyfmWrnbtpqPJ85eKY6R+zNXIr34b2QK/kSWcPSxg5QxV2KbQ Sax4BImlFP0FrOkCK1WJa+iJe6VRRq2sS9oeLPJajC1jFaKaJGWdlqxVtX9xrjVcwZRV yUoEzwOB+t9PiuRh47/ZAJto+ZVryrpyIdXgP6cRkvdQToug/0W1Q+IUuKP2plwE6q1c cmiDMwpHIKwyF7uqPHpZB6zyRo9rcqBLDz1cpIbSPenSd7mK/YiC/DI3ECPcK+fOIywe m4CQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:references:in-reply-to :message-id:date:to:from:dkim-signature; bh=6tbhahyqg98K1x+3k/hxRj80Xkv0C+uJ9sa5cUUmxjM=; b=jFxhgiX+rvAFAVMJ+4ySJCa9Z3Z6z1aM8fm7UeZ5LfIl7ieLf2GO2Of3nqE9g61wCb 08RuoJUlhD/V7FhBArBmXdOEyxt7Kugl5JlPOHcTfB0AfIugIr/Z/KxEDzHPn0sBybZD GzSQFX2a4OCNxc2jNJ52Jdq3QzlBeQzW9ntif3AJVXLGrHtoLqLfE+EZ2/2qnHx0VBM5 YPpZFlP9cZJWIa1dknsYpHt14K26qMepcljxJASRJIq2w/6UL+tKXw+PN1QSE7mCSyAN 1Yys9ht1NqKzwSe4bgpTIEl9Bbq/EhufLzBtF4wJbOGVq83K7XESBV6LgDdznWPeHl8k xQeA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=wSMTzZ2f; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id h2si7026437ybh.459.2019.02.11.21.03.51 for (version=TLS1 cipher=AES128-SHA bits=128/128); Mon, 11 Feb 2019 21:03:52 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=wSMTzZ2f; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([127.0.0.1]:33154 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gtQEZ-0006D6-GN for patch@linaro.org; Tue, 12 Feb 2019 00:03:51 -0500 Received: from eggs.gnu.org ([209.51.188.92]:49343) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gtQ8n-0002Xy-AA for qemu-devel@nongnu.org; Mon, 11 Feb 2019 23:57:57 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gtQ8l-0001mD-37 for qemu-devel@nongnu.org; Mon, 11 Feb 2019 23:57:52 -0500 Received: from mail-pl1-x635.google.com ([2607:f8b0:4864:20::635]:38694) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gtQ8e-0001bf-Cw for qemu-devel@nongnu.org; Mon, 11 Feb 2019 23:57:46 -0500 Received: by mail-pl1-x635.google.com with SMTP id e5so690842plb.5 for ; Mon, 11 Feb 2019 20:57:36 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=6tbhahyqg98K1x+3k/hxRj80Xkv0C+uJ9sa5cUUmxjM=; b=wSMTzZ2fifLAKTru9Ef0Nc7J9Kg6ebOrjpZhsNZMKfzsp38vPFFX0uzlGyHj+0h3SG ycatbMKuozzR9cfen3yDvMEvN4KhXoTxUncglE0gLvRlA97olDwKkSsr+1VEkVRBavGD LzCYdQdxS2cA15TKgyl0kt4iAefpRxYltBillge0bVLc2WfN0sadrVF6gXxlcpDMFKun 5OIIulUlRzsmpFcI5fY1l+dIScJA9MtQ2oIju6VlRMqvGFaG37yqS7kfmVi+rnbEFFvz UzKheDxhuxW6+uTRvsHedA1e9/khmT/nI6/iWMRdhu0FXZ8+fUfo7sACs8J6fpSV1g78 5Q9g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=6tbhahyqg98K1x+3k/hxRj80Xkv0C+uJ9sa5cUUmxjM=; b=I/oaqIdRNjarkrVALWXsOGx8OwpCdP05tuix8KgVc5QqS4dGRniQkWlmkE9sdaUNw4 K1pf/hPSRcOyhgDdCxJ2JMpQQQB1yJKq8kqLz0PBOjZaRqR7FGyGGG6ysCUtc5pEZCaM 5t7RHWJtQk6NF1SYuUURc6y/Pp5WHnqyOJNHkV0UFcEaEwtsnt5GPWrGvjtQLy/BClHo teBC7pwnxzoBJAk/GDP+4GpvZppCIJ3ofyxrJJOg2xmpiTJ692vMbC0Hw2sUWRPO/e0k hzwsO+0zqMsAtl6dNwKwrRVTIp3tyb5TEsIx0scUvHVxcY+d2Z8T9/3dzsIbrCYOW47L mYzg== X-Gm-Message-State: AHQUAuYCyl0ZnGFsm0xWhM2N9uBXtNIyNB3ozS4vG5TvqHQeEetbMBHm B7XQgIYpeM+Pc92XsrPg0lJ4YyF68EU= X-Received: by 2002:a17:902:24a2:: with SMTP id w31mr2078242pla.216.1549947454851; Mon, 11 Feb 2019 20:57:34 -0800 (PST) Received: from cloudburst.twiddle.net (97-113-188-82.tukw.qwest.net. [97.113.188.82]) by smtp.gmail.com with ESMTPSA id a90sm22088923pfj.109.2019.02.11.20.57.33 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 11 Feb 2019 20:57:33 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Date: Mon, 11 Feb 2019 20:57:06 -0800 Message-Id: <20190212045721.28041-10-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.2 In-Reply-To: <20190212045721.28041-1-richard.henderson@linaro.org> References: <20190212045721.28041-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::635 Subject: [Qemu-devel] [PULL 09/24] target/hppa: Convert fp multiply-add X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: peter.maydell@linaro.org Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Tested-by: Helge Deller Tested-by: Sven Schnelle Signed-off-by: Richard Henderson --- target/hppa/translate.c | 69 +++++++++++++++++++++++----------------- target/hppa/insns.decode | 12 +++++++ 2 files changed, 52 insertions(+), 29 deletions(-) -- 2.17.2 diff --git a/target/hppa/translate.c b/target/hppa/translate.c index 822d93fb23..2f4a50e113 100644 --- a/target/hppa/translate.c +++ b/target/hppa/translate.c @@ -4255,37 +4255,54 @@ static inline int fmpyadd_s_reg(unsigned r) return (r & 16) * 2 + 16 + (r & 15); } -static bool trans_fmpyadd(DisasContext *ctx, uint32_t insn, bool is_sub) +static bool do_fmpyadd_s(DisasContext *ctx, arg_mpyadd *a, bool is_sub) { - unsigned tm = extract32(insn, 0, 5); - unsigned f = extract32(insn, 5, 1); - unsigned ra = extract32(insn, 6, 5); - unsigned ta = extract32(insn, 11, 5); - unsigned rm2 = extract32(insn, 16, 5); - unsigned rm1 = extract32(insn, 21, 5); + int tm = fmpyadd_s_reg(a->tm); + int ra = fmpyadd_s_reg(a->ra); + int ta = fmpyadd_s_reg(a->ta); + int rm2 = fmpyadd_s_reg(a->rm2); + int rm1 = fmpyadd_s_reg(a->rm1); nullify_over(ctx); - /* Independent multiply & add/sub, with undefined behaviour - if outputs overlap inputs. */ - if (f == 0) { - tm = fmpyadd_s_reg(tm); - ra = fmpyadd_s_reg(ra); - ta = fmpyadd_s_reg(ta); - rm2 = fmpyadd_s_reg(rm2); - rm1 = fmpyadd_s_reg(rm1); - do_fop_weww(ctx, tm, rm1, rm2, gen_helper_fmpy_s); - do_fop_weww(ctx, ta, ta, ra, - is_sub ? gen_helper_fsub_s : gen_helper_fadd_s); - } else { - do_fop_dedd(ctx, tm, rm1, rm2, gen_helper_fmpy_d); - do_fop_dedd(ctx, ta, ta, ra, - is_sub ? gen_helper_fsub_d : gen_helper_fadd_d); - } + do_fop_weww(ctx, tm, rm1, rm2, gen_helper_fmpy_s); + do_fop_weww(ctx, ta, ta, ra, + is_sub ? gen_helper_fsub_s : gen_helper_fadd_s); return nullify_end(ctx); } +static bool trans_fmpyadd_f(DisasContext *ctx, arg_mpyadd *a) +{ + return do_fmpyadd_s(ctx, a, false); +} + +static bool trans_fmpysub_f(DisasContext *ctx, arg_mpyadd *a) +{ + return do_fmpyadd_s(ctx, a, true); +} + +static bool do_fmpyadd_d(DisasContext *ctx, arg_mpyadd *a, bool is_sub) +{ + nullify_over(ctx); + + do_fop_dedd(ctx, a->tm, a->rm1, a->rm2, gen_helper_fmpy_d); + do_fop_dedd(ctx, a->ta, a->ta, a->ra, + is_sub ? gen_helper_fsub_d : gen_helper_fadd_d); + + return nullify_end(ctx); +} + +static bool trans_fmpyadd_d(DisasContext *ctx, arg_mpyadd *a) +{ + return do_fmpyadd_d(ctx, a, false); +} + +static bool trans_fmpysub_d(DisasContext *ctx, arg_mpyadd *a) +{ + return do_fmpyadd_d(ctx, a, true); +} + static bool trans_fmpyfadd_s(DisasContext *ctx, uint32_t insn, const DisasInsn *di) { @@ -4376,9 +4393,6 @@ static void translate_one(DisasContext *ctx, uint32_t insn) opc = extract32(insn, 26, 6); switch (opc) { - case 0x06: - trans_fmpyadd(ctx, insn, false); - return; case 0x08: trans_ldil(ctx, insn); return; @@ -4456,9 +4470,6 @@ static void translate_one(DisasContext *ctx, uint32_t insn) case 0x25: trans_subi(ctx, insn); return; - case 0x26: - trans_fmpyadd(ctx, insn, true); - return; case 0x27: trans_cmpb(ctx, insn, true, false, true); return; diff --git a/target/hppa/insns.decode b/target/hppa/insns.decode index 38f5fb6be2..16a999b05f 100644 --- a/target/hppa/insns.decode +++ b/target/hppa/insns.decode @@ -153,3 +153,15 @@ lda 000011 ..... ..... .. . 1 -- 0110 ...... @ldim5 size=2 lda 000011 ..... ..... .. . 0 -- 0110 ...... @ldstx size=2 sta 000011 ..... ..... .. . 1 -- 1110 ...... @stim5 size=2 stby 000011 b:5 r:5 sp:2 a:1 1 -- 1100 m:1 ..... disp=%im5_0 + +#### +# Floating-point Multiply Add +#### + +&mpyadd rm1 rm2 ta ra tm +@mpyadd ...... rm1:5 rm2:5 ta:5 ra:5 . tm:5 &mpyadd + +fmpyadd_f 000110 ..... ..... ..... ..... 0 ..... @mpyadd +fmpyadd_d 000110 ..... ..... ..... ..... 1 ..... @mpyadd +fmpysub_f 100110 ..... ..... ..... ..... 0 ..... @mpyadd +fmpysub_d 100110 ..... ..... ..... ..... 1 ..... @mpyadd