From patchwork Mon Dec 19 01:08:33 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Christoph_M=C3=BCllner?= X-Patchwork-Id: 34358 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:e747:0:0:0:0:0 with SMTP id c7csp2133412wrn; Sun, 18 Dec 2022 17:13:17 -0800 (PST) X-Google-Smtp-Source: AA0mqf4wdjhzjDM7XojCganAAJTrZVHNzyx0Z/tlrrlk8LA3A+aD3rL4WKb/9YsLW9uGE7vBsMFw X-Received: by 2002:a17:906:dfed:b0:7c1:3f04:efa2 with SMTP id lc13-20020a170906dfed00b007c13f04efa2mr30266047ejc.29.1671412397121; Sun, 18 Dec 2022 17:13:17 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1671412397; cv=none; d=google.com; s=arc-20160816; b=E+yxD5FQMSguN5LwfwIp92ujxbi0sDFodQd1TlV9L8uTIknSVugMCx+lQxZIXbwN9t QI8RWHBC5yKQtM09fpTUgUVJ38hlpX9t7km/jaujjoB6OpjwUUrPQIQd6ozzKea0MMpK JUTY4RdskkM+A+viz2SXRou+F54BrsvrHsaPTA+yeFdjofTnA1mBTnS/3jDgsXNwADNP ySJIUiQVhl+J5Za1MR9uaIWVDrmiyqTdOkIax7aujpk7MMtbEfPdB2L8sv/99aZsgila uS7SvZhFWjLpScUtUbGigs90HhEAzdkDuq904urLa23jQoaolqbKj0HC9LoTxiJC7byx S3GQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; 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:dmarc-filter:delivered-to; bh=jwS2qz+WVrg2mL0XVwn3XBT0Yb8VsX9YZyklh5sNnd0=; b=UC2SSNUeF9TBbgOtqv+NuHul9wIYfNMESckHoH1GAnLuAO9nqeRxmwhPiPVWaqx/la uV93DeeCMseBZIJdj5uO8D3TF6CJ/McKgYVcDqW+P0HcBsF9E29fVLtf2aCYtXuCUiEc LCYkELti/ZWbqdjp8vEZO/k74BN3vLXdAOqKFlMtQuWKSw2N07rcOa8P8ceRXF3EoBkO NFr/vgK4ybcohhfFTwJnHzbH4reuiYxnKLnM6QsFOR2zd+HwP4qCfZrn3k1mI3bsW3pv b3M1nBMlFT7c888QfU+KJF+9NeN6dXSVjbjNC2F5GqKTf6VilHHz7S8owKQ959Ob5yRm C2bQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@vrull.eu header.s=google header.b=LveyQQXP; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org" Received: from sourceware.org (server2.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id hy22-20020a1709068a7600b007c1703295b4si6105706ejc.843.2022.12.18.17.13.16 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 18 Dec 2022 17:13:17 -0800 (PST) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) client-ip=8.43.85.97; Authentication-Results: mx.google.com; dkim=pass header.i=@vrull.eu header.s=google header.b=LveyQQXP; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org" Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 0D52038FAB40 for ; Mon, 19 Dec 2022 01:10:53 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-ed1-x52a.google.com (mail-ed1-x52a.google.com [IPv6:2a00:1450:4864:20::52a]) by sourceware.org (Postfix) with ESMTPS id BCB9939E8F0E for ; Mon, 19 Dec 2022 01:08:51 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org BCB9939E8F0E Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=vrull.eu Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=vrull.eu Received: by mail-ed1-x52a.google.com with SMTP id r26so10853194edc.10 for ; Sun, 18 Dec 2022 17:08:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=vrull.eu; s=google; 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=jwS2qz+WVrg2mL0XVwn3XBT0Yb8VsX9YZyklh5sNnd0=; b=LveyQQXPx9kS/ppgwE2PIGI/ZDXAkXEVN9hYSlFq5mo62yT0+YTKNftpzmPCCyEwrF +/0+0FVgqwbu/i4qUsDB3SUrZipIqzATtWmxxTkGGRpcL3kEqoxLuZlPwj1GQ6HL2ur8 ypgji+MRjP/kyONO/8d6m35KNmxLK/c3+B7mOf6Qij1BU5lGA4qzasoLOPLd6eN0+M05 RP5Khq2S5rDe6JRVkcUyylLc9nj2IW4nWLddGfChVmNEnORu/u4T/Gk4Vp6JvB0O12fd KjMmivAMja+Wr4AsziXefJm6+ToEwp669w7Ztc5aUMLSq8Z3KZ4pfs/lMx3aLrsk7S7I dbzA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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=jwS2qz+WVrg2mL0XVwn3XBT0Yb8VsX9YZyklh5sNnd0=; b=Y8/7jLfqU/mfVyEvyvUXcAskUz2NU5lAEtpiRXnIJHk8DEN5uxvg7/2+Auyg4eMH8c ccIZx77L4oaV1+hvSFYNTr7m17gwxN92sqOb8U4rUwKjoxWM6ukfwxdV6Ls3lPdKDMHc ZY6Xw4BO26hLMcLsqz2fZZU7h6cr5j5LsBpKpX4IOHDF/Bc/2lc5cOnKuvqwRMeQF14Y CQaS5LucNN0WMbxTl2VPrlasSESesJlbTE5sfonWaw3k2JNKJQHdIL62YdfdN+mOk8mz fbO6rOQN6lpn/UfnbN7m1HGQ2rJEcFBQRuyqFqAREvK4V1tX6cBY2TNdICDzPenafVQr wIdA== X-Gm-Message-State: AFqh2koMnUQ79FDcYOc5H9AjPHlc+vIOeOmfh4U3t6qVE3lxjSQc7h5F PZC79UZzP4r3RfKyIVNpD8GwpKT81HTqdL5T X-Received: by 2002:a05:6402:25c7:b0:461:c5b4:a7d0 with SMTP id x7-20020a05640225c700b00461c5b4a7d0mr2805395edb.24.1671412130193; Sun, 18 Dec 2022 17:08:50 -0800 (PST) Received: from beast.fritz.box (62-178-148-172.cable.dynamic.surfer.at. [62.178.148.172]) by smtp.gmail.com with ESMTPSA id eg53-20020a05640228b500b0044dbecdcd29sm3744648edb.12.2022.12.18.17.08.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 18 Dec 2022 17:08:49 -0800 (PST) From: Christoph Muellner To: gcc-patches@gcc.gnu.org, Kito Cheng , Jim Wilson , Palmer Dabbelt , Andrew Waterman , Philipp Tomsich , Jeff Law , Cooper Qu , Lifang Xia , Yunhai Shang , Zhiwei Liu Cc: =?utf-8?q?Christoph_M=C3=BCllner?= Subject: [PATCH v2 06/11] riscv: thead: Add support for the XTheadBs ISA extension Date: Mon, 19 Dec 2022 02:08:33 +0100 Message-Id: <20221219010838.3878675-7-christoph.muellner@vrull.eu> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221219010838.3878675-1-christoph.muellner@vrull.eu> References: <20221219010838.3878675-1-christoph.muellner@vrull.eu> MIME-Version: 1.0 X-Spam-Status: No, score=-12.5 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, JMQ_SPF_NEUTRAL, KAM_MANYTO, KAM_SHORT, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1752602925912602951?= X-GMAIL-MSGID: =?utf-8?q?1752602925912602951?= From: Christoph Müllner This patch adds support for the XTheadBs ISA extension. The new INSN pattern is defined in a new file to separate this vendor extension from the standard extensions. The cost model adjustment reuses the xbs:bext cost. gcc/ChangeLog: * config/riscv/riscv.cc (riscv_rtx_costs): Add xthead:tst cost. * config/riscv/thead.md (*th_tst): New INSN. gcc/testsuite/ChangeLog: * gcc.target/riscv/xtheadbs-tst.c: New test. Signed-off-by: Christoph Müllner --- gcc/config/riscv/riscv.cc | 4 ++-- gcc/config/riscv/thead.md | 11 +++++++++++ gcc/testsuite/gcc.target/riscv/xtheadbs-tst.c | 13 +++++++++++++ 3 files changed, 26 insertions(+), 2 deletions(-) create mode 100644 gcc/testsuite/gcc.target/riscv/xtheadbs-tst.c diff --git a/gcc/config/riscv/riscv.cc b/gcc/config/riscv/riscv.cc index a8d5e1dac7f..537515771c6 100644 --- a/gcc/config/riscv/riscv.cc +++ b/gcc/config/riscv/riscv.cc @@ -2400,8 +2400,8 @@ riscv_rtx_costs (rtx x, machine_mode mode, int outer_code, int opno ATTRIBUTE_UN *total = COSTS_N_INSNS (SINGLE_SHIFT_COST); return true; } - /* bext pattern for zbs. */ - if (TARGET_ZBS && outer_code == SET + /* bit extraction pattern (zbs:bext, xtheadbs:tst). */ + if ((TARGET_ZBS || TARGET_XTHEADBS) && outer_code == SET && GET_CODE (XEXP (x, 1)) == CONST_INT && INTVAL (XEXP (x, 1)) == 1) { diff --git a/gcc/config/riscv/thead.md b/gcc/config/riscv/thead.md index 0257cbfad3e..0e23644ef59 100644 --- a/gcc/config/riscv/thead.md +++ b/gcc/config/riscv/thead.md @@ -29,3 +29,14 @@ (define_insn "*th_addsl" "th.addsl\t%0,%1,%3,%2" [(set_attr "type" "bitmanip") (set_attr "mode" "")]) + +;; XTheadBs + +(define_insn "*th_tst" + [(set (match_operand:X 0 "register_operand" "=r") + (zero_extract:X (match_operand:X 1 "register_operand" "r") + (const_int 1) + (match_operand 2 "immediate_operand" "i")))] + "TARGET_XTHEADBS" + "th.tst\t%0,%1,%2" + [(set_attr "type" "bitmanip")]) diff --git a/gcc/testsuite/gcc.target/riscv/xtheadbs-tst.c b/gcc/testsuite/gcc.target/riscv/xtheadbs-tst.c new file mode 100644 index 00000000000..674cec09128 --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/xtheadbs-tst.c @@ -0,0 +1,13 @@ +/* { dg-do compile } */ +/* { dg-options "-march=rv32gc_xtheadbs" { target { rv32 } } } */ +/* { dg-options "-march=rv64gc_xtheadbs" { target { rv64 } } } */ +/* { dg-skip-if "" { *-*-* } { "-O0" } } */ + +long +foo1 (long i) +{ + return 1L & (i >> 20); +} + +/* { dg-final { scan-assembler-times "th.tst\t" 1 } } */ +/* { dg-final { scan-assembler-not "andi" } } */