From patchwork Wed Aug 8 12:39:32 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 143620 Delivered-To: patch@linaro.org Received: by 2002:a2e:9754:0:0:0:0:0 with SMTP id f20-v6csp795443ljj; Wed, 8 Aug 2018 06:00:46 -0700 (PDT) X-Google-Smtp-Source: AA+uWPzyWY5d+c9c9t1071OmbkJIL4P4Qn3H57B3MmYBJPLndLGLLDIDxro94ImmHIlaYCZFrU3m X-Received: by 2002:aed:2496:: with SMTP id t22-v6mr2481445qtc.44.1533733246081; Wed, 08 Aug 2018 06:00:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1533733246; cv=none; d=google.com; s=arc-20160816; b=iYeYvBxX/LvTqhzZpCuUp+aB2m36h9Pd1thnttm+RnxqMv6rLXRS4SEXTBUNhymNmT MOm/8PvXAXRIQ11ACXilyWB01KGTwoF0UGGfUw3VolbXrynCp8lHduyeR3UAung3Gdvb rqP0IaMxUE6wJNQN/ZO1+FsvlqkUHCDdPAFkEcQ0Q1d6LRry9ZRCEQFaFB8lfrB+ACUL pOfHQC8NK14B63r8Q2h9IVDzf0W9Ktrjiw4nKtlW4EpL46HRAYAIaQWUu+8U0SMwIvJK OshbDjO0JIdYsCwOuLWNxHpfAqrvEuOZg3maRhtpBnoMY4dfD8/54J2TjX7ZOChfeNqI 9d5Q== 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 :content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:to:from:dkim-signature:arc-authentication-results; bh=kjYXopRY/Y8xZE7P4nvS2g/cTAbh5sRmsKoa7mkiFvk=; b=kIPalo5OG2uIphejH1XEMqwNwcefEDWP1eilaIJaLMOLcvguCgbnzKEj7XySnj9kg5 g7ng4g+b5iEqb4OxgJ52ch7PMK/wYjycO6EID2oehSo17M7qlz92OI2RyHTb9kFWcfF0 dru359DXHA7X1vasLs3Q1AL6nsEY+wz5w++/jYgvwHlR2qyMQPT2UdvEIoLOmmik1My/ iCXQInL80lihOHFs7E+p4LwOGur/LnsvD1cnqSOz8E5jWYN3aO1b1Izy3/NUpH11hMD3 KZemRRWgpZlPM0vGYCEYLpyRRwLNXgXkIK9nPpuKtaZ6+45TXd6XHeuzhbOlWtm0khKt NNng== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b="fwLUDz+/"; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 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. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id v21-v6si4020536qtc.391.2018.08.08.06.00.45 for (version=TLS1 cipher=AES128-SHA bits=128/128); Wed, 08 Aug 2018 06:00:46 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b="fwLUDz+/"; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 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 ([::1]:43566 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fnO4z-00059f-Ex for patch@linaro.org; Wed, 08 Aug 2018 09:00:45 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:35413) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fnNka-0004Vs-AJ for qemu-devel@nongnu.org; Wed, 08 Aug 2018 08:39:42 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fnNkY-0006tP-F5 for qemu-devel@nongnu.org; Wed, 08 Aug 2018 08:39:40 -0400 Received: from mail-wr1-x441.google.com ([2a00:1450:4864:20::441]:35933) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fnNkY-0006rR-77 for qemu-devel@nongnu.org; Wed, 08 Aug 2018 08:39:38 -0400 Received: by mail-wr1-x441.google.com with SMTP id h9-v6so1906780wro.3 for ; Wed, 08 Aug 2018 05:39:38 -0700 (PDT) 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 :mime-version:content-transfer-encoding; bh=kjYXopRY/Y8xZE7P4nvS2g/cTAbh5sRmsKoa7mkiFvk=; b=fwLUDz+/JpztsP+YCKvmWUnYPoC86GI0FeN+CXmuHGOpITak5Jx5ioV18xNskY544A pNNVdIWvzK6bWU2ibkftYvswMA6nAs8CUUzL7N6DKLIpXome2IP/cKR7WndL393/97VB /Vi/zyT6nXxCV3nOLgTSRlA9wGpXS3GfcGnC0= 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:mime-version:content-transfer-encoding; bh=kjYXopRY/Y8xZE7P4nvS2g/cTAbh5sRmsKoa7mkiFvk=; b=awWM7/DjXr8aFiguLxt1+tFZ5D/XpleobMGiaC3gMrSkNmb8s4+PceMxr0UVwgjjmY 66YtWETlfipTMssVXzldI/tXm49M8yfWLUQBiA5iQA+YXfZgmf6n6YUZJCCSELFTPPLj 3RqTFxiS0+cSIWfzpSb1V9B818wUmZxEwpelglcgrhPFfqEkKW2AqQ3mfPz3AWeqOCHU CXXhuANZ3cmJkRYR1E7zLKjvGakvJFWFHvEqSkkszk5n7LHcOylHi6zSQ5X7Bfd/CD2j 7MBvhbCB8d3f4UwCZQP62vhA+uYIP7HY4RDRf8UCQ4VDxzF5JEz1stcVD82mUfysgwZI dB9g== X-Gm-Message-State: AOUpUlGBaM+YSfBpFYzeYahEPL9/MxAR5Tr6dLGnJ3jtoQkgdU7Vt7dI 8p7aD51BeCuQIqx70LIGMDyMlA== X-Received: by 2002:adf:90e9:: with SMTP id i96-v6mr1956494wri.146.1533731977048; Wed, 08 Aug 2018 05:39:37 -0700 (PDT) Received: from zen.linaro.local ([81.128.185.34]) by smtp.gmail.com with ESMTPSA id u14-v6sm4703438wrs.57.2018.08.08.05.39.34 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 08 Aug 2018 05:39:35 -0700 (PDT) Received: from zen.linaroharston (localhost [127.0.0.1]) by zen.linaro.local (Postfix) with ESMTP id 7B49B3E061C; Wed, 8 Aug 2018 13:39:34 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Date: Wed, 8 Aug 2018 13:39:32 +0100 Message-Id: <20180808123934.17450-3-alex.bennee@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180808123934.17450-1-alex.bennee@linaro.org> References: <20180808123934.17450-1-alex.bennee@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::441 Subject: [Qemu-devel] [RFC PATCH 2/4] target/arm: move decoder helpers into header 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: =?utf-8?q?Alex_Benn=C3=A9e?= , qemu-arm@nongnu.org, richard.henderson@linaro.org, Peter Maydell Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" We want to re-use these helpers. Signed-off-by: Alex Bennée --- target/arm/decoder.h | 50 ++++++++++++++++++++++++++++++++++++++ target/arm/translate-sve.c | 50 +------------------------------------- 2 files changed, 51 insertions(+), 49 deletions(-) create mode 100644 target/arm/decoder.h -- 2.17.1 diff --git a/target/arm/decoder.h b/target/arm/decoder.h new file mode 100644 index 0000000000..09a043fb2b --- /dev/null +++ b/target/arm/decoder.h @@ -0,0 +1,50 @@ +/* + * Helpers for extracting complex instruction fields. + * + * These are referenced in the .decode file and emitted by decodetree.py + */ + +/* See e.g. ASR (immediate, predicated). + * Returns -1 for unallocated encoding; diagnose later. + */ +static inline int tszimm_esz(int x) +{ + x >>= 3; /* discard imm3 */ + return 31 - clz32(x); +} + +static inline int tszimm_shr(int x) +{ + return (16 << tszimm_esz(x)) - x; +} + +/* See e.g. LSL (immediate, predicated). */ +static inline int tszimm_shl(int x) +{ + return x - (8 << tszimm_esz(x)); +} + +static inline int plus1(int x) +{ + return x + 1; +} + +/* The SH bit is in bit 8. Extract the low 8 and shift. */ +static inline int expand_imm_sh8s(int x) +{ + return (int8_t)x << (x & 0x100 ? 8 : 0); +} + +static inline int expand_imm_sh8u(int x) +{ + return (uint8_t)x << (x & 0x100 ? 8 : 0); +} + +/* Convert a 2-bit memory size (msz) to a 4-bit data type (dtype) + * with unsigned data. C.f. SVE Memory Contiguous Load Group. + */ +static inline int msz_dtype(int msz) +{ + static const uint8_t dtype[4] = { 0, 5, 10, 15 }; + return dtype[msz]; +} diff --git a/target/arm/translate-sve.c b/target/arm/translate-sve.c index 374051cd20..e3ec5c8ec2 100644 --- a/target/arm/translate-sve.c +++ b/target/arm/translate-sve.c @@ -33,7 +33,7 @@ #include "trace-tcg.h" #include "translate-a64.h" #include "fpu/softfloat.h" - +#include "decoder.h" typedef void GVecGen2sFn(unsigned, uint32_t, uint32_t, TCGv_i64, uint32_t, uint32_t); @@ -47,54 +47,6 @@ typedef void gen_helper_gvec_mem(TCGv_env, TCGv_ptr, TCGv_i64, TCGv_i32); typedef void gen_helper_gvec_mem_scatter(TCGv_env, TCGv_ptr, TCGv_ptr, TCGv_ptr, TCGv_i64, TCGv_i32); -/* - * Helpers for extracting complex instruction fields. - */ - -/* See e.g. ASR (immediate, predicated). - * Returns -1 for unallocated encoding; diagnose later. - */ -static int tszimm_esz(int x) -{ - x >>= 3; /* discard imm3 */ - return 31 - clz32(x); -} - -static int tszimm_shr(int x) -{ - return (16 << tszimm_esz(x)) - x; -} - -/* See e.g. LSL (immediate, predicated). */ -static int tszimm_shl(int x) -{ - return x - (8 << tszimm_esz(x)); -} - -static inline int plus1(int x) -{ - return x + 1; -} - -/* The SH bit is in bit 8. Extract the low 8 and shift. */ -static inline int expand_imm_sh8s(int x) -{ - return (int8_t)x << (x & 0x100 ? 8 : 0); -} - -static inline int expand_imm_sh8u(int x) -{ - return (uint8_t)x << (x & 0x100 ? 8 : 0); -} - -/* Convert a 2-bit memory size (msz) to a 4-bit data type (dtype) - * with unsigned data. C.f. SVE Memory Contiguous Load Group. - */ -static inline int msz_dtype(int msz) -{ - static const uint8_t dtype[4] = { 0, 5, 10, 15 }; - return dtype[msz]; -} /* * Include the generated decoder.