From patchwork Wed Nov 8 11:09:12 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mary Bennett X-Patchwork-Id: 162950 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:aa0b:0:b0:403:3b70:6f57 with SMTP id k11csp837214vqo; Wed, 8 Nov 2023 03:10:10 -0800 (PST) X-Google-Smtp-Source: AGHT+IHmLMcgaUNntDDzdQRUwKpDcL8F5mdLsxt1AQVFvBd8kkWvdqvirQ08nII2BebiyolVnEfz X-Received: by 2002:ae9:c102:0:b0:774:500:a18e with SMTP id z2-20020ae9c102000000b007740500a18emr1165987qki.75.1699441810197; Wed, 08 Nov 2023 03:10:10 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1699441810; cv=pass; d=google.com; s=arc-20160816; b=iTBFayc8nZDTPysZrFfbq7GiiBT+Lf5V3qJCffNl5FVG8MdT/GuudNySMR3vGkqIPf ifaNBUip4nCv/suEHX5PJ59IzHcYZTSGK64xpqygTmwQeTshUtPXUE4+IKGUcm4p7j84 5hYao15yAGDZ156uhxjbSNUr00nKaFzBCJ/IyUYQKcWDqujW9bkA85I3ySa+fOh34e3k wi3Ks8b+Uq311LXxpW/tMeuLaLLSHljRDvcnqoxWgCZ29Hro92X7/99wFilTodDnGJnC KSBSdYhK/+28Q4RHI+rsvAxPmutgSIBU9gUbrH+x1SFEuxJ2ScMxVLDcMHiY0pWEjlZX Oi6A== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=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:arc-filter:dmarc-filter:delivered-to; bh=6v/5BIqOh0USHFXtbcOwLczzKBEEaY/lkmbLU4Uorvw=; fh=qiT4HZV9olO2fGAIgbF8w4l7HXh8ja5CJNGeguP7WSc=; b=yGqUOT4l5oLwl98Z8hEDuqhVDyLAheIPXeiHX5Q/a9JvBv3nk8u7xxBI6O1RaNfXQd 5KYnPutQH/vwhhosYwuFYF8BxzrU6Hx7C1fAbr1OMudftpcxScIBeioC6iYnneVJPH1t ywmnygS+O10y07rADTRepnW+pdGkeDG8RptAXSPIg320ZIBUREgoh5Z5dVp/7o1vk79e lvCswuJGT/6fI9hqlsubicbzMjCr2aSKCddYjKtfXYfAK7qcf4+i1NSYg48GX7+Nm5yg A/jdXPUAj3/WtDfoqvoNjsFSd2PISJD37w72tdMmGUo6qij2fYk/9OuRYjHLnNuOUUrk boTw== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@embecosm.com header.s=google header.b=E+1JxSsU; arc=pass (i=1); 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 (server2.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id de44-20020a05620a372c00b0077703bd9771si1159753qkb.364.2023.11.08.03.10.10 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 Nov 2023 03:10: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=@embecosm.com header.s=google header.b=E+1JxSsU; arc=pass (i=1); 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 4779D385B528 for ; Wed, 8 Nov 2023 11:10:03 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-wm1-x32e.google.com (mail-wm1-x32e.google.com [IPv6:2a00:1450:4864:20::32e]) by sourceware.org (Postfix) with ESMTPS id 43AD03858D38 for ; Wed, 8 Nov 2023 11:09:36 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 43AD03858D38 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=embecosm.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=embecosm.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 43AD03858D38 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2a00:1450:4864:20::32e ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1699441779; cv=none; b=gQZRAF92TSTRP5pBbFm4+UdkIp4j2bYt2aNXf+VEkzNidJNfryc4nbbKnn0VU+RZTUIj3IZSjT6F59heWxCa7glXSttlxLgTxiKmfxW1SkmpY94psYoD14MXB5WZyO/EQqDscepFYZSvB05MaicjFe6QbAJYcHq3OkHOnoX1hgo= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1699441779; c=relaxed/simple; bh=cnSa3lpbFd2Oz5FXAzg9uGNGyQV4KPa53rRQvKISaGk=; h=DKIM-Signature:From:To:Subject:Date:Message-Id:MIME-Version; b=eEnIzrO1Pa5GjXMyHw69jYgBGVDJToFhW1SUaF699W6iIfEiX8sduRTST10tvw68e7fMEn2qa9xo9QL9Tuh3V54o/6gZBNN6YN5cDTmrUWeb8dh5SYvRNqnhq1l3Tx0p+1SHO7wTtbK08JjN2u3H/QwLXo36dKl9tCfER9rim+4= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-wm1-x32e.google.com with SMTP id 5b1f17b1804b1-40906fc54fdso51589505e9.0 for ; Wed, 08 Nov 2023 03:09:36 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=embecosm.com; s=google; t=1699441774; x=1700046574; darn=gcc.gnu.org; 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=6v/5BIqOh0USHFXtbcOwLczzKBEEaY/lkmbLU4Uorvw=; b=E+1JxSsUqpDrI0SJPPUED0TO5v6+U9n4ucd5IYgXM7C4zTAQivxMWNgZUgdDrzBHry xdx9iBkjHHpet2D7dVU/z+CbBqi03cdoP+deljcYJTuUfx7n+DvIVG7URiU1O5j6dyeP lFmYdF4pKGOoq5N+eVHjOlLxIpWE9ou4F6CpiRk0LLRiVPR3BDGKOWRAoEg4ZMj5m9Ub 8xEuppr7AqdnZ31hHH0kzSiFSCs5inz/FldLftoN5FR4d2+pZV7bvU73obyoPe5FRyrs ku04eB3dS7zyZ6kkFpUhGqM+KVaAXB2Y0wjTdaI5FL9XRN5gVJXZ9rqVPRL22aGpqwOf hnwg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1699441774; x=1700046574; 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=6v/5BIqOh0USHFXtbcOwLczzKBEEaY/lkmbLU4Uorvw=; b=OVJlu7FBCFAjnWw0CrP4zJyGeUJ0YcbMgB2AI8lC4Htc7dLWAvjwjJqmzGjeg4BU1Y lTH0PgsNfFQ1iu2iACaKZffxTdMLixeoWZm1wCbT09HFLLtNXIfxYYBAAVuuInpmYWMc 85iZNjAWPBBF+7wySEkfMBMums1am6YpWm+1SzIBgK0pv2MM6PbMj6ApCo6wpis0hKs4 +xABl1Xkk/d1sDk9tdVNO4KYJKukSaYeo542/Z9ES9MZhLnDF/yLE6s0YIQKmWwlrf/b rbRlt/JOqNdO3y5Rj1rXdkSeKVxwMLDgLSHRKO97dVY6rhmYEutd8Xllta2/Kk3JIWad eX5A== X-Gm-Message-State: AOJu0Yy68lQGS9r7GSmk2RwdOr4+U2aBuae5kwL5fhhnzky4n5/aloaz thdyczPNWplwFoJXnNli3u2s152bGHLI1ca3VGiPEw== X-Received: by 2002:a05:600c:4f41:b0:402:98cd:a3e9 with SMTP id m1-20020a05600c4f4100b0040298cda3e9mr1385685wmq.32.1699441773937; Wed, 08 Nov 2023 03:09:33 -0800 (PST) Received: from troughton.sou.embecosm-corp.com ([212.69.42.53]) by smtp.gmail.com with ESMTPSA id g4-20020a05600c310400b004068e09a70bsm18903289wmo.31.2023.11.08.03.09.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 Nov 2023 03:09:33 -0800 (PST) From: Mary Bennett To: gcc-patches@gcc.gnu.org Cc: mary.bennett@embecosm.com Subject: [PATCH 1/3] RISC-V: Add support for XCVelw extension in CV32E40P Date: Wed, 8 Nov 2023 11:09:12 +0000 Message-Id: <20231108110914.2710021-2-mary.bennett@embecosm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231108110914.2710021-1-mary.bennett@embecosm.com> References: <20231108110914.2710021-1-mary.bennett@embecosm.com> MIME-Version: 1.0 X-Spam-Status: No, score=-11.2 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.30 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 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1781993895632283424 X-GMAIL-MSGID: 1781993895632283424 Spec: github.com/openhwgroup/core-v-sw/blob/master/specifications/corev-builtin-spec.md Contributors: Mary Bennett Nandni Jamnadas Pietra Ferreira Charlie Keaney Jessica Mills Craig Blackmore Simon Cook Jeremy Bennett Helene Chelin gcc/ChangeLog: * common/config/riscv/riscv-common.cc: Add XCVelw. * config/riscv/corev.def: Likewise. * config/riscv/corev.md: Likewise. * config/riscv/riscv-builtins.cc (AVAIL): Likewise. * config/riscv/riscv-ftypes.def: Likewise. * config/riscv/riscv.opt: Likewise. * doc/extend.texi: Add XCVelw builtin documentation. * doc/sourcebuild.texi: Likewise. gcc/testsuite/ChangeLog: * gcc.target/riscv/cv-elw-compile-1.c: Create test for cv.elw. * testsuite/lib/target-supports.exp: Add proc for the XCVelw extension. --- gcc/common/config/riscv/riscv-common.cc | 2 ++ gcc/config/riscv/corev.def | 3 +++ gcc/config/riscv/corev.md | 15 +++++++++++++++ gcc/config/riscv/riscv-builtins.cc | 2 ++ gcc/config/riscv/riscv-ftypes.def | 1 + gcc/config/riscv/riscv.opt | 2 ++ gcc/doc/extend.texi | 8 ++++++++ gcc/doc/sourcebuild.texi | 3 +++ .../gcc.target/riscv/cv-elw-elw-compile-1.c | 11 +++++++++++ gcc/testsuite/lib/target-supports.exp | 13 +++++++++++++ 10 files changed, 60 insertions(+) create mode 100644 gcc/testsuite/gcc.target/riscv/cv-elw-elw-compile-1.c diff --git a/gcc/common/config/riscv/riscv-common.cc b/gcc/common/config/riscv/riscv-common.cc index 526dbb7603b..6a1978bd0e4 100644 --- a/gcc/common/config/riscv/riscv-common.cc +++ b/gcc/common/config/riscv/riscv-common.cc @@ -312,6 +312,7 @@ static const struct riscv_ext_version riscv_ext_version_table[] = {"xcvmac", ISA_SPEC_CLASS_NONE, 1, 0}, {"xcvalu", ISA_SPEC_CLASS_NONE, 1, 0}, + {"xcvelw", ISA_SPEC_CLASS_NONE, 1, 0}, {"xtheadba", ISA_SPEC_CLASS_NONE, 1, 0}, {"xtheadbb", ISA_SPEC_CLASS_NONE, 1, 0}, @@ -1667,6 +1668,7 @@ static const riscv_ext_flag_table_t riscv_ext_flag_table[] = {"xcvmac", &gcc_options::x_riscv_xcv_subext, MASK_XCVMAC}, {"xcvalu", &gcc_options::x_riscv_xcv_subext, MASK_XCVALU}, + {"xcvelw", &gcc_options::x_riscv_xcv_subext, MASK_XCVELW}, {"xtheadba", &gcc_options::x_riscv_xthead_subext, MASK_XTHEADBA}, {"xtheadbb", &gcc_options::x_riscv_xthead_subext, MASK_XTHEADBB}, diff --git a/gcc/config/riscv/corev.def b/gcc/config/riscv/corev.def index 17580df3c41..3b9ec029d06 100644 --- a/gcc/config/riscv/corev.def +++ b/gcc/config/riscv/corev.def @@ -41,3 +41,6 @@ RISCV_BUILTIN (cv_alu_subN, "cv_alu_subN", RISCV_BUILTIN_DIRECT, RISCV_SI_FT RISCV_BUILTIN (cv_alu_subuN, "cv_alu_subuN", RISCV_BUILTIN_DIRECT, RISCV_USI_FTYPE_USI_USI_UQI, cvalu), RISCV_BUILTIN (cv_alu_subRN, "cv_alu_subRN", RISCV_BUILTIN_DIRECT, RISCV_SI_FTYPE_SI_SI_UQI, cvalu), RISCV_BUILTIN (cv_alu_subuRN, "cv_alu_subuRN",RISCV_BUILTIN_DIRECT, RISCV_USI_FTYPE_USI_USI_UQI, cvalu), + +// XCVELW +RISCV_BUILTIN (cv_elw_elw_si, "cv_elw_elw", RISCV_BUILTIN_DIRECT, RISCV_USI_FTYPE_VOID_PTR, cvelw), diff --git a/gcc/config/riscv/corev.md b/gcc/config/riscv/corev.md index 1350bd4b81e..be66b1428a7 100644 --- a/gcc/config/riscv/corev.md +++ b/gcc/config/riscv/corev.md @@ -24,6 +24,9 @@ UNSPEC_CV_ALU_CLIPR UNSPEC_CV_ALU_CLIPU UNSPEC_CV_ALU_CLIPUR + + ;;CORE-V EVENT LOAD + UNSPECV_CV_ELW ]) ;; XCVMAC extension. @@ -691,3 +694,15 @@ cv.suburnr\t%0,%2,%3" [(set_attr "type" "arith") (set_attr "mode" "SI")]) + +;; XCVELW builtins +(define_insn "riscv_cv_elw_elw_si" + [(set (match_operand:SI 0 "register_operand" "=r") + (unspec_volatile [(mem:SI (match_operand:SI 1 "address_operand" "p"))] + UNSPECV_CV_ELW))] + + "TARGET_XCVELW && !TARGET_64BIT" + "cv.elw\t%0,%a1" + + [(set_attr "type" "load") + (set_attr "mode" "SI")]) diff --git a/gcc/config/riscv/riscv-builtins.cc b/gcc/config/riscv/riscv-builtins.cc index fc3976f3ba1..5ee11ebe3bc 100644 --- a/gcc/config/riscv/riscv-builtins.cc +++ b/gcc/config/riscv/riscv-builtins.cc @@ -128,6 +128,7 @@ AVAIL (hint_pause, (!0)) // CORE-V AVAIL AVAIL (cvmac, TARGET_XCVMAC && !TARGET_64BIT) AVAIL (cvalu, TARGET_XCVALU && !TARGET_64BIT) +AVAIL (cvelw, TARGET_XCVELW && !TARGET_64BIT) /* Construct a riscv_builtin_description from the given arguments. @@ -168,6 +169,7 @@ AVAIL (cvalu, TARGET_XCVALU && !TARGET_64BIT) #define RISCV_ATYPE_HI intHI_type_node #define RISCV_ATYPE_SI intSI_type_node #define RISCV_ATYPE_VOID_PTR ptr_type_node +#define RISCV_ATYPE_INT_PTR integer_ptr_type_node /* RISCV_FTYPE_ATYPESN takes N RISCV_FTYPES-like type codes and lists their associated RISCV_ATYPEs. */ diff --git a/gcc/config/riscv/riscv-ftypes.def b/gcc/config/riscv/riscv-ftypes.def index 0d1e4dd061e..3e7d5c69503 100644 --- a/gcc/config/riscv/riscv-ftypes.def +++ b/gcc/config/riscv/riscv-ftypes.def @@ -30,6 +30,7 @@ DEF_RISCV_FTYPE (0, (USI)) DEF_RISCV_FTYPE (0, (VOID)) DEF_RISCV_FTYPE (1, (VOID, USI)) DEF_RISCV_FTYPE (1, (VOID, VOID_PTR)) +DEF_RISCV_FTYPE (1, (USI, VOID_PTR)) DEF_RISCV_FTYPE (1, (USI, USI)) DEF_RISCV_FTYPE (1, (UDI, UDI)) DEF_RISCV_FTYPE (1, (USI, UQI)) diff --git a/gcc/config/riscv/riscv.opt b/gcc/config/riscv/riscv.opt index 70d78151cee..0eac6d44fae 100644 --- a/gcc/config/riscv/riscv.opt +++ b/gcc/config/riscv/riscv.opt @@ -411,6 +411,8 @@ Mask(XCVMAC) Var(riscv_xcv_subext) Mask(XCVALU) Var(riscv_xcv_subext) +Mask(XCVELW) Var(riscv_xcv_subext) + TargetVariable int riscv_xthead_subext diff --git a/gcc/doc/extend.texi b/gcc/doc/extend.texi index c8fc4e391b5..b890acccac1 100644 --- a/gcc/doc/extend.texi +++ b/gcc/doc/extend.texi @@ -21970,6 +21970,14 @@ Generated assembler @code{cv.subuRN} if the uint8_t operand is a constant and in Generated assembler @code{cv.subuRNr} if the it is a register. @end deftypefn +These built-in functions are available for the CORE-V Event Load machine +architecture. For more information on CORE-V ELW builtins, please see +@uref{https://github.com/openhwgroup/core-v-sw/blob/master/specifications/corev-builtin-spec.md#listing-of-event-load-word-builtins-xcvelw} + +@deftypefn {Built-in Function} {uint32_t} __builtin_riscv_cv_elw_elw (uint32_t *) +Generated assembler @code{cv.elw} +@end deftypefn + @node RX Built-in Functions @subsection RX Built-in Functions GCC supports some of the RX instructions which cannot be expressed in diff --git a/gcc/doc/sourcebuild.texi b/gcc/doc/sourcebuild.texi index c20af31c642..06a6d1776ff 100644 --- a/gcc/doc/sourcebuild.texi +++ b/gcc/doc/sourcebuild.texi @@ -2481,6 +2481,9 @@ Test system has support for the CORE-V MAC extension. @item cv_alu Test system has support for the CORE-V ALU extension. +@item cv_elw +Test system has support for the CORE-V ELW extension. + @end table @subsubsection Other hardware attributes diff --git a/gcc/testsuite/gcc.target/riscv/cv-elw-elw-compile-1.c b/gcc/testsuite/gcc.target/riscv/cv-elw-elw-compile-1.c new file mode 100644 index 00000000000..bafb9f29e8c --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/cv-elw-elw-compile-1.c @@ -0,0 +1,11 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target cv_elw } */ +/* { dg-options "-march=rv32i_xcvelw -mabi=ilp32" } */ + +int +foo (void* b) +{ + return __builtin_riscv_cv_elw_elw (b + 8); +} + +/* { dg-final { scan-assembler-times "cv\\.elw" 1 } } */ diff --git a/gcc/testsuite/lib/target-supports.exp b/gcc/testsuite/lib/target-supports.exp index 024939ee2e7..f388360ae56 100644 --- a/gcc/testsuite/lib/target-supports.exp +++ b/gcc/testsuite/lib/target-supports.exp @@ -13085,6 +13085,19 @@ proc check_effective_target_cv_alu { } { } "-march=rv32i_xcvalu" ] } +# Return 1 if the CORE-V ELW extension is available. +proc check_effective_target_cv_elw { } { + if { !([istarget riscv*-*-*]) } { + return 0 + } + return [check_no_compiler_messages cv_elw object { + void foo (void) + { + asm ("cv.elw x0, 0(x0)"); + } + } "-march=rv32i_xcvelw" ] +} + proc check_effective_target_loongarch_sx { } { return [check_no_compiler_messages loongarch_lsx assembly { #if !defined(__loongarch_sx) From patchwork Wed Nov 8 11:09:13 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mary Bennett X-Patchwork-Id: 162951 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:aa0b:0:b0:403:3b70:6f57 with SMTP id k11csp837255vqo; Wed, 8 Nov 2023 03:10:15 -0800 (PST) X-Google-Smtp-Source: AGHT+IG2yIefPGyvjOId38n8tR68LJbPb2MhP+xKsR7VHQYHqKjvQGWmqWWjlSKzI57MdpSsB/5u X-Received: by 2002:a25:c00f:0:b0:da0:400e:750c with SMTP id c15-20020a25c00f000000b00da0400e750cmr1310508ybf.27.1699441815672; Wed, 08 Nov 2023 03:10:15 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1699441815; cv=pass; d=google.com; s=arc-20160816; b=uZfBJIlOZAFJPVTiXHIv11+cSvRnXoY+0qJK2UDrrdWwWGyE+cibn0MRRuqsrL3Gdh RH1XHJYD60/SVBycuJQMWqkyL1JynI4nfnqmv4pncJjHqQm51M9aC4WijNAbqKk/s14m 7j36+WB6tGqK+0AVcCwQlXFseUaOqR9Hev6VdJfnjBQFDRSMMn8071/hJRbfaihdW2Lt Q3H6nWQbsuskc/bw6qYYLAYfVm3B41dVN6AumH4wIpNV66Ano5F/6GH+/eAYK42MlO4w SmrN3x8rHGs2XsxuwbyxBb7NXqriqFlIF0gJ8f25o0KrIlxSoxEl91ekXGURksLJz6Ha /D8g== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=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:arc-filter:dmarc-filter:delivered-to; bh=pnTctBQe+C91dJSpFcaZX61wy8ziDziud3AdbvexBXs=; fh=qiT4HZV9olO2fGAIgbF8w4l7HXh8ja5CJNGeguP7WSc=; b=EH639gI9vhH4hzyXI4bHsLCzGH1sGWus7AkBeChLx5wDtx5jzlVdAxwdpv0i+0Fprh nZWMCOj5fTZ7qk+7EN5dWKAVPBQ45drlyO/GMadzk7bUXEaFrL2kIjXKF8o0cY5rASEN x0UHeNh6D+OlxM6IoZyMx9gx0UQJ3xUcJM7Oj/gevbK8X0akP3V35VzlNiH8Jf7s0j36 CsEZFWKwAyediT20KPgPIfds+1rcTcYTkJ+r5+cNbwcQuC9SWE/34q7Ki6V2GXlEu/O0 2yuCs9Mj8cRWdwTS9o+qrWBz/YZr1w6l6MjdWWX+v0HjcrHAex/hOy/B0QmqpPsoZBpE uH5w== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@embecosm.com header.s=google header.b=gKs4fxpu; arc=pass (i=1); 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 (server2.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id p1-20020a05621415c100b0066d132b1c94si1178953qvz.32.2023.11.08.03.10.15 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 Nov 2023 03:10:15 -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=@embecosm.com header.s=google header.b=gKs4fxpu; arc=pass (i=1); 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 5E4293858C36 for ; Wed, 8 Nov 2023 11:10:07 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-lj1-x232.google.com (mail-lj1-x232.google.com [IPv6:2a00:1450:4864:20::232]) by sourceware.org (Postfix) with ESMTPS id 4AE013858D3C for ; Wed, 8 Nov 2023 11:09:37 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 4AE013858D3C Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=embecosm.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=embecosm.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 4AE013858D3C Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2a00:1450:4864:20::232 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1699441779; cv=none; b=oz7EV/gu6mYncrwk6/8TEFKIl4UGRYucP5oHEYkaStUSf0lzXXAQ293oscIqU6j08aI9F9Tq+6wWWLU0P8F3efP6EszEfmd+tsd6wEUG0NngfjE3APS/vdkli3JE1r3SVjptjH50dK2nkY+IDUt9V0ZcKilL15v3cR/1o73OYhA= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1699441779; c=relaxed/simple; bh=OWCuDmA5lKn4f1v+Y0PiC5DP+Dq59WFQbSTbTUucQj8=; h=DKIM-Signature:From:To:Subject:Date:Message-Id:MIME-Version; b=mKNhjc9ziuFl+TnWkWIZZmwCDqIP8dZN3kBW7/PG4O5uhwuqtgv5om4aILeBxVkX6ckGCQDFyoPRmY74n8O6I/bBI9g7f1OsdJNuDQlMuD4IbQ2ZNFMK+PfulSwu6zvjWJFyOKwJusNMti7yOTX4kpGjHs35HJnWf33P1SSdl9E= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-lj1-x232.google.com with SMTP id 38308e7fff4ca-2c6b30aca06so88759491fa.3 for ; Wed, 08 Nov 2023 03:09:37 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=embecosm.com; s=google; t=1699441775; x=1700046575; darn=gcc.gnu.org; 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=pnTctBQe+C91dJSpFcaZX61wy8ziDziud3AdbvexBXs=; b=gKs4fxpu9B2lIZRZkWTUah8K/BBOknz9Jc2aNNNOO2IiYAUEYURcXm7b37dY6EIpPD Bgf6LfIUkZDJx9lR9EeoQn1sAtG20Ny5XxQ+rHCtyIfYjzPRExj++nplZr3R/AkYrf5H lGSbzcH+kej3tSc91qJF7VGa4Sdv645wHnjnDy5XWmE5JrGUPkkJ9FSahF2QkJKVI/je xe6LaCqjvRZb6KfJmo+9e3nUH3+pOWFoMBsDP3BhTkHHbEjeep/ArpGiOG3uiQn4N9bo P+2YN2QOcm6uMBDs+yGpnl8hQO6GqV7N0Lm3WWXK+01u7vei0XjXMvOcY2P2GJJ2bPGo /cYA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1699441775; x=1700046575; 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=pnTctBQe+C91dJSpFcaZX61wy8ziDziud3AdbvexBXs=; b=B9DoWTkHi0suqtqZkQvUcXxwh1jwidP7QSWXOtZy7ZF4AZ3PK3UuVN+IqTQ5CC8yvc IVC9Xs1PYwuNHBn+fiGQmIPxkyotMej6wtzncoRF2vdfZZpzQNgZDY9rlCXQb7XXwc/V z92KCJq1jyitSOk3q4CTRO4mFf8tfIdYR22xlpPLnyjAOQnEzHIUx0baDnRIcPibhM60 NRopeVCU2353TtKKuT1XHNgTZC/7DG7GGzWJEr8QRxTgibT2iP+of1Mw4AtKORl2XcJK sORFSqi54/YI3FTP38Tpt1FMr+kCAKT4k7wMH+K1ft0hcGvE7wzTJxheWZgr4LKiUk50 lblg== X-Gm-Message-State: AOJu0YyukFLRu0RA4+k5ci9jxr12g8O4iKtcgY95FAt0cjtnb2w8lbY1 eWQx6VdH88IKZATJqkAty9XIt8Z9TdfEIsmfeSLFJg== X-Received: by 2002:a05:651c:154c:b0:2c5:1eb6:bd1e with SMTP id y12-20020a05651c154c00b002c51eb6bd1emr2057447ljp.43.1699441774892; Wed, 08 Nov 2023 03:09:34 -0800 (PST) Received: from troughton.sou.embecosm-corp.com ([212.69.42.53]) by smtp.gmail.com with ESMTPSA id g4-20020a05600c310400b004068e09a70bsm18903289wmo.31.2023.11.08.03.09.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 Nov 2023 03:09:34 -0800 (PST) From: Mary Bennett To: gcc-patches@gcc.gnu.org Cc: mary.bennett@embecosm.com Subject: [PATCH 2/3] RISC-V: Update XCValu constraints to match other vendors Date: Wed, 8 Nov 2023 11:09:13 +0000 Message-Id: <20231108110914.2710021-3-mary.bennett@embecosm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231108110914.2710021-1-mary.bennett@embecosm.com> References: <20231108110914.2710021-1-mary.bennett@embecosm.com> MIME-Version: 1.0 X-Spam-Status: No, score=-11.3 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, 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.30 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 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1781993901479841799 X-GMAIL-MSGID: 1781993901479841799 gcc/ChangeLog: * config/riscv/constraints.md: CVP2 -> CV_alu_pow2. * config/riscv/corev.md: Likewise. --- gcc/config/riscv/constraints.md | 15 ++++++++------- gcc/config/riscv/corev.md | 4 ++-- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/gcc/config/riscv/constraints.md b/gcc/config/riscv/constraints.md index 68be4515c04..2711efe68c5 100644 --- a/gcc/config/riscv/constraints.md +++ b/gcc/config/riscv/constraints.md @@ -151,13 +151,6 @@ (define_register_constraint "zmvr" "(TARGET_ZFA || TARGET_XTHEADFMV) ? GR_REGS : NO_REGS" "An integer register for ZFA or XTheadFmv.") -;; CORE-V Constraints -(define_constraint "CVP2" - "Checking for CORE-V ALU clip if ival plus 1 is a power of 2" - (and (match_code "const_int") - (and (match_test "IN_RANGE (ival, 0, 1073741823)") - (match_test "exact_log2 (ival + 1) != -1")))) - ;; Vector constraints. (define_register_constraint "vr" "TARGET_VECTOR ? V_REGS : NO_REGS" @@ -246,3 +239,11 @@ A MEM with a valid address for th.[l|s]*ur* instructions." (and (match_code "mem") (match_test "th_memidx_legitimate_index_p (op, true)"))) + +;; CORE-V Constraints +(define_constraint "CV_alu_pow2" + "@internal + Checking for CORE-V ALU clip if ival plus 1 is a power of 2" + (and (match_code "const_int") + (and (match_test "IN_RANGE (ival, 0, 1073741823)") + (match_test "exact_log2 (ival + 1) != -1")))) diff --git a/gcc/config/riscv/corev.md b/gcc/config/riscv/corev.md index be66b1428a7..0109e1836cf 100644 --- a/gcc/config/riscv/corev.md +++ b/gcc/config/riscv/corev.md @@ -516,7 +516,7 @@ (define_insn "riscv_cv_alu_clip" [(set (match_operand:SI 0 "register_operand" "=r,r") (unspec:SI [(match_operand:SI 1 "register_operand" "r,r") - (match_operand:SI 2 "immediate_register_operand" "CVP2,r")] + (match_operand:SI 2 "immediate_register_operand" "CV_alu_pow2,r")] UNSPEC_CV_ALU_CLIP))] "TARGET_XCVALU && !TARGET_64BIT" @@ -529,7 +529,7 @@ (define_insn "riscv_cv_alu_clipu" [(set (match_operand:SI 0 "register_operand" "=r,r") (unspec:SI [(match_operand:SI 1 "register_operand" "r,r") - (match_operand:SI 2 "immediate_register_operand" "CVP2,r")] + (match_operand:SI 2 "immediate_register_operand" "CV_alu_pow2,r")] UNSPEC_CV_ALU_CLIPU))] "TARGET_XCVALU && !TARGET_64BIT" From patchwork Wed Nov 8 11:09:14 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mary Bennett X-Patchwork-Id: 162952 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:aa0b:0:b0:403:3b70:6f57 with SMTP id k11csp837420vqo; Wed, 8 Nov 2023 03:10:35 -0800 (PST) X-Google-Smtp-Source: AGHT+IGxPxiicnTcmwcy/JCFFw8lIRIgTs3qYeKI0cWk0CF2isw9bxbUotovSJ1v/hiO90/qpOKH X-Received: by 2002:ad4:4ea1:0:b0:671:6003:73b1 with SMTP id ed1-20020ad44ea1000000b00671600373b1mr1521185qvb.60.1699441835574; Wed, 08 Nov 2023 03:10:35 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1699441835; cv=pass; d=google.com; s=arc-20160816; b=uplWTi0yPltUN5i86W1rUGD6eaEvoGJSOaYNJC93xvjCrJanuIz/64AImZO7OVJRk+ 1tq/S1SYF3DWsN2oHTCEwiL1GjkFvYH6C/V9U+aGouPij4MqBEhVCU0yCCdXFWsczMBR ISk3/AsX43+OciVPgxuNO2AFLKgJL6NRjSlfpJzExCgRywW/DwnGL1HrD13UO11KhenO VhgOT5ymY5f8rHZ8BvJkA3zeYFdsWfFMw2qatp+KqTVN0eReSzkdVu89fcLaTJVtQtLv Kl9szx0AcCmbAJvKPcIRmnk4/NwtaJYn3TBhc++dtWSwOf99kOmMHyJ9tbhing8i3jfD 89iQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=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:arc-filter:dmarc-filter:delivered-to; bh=yUCjiQnOYoe9pWqlTOENQjiix+dCr+X7kdCInoDcMWo=; fh=qiT4HZV9olO2fGAIgbF8w4l7HXh8ja5CJNGeguP7WSc=; b=MiV/++nSmHiApK0EklHC38ScQCsDq67WvoveNob50nDivw7hqTf9R48uZg+9aTum62 A84HjooKrdDk6Vlk8aM2nj/TIB/EZ0MBNd01+qAsVAtYFitPW/qXSRCaXawNngYw5ogd KIukPVpxxVl6NCpIaeoKX7ZNUHMA4smgp7BrpTPwfWeQgElMxKLNJz5ClCCKE6Xo0U7i bUKR+JYDOivwk9DLl8gs2VhJUu6E2qqR1awmaM/2spmyJiJXLIlS/FTyFRCp9KvlpsU/ 53ZzOy+OZAHyKUdc2ymloaGTV3uuo9jte3SWgOAGIkIDRimTxrL0KoXLxM4cI1eSDsps bY+g== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@embecosm.com header.s=google header.b=SUB6C5ND; arc=pass (i=1); 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 (server2.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id m15-20020a0ce8cf000000b0066d04374288si1164949qvo.590.2023.11.08.03.10.35 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 Nov 2023 03:10:35 -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=@embecosm.com header.s=google header.b=SUB6C5ND; arc=pass (i=1); 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 B0E153857029 for ; Wed, 8 Nov 2023 11:10:33 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-lf1-x12b.google.com (mail-lf1-x12b.google.com [IPv6:2a00:1450:4864:20::12b]) by sourceware.org (Postfix) with ESMTPS id 175B23858CDB for ; Wed, 8 Nov 2023 11:09:38 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 175B23858CDB Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=embecosm.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=embecosm.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 175B23858CDB Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2a00:1450:4864:20::12b ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1699441781; cv=none; b=dcmKH1pc4Etq3MXRqtmsdJssTomavCFWei48PWvgZEkg568R1HoyMYRpneli6/c0YtOmuKMblDXVIcu+3aEeeWYTZ42xZuFzS0w3pLVis1fAPteo6PvPY4U3e72rUjfiJU96TnoWVP8XnO2qq5JrpMuQx3uQQX2I7vVyk3ZIwWg= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1699441781; c=relaxed/simple; bh=wT1IbISN3cnZCeTpx/iREb68/nTpCNU0acSd4cXKZKg=; h=DKIM-Signature:From:To:Subject:Date:Message-Id:MIME-Version; b=ao2aPOfvy9eh1wl5HUydaFd1TFrCU7bMhNrjFnQb2WL0QCCojSAerG2Xr/V9NF/pH8m9CN8GS0Ma6/g5eNZMiIbT+FUnVkDhI5FLmEg2JAeYNjbI8XqmaeaIGhiW+Rg0FjhR+FwMDDPmgdiWXOzifeAVRhOFIajXRBFxkmHKwNU= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-lf1-x12b.google.com with SMTP id 2adb3069b0e04-507962561adso8918253e87.0 for ; Wed, 08 Nov 2023 03:09:38 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=embecosm.com; s=google; t=1699441776; x=1700046576; darn=gcc.gnu.org; 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=yUCjiQnOYoe9pWqlTOENQjiix+dCr+X7kdCInoDcMWo=; b=SUB6C5ND9Wai78OUJQB9VnoxlmZ7UI0lUhbBusy/7tBkhmOLoggNHMqNsvIj9zNCS9 nkQz8ChHpY2XSz61oYWlufIWEYoVe5BSzoZFccQcRFNLj/pUYhYdJA6Ko3p30SvXxKR4 8H1/i7bXBPee3OcXJo+gRJmyBgjW5rkLlsE5mEmp6avG97QGAPrgcFGZmEg8qJNYmjJn ZbGFvFmvuihJwb86DfYcn3XhxsZKoA5Kem+WgsHvpBbJrqnmzSuwaucGgq17rncFL2F3 GFQF/vzM4Rx7WZdsp1nx/Tb2cHUr+JR7S+r4QVTveDJLGPDAyJ9VB/4BvKvusTMlyKVJ zYNA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1699441776; x=1700046576; 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=yUCjiQnOYoe9pWqlTOENQjiix+dCr+X7kdCInoDcMWo=; b=lHxDLgX2iwQcJUDKHg0+j8fP3ZHLKoDc2+jcSSZS04WhfRoanKLEYSAyaXP7Tcd7TF ovkw72Y47m4ebZFwp3Ilyn41ZRpIwBeSVmgOVy+kCzxsLkBDDZOp5uliK9Q7018/ougM jQYsJJZJ4yFV356hlR6kvBcJcQBXMaLQULTso+aK3J9palpPlAfBfZktREIQvTUzEwv7 irDihRx4JEejLLyoRQVOFKX11H3l7Ao1aXy6iyBIUN5/BPrpXoNDzDlUGebmvdfU8E19 GPWSExWXiWp9QHtKx/TdgBoGIhJkpjPb1l/Hw9xAgjr5+8EWTauZz9HTo+/MgUjWy/Hf aGnA== X-Gm-Message-State: AOJu0Yw4b2EMmQ1AsniEUr0+yupUMTU69JrStQeaos8AHlNaLzJavntY EM7F9CQsckLLcNDPRCslqZSIqjiCGsW/eJI3UW7bwg== X-Received: by 2002:a2e:bc1f:0:b0:2c5:2fcd:2598 with SMTP id b31-20020a2ebc1f000000b002c52fcd2598mr1871063ljf.8.1699441775759; Wed, 08 Nov 2023 03:09:35 -0800 (PST) Received: from troughton.sou.embecosm-corp.com ([212.69.42.53]) by smtp.gmail.com with ESMTPSA id g4-20020a05600c310400b004068e09a70bsm18903289wmo.31.2023.11.08.03.09.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 Nov 2023 03:09:35 -0800 (PST) From: Mary Bennett To: gcc-patches@gcc.gnu.org Cc: mary.bennett@embecosm.com Subject: [PATCH 3/3] RISC-V: Add support for XCVbi extension in CV32E40P Date: Wed, 8 Nov 2023 11:09:14 +0000 Message-Id: <20231108110914.2710021-4-mary.bennett@embecosm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231108110914.2710021-1-mary.bennett@embecosm.com> References: <20231108110914.2710021-1-mary.bennett@embecosm.com> MIME-Version: 1.0 X-Spam-Status: No, score=-11.4 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.30 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 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1781993922552599359 X-GMAIL-MSGID: 1781993922552599359 Spec: github.com/openhwgroup/core-v-sw/blob/master/specifications/corev-builtin-spec.md Contributors: Mary Bennett Nandni Jamnadas Pietra Ferreira Charlie Keaney Jessica Mills Craig Blackmore Simon Cook Jeremy Bennett Helene Chelin gcc/ChangeLog: * common/config/riscv/riscv-common.cc: Create XCVbi extension support. * config/riscv/riscv.opt: Likewise. * config/riscv/corev.md: Implement cv_branch pattern for cv.beqimm and cv.bneimm. * config/riscv/riscv.md: Change pattern priority so corev.md patterns run before riscv.md patterns. * config/riscv/constraints.md: Implement constraints cv_bi_s5 - signed 5-bit immediate. * config/riscv/predicates.md: Implement predicate const_int5s_operand - signed 5 bit immediate. * doc/sourcebuild.texi: Add XCVbi documentation. gcc/testsuite/ChangeLog: * gcc.target/riscv/cv-bi-beqimm-compile-1.c: New test. * gcc.target/riscv/cv-bi-beqimm-compile-2.c: New test. * gcc.target/riscv/cv-bi-bneimm-compile-1.c: New test. * gcc.target/riscv/cv-bi-bneimm-compile-2.c: New test. * lib/target-supports.exp: Add proc for XCVbi. --- gcc/common/config/riscv/riscv-common.cc | 2 + gcc/config/riscv/constraints.md | 6 +++ gcc/config/riscv/corev.md | 14 ++++++ gcc/config/riscv/predicates.md | 4 ++ gcc/config/riscv/riscv.md | 9 +++- gcc/config/riscv/riscv.opt | 2 + gcc/doc/sourcebuild.texi | 3 ++ .../gcc.target/riscv/cv-bi-beqimm-compile-1.c | 17 +++++++ .../gcc.target/riscv/cv-bi-beqimm-compile-2.c | 48 +++++++++++++++++++ .../gcc.target/riscv/cv-bi-bneimm-compile-1.c | 17 +++++++ .../gcc.target/riscv/cv-bi-bneimm-compile-2.c | 48 +++++++++++++++++++ gcc/testsuite/lib/target-supports.exp | 13 +++++ 12 files changed, 182 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/gcc.target/riscv/cv-bi-beqimm-compile-1.c create mode 100644 gcc/testsuite/gcc.target/riscv/cv-bi-beqimm-compile-2.c create mode 100644 gcc/testsuite/gcc.target/riscv/cv-bi-bneimm-compile-1.c create mode 100644 gcc/testsuite/gcc.target/riscv/cv-bi-bneimm-compile-2.c diff --git a/gcc/common/config/riscv/riscv-common.cc b/gcc/common/config/riscv/riscv-common.cc index 6a1978bd0e4..04631e007f0 100644 --- a/gcc/common/config/riscv/riscv-common.cc +++ b/gcc/common/config/riscv/riscv-common.cc @@ -313,6 +313,7 @@ static const struct riscv_ext_version riscv_ext_version_table[] = {"xcvmac", ISA_SPEC_CLASS_NONE, 1, 0}, {"xcvalu", ISA_SPEC_CLASS_NONE, 1, 0}, {"xcvelw", ISA_SPEC_CLASS_NONE, 1, 0}, + {"xcvbi", ISA_SPEC_CLASS_NONE, 1, 0}, {"xtheadba", ISA_SPEC_CLASS_NONE, 1, 0}, {"xtheadbb", ISA_SPEC_CLASS_NONE, 1, 0}, @@ -1669,6 +1670,7 @@ static const riscv_ext_flag_table_t riscv_ext_flag_table[] = {"xcvmac", &gcc_options::x_riscv_xcv_subext, MASK_XCVMAC}, {"xcvalu", &gcc_options::x_riscv_xcv_subext, MASK_XCVALU}, {"xcvelw", &gcc_options::x_riscv_xcv_subext, MASK_XCVELW}, + {"xcvbi", &gcc_options::x_riscv_xcv_subext, MASK_XCVBI}, {"xtheadba", &gcc_options::x_riscv_xthead_subext, MASK_XTHEADBA}, {"xtheadbb", &gcc_options::x_riscv_xthead_subext, MASK_XTHEADBB}, diff --git a/gcc/config/riscv/constraints.md b/gcc/config/riscv/constraints.md index 2711efe68c5..718b4bd77df 100644 --- a/gcc/config/riscv/constraints.md +++ b/gcc/config/riscv/constraints.md @@ -247,3 +247,9 @@ (and (match_code "const_int") (and (match_test "IN_RANGE (ival, 0, 1073741823)") (match_test "exact_log2 (ival + 1) != -1")))) + +(define_constraint "CV_bi_sign5" + "@internal + A 5-bit signed immediate for CORE-V Immediate Branch." + (and (match_code "const_int") + (match_test "IN_RANGE (ival, -16, 15)"))) diff --git a/gcc/config/riscv/corev.md b/gcc/config/riscv/corev.md index 0109e1836cf..7d7b952d817 100644 --- a/gcc/config/riscv/corev.md +++ b/gcc/config/riscv/corev.md @@ -706,3 +706,17 @@ [(set_attr "type" "load") (set_attr "mode" "SI")]) + +;; XCVBI Builtins +(define_insn "cv_branch" + [(set (pc) + (if_then_else + (match_operator 1 "equality_operator" + [(match_operand:X 2 "register_operand" "r") + (match_operand:X 3 "const_int5s_operand" "CV_bi_sign5")]) + (label_ref (match_operand 0 "" "")) + (pc)))] + "TARGET_XCVBI" + "cv.b%C1imm\t%2,%3,%0" + [(set_attr "type" "branch") + (set_attr "mode" "none")]) diff --git a/gcc/config/riscv/predicates.md b/gcc/config/riscv/predicates.md index a37d035fa61..69a6319c2c8 100644 --- a/gcc/config/riscv/predicates.md +++ b/gcc/config/riscv/predicates.md @@ -400,6 +400,10 @@ (ior (match_operand 0 "register_operand") (match_code "const_int"))) +(define_predicate "const_int5s_operand" + (and (match_code "const_int") + (match_test "IN_RANGE (INTVAL (op), -16, 15)"))) + ;; Predicates for the V extension. (define_special_predicate "vector_length_operand" (ior (match_operand 0 "pmode_register_operand") diff --git a/gcc/config/riscv/riscv.md b/gcc/config/riscv/riscv.md index ae2217d0907..168c8665a7a 100644 --- a/gcc/config/riscv/riscv.md +++ b/gcc/config/riscv/riscv.md @@ -579,6 +579,14 @@ (define_asm_attributes [(set_attr "type" "multi")]) +;; .............................. +;; +;; Machine Description Patterns +;; +;; .............................. + +(include "corev.md") + ;; Ghost instructions produce no real code and introduce no hazards. ;; They exist purely to express an effect on dataflow. (define_insn_reservation "ghost" 0 @@ -3632,4 +3640,3 @@ (include "vector.md") (include "zicond.md") (include "zc.md") -(include "corev.md") diff --git a/gcc/config/riscv/riscv.opt b/gcc/config/riscv/riscv.opt index 0eac6d44fae..d06c0f8f416 100644 --- a/gcc/config/riscv/riscv.opt +++ b/gcc/config/riscv/riscv.opt @@ -413,6 +413,8 @@ Mask(XCVALU) Var(riscv_xcv_subext) Mask(XCVELW) Var(riscv_xcv_subext) +Mask(XCVBI) Var(riscv_xcv_subext) + TargetVariable int riscv_xthead_subext diff --git a/gcc/doc/sourcebuild.texi b/gcc/doc/sourcebuild.texi index 06a6d1776ff..6fee1144238 100644 --- a/gcc/doc/sourcebuild.texi +++ b/gcc/doc/sourcebuild.texi @@ -2484,6 +2484,9 @@ Test system has support for the CORE-V ALU extension. @item cv_elw Test system has support for the CORE-V ELW extension. +@item cv_bi +Test system has support for the CORE-V BI extension. + @end table @subsubsection Other hardware attributes diff --git a/gcc/testsuite/gcc.target/riscv/cv-bi-beqimm-compile-1.c b/gcc/testsuite/gcc.target/riscv/cv-bi-beqimm-compile-1.c new file mode 100644 index 00000000000..5b6ba5b8ae6 --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/cv-bi-beqimm-compile-1.c @@ -0,0 +1,17 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target cv_bi } */ +/* { dg-options "-march=rv32i_xcvbi -mabi=ilp32" } */ +/* { dg-skip-if "" { *-*-* } { "-O0" } { "" } } */ + +/* __builtin_expect is used to provide the compiler with + branch prediction information and to direct the compiler + to the expected flow through the code. */ + +int +foo1 (int a, int x, int y) +{ + a = __builtin_expect (a, 12); + return a != 10 ? x : y; +} + +/* { dg-final { scan-assembler-times "cv\\.beqimm\t\(\?\:t\[0-6\]\|a\[0-7\]\|s\[1-11\]\),10,\(\?\:.L\[0-9\]\)" 1 } } */ diff --git a/gcc/testsuite/gcc.target/riscv/cv-bi-beqimm-compile-2.c b/gcc/testsuite/gcc.target/riscv/cv-bi-beqimm-compile-2.c new file mode 100644 index 00000000000..bb2e5843957 --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/cv-bi-beqimm-compile-2.c @@ -0,0 +1,48 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target cv_bi } */ +/* { dg-options "-march=rv32i_xcvbi -mabi=ilp32" } */ +/* { dg-skip-if "" { *-*-* } { "-O0" } { "" } } */ + +/* __builtin_expect is used to provide the compiler with + branch prediction information and to direct the compiler + to the expected flow through the code. */ + +int +foo1 (int a, int x, int y) +{ + a = __builtin_expect (a, 10); + return a != -16 ? x : y; +} + +int +foo2 (int a, int x, int y) +{ + a = __builtin_expect (a, 10); + return a != 0 ? x : y; +} + +int +foo3 (int a, int x, int y) +{ + a = __builtin_expect (a, 10); + return a != 15 ? x : y; +} + +int +foo4 (int a, int x, int y) +{ + a = __builtin_expect (a, 10); + return a != -17 ? x : y; +} + +int +foo5 (int a, int x, int y) +{ + a = __builtin_expect (a, 10); + return a != 16 ? x : y; +} + +/* { dg-final { scan-assembler-times "cv\\.beqimm\t\(\?\:t\[0-6\]\|a\[0-7\]\|s\[1-11\]\),-16,\(\?\:.L\[0-9\]\)" 1 } } */ +/* { dg-final { scan-assembler-times "cv\\.beqimm\t\(\?\:t\[0-6\]\|a\[0-7\]\|s\[1-11\]\),0,\(\?\:.L\[0-9\]\)" 1 } } */ +/* { dg-final { scan-assembler-times "cv\\.beqimm\t\(\?\:t\[0-6\]\|a\[0-7\]\|s\[1-11\]\),15,\(\?\:.L\[0-9\]\)" 1 } } */ +/* { dg-final { scan-assembler-times "beq\t\(\?\:t\[0-6\]\|a\[0-7\]\|s\[1-11\]\),\(\?\:t\[0-6\]\|a\[0-7\]\|s\[1-11\]\),\(\?\:.L\[0-9\]+\)" 2 } } */ diff --git a/gcc/testsuite/gcc.target/riscv/cv-bi-bneimm-compile-1.c b/gcc/testsuite/gcc.target/riscv/cv-bi-bneimm-compile-1.c new file mode 100644 index 00000000000..21eab38a08d --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/cv-bi-bneimm-compile-1.c @@ -0,0 +1,17 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target cv_bi } */ +/* { dg-options "-march=rv32i_xcvbi -mabi=ilp32" } */ +/* { dg-skip-if "" { *-*-* } { "-O0" } { "" } } */ + +/* __builtin_expect is used to provide the compiler with + branch prediction information and to direct the compiler + to the expected flow through the code. */ + +int +foo1(int a, int x, int y) +{ + a = __builtin_expect(a, 10); + return a == 10 ? x : y; +} + +/* { dg-final { scan-assembler-times "cv\\.bneimm\t\(\?\:t\[0-6\]\|a\[0-7\]\|s\[1-11\]\),10,\(\?\:.L\[0-9\]\)" 1 } } */ diff --git a/gcc/testsuite/gcc.target/riscv/cv-bi-bneimm-compile-2.c b/gcc/testsuite/gcc.target/riscv/cv-bi-bneimm-compile-2.c new file mode 100644 index 00000000000..a028f684489 --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/cv-bi-bneimm-compile-2.c @@ -0,0 +1,48 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target cv_bi } */ +/* { dg-options "-march=rv32i_xcvbi -mabi=ilp32" } */ +/* { dg-skip-if "" { *-*-* } { "-O0" } { "" } } */ + +/* __builtin_expect is used to provide the compiler with + branch prediction information and to direct the compiler + to the expected flow through the code. */ + +int +foo1(int a, int x, int y) +{ + a = __builtin_expect(a, -16); + return a == -16 ? x : y; +} + +int +foo2(int a, int x, int y) +{ + a = __builtin_expect(a, 0); + return a == 0 ? x : y; +} + +int +foo3(int a, int x, int y) +{ + a = __builtin_expect(a, 15); + return a == 15 ? x : y; +} + +int +foo4(int a, int x, int y) +{ + a = __builtin_expect(a, -17); + return a == -17 ? x : y; +} + +int +foo5(int a, int x, int y) +{ + a = __builtin_expect(a, 16); + return a == 16 ? x : y; +} + +/* { dg-final { scan-assembler-times "cv\\.bneimm\t\(\?\:t\[0-6\]\|a\[0-7\]\|s\[1-11\]\),-16,\(\?\:.L\[0-9\]\)" 1 } } */ +/* { dg-final { scan-assembler-times "cv\\.bneimm\t\(\?\:t\[0-6\]\|a\[0-7\]\|s\[1-11\]\),0,\(\?\:.L\[0-9\]\)" 1 } } */ +/* { dg-final { scan-assembler-times "cv\\.bneimm\t\(\?\:t\[0-6\]\|a\[0-7\]\|s\[1-11\]\),15,\(\?\:.L\[0-9\]\)" 1 } } */ +/* { dg-final { scan-assembler-times "bne\t\(\?\:t\[0-6\]\|a\[0-7\]\|s\[1-11\]\),\(\?\:t\[0-6\]\|a\[0-7\]\|s\[1-11\]\),\(\?\:.L\[0-9\]+\)" 2 } } */ diff --git a/gcc/testsuite/lib/target-supports.exp b/gcc/testsuite/lib/target-supports.exp index f388360ae56..0eae746e848 100644 --- a/gcc/testsuite/lib/target-supports.exp +++ b/gcc/testsuite/lib/target-supports.exp @@ -13098,6 +13098,19 @@ proc check_effective_target_cv_elw { } { } "-march=rv32i_xcvelw" ] } +# Return 1 if the CORE-V BI extension is available +proc check_effective_target_cv_bi { } { + if { !([istarget riscv*-*-*]) } { + return 0 + } + return [check_no_compiler_messages cv_bi object { + void foo (void) + { + asm ("cv.beqimm t0, -16, foo"); + } + } "-march=rv32i_xcvbi" ] +} + proc check_effective_target_loongarch_sx { } { return [check_no_compiler_messages loongarch_lsx assembly { #if !defined(__loongarch_sx)