From patchwork Fri Feb 24 05:51:20 2023 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: 61123 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5915:0:0:0:0:0 with SMTP id v21csp723679wrd; Thu, 23 Feb 2023 21:53:10 -0800 (PST) X-Google-Smtp-Source: AK7set//Fd95c15yliaC8SRv6tKVaUML1X46THKe9ZMkcOhsu8gXHACfLMWCY68mkOyllSEwIUug X-Received: by 2002:a17:907:9620:b0:8ab:a378:5f96 with SMTP id gb32-20020a170907962000b008aba3785f96mr23203570ejc.3.1677217990447; Thu, 23 Feb 2023 21:53:10 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1677217990; cv=none; d=google.com; s=arc-20160816; b=UmZBM0CAGxVR5C4JAhR3l9T1NGfoQvYKDV00MbY7ESqfjL/ExiqAJYrO7qu3xcPf7V Idgl28QYDjZPdFmFHcYHP0dSMY1vLhXMvpOQwtPNwaUEm0PMAuvyxNArPcU4pCgBioXE rGmQvZ5FLpClR9BZo9vFShuWvwJu87BFm0gljconewZsONOEr3CTG3YkrwDmtR3i/qUi CMyJXlKd530894FULsBQ9PY1LZsS01QTSJ+QOnauBKrGB2iTXHG3RgiU6je+p9WP1lWc DG1GiGgbmjtqcwz/mdezJfMzte3LEnQJuPYnIKjvQ2+XzrJlwQDgncwp6nlCtq5/98Zx WgRw== 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=GYXOlOd7Q7luwkWUh38lFwuKiDMWoPJh8wz/t8z+iYE=; b=LSX0xclLOKNYPBYmrOI/sBOMNSaZlsYRPif5FIvDB06L/vLzdDICO7HG4CrVOZvZdI 4qCMjcT7ypGhjIY2zjHR8z9724AhV+T8+NIHuJgMSjChegXaogKRYH6obOUJbBzeQr/8 7lti7qQfl9aVtktIxoQaHfVqwf4PJ2ZrZmaq+4fp+5Wqfcwd5voXnSFaLNrjAaKVWFEv lsp/AEHyzKqLAXWZg5IqVh4JxqqlmGsVnKq6rD66732TRNiKkDFL3R8vNih/yNQnMbGp Vs3hDhj3AWTClDSp5kJKGxQTuNpLcyymKRpbEWQCHtBkNaTuMg2k/q8E44gcmglJI0zj Gj9g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@vrull.eu header.s=google header.b=GcfvF0N7; 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 (ip-8-43-85-97.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id p5-20020a170907910500b008b17e88ee81si20923395ejq.240.2023.02.23.21.53.10 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 Feb 2023 21:53:10 -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=GcfvF0N7; 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 ABD04384B801 for ; Fri, 24 Feb 2023 05:52:07 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-wr1-x42c.google.com (mail-wr1-x42c.google.com [IPv6:2a00:1450:4864:20::42c]) by sourceware.org (Postfix) with ESMTPS id 99717385B501 for ; Fri, 24 Feb 2023 05:51:39 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 99717385B501 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-wr1-x42c.google.com with SMTP id j2so12598934wrh.9 for ; Thu, 23 Feb 2023 21:51:39 -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=GYXOlOd7Q7luwkWUh38lFwuKiDMWoPJh8wz/t8z+iYE=; b=GcfvF0N7tu20YHtZ+8ya67SFTPa84xMTWqiZWFo8lxeNrbsICQYdGt9zzRA7HpqniS 863tUV2tY2W+RPn/Bk8GDpn0FqSyTh4OHz+a1iXcK6IzaNu+Gzd3o42ghSl3BbFOQL2m dTPlbb2nZRU+7tG+dq7ftLNDGGGmL/kHZpuYd6Ic5yRQuDLQ1KGatcch+imC8cUFPbo4 Xdx6/NedxKN5wc73+NH2ETCMvG/G2LjqWlgmmvJpthCRiANLilIlCWnG9rzFmhZF9UvN 3qgD15MdNoHPyt4UgGs+8JSrQ77ZNZVpAmi11KO3aPdM/6V1nMTnGiX6dWaGz0TFbrbN lm/w== 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=GYXOlOd7Q7luwkWUh38lFwuKiDMWoPJh8wz/t8z+iYE=; b=VAFpXUR7U5hW/N4uCyTTlCqXmzBMIz++afCib8rsppg2XRYDhPm0hhDJXOsp1rwc/4 gLGQahxe0IVBr3Vbigy4DyLTlQuPuiWHAl1krD0spuoGUo70SHaRWdqTvBNN+AMoZElb 7H0VoiZsvZzgZaE/TuZl/GcLiDVJbcdtiJdGqep+O/AO5dDaVHxAur4FPX3Rzs1zVBzD fOsI0GkTmllpOgOlFpu4ydY58RqPyu0EnFQqgFF386ooTz1lOYtxYioDSEdXtT7OerZJ sxIQB5ZMBSpNKWW4NrZisEQeAu4Vet3BfHbuqz/G92Bfw8KHUUOZlDJexXWvegY327W1 sptA== X-Gm-Message-State: AO0yUKUEFtfSFGwZ9G5FIFw5VA+y2iZIttKyoitfGu5cdscXc02npsUX VIXRi4d+lRRaMCOcCg7CveScSZIyYp3gizqg X-Received: by 2002:a05:6000:170a:b0:2c5:4c9d:2dab with SMTP id n10-20020a056000170a00b002c54c9d2dabmr10899588wrc.10.1677217898020; Thu, 23 Feb 2023 21:51:38 -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 f18-20020adffcd2000000b002c59e001631sm11704055wrs.77.2023.02.23.21.51.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 Feb 2023 21:51:37 -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 v3 04/11] riscv: thead: Add support for the XTheadBs ISA extension Date: Fri, 24 Feb 2023 06:51:20 +0100 Message-Id: <20230224055127.2500953-5-christoph.muellner@vrull.eu> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230224055127.2500953-1-christoph.muellner@vrull.eu> References: <20230224055127.2500953-1-christoph.muellner@vrull.eu> MIME-Version: 1.0 X-Spam-Status: No, score=-12.7 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?1758690531722462925?= X-GMAIL-MSGID: =?utf-8?q?1758690531722462925?= 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 f11b7949a49..e35bc0a745b 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 158e9124c3a..2c684885850 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,%3,%1,%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" } } */