From patchwork Thu Jan 2 18:06:15 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 854670 Delivered-To: patch@linaro.org Received: by 2002:a5d:4888:0:b0:385:e875:8a9e with SMTP id g8csp7901420wrq; Thu, 2 Jan 2025 10:08:22 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCXS178HUynJJbpd4zYdABrBWn4FgfGB/YpMyRRrfAFKVdZowoHOTk1fJZ1ZG9QF8tlxR/03rQ==@linaro.org X-Google-Smtp-Source: AGHT+IF2WG6d4j5zt+rC1O1Ql7JP6Saf0/4aG8OBKavaXNpB+S/Z4XZzRbBNWJZZIjjLoZCjkbT6 X-Received: by 2002:a05:622a:164e:b0:467:67ad:e2a6 with SMTP id d75a77b69052e-46a4a8efcabmr663548531cf.26.1735841301946; Thu, 02 Jan 2025 10:08:21 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1735841301; cv=none; d=google.com; s=arc-20240605; b=fyLL6Y1r1i3PElx1feLcgpVPuXyvD4oOlLfgyB8LsGss/6Snxtq6MUzX1lhKMcFoIb zRVUp+vWfR9DvWiObC8f8fjwRfPHRsN/G0QxjRx/fAVtTPFkts8fy9C0fmxAoGTMT6vv +yV0/IMRw/6nBS+UcBa2UHdzsxsUcKk5YsVNsWEDQ+abOUGJ/avrFneUEGNo6usdpvmU 36mxaMkQfEqaN/+zHPcExYo/DUdh+MH9ytvhJMc9vRdg2KRiOTPuWNyzUUrYTWtEX/eZ 9PQEmu9wfb4qndz/Q7YvdyepLeHBOcAmJ7adGjUHG4U48gt0Z+BdAXH2F1gorD/YllJj er3w== 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:to:from :dkim-signature; bh=XUTpaBvkK/AmU9Br3cCuRs2TbKk17VU1RK81NC2aO4E=; fh=PnYt+qEB9tAfMKoqBm2xjKOFpYyFFGPudh5cVIoieJM=; b=LWr/lcUrib3/T3db/3uHsYJrmFLTWEg1aPczE0380gaLscC0i5PslTBeSlPW+olm6l cBWV5ERFb86y9BAyHevG7iO0mYPyK49+PmpQ4Xyt3O1akoAzn66RPAukbB1sSldBYdXj yQXEW2h1YViblC5l7YUc4u9MdqLFgs852GlyCH3A/ahU6GUb2XKl9zIh8AYGrZ0W1LIo iEpNXKgwy/t04AnmXmxr0iLXn/ylaDxs7iQLC/bcNcDNV6QqiZ8ZEOlR9b9WS88nQI/i fQH87V2c8bxNxeRbIVWVt8Y8xfWeeJY5ZSV9q46CduKNsv1Qa1ROyCbbzquT2ctuCLXM TQ7g==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=nLMpQWoK; 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 d75a77b69052e-46a3e680894si379964931cf.34.2025.01.02.10.08.21 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 02 Jan 2025 10:08:21 -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=nLMpQWoK; 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 1tTPbl-0007OH-UF; Thu, 02 Jan 2025 13:07:46 -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 1tTPbS-00072j-Vr for qemu-devel@nongnu.org; Thu, 02 Jan 2025 13:07:29 -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 1tTPbQ-0005CE-Ju for qemu-devel@nongnu.org; Thu, 02 Jan 2025 13:07:26 -0500 Received: by mail-pl1-x62a.google.com with SMTP id d9443c01a7336-21669fd5c7cso160655405ad.3 for ; Thu, 02 Jan 2025 10:07:23 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1735841242; x=1736446042; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=XUTpaBvkK/AmU9Br3cCuRs2TbKk17VU1RK81NC2aO4E=; b=nLMpQWoKwEpFfklF9u8jMUY0i24NPlUi++uW1Gph6OoHjOt3qxUYg33cpcxOBr6Aov B6lJezU4a4jaJtEvgJa/12bT7F92S395iFjyKjuLhrftIL8JIY/GBbv9dUjzsrS3IQ3B Wm6inJt/5jzZl6nCFyY4Iu1oa/oGzZ3uhzgnMICa6hsHMW/TMyxeH2Z8pCL1z+HhC489 PKsJ/4YGv1tbvpr9gtDPpam8Oxktn82z8oERx7ZIvEIPmBjLyCC/oSKWpTu5wkAsEHqe RHy8ARLmJ365m+aymbusPLPOvuHImeNloqWSIPvwBWLC0u87G4RolUhzEgPHeF9S0wR0 HkBg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1735841242; x=1736446042; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=XUTpaBvkK/AmU9Br3cCuRs2TbKk17VU1RK81NC2aO4E=; b=xF8B6BAIIG3cCVn0yjvhpj8VYlqMXS1Kvkh27vf1qFLBpLNPr+0+WLimTOa2G9Pv9B tx466IW26ShMys0l4oSmUHHuvbyMzZiqCE7EHuzVmj1ONmuS3QMpRoA747BycIJx5VHu rGbOc2LZXSjw/tZGVn0b3BZ7UuuDmgZbAwy/uYw0ALJUputPJc60Pdy7lqvM/xsuw/Sy WQAvLbEO8quP/c5ztlT19gTqwpiWizpFk+pk8asRrTSuVm0bGtJlLt+Tu8jbC2ghxN8+ JlskNDBI017lXYHB1ZI0nfDkrqOZLHAq9miPvs2JWb4fnGtsvbyCAM0F8E2yu1qpy3os N83g== X-Gm-Message-State: AOJu0YwSOducf9VVfhoF1i6+R7XtZtIZSw/DW160sC1m+jf1/V+PQjt/ lq0TeChQouK+7y4iA3rGp5xq5f+A76a+Yvbq+zfjjLH+2fevXgiEDpqSNJx0CXdau3NNM5EP4bK S X-Gm-Gg: ASbGncvvKtVHbY80Qrr9SIyC0A/4ftw7qyBRYljKKFdurS41kHG0Du2XaUFPk64MGpb qFHbiLlfi8f6gAAGvf1EOSosYnpt6p+WS4NJAK6wi94/WCenhAJzqRhQwrtMf33UsSnTmZQDhUF t4FfLuWaqmxvPvOzgCcS2L+KKtzSE8kDwI3y2+kmeDbDsdubxd9NQf08MlmpKkLDNWePWOQP8PI ic2I2V3pzj5hQU59w58uhnMs+PILWSInl9hm24EkBdwo3sPsOT2EQsR6/H+XA== X-Received: by 2002:a05:6a00:430d:b0:728:e906:e466 with SMTP id d2e1a72fcca58-72abdeb4793mr65138694b3a.21.1735841242510; Thu, 02 Jan 2025 10:07:22 -0800 (PST) Received: from stoup.. ([63.239.63.212]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-72ad3393d5fsm20604456b3a.154.2025.01.02.10.07.22 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 02 Jan 2025 10:07:22 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH 35/73] tcg/loongarch64: Fold the ext{8, 16, 32}[us] cases into {s}extract Date: Thu, 2 Jan 2025 10:06:15 -0800 Message-ID: <20250102180654.1420056-36-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250102180654.1420056-1-richard.henderson@linaro.org> References: <20250102180654.1420056-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 2716f9d0bc..48dc703ad5 100644 --- a/tcg/loongarch64/tcg-target-has.h +++ b/tcg/loongarch64/tcg-target-has.h @@ -35,7 +35,7 @@ #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_ext8s_i32 1 #define TCG_TARGET_HAS_ext16s_i32 1 @@ -48,7 +48,7 @@ /* 64-bit operations */ #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 @@ -81,5 +81,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 a273e7fce5..13debee683 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, 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: @@ -2242,6 +2270,8 @@ static TCGConstraintSetIndex tcg_target_op_def(TCGOpcode op) 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: