From patchwork Tue Jan 7 08:00:29 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 855452 Delivered-To: patch@linaro.org Received: by 2002:adf:8b05:0:b0:385:e875:8a9e with SMTP id n5csp100809wra; Tue, 7 Jan 2025 00:10:38 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCXPHDlhd7GcLCV1S5eneO39C5Zu0t45bzHP9P9sjjHI8zKhuHpLzMtY3iRqFjXtonRxBo1dug==@linaro.org X-Google-Smtp-Source: AGHT+IFZrmzTs0eA6i7oUlB21QEQJ6mP0rQYi+MMHJ+xhSy+6JNqYir1BcWVC5+Y06eudi07amIg X-Received: by 2002:a05:620a:2681:b0:7b6:cd90:c0d4 with SMTP id af79cd13be357-7b9ba7aa924mr10220051185a.31.1736237438176; Tue, 07 Jan 2025 00:10:38 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1736237438; cv=none; d=google.com; s=arc-20240605; b=RWjrbBWXei+2NbDEjRn08uUi3kl6FkvK3lqiJtL6mNX+A7LYAvtEgLrREaNzRifqRF /Bap4m5g51+ojaBzzyw0vkyLyWk1N2SAlEFDox8lCDMHVOQc6i6joheg7eyjgE8VCgc1 MsK8367hgJfcbJblQJsT6RmTJhxzQrKr9rlj87AOWVc3L7RIURfpnQpAsElLqPr30BJU nXD/aX1NO3nfbgOZ4NMH+5zwUXjF4qX/DPv5/WGflkEDA0khcf9MVHm5v5Q7+I0YRstI g/kYaZ0eNYFKGKyQLE/0ufH8wRjS8ZjmtaGUzpV+UStul7Fpe11YG6Gr6JZrz+QKTUqF 0f4Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=a1bNfY/97XJ3h+VRN9JxDBynW7EJ1OysO0WoaVxBH6w=; fh=1AaLZNOiARaO2MErHmdWiM20H44tzxxDYMw0tHmbGN4=; b=SsIEE+Sk5hvWdeoWePKa+N3ifPIQws3zinHc+HAedHbZAPFD74owavAX8TjycwPfQL OqXtiHhJouxBfztNHJDuCpzwZTemo/MhSoa84rtTQjWOdcpjXx1yPkCCgtDwYUhcHLrF M0V5q+f/Wexel7ic6FIpDtqH8wVnIPx0KS/GklIawuyTE56QzkpswTsbNiWMnUo0Hnic x5o07ovjsHdSih9+WzV70g8qH0Wu6TmmErYMyT8MoVwIqrFr08VEgUDtM8KjUfjrn5Mw KwiQNTCRTODTs6hQxX4iWhAtXdSav942nfR/saQAK9OHbeUd0qMoU+ZoeCLFOF8Kvacw NdHA==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=ubo70EWI; 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; dara=fail header.i=@linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id af79cd13be357-7b9ac4fa3d0si1470103285a.557.2025.01.07.00.10.38 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 07 Jan 2025 00:10:38 -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=ubo70EWI; 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; dara=fail header.i=@linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tV4Xg-00015V-TJ; Tue, 07 Jan 2025 03:02:24 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tV4XH-0000Pm-U0 for qemu-devel@nongnu.org; Tue, 07 Jan 2025 03:02:00 -0500 Received: from mail-pl1-x62a.google.com ([2607:f8b0:4864:20::62a]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tV4XF-00030p-80 for qemu-devel@nongnu.org; Tue, 07 Jan 2025 03:01:58 -0500 Received: by mail-pl1-x62a.google.com with SMTP id d9443c01a7336-21634338cfdso1873655ad.2 for ; Tue, 07 Jan 2025 00:01:56 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1736236915; x=1736841715; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=a1bNfY/97XJ3h+VRN9JxDBynW7EJ1OysO0WoaVxBH6w=; b=ubo70EWIkw/5IvE5upz7cTPxFpDeflEG0y58aTdi1Grkdi2vPgaL0d7R1RxZbnyJp8 y1m/X3GfzDxENrViqpN84Ir05mdW7FdyXQ2ned9C4ULiVZF7e4/rwPhL0DhP5GHK/kbi hILp7PK4JNRkpC97VbTjkP86DtOqhkGbgXzjQ0jcRcQWsUlUd1LnI81Lh9s4t1QxXuTZ DHse5Ef3zB/u/YR7tyRIY24mgprH5yZaLlliQGoOnc9F1HTwNc0I7E+nDvFmJ2Bjwii9 3VfJ8+fe/LhYcA5Z/flYInVthqGZJKL7QGdir2oc5pCa4t4k8yD5sJ6WFDHvKTFF71vW 0Zpw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1736236915; x=1736841715; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=a1bNfY/97XJ3h+VRN9JxDBynW7EJ1OysO0WoaVxBH6w=; b=O99oFcs1idVt7nX2qv5vSnwNml1PcULaersgtEGoD5K3uszY+VQQ9d5etnVicg+s29 e8zcVxWtSK/jCPI/YyO0FnoCjvkUE/DFpE+4Z4kRXAsuszzy3EsldK4Htaa64z73aP5h vS5Jv6nllGBpt7jBlCUvs6G7pdKJYbza8+jkaJWa4eUN0f35WZJHJMLYiEkxiusDp5S/ H6ZHHAJ+mWf/glaZ8RL9X3G0TYj40Ydh8tDW1Ob6AbswxBw7lYA0dc5N8JalsmXnSzQ6 8TtMfz8QMzhXfDycZgALa+R/gaXzMh13KdfjYsooKzQaU4pBqIevdM56FcAA2fQbprxX 0OcQ== X-Gm-Message-State: AOJu0YxdEqaxTQjcG4VOav//z3dO6jFrJ7alWqvHshNmU87lWDqLS9Hk 9vbNkYMoLj8n9N1UZg0yKgkpZ6Jd9t5wFIxZy5zUqqBkBDU07zbwNAtys0djQ0GCyrT7FETqiwe 0 X-Gm-Gg: ASbGncsC8vp21nJwAHaFDpqe1CCjx/CLZjKdqL+sdydQEVX6NcOralTCikIFsCxk9DX 3sBqgCwzeVUY2BoeAfdyFuRdyvHZbiIRZEYfQ5nZ4X67XEQ2eXbJoC+uRa+WjWoqZIavr1nxQMh HyUaSKpyHrORsRVokMq2b4DmXea+RIeEqnE1U2H8uf62bIQ+KBaDFYI6NyvS43WP5fbi+kVFbE5 8dqJ803GF8VVWWL7HzBxxyX/4siCsVl5MJfOlWzEFnPMjCCwP/Y8KqmvmVwCgTV3Nenvs5sWbAB Fyj1mZDfFLeZa+KyvA== X-Received: by 2002:a17:902:f54e:b0:210:f706:dc4b with SMTP id d9443c01a7336-219e6ea1b6dmr842678445ad.13.1736236915279; Tue, 07 Jan 2025 00:01:55 -0800 (PST) Received: from stoup.. (76-14-228-138.or.wavecable.com. [76.14.228.138]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-219dc96eb12sm306765995ad.87.2025.01.07.00.01.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Jan 2025 00:01:54 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: philmd@linaro.org, pierrick.bouvier@linaro.org Subject: [PATCH v2 38/81] tcg/loongarch64: Fold the ext{8, 16, 32}[us] cases into {s}extract Date: Tue, 7 Jan 2025 00:00:29 -0800 Message-ID: <20250107080112.1175095-39-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250107080112.1175095-1-richard.henderson@linaro.org> References: <20250107080112.1175095-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::62a; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x62a.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org Accept byte and word extensions with the extract opcodes. This is preparatory to removing the specialized extracts. Signed-off-by: Richard Henderson --- tcg/loongarch64/tcg-target-has.h | 15 ++++++++++++-- tcg/loongarch64/tcg-target.c.inc | 34 ++++++++++++++++++++++++++++++-- 2 files changed, 45 insertions(+), 4 deletions(-) diff --git a/tcg/loongarch64/tcg-target-has.h b/tcg/loongarch64/tcg-target-has.h index e4333c36c6..ac7d2fcdf9 100644 --- a/tcg/loongarch64/tcg-target-has.h +++ b/tcg/loongarch64/tcg-target-has.h @@ -17,7 +17,7 @@ #define TCG_TARGET_HAS_rot_i32 1 #define TCG_TARGET_HAS_deposit_i32 1 #define TCG_TARGET_HAS_extract_i32 1 -#define TCG_TARGET_HAS_sextract_i32 0 +#define TCG_TARGET_HAS_sextract_i32 1 #define TCG_TARGET_HAS_extract2_i32 0 #define TCG_TARGET_HAS_add2_i32 0 #define TCG_TARGET_HAS_sub2_i32 0 @@ -52,7 +52,7 @@ #define TCG_TARGET_HAS_rot_i64 1 #define TCG_TARGET_HAS_deposit_i64 1 #define TCG_TARGET_HAS_extract_i64 1 -#define TCG_TARGET_HAS_sextract_i64 0 +#define TCG_TARGET_HAS_sextract_i64 1 #define TCG_TARGET_HAS_extract2_i64 0 #define TCG_TARGET_HAS_extr_i64_i32 1 #define TCG_TARGET_HAS_ext8s_i64 1 @@ -109,5 +109,16 @@ #define TCG_TARGET_HAS_cmpsel_vec 0 #define TCG_TARGET_HAS_tst_vec 0 +#define TCG_TARGET_extract_valid(type, ofs, len) 1 + +static inline bool +tcg_target_sextract_valid(TCGType type, unsigned ofs, unsigned len) +{ + if (type == TCG_TYPE_I64 && ofs + len == 32) { + return true; + } + return ofs == 0 && (len == 8 || len == 16); +} +#define TCG_TARGET_sextract_valid tcg_target_sextract_valid #endif diff --git a/tcg/loongarch64/tcg-target.c.inc b/tcg/loongarch64/tcg-target.c.inc index 3dff29facb..cebe8dd354 100644 --- a/tcg/loongarch64/tcg-target.c.inc +++ b/tcg/loongarch64/tcg-target.c.inc @@ -1375,10 +1375,38 @@ static void tcg_out_op(TCGContext *s, TCGOpcode opc, TCGType type, break; case INDEX_op_extract_i32: - tcg_out_opc_bstrpick_w(s, a0, a1, a2, a2 + args[3] - 1); + if (a2 == 0 && args[3] <= 12) { + tcg_out_opc_andi(s, a0, a1, (1 << args[3]) - 1); + } else { + tcg_out_opc_bstrpick_w(s, a0, a1, a2, a2 + args[3] - 1); + } break; case INDEX_op_extract_i64: - tcg_out_opc_bstrpick_d(s, a0, a1, a2, a2 + args[3] - 1); + if (a2 == 0 && args[3] <= 12) { + tcg_out_opc_andi(s, a0, a1, (1 << args[3]) - 1); + } else { + tcg_out_opc_bstrpick_d(s, a0, a1, a2, a2 + args[3] - 1); + } + break; + + case INDEX_op_sextract_i64: + if (a2 + args[3] == 32) { + if (a2 == 0) { + tcg_out_ext32s(s, a0, a1); + } else { + tcg_out_opc_srai_w(s, a0, a1, a2); + } + break; + } + /* FALLTHRU */ + case INDEX_op_sextract_i32: + if (a2 == 0 && args[3] == 8) { + tcg_out_ext8s(s, TCG_TYPE_REG, a0, a1); + } else if (a2 == 0 && args[3] == 16) { + tcg_out_ext16s(s, TCG_TYPE_REG, a0, a1); + } else { + g_assert_not_reached(); + } break; case INDEX_op_deposit_i32: @@ -2243,6 +2271,8 @@ tcg_target_op_def(TCGOpcode op, TCGType type, unsigned flags) case INDEX_op_not_i64: case INDEX_op_extract_i32: case INDEX_op_extract_i64: + case INDEX_op_sextract_i32: + case INDEX_op_sextract_i64: case INDEX_op_bswap16_i32: case INDEX_op_bswap16_i64: case INDEX_op_bswap32_i32: