From patchwork Thu Jul 13 05:38:55 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Monk Chiang X-Patchwork-Id: 119551 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:a6b2:0:b0:3e4:2afc:c1 with SMTP id c18csp1606739vqm; Wed, 12 Jul 2023 22:40:02 -0700 (PDT) X-Google-Smtp-Source: APBJJlFMnpb1fKjUrZRtUQ/fVQ1agzurotvauuNlYsnvY+Jg9xFwmsqGJEElky66IVf0VPr9vUNH X-Received: by 2002:a17:906:f191:b0:992:462d:e2af with SMTP id gs17-20020a170906f19100b00992462de2afmr342206ejb.75.1689226801924; Wed, 12 Jul 2023 22:40:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689226801; cv=none; d=google.com; s=arc-20160816; b=05iYBtIZbvpxg6RJh1X1qqtMSDxCUWyAIae/br2ZZjJfeZD6uMBDF+zyX+bKTsGbto d6fhWfvAuuA47r+KV6WJUj8eh9u3Iuftjht6acjkriCLPI5/EfAh+eTrBgz1SKZNxV57 D1EopNT6JSkrp+V3btK+ZAGGrb5sdF+XmC/HSdNDAlqWTmzVoTGV5AkmBP3f2KcNypTV xX1Sj3RAlr70D0OOnTa2fFMkffCLcgLBtS7rvzDgBCh2cga4svdg5XLBYp1ZJnDuHjsp Az5vCKYXZT+z8eYLlpaVYEFfJIizVUMHXgMUQ7KW2KsGInkZHWbRe1c1wQjoNLNX+ivz GFYQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:reply-to:from:list-subscribe:list-help:list-post :list-archive:list-unsubscribe:list-id:precedence :content-transfer-encoding:mime-version:message-id:date:subject:cc :to:dmarc-filter:delivered-to:dkim-signature:dkim-filter; bh=IfJ/amF7vTZyVpN/GLbMFhRsLkKP1fM9bP6uXNFCO8s=; fh=qrSW5/0w8xlfh7jG4vyw/+s8w25ncmPbe4tg/uQ/wDo=; b=n2l9raNfacbs7s8jYnY3Mu8rMPSIrShMUKc5fJbxZzTgPmKx2BxpIdwfPXtPq9IeE6 xjFD1y9zY5NwOJ9WydnSHd9yJDCqgM+WPrK/IwviE6ke69muwLDKi1H0xDzZO1rN6ItF C7CxPq3+E1B8wj/JAwZPJx9JHExLCVaA3cWOmNQDdAMmZEXd5A8U6C4ybDKuVFQeQDRV AzQRb+qBgMErD9QCpiXOxnSLO8RDSCN9Gp9XjnlDXmYNXkI/QCdvMdC8VhB3gDMarAkH cxOsM3jIRu/4JG8AsKTcXmRAnW23w18JhK7cr2fc4bj1afZp5/PqqvZBSBubBSRmNVWY vFag== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=q8bC0RMY; 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"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from server2.sourceware.org (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id k10-20020a170906970a00b00992bf74c316si5854438ejx.974.2023.07.12.22.40.01 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 12 Jul 2023 22:40:01 -0700 (PDT) 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=@gcc.gnu.org header.s=default header.b=q8bC0RMY; 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"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 35D693857437 for ; Thu, 13 Jul 2023 05:39:58 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 35D693857437 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1689226798; bh=IfJ/amF7vTZyVpN/GLbMFhRsLkKP1fM9bP6uXNFCO8s=; h=To:Cc:Subject:Date:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From:Reply-To:From; b=q8bC0RMY1fjb+qEYmUbUF8wBCd01TmZx3TVAbfSQTCXEGrKCzyZAHz9XhYFYJYny0 kKr56D7Cx7S0z9KfBM4m26ZJwqG9CZnjjbpKrhKYl+sa06LV9/Bc0R9cKs/TewYu2O wWc/FABPHSOImeul3NhOhOD5wwk7ugv3ic+fqgz8= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-yb1-xb2e.google.com (mail-yb1-xb2e.google.com [IPv6:2607:f8b0:4864:20::b2e]) by sourceware.org (Postfix) with ESMTPS id 906C7385842A for ; Thu, 13 Jul 2023 05:39:13 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 906C7385842A Received: by mail-yb1-xb2e.google.com with SMTP id 3f1490d57ef6-ca4a6e11f55so253956276.1 for ; Wed, 12 Jul 2023 22:39:13 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1689226752; x=1691818752; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=IfJ/amF7vTZyVpN/GLbMFhRsLkKP1fM9bP6uXNFCO8s=; b=F/a8X62rEzzsUiIsE0uMH78b4bS1mKFH77v+L6gwImcvtUztrTf6732N4cG19dLQDi jrCDRbF01c4pfCcZp/UO90Ps4tX7Udw+OhiWJIeR/0P9xHjuC58G2ZDlqRnIwkCvrWyd HF+aYWBBMRHqs47bdGxhsVelKmsx1wme6gF6p85XirTQLKpRd+pW00MjZgI4WYWU/xNM 0KKz3mvWgROJDi/yFFng5jBZxHUyjC/xV1jOMcx9mqKjDyjkY2ZnFILAXvFfmxnaNnXy 3+psY6tz86NjlEEf0FMICeUiACt437o/9US8NhXZuG4y6BPDfS4dHxrmmE/juoy06HGY wQFw== X-Gm-Message-State: ABy/qLZXaOH2klthrdGloWX2jo2WBqL19uBhFftk2qLhgv2DfTZZWLk/ GaFd5mA+bV+kLogFSjOYUxFiuJMglqP42j2AETr6D0fhI8i94YSf3PjXcwVp/jd/BBh87raXSOc gMkoCDYdXoQeYINcOIV0RLja3TaT8w2THaCvtsXycu5wCL4DAOmBiO/Ziwjc3v/Dhcv3dciHP3M 8WRNO2 X-Received: by 2002:a25:c50a:0:b0:c9d:5d2e:59ca with SMTP id v10-20020a25c50a000000b00c9d5d2e59camr538473ybe.57.1689226751946; Wed, 12 Jul 2023 22:39:11 -0700 (PDT) Received: from hsinchu02.internal.sifive.com (59-124-168-89.hinet-ip.hinet.net. [59.124.168.89]) by smtp.gmail.com with ESMTPSA id m13-20020aa78a0d000000b006828ee9fa69sm4497399pfa.206.2023.07.12.22.39.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 12 Jul 2023 22:39:11 -0700 (PDT) To: gcc-patches@gcc.gnu.org, kito.cheng@gmail.com Cc: Monk Chiang Subject: [PATCH 1/2] RISC-V: Recognized zihintntl extensions Date: Thu, 13 Jul 2023 13:38:55 +0800 Message-Id: <20230713053856.101950-1-monk.chiang@sifive.com> X-Mailer: git-send-email 2.40.1 MIME-Version: 1.0 X-Spam-Status: No, score=-13.7 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_SHORT, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE 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: , X-Patchwork-Original-From: Monk Chiang via Gcc-patches From: Monk Chiang Reply-To: Monk Chiang Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1771282683123606991 X-GMAIL-MSGID: 1771282683123606991 gcc/ChangeLog: * common/config/riscv/riscv-common.cc: (riscv_implied_info): Add zihintntl item. (riscv_ext_version_table): Ditto. (riscv_ext_flag_table): Ditto. * config/riscv/riscv-opts.h (MASK_ZIHINTNTL): New macro. (TARGET_ZIHINTNTL): Ditto. gcc/testsuite/ChangeLog: * gcc.target/riscv/arch-22.c: New test. * gcc.target/riscv/predef-28.c: New test. --- gcc/common/config/riscv/riscv-common.cc | 4 ++ gcc/config/riscv/riscv-opts.h | 2 + gcc/testsuite/gcc.target/riscv/arch-22.c | 5 +++ gcc/testsuite/gcc.target/riscv/predef-28.c | 47 ++++++++++++++++++++++ 4 files changed, 58 insertions(+) create mode 100644 gcc/testsuite/gcc.target/riscv/arch-22.c create mode 100644 gcc/testsuite/gcc.target/riscv/predef-28.c diff --git a/gcc/common/config/riscv/riscv-common.cc b/gcc/common/config/riscv/riscv-common.cc index 6091d8f281b..28c8f0c1489 100644 --- a/gcc/common/config/riscv/riscv-common.cc +++ b/gcc/common/config/riscv/riscv-common.cc @@ -206,6 +206,8 @@ static const struct riscv_ext_version riscv_ext_version_table[] = {"zksh", ISA_SPEC_CLASS_NONE, 1, 0}, {"zkt", ISA_SPEC_CLASS_NONE, 1, 0}, + {"zihintntl", ISA_SPEC_CLASS_NONE, 1, 0}, + {"zicboz",ISA_SPEC_CLASS_NONE, 1, 0}, {"zicbom",ISA_SPEC_CLASS_NONE, 1, 0}, {"zicbop",ISA_SPEC_CLASS_NONE, 1, 0}, @@ -1267,6 +1269,8 @@ static const riscv_ext_flag_table_t riscv_ext_flag_table[] = {"zksh", &gcc_options::x_riscv_zk_subext, MASK_ZKSH}, {"zkt", &gcc_options::x_riscv_zk_subext, MASK_ZKT}, + {"zihintntl", &gcc_options::x_riscv_zi_subext, MASK_ZIHINTNTL}, + {"zicboz", &gcc_options::x_riscv_zicmo_subext, MASK_ZICBOZ}, {"zicbom", &gcc_options::x_riscv_zicmo_subext, MASK_ZICBOM}, {"zicbop", &gcc_options::x_riscv_zicmo_subext, MASK_ZICBOP}, diff --git a/gcc/config/riscv/riscv-opts.h b/gcc/config/riscv/riscv-opts.h index cfcf608ea62..beee241aa1b 100644 --- a/gcc/config/riscv/riscv-opts.h +++ b/gcc/config/riscv/riscv-opts.h @@ -101,9 +101,11 @@ enum riscv_entity #define MASK_ZICSR (1 << 0) #define MASK_ZIFENCEI (1 << 1) +#define MASK_ZIHINTNTL (1 << 2) #define TARGET_ZICSR ((riscv_zi_subext & MASK_ZICSR) != 0) #define TARGET_ZIFENCEI ((riscv_zi_subext & MASK_ZIFENCEI) != 0) +#define TARGET_ZIHINTNTL ((riscv_zi_subext & MASK_ZIHINTNTL) != 0) #define MASK_ZAWRS (1 << 0) #define TARGET_ZAWRS ((riscv_za_subext & MASK_ZAWRS) != 0) diff --git a/gcc/testsuite/gcc.target/riscv/arch-22.c b/gcc/testsuite/gcc.target/riscv/arch-22.c new file mode 100644 index 00000000000..cdc18e13d0f --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/arch-22.c @@ -0,0 +1,5 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -march=rv64gc_zihintntl -mabi=lp64 -mcmodel=medlow" } */ +int foo() +{ +} diff --git a/gcc/testsuite/gcc.target/riscv/predef-28.c b/gcc/testsuite/gcc.target/riscv/predef-28.c new file mode 100644 index 00000000000..81fdad571e7 --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/predef-28.c @@ -0,0 +1,47 @@ +/* { dg-do compile } */ +/* { dg-options "-march=rv64gc_zihintntl -mabi=lp64 -mcmodel=medlow" } */ + +int main () { + +#ifndef __riscv_arch_test +#error "__riscv_arch_test" +#endif + +#if __riscv_xlen != 64 +#error "__riscv_xlen" +#endif + +#if !defined(__riscv_i) +#error "__riscv_i" +#endif + +#if !defined(__riscv_c) +#error "__riscv_c" +#endif + +#if defined(__riscv_e) +#error "__riscv_e" +#endif + +#if !defined(__riscv_a) +#error "__riscv_a" +#endif + +#if !defined(__riscv_m) +#error "__riscv_m" +#endif + +#if !defined(__riscv_f) +#error "__riscv_f" +#endif + +#if !defined(__riscv_d) +#error "__riscv_d" +#endif + +#if !defined(__riscv_zihintntl) +#error "__riscv_zihintntl" +#endif + + return 0; +} From patchwork Thu Jul 13 05:38:56 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Monk Chiang X-Patchwork-Id: 119552 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:a6b2:0:b0:3e4:2afc:c1 with SMTP id c18csp1607067vqm; Wed, 12 Jul 2023 22:41:03 -0700 (PDT) X-Google-Smtp-Source: APBJJlEQbnft/lDszHd77e3qzc5xrO+wiUCxGhuWuI8Q1jLVSO5ECeZc5eIJVw3y+lk1AnbGqYIl X-Received: by 2002:a17:906:2308:b0:98d:e7e3:5ab7 with SMTP id l8-20020a170906230800b0098de7e35ab7mr459837eja.11.1689226863184; Wed, 12 Jul 2023 22:41:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689226863; cv=none; d=google.com; s=arc-20160816; b=jXLqJACh3CHzydHehIca68BzZSww4fPit9V+4TAeKRQ25UKRyBMFQ72JSG4t2WAExc Y/Yy9oVBa4jzlLmezqealcX0/5PAegPEyWoqfG94DrxzxJnuyQrV96ovhwTB/Oxr/oj/ el+xIRKBIrFrkrkyXfN/QQciZBcVMqhncF7BqBRZ6tq1cDg2Vc+s0iJeBWKLOa4O057I xjPO9G/R+HxX8jB9its3diMQtPkyAh7+bccjtMqrKL3XM4tWJkKPvYKDFcYsW+yuhal0 y0UOl2vHs1QBKgthk//kEMe1Jja7S5FRSz0vylFRRCl+FYmPu+u8oKreWxsgJ5ByQeSG qDOw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:reply-to:from: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:dmarc-filter:delivered-to :dkim-signature:dkim-filter; bh=C92HLFs5kPQ6rymxikgkieKOT2AmR9ONt/Ei48K+zT4=; fh=qrSW5/0w8xlfh7jG4vyw/+s8w25ncmPbe4tg/uQ/wDo=; b=ik/oGF2oba4KPCCNoP6VxnpvBpALz6y+uh5QHa15PcCW0Ft9yIAHJ/2D6Nqx7tqoN1 D6nUzU6/iwWgP/4OdeQuAL2Ly8QApCgeQca5BDxVa1XIH79Fe2PTMAmSLA/v4kGjRWfn yEEKlPi07Bd2XXpSP6tfQWlBMsfvPowYhX0zxLpyYxrOCsJS3IUC5sGc3lGlobYVe1S3 K4g/PEpQ85PyqvqTwxFVBh2EFONCNkdkEnnneCcuHcIthILtdC0sGeno1in7gqf0pnzF rTHmLBZj3En9rmyqqBRuF+7JnHrAu+NELjcGuVdG1TYUBcVyhZR9mMWs8lRGOTGzkR9U d9yg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=pbZRcfIp; 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"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from server2.sourceware.org (ip-8-43-85-97.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id p1-20020a1709060dc100b0099027b40d82si5830317eji.243.2023.07.12.22.41.02 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 12 Jul 2023 22:41:03 -0700 (PDT) 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=@gcc.gnu.org header.s=default header.b=pbZRcfIp; 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"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 3DC8A3856DE6 for ; Thu, 13 Jul 2023 05:40:54 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 3DC8A3856DE6 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1689226854; bh=C92HLFs5kPQ6rymxikgkieKOT2AmR9ONt/Ei48K+zT4=; h=To:Cc:Subject:Date:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From:Reply-To:From; b=pbZRcfIpxPtuFEB00SaT8ejuNiDuv2PlXfqF0S41XUnMy+0iLZhnqQJm/CS9s5jaQ GvYs0b1swEWWfrwXDFazSyGzcfIFwJkbLt2rQ/U+JdJZ9WNYTadkHf2RGuzQ8ABT9N dwYMmPZv/Q3I9Rl4tReijV/KLECV20rXKlIOPTnY= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-pf1-x435.google.com (mail-pf1-x435.google.com [IPv6:2607:f8b0:4864:20::435]) by sourceware.org (Postfix) with ESMTPS id 0B9933857341 for ; Thu, 13 Jul 2023 05:39:21 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 0B9933857341 Received: by mail-pf1-x435.google.com with SMTP id d2e1a72fcca58-68336d06620so350947b3a.1 for ; Wed, 12 Jul 2023 22:39:20 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1689226759; x=1691818759; 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=C92HLFs5kPQ6rymxikgkieKOT2AmR9ONt/Ei48K+zT4=; b=c6s8ozUfCnIGbn2VLDSJJ7f8yrcMS0GS74q5PY9y4cvedcfum7MVuvIfOHjxQmb8TZ RRtcB8O4bV6f687Kd2oYSTvGOXArm1F1d1friAjGTUlztjaKqpW8NIlT1D2jD5l6ugPa fkPwwAJIiTvcSW0Tmimsx4qGQV+Y29OaY0mgUGdu092Mom38uEwfM4fNgZ9KysWdohNp FIQ2Td+6X/UBNstqSP3uEWnzBCESIgSxrhmLvk9Yhk7iACzTrzY8PY1ajgDo1DEBpIfg nyELcHP4hGfSURqpehLpu2wRFZiQtEEmrMvOjEO3DM4PasSKMF6XDRqmPcQbjZaINKC/ jE5g== X-Gm-Message-State: ABy/qLZvtq/YS3L9KfzSLNeVBUK+P+pc47pvslpd3SVuGM1RBxCFd1J8 X296aZbwCECKhGJR4nIFiTj24ZKZtYZyQWX3JGDuE9cW6bTODT/aBi/isfYYFlzqE/kSdpPS7Uk ZS1L6gg/CfiZnj/071HG++frZD3MzmTbcokRUpnC2MmHzhtpqPP/dCFA5BYttdU4g4Ic/ukvFCE T5CtoK X-Received: by 2002:a05:6a21:7803:b0:118:eeef:2a25 with SMTP id be3-20020a056a21780300b00118eeef2a25mr567132pzc.34.1689226758696; Wed, 12 Jul 2023 22:39:18 -0700 (PDT) Received: from hsinchu02.internal.sifive.com (59-124-168-89.hinet-ip.hinet.net. [59.124.168.89]) by smtp.gmail.com with ESMTPSA id m13-20020aa78a0d000000b006828ee9fa69sm4497399pfa.206.2023.07.12.22.39.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 12 Jul 2023 22:39:18 -0700 (PDT) To: gcc-patches@gcc.gnu.org, kito.cheng@gmail.com Cc: Monk Chiang Subject: [PATCH 2/2] RISC-V: Implement locality for __builtin_prefetch Date: Thu, 13 Jul 2023 13:38:56 +0800 Message-Id: <20230713053856.101950-2-monk.chiang@sifive.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230713053856.101950-1-monk.chiang@sifive.com> References: <20230713053856.101950-1-monk.chiang@sifive.com> MIME-Version: 1.0 X-Spam-Status: No, score=-13.7 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_SHORT, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE 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: , X-Patchwork-Original-From: Monk Chiang via Gcc-patches From: Monk Chiang Reply-To: Monk Chiang Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1771282747229478830 X-GMAIL-MSGID: 1771282747229478830 gcc/ChangeLog: * config/riscv/riscv.cc (riscv_print_operand): Add 'N' for print a non-temporal locality hints instruction. * config/riscv/riscv.md (prefetch): Add NTLH instruction for prefetch.r and prefetch.w. gcc/testsuite/ChangeLog: * gcc.target/riscv/prefetch-zihintntl.c: New test. --- gcc/config/riscv/riscv.cc | 22 +++++++++++++++++++ gcc/config/riscv/riscv.md | 10 ++++++--- .../gcc.target/riscv/prefetch-zihintntl.c | 20 +++++++++++++++++ 3 files changed, 49 insertions(+), 3 deletions(-) create mode 100644 gcc/testsuite/gcc.target/riscv/prefetch-zihintntl.c diff --git a/gcc/config/riscv/riscv.cc b/gcc/config/riscv/riscv.cc index 706c18416db..42f80088bab 100644 --- a/gcc/config/riscv/riscv.cc +++ b/gcc/config/riscv/riscv.cc @@ -4532,6 +4532,7 @@ riscv_memmodel_needs_amo_release (enum memmodel model) 'A' Print the atomic operation suffix for memory model OP. 'I' Print the LR suffix for memory model OP. 'J' Print the SC suffix for memory model OP. + 'N' Print a non-temporal locality hints instruction. 'z' Print x0 if OP is zero, otherwise print OP normally. 'i' Print i if the operand is not a register. 'S' Print shift-index of single-bit mask OP. @@ -4718,6 +4719,27 @@ riscv_print_operand (FILE *file, rtx op, int letter) break; } + case 'N': + { + const char *ntl_hint = NULL; + switch (INTVAL (op)) + { + case 0: + ntl_hint = "ntl.all"; + break; + case 1: + ntl_hint = "ntl.pall"; + break; + case 2: + ntl_hint = "ntl.p1"; + break; + } + + if (ntl_hint) + asm_fprintf (file, "%s\n\t", ntl_hint); + break; + } + case 'i': if (code != REG) fputs ("i", file); diff --git a/gcc/config/riscv/riscv.md b/gcc/config/riscv/riscv.md index 7988026d129..3357c981b5d 100644 --- a/gcc/config/riscv/riscv.md +++ b/gcc/config/riscv/riscv.md @@ -3256,11 +3256,15 @@ { switch (INTVAL (operands[1])) { - case 0: return "prefetch.r\t%a0"; - case 1: return "prefetch.w\t%a0"; + case 0: return TARGET_ZIHINTNTL ? "%N2prefetch.r\t%a0" : "prefetch.r\t%a0"; + case 1: return TARGET_ZIHINTNTL ? "%N2prefetch.w\t%a0" : "prefetch.w\t%a0"; default: gcc_unreachable (); } -}) +} + [(set (attr "length") (if_then_else (and (match_test "TARGET_ZIHINTNTL") + (match_test "INTVAL (operands[2]) != 3")) + (const_string "8") + (const_string "4")))]) (define_insn "riscv_prefetchi_" [(unspec_volatile:X [(match_operand:X 0 "address_operand" "r") diff --git a/gcc/testsuite/gcc.target/riscv/prefetch-zihintntl.c b/gcc/testsuite/gcc.target/riscv/prefetch-zihintntl.c new file mode 100644 index 00000000000..78a3afe6833 --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/prefetch-zihintntl.c @@ -0,0 +1,20 @@ +/* { dg-do compile target { { rv64-*-*}}} */ +/* { dg-options "-march=rv64gc_zicbop_zihintntl -mabi=lp64" } */ + +void foo (char *p) +{ + __builtin_prefetch (p, 0, 0); + __builtin_prefetch (p, 0, 1); + __builtin_prefetch (p, 0, 2); + __builtin_prefetch (p, 0, 3); + __builtin_prefetch (p, 1, 0); + __builtin_prefetch (p, 1, 1); + __builtin_prefetch (p, 1, 2); + __builtin_prefetch (p, 1, 3); +} + +/* { dg-final { scan-assembler-times "ntl.all" 2 } } */ +/* { dg-final { scan-assembler-times "ntl.pall" 2 } } */ +/* { dg-final { scan-assembler-times "ntl.p1" 2 } } */ +/* { dg-final { scan-assembler-times "prefetch.r" 4 } } */ +/* { dg-final { scan-assembler-times "prefetch.w" 4 } } */