From patchwork Mon Dec 19 01:08:32 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: 34361 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:e747:0:0:0:0:0 with SMTP id c7csp2134060wrn; Sun, 18 Dec 2022 17:15:32 -0800 (PST) X-Google-Smtp-Source: AA0mqf5100pxgPfjAcgHw2bsjpqq7IoDfQaYfONv5TCrSGQlgyRp0n5hp/WO8hge5zCcccMRjnnI X-Received: by 2002:a17:907:2458:b0:7c1:1e5a:ed10 with SMTP id yw24-20020a170907245800b007c11e5aed10mr51258425ejb.8.1671412532581; Sun, 18 Dec 2022 17:15:32 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1671412532; cv=none; d=google.com; s=arc-20160816; b=lAZIEbUHE8TwugmmDsFHRB7dW1eY3e8bo6r9Il0XF0j6jGMXxZYEAAA9snLUrASXus jHBKRD6oJBQhuZ9mMXTDALZP/4hLnIXhipjzbTnfVkZUezJaYUAJlwtO3EMwb9O7H04w mNQdd4PtjNuviyYrsMFg3C0s3p93h2Th3rU1A8oR2zMbpINnD7e5ZhgU6YtRYJdEn+T3 5nmVhzhKZWsXCs/6hLHQvR3ypO/DOcpQH4L+26R/nVMyjdbRsG+uJ8eM1rg0b+u5xMhM ABi5WTVWOFSWg5b5HA2jnhmIz/pB0vLrROrh7dsXx+zUc/rOGeyU4k+kr+gRwzx22o7i JyMw== 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=OUgg8Du+/Wff+DQETawiCgu8tK0Xr9+pCS0ZJabuwZA=; b=nw3bMxNwcDTBizwGxim7z+P71uS2DL2FebuDHmHM8ON1DJTq+2Hk0eVEr9/Mn6z2L9 WUl1MrwM1k0CqYNTL8YcFN5ZcSQe0xrzzLBVYCYSCR8wLEBcgMY2Ce5pKR1RGo33dIr9 rQghr9vakANebgqJTwtxMlFOot+kThRE7yfw9QP/flljuI6ALjwcuGbhtJUUzGxnCrZi uHrWimFjoeItm0FnHK5AzSJVAtjD1vMQWtHRjTXjkTEW5iKuE8eDbwusvz9K8gA0A+b6 9xm2y0WdGFPwpg3AbNJ4Jktx+m1Cyc1GqQBxp90GsdrdWh60lUaWjvUzFSOyDt7+akq2 J5Iw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@vrull.eu header.s=google header.b=AfyhcD1N; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org" Received: from sourceware.org (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id qx2-20020a170906fcc200b007c3d44b41cfsi6258997ejb.988.2022.12.18.17.15.32 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 18 Dec 2022 17:15:32 -0800 (PST) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) client-ip=2620:52:3:1:0:246e:9693:128c; Authentication-Results: mx.google.com; dkim=pass header.i=@vrull.eu header.s=google header.b=AfyhcD1N; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c 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 C5A2C392C7B1 for ; Mon, 19 Dec 2022 01:11:51 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-ed1-x529.google.com (mail-ed1-x529.google.com [IPv6:2a00:1450:4864:20::529]) by sourceware.org (Postfix) with ESMTPS id 8964739578EB for ; Mon, 19 Dec 2022 01:08:50 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 8964739578EB 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-x529.google.com with SMTP id r26so10853158edc.10 for ; Sun, 18 Dec 2022 17:08:50 -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=OUgg8Du+/Wff+DQETawiCgu8tK0Xr9+pCS0ZJabuwZA=; b=AfyhcD1Niy8qh8XmDWHjI7b7nAoGud3DpKVBZdiYFDVwcrpfwg9qxGhiDn56Xdaq97 XoDiINqrke8j7D9RBbji6BarQmlurqisJTlgZKrH8CBq7DsZaa0U2257dmxadq2swrM4 doUi5M/Dv2CqrudBxKydXloHuy6UkafsP7KptKR0QduM34R46NCHC6UK/MJYEy5CuO0v mGnhXc99JhkpbYxpARwtHIETXd0a4veaJRXiNoxiykrDjfiIJJMRrEnbdLXbzovMRs7O bBDEmUIRTX3ffcGY3TVfj5o5cjs/AuRWdEja23YWNUjTBsrqckRS+EC+QnR60RqP/xy9 punA== 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=OUgg8Du+/Wff+DQETawiCgu8tK0Xr9+pCS0ZJabuwZA=; b=DyFLzK6vRiObEQ+cKwbqxsVpGpVMAamsASWSpDKaUE29oRzhkNUWgK48sEEK2paqOc vygW4GhQF5649evmDmO0kKoRP/E/HHDvffqum6dYhrw7eOrclqBpoW3Qz0rAhSFIZlTM VkXe1lwH4VUtg1K8cmq8sNO9cbOhw3dE6Ii5tUrVYQslW+8PtWy0ZUbP2qLA6uJCNtkj l0K9X8RxcfJHOwMOljo+f24DoIUF6W1vWPwCD9WGJNlt5Ah7sIIvFes00DY2EEW4/jkc ou6RT/cw2m82L++BrKeHalfutqmzOZiCQs3SwXsCP4Kiwb+Y8WRAXkx3RkFoJoJWn8V9 A2XA== X-Gm-Message-State: ANoB5pn8i41qam6gRUypCthwHRjX5S7MkH+tH7QoiEahW5ESo4ZJXKAs A8r9d0VxbCNFsI2JNBE8a/z48P0pRUKKDpRy X-Received: by 2002:aa7:da85:0:b0:46c:b385:83d2 with SMTP id q5-20020aa7da85000000b0046cb38583d2mr50564935eds.0.1671412128937; Sun, 18 Dec 2022 17:08:48 -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.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 18 Dec 2022 17:08:48 -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 05/11] riscv: thead: Add support for the XTheadBa ISA extension Date: Mon, 19 Dec 2022 02:08:32 +0100 Message-Id: <20221219010838.3878675-6-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?1752603067506366802?= X-GMAIL-MSGID: =?utf-8?q?1752603067506366802?= From: Christoph Müllner This patch adds support for the XTheadBa ISA extension. The new INSN pattern is defined in a new file to separate this vendor extension from the standard extensions. gcc/ChangeLog: * config/riscv/riscv.md: Include thead.md * config/riscv/thead.md: New file. gcc/testsuite/ChangeLog: * gcc.target/riscv/xtheadba-addsl.c: New test. Signed-off-by: Christoph Müllner --- gcc/config/riscv/riscv.md | 1 + gcc/config/riscv/thead.md | 31 +++++++++++ .../gcc.target/riscv/xtheadba-addsl.c | 55 +++++++++++++++++++ 3 files changed, 87 insertions(+) create mode 100644 gcc/config/riscv/thead.md create mode 100644 gcc/testsuite/gcc.target/riscv/xtheadba-addsl.c diff --git a/gcc/config/riscv/riscv.md b/gcc/config/riscv/riscv.md index a8bb331f25c..571349b1ca5 100644 --- a/gcc/config/riscv/riscv.md +++ b/gcc/config/riscv/riscv.md @@ -3073,4 +3073,5 @@ (define_insn "riscv_prefetchi_" (include "pic.md") (include "generic.md") (include "sifive-7.md") +(include "thead.md") (include "vector.md") diff --git a/gcc/config/riscv/thead.md b/gcc/config/riscv/thead.md new file mode 100644 index 00000000000..0257cbfad3e --- /dev/null +++ b/gcc/config/riscv/thead.md @@ -0,0 +1,31 @@ +;; Machine description for T-Head vendor extensions +;; Copyright (C) 2021-2022 Free Software Foundation, Inc. + +;; This file is part of GCC. + +;; GCC is free software; you can redistribute it and/or modify +;; it under the terms of the GNU General Public License as published by +;; the Free Software Foundation; either version 3, or (at your option) +;; any later version. + +;; GCC is distributed in the hope that it will be useful, +;; but WITHOUT ANY WARRANTY; without even the implied warranty of +;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +;; GNU General Public License for more details. + +;; You should have received a copy of the GNU General Public License +;; along with GCC; see the file COPYING3. If not see +;; . + +;; XTheadBa + +(define_insn "*th_addsl" + [(set (match_operand:X 0 "register_operand" "=r") + (plus:X (ashift:X (match_operand:X 1 "register_operand" "r") + (match_operand:QI 2 "immediate_operand" "I")) + (match_operand:X 3 "register_operand" "r")))] + "TARGET_XTHEADBA + && (INTVAL (operands[2]) >= 0) && (INTVAL (operands[2]) <= 3)" + "th.addsl\t%0,%1,%3,%2" + [(set_attr "type" "bitmanip") + (set_attr "mode" "")]) diff --git a/gcc/testsuite/gcc.target/riscv/xtheadba-addsl.c b/gcc/testsuite/gcc.target/riscv/xtheadba-addsl.c new file mode 100644 index 00000000000..5004735a246 --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/xtheadba-addsl.c @@ -0,0 +1,55 @@ +/* { dg-do compile } */ +/* { dg-options "-march=rv32gc_xtheadba" { target { rv32 } } } */ +/* { dg-options "-march=rv64gc_xtheadba" { target { rv64 } } } */ +/* { dg-skip-if "" { *-*-* } { "-O0" } } */ + +long +test_1 (long a, long b) +{ + /* th.addsl aX, aX, 1 */ + return a + (b << 1); +} + +int +foos (short *x, int n) +{ + /* th.addsl aX, aX, 1 */ + return x[n]; +} + +long +test_2 (long a, long b) +{ + /* th.addsl aX, aX, 2 */ + return a + (b << 2); +} + +int +fooi (int *x, int n) +{ + /* th.addsl aX, aX, 2 */ + return x[n]; +} + +long +test_3 (long a, long b) +{ + /* th.addsl aX, aX, 3 */ + return a + (b << 3); +} + +long +fool (long *x, int n) +{ + /* th.addsl aX, aX, 2 (rv32) */ + /* th.addsl aX, aX, 3 (rv64) */ + return x[n]; +} + +/* { dg-final { scan-assembler-times "th.addsl\[ \t\]*a\[0-9\]+,a\[0-9\]+,a\[0-9\]+,1" 2 } } */ + +/* { dg-final { scan-assembler-times "th.addsl\[ \t\]*a\[0-9\]+,a\[0-9\]+,a\[0-9\]+,2" 3 { target { rv32 } } } } */ +/* { dg-final { scan-assembler-times "th.addsl\[ \t\]*a\[0-9\]+,a\[0-9\]+,a\[0-9\]+,2" 2 { target { rv64 } } } } */ + +/* { dg-final { scan-assembler-times "th.addsl\[ \t\]*a\[0-9\]+,a\[0-9\]+,a\[0-9\]+,3" 1 { target { rv32 } } } } */ +/* { dg-final { scan-assembler-times "th.addsl\[ \t\]*a\[0-9\]+,a\[0-9\]+,a\[0-9\]+,3" 2 { target { rv64 } } } } */