From patchwork Wed May 22 22:28:20 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 164917 Delivered-To: patch@linaro.org Received: by 2002:a92:9e1a:0:0:0:0:0 with SMTP id q26csp1421795ili; Wed, 22 May 2019 15:42:55 -0700 (PDT) X-Google-Smtp-Source: APXvYqwbFaOmRX3BeXPxue5s0ExbRaG3pQRL2+Qc1KuLx6zAMpoiiMbh51/wyxJ3wZcb6l8hMyKA X-Received: by 2002:a17:906:7206:: with SMTP id m6mr74006010ejk.39.1558564975442; Wed, 22 May 2019 15:42:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1558564975; cv=none; d=google.com; s=arc-20160816; b=LiRZFiXbu8HYQmjEK8s3hGERb49yzhBExiUjQfvi9jERAvVtB7aj+pfXtltyRWdnjh g7HtEgMU7Ceg3VqyhMLAmszJIUUhrDVOn1tAEgTuG5iudwx7BKwpAy6PrXDg4eHkcC2v sKfMjZATLL3h8GmT28VFZFXiWBgz/F3TgjfYDck6IGvB6FybZLhafDqqAN3sIgEXyEaP Uo1J4N2lEYORGsa4XACDB2yZrAriuoJhaWXW99bXi+EEydE/KhhJS7t8ui6JxYlLwgNr wyTtemhNZxkwruaRaPHD52EczUYYtC5LESJ/BiFqR9CJfa4LirDlA0IGadQyStpSOEPA yhrQ== 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=AirXKI1PS8HjM151RJTWK1/DcdzF7g0f+0zrycENkFI=; b=SKLZp3KkWnVyG5XTBHd6CdtipM9jT7kboPIJeE/52Ke/bFW1IDsqIwqFFYJTIQ4Uz7 dl0hBxQp+cm3CJ38enZ3BfS5vjf7VAxqddMPQme1YULqYg/aSlcO3ZGG0H9cDlncm1gO 3q0pyEg+5RnUecYhjqlYz/gkqtNoge8VfP68sEaTOfMBCGzVwjY1MvPhQvfgvximg5Rk UDuISp4SOGWDXyQG7HYZlv04SnN9l2/5/g2axURXAFjFglfjGZ+Sqelmjw9zJRb+dtSi rYt9Fv2K8wXelwYfIfzQ1LAW3dRybnwJ0LFQYsGKftwQzhRRQiNbjih+yk81kMaD44fD 5U1Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=znq81cNx; 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 gf24si2159310ejb.139.2019.05.22.15.42.55 for (version=TLS1 cipher=AES128-SHA bits=128/128); Wed, 22 May 2019 15:42:55 -0700 (PDT) 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=znq81cNx; 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]:52689 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hTZwk-0004tg-CV for patch@linaro.org; Wed, 22 May 2019 18:42:54 -0400 Received: from eggs.gnu.org ([209.51.188.92]:49957) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hTZj5-0003Ai-Cx for qemu-devel@nongnu.org; Wed, 22 May 2019 18:28:48 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hTZj3-0007Rv-T4 for qemu-devel@nongnu.org; Wed, 22 May 2019 18:28:47 -0400 Received: from mail-yb1-xb30.google.com ([2607:f8b0:4864:20::b30]:46061) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hTZj3-0007PU-LX for qemu-devel@nongnu.org; Wed, 22 May 2019 18:28:45 -0400 Received: by mail-yb1-xb30.google.com with SMTP id e128so1480256ybc.12 for ; Wed, 22 May 2019 15:28:40 -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; bh=AirXKI1PS8HjM151RJTWK1/DcdzF7g0f+0zrycENkFI=; b=znq81cNxYJ9g9UuAhySNCaQGt5NzrUBrLXec0wgVcvco3cbRyvXp4gn5o8PFqAKx4V bjrU9tGZAHQFK9yhYYM0HVrRoXqNgMD/bw1NQZx+Var/9j8x5jx18Cvu8l9PZcRqRHKr yG3bbV+Esbu4eujiqBkquTs/rol4gBu4CIRrX4NyC4wBXqol+gBXkZdLUMV0OJPl0xvz XRwFKLq1/Ss6uq7Gx4yOiiP9QpusQEFrxxocaDqnYvTK0MyCs6fssDYmbgtOHmwbkePz YndSUmtk0nKdc1jqH9oXIQAIRZ9eRcflCiQoXEk/a7rlh12udjwHDkCugQLM2d0WnwEK 7gRg== 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=AirXKI1PS8HjM151RJTWK1/DcdzF7g0f+0zrycENkFI=; b=oFz0Nuej9wNzk3H3+EHhtF5CvDks4f86USAPtgCEd4OczAAu/Kg4BLVt6Ml/nxX9mJ ZijGLoEmq0aQ9LySI+VLk610Co8ArmOebY65HJEvr4vrtnezfObKm9Zlq6XhzYRTaSyd 7Dq+Z7fMoQcpel5YsdJhSmEPNpNVPRMlpS1lQoMAepGFPF04HE5rZY2EFU1vxEtZ1CNk YrLU7L/mmjMTSSyeYuQAsoyactZIobxUcbUCFkiSkFi6uVY0C3MoiAxgNFHmOENoYdZf hZOGmXRVEyQ/j9zrA9mE3DQ3MPx1xfYxz8qBS7e1wI+lE9t4b1WnoK9/+9PlA9Q1pc5X D0aw== X-Gm-Message-State: APjAAAUrwibEf91Cd3u6yF+86yDHBDNJ9kxWycy8B4jgJTLttOlMZ7QL vEWNYL9NvWcwghun5JQSgPeu+slmSY8= X-Received: by 2002:a25:7502:: with SMTP id q2mr22709271ybc.31.1558564120013; Wed, 22 May 2019 15:28:40 -0700 (PDT) Received: from localhost.localdomain ([71.46.56.17]) by smtp.gmail.com with ESMTPSA id q11sm2276453ywg.7.2019.05.22.15.28.39 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 22 May 2019 15:28:39 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Wed, 22 May 2019 18:28:20 -0400 Message-Id: <20190522222821.23850-16-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190522222821.23850-1-richard.henderson@linaro.org> References: <20190522222821.23850-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::b30 Subject: [Qemu-devel] [PULL 15/16] tcg/aarch64: Allow immediates for vector ORR and BIC 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" The allows immediates to be used for ORR and BIC, as well as the trivial inversions, ORC and AND. Signed-off-by: Richard Henderson --- tcg/aarch64/tcg-target.inc.c | 90 +++++++++++++++++++++++++++++++++--- 1 file changed, 83 insertions(+), 7 deletions(-) -- 2.17.1 diff --git a/tcg/aarch64/tcg-target.inc.c b/tcg/aarch64/tcg-target.inc.c index 52c18074ae..9e1dad9696 100644 --- a/tcg/aarch64/tcg-target.inc.c +++ b/tcg/aarch64/tcg-target.inc.c @@ -119,6 +119,8 @@ static inline bool patch_reloc(tcg_insn_unit *code_ptr, int type, #define TCG_CT_CONST_LIMM 0x200 #define TCG_CT_CONST_ZERO 0x400 #define TCG_CT_CONST_MONE 0x800 +#define TCG_CT_CONST_ORRI 0x1000 +#define TCG_CT_CONST_ANDI 0x2000 /* parse target specific constraints */ static const char *target_parse_constraint(TCGArgConstraint *ct, @@ -154,6 +156,12 @@ static const char *target_parse_constraint(TCGArgConstraint *ct, case 'M': /* minus one */ ct->ct |= TCG_CT_CONST_MONE; break; + case 'O': /* vector orr/bic immediate */ + ct->ct |= TCG_CT_CONST_ORRI; + break; + case 'N': /* vector orr/bic immediate, inverted */ + ct->ct |= TCG_CT_CONST_ANDI; + break; case 'Z': /* zero */ ct->ct |= TCG_CT_CONST_ZERO; break; @@ -293,6 +301,16 @@ static int is_shimm32_pair(uint32_t v32, int *cmode, int *imm8) return i; } +/* Return true if V is a valid 16-bit or 32-bit shifted immediate. */ +static bool is_shimm1632(uint32_t v32, int *cmode, int *imm8) +{ + if (v32 == deposit32(v32, 16, 16, v32)) { + return is_shimm16(v32, cmode, imm8); + } else { + return is_shimm32(v32, cmode, imm8); + } +} + static int tcg_target_const_match(tcg_target_long val, TCGType type, const TCGArgConstraint *arg_ct) { @@ -317,6 +335,23 @@ static int tcg_target_const_match(tcg_target_long val, TCGType type, return 1; } + switch (ct & (TCG_CT_CONST_ORRI | TCG_CT_CONST_ANDI)) { + case 0: + break; + case TCG_CT_CONST_ANDI: + val = ~val; + /* fallthru */ + case TCG_CT_CONST_ORRI: + if (val == deposit64(val, 32, 32, val)) { + int cmode, imm8; + return is_shimm1632(val, &cmode, &imm8); + } + break; + default: + /* Both bits should not be set for the same insn. */ + g_assert_not_reached(); + } + return 0; } @@ -2278,6 +2313,7 @@ static void tcg_out_vec_op(TCGContext *s, TCGOpcode opc, TCGType type = vecl + TCG_TYPE_V64; unsigned is_q = vecl; TCGArg a0, a1, a2, a3; + int cmode, imm8; a0 = args[0]; a1 = args[1]; @@ -2309,20 +2345,56 @@ static void tcg_out_vec_op(TCGContext *s, TCGOpcode opc, tcg_out_insn(s, 3617, ABS, is_q, vece, a0, a1); break; case INDEX_op_and_vec: + if (const_args[2]) { + is_shimm1632(~a2, &cmode, &imm8); + if (a0 == a1) { + tcg_out_insn(s, 3606, BIC, is_q, a0, 0, cmode, imm8); + return; + } + tcg_out_insn(s, 3606, MVNI, is_q, a0, 0, cmode, imm8); + a2 = a0; + } tcg_out_insn(s, 3616, AND, is_q, 0, a0, a1, a2); break; case INDEX_op_or_vec: + if (const_args[2]) { + is_shimm1632(a2, &cmode, &imm8); + if (a0 == a1) { + tcg_out_insn(s, 3606, ORR, is_q, a0, 0, cmode, imm8); + return; + } + tcg_out_insn(s, 3606, MOVI, is_q, a0, 0, cmode, imm8); + a2 = a0; + } tcg_out_insn(s, 3616, ORR, is_q, 0, a0, a1, a2); break; - case INDEX_op_xor_vec: - tcg_out_insn(s, 3616, EOR, is_q, 0, a0, a1, a2); - break; case INDEX_op_andc_vec: + if (const_args[2]) { + is_shimm1632(a2, &cmode, &imm8); + if (a0 == a1) { + tcg_out_insn(s, 3606, BIC, is_q, a0, 0, cmode, imm8); + return; + } + tcg_out_insn(s, 3606, MOVI, is_q, a0, 0, cmode, imm8); + a2 = a0; + } tcg_out_insn(s, 3616, BIC, is_q, 0, a0, a1, a2); break; case INDEX_op_orc_vec: + if (const_args[2]) { + is_shimm1632(~a2, &cmode, &imm8); + if (a0 == a1) { + tcg_out_insn(s, 3606, ORR, is_q, a0, 0, cmode, imm8); + return; + } + tcg_out_insn(s, 3606, MVNI, is_q, a0, 0, cmode, imm8); + a2 = a0; + } tcg_out_insn(s, 3616, ORN, is_q, 0, a0, a1, a2); break; + case INDEX_op_xor_vec: + tcg_out_insn(s, 3616, EOR, is_q, 0, a0, a1, a2); + break; case INDEX_op_ssadd_vec: tcg_out_insn(s, 3616, SQADD, is_q, vece, a0, a1, a2); break; @@ -2505,6 +2577,8 @@ static const TCGTargetOpDef *tcg_target_op_def(TCGOpcode op) static const TCGTargetOpDef lZ_l = { .args_ct_str = { "lZ", "l" } }; static const TCGTargetOpDef r_r_r = { .args_ct_str = { "r", "r", "r" } }; static const TCGTargetOpDef w_w_w = { .args_ct_str = { "w", "w", "w" } }; + static const TCGTargetOpDef w_w_wO = { .args_ct_str = { "w", "w", "wO" } }; + static const TCGTargetOpDef w_w_wN = { .args_ct_str = { "w", "w", "wN" } }; static const TCGTargetOpDef w_w_wZ = { .args_ct_str = { "w", "w", "wZ" } }; static const TCGTargetOpDef r_r_ri = { .args_ct_str = { "r", "r", "ri" } }; static const TCGTargetOpDef r_r_rA = { .args_ct_str = { "r", "r", "rA" } }; @@ -2660,11 +2734,7 @@ static const TCGTargetOpDef *tcg_target_op_def(TCGOpcode op) case INDEX_op_add_vec: case INDEX_op_sub_vec: case INDEX_op_mul_vec: - case INDEX_op_and_vec: - case INDEX_op_or_vec: case INDEX_op_xor_vec: - case INDEX_op_andc_vec: - case INDEX_op_orc_vec: case INDEX_op_ssadd_vec: case INDEX_op_sssub_vec: case INDEX_op_usadd_vec: @@ -2691,6 +2761,12 @@ static const TCGTargetOpDef *tcg_target_op_def(TCGOpcode op) return &w_r; case INDEX_op_dup_vec: return &w_wr; + case INDEX_op_or_vec: + case INDEX_op_andc_vec: + return &w_w_wO; + case INDEX_op_and_vec: + case INDEX_op_orc_vec: + return &w_w_wN; case INDEX_op_cmp_vec: return &w_w_wZ; case INDEX_op_bitsel_vec: