Message ID | 20230831122618.3516601-1-lehua.ding@rivai.ai |
---|---|
Headers |
Return-Path: <gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:c792:0:b0:3f2:4152:657d with SMTP id b18csp205721vqu; Thu, 31 Aug 2023 05:27:29 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEt+rg/KWJ5+JFsHCt/daZ62v6GoZdeA3E/iSOYiY0TipWA2LdS4cHARyZX3r1N0G22bcyu X-Received: by 2002:a05:6512:2311:b0:500:aaea:149d with SMTP id o17-20020a056512231100b00500aaea149dmr4636356lfu.46.1693484849198; Thu, 31 Aug 2023 05:27:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1693484849; cv=none; d=google.com; s=arc-20160816; b=CVlbCm2FGVvJh++i7mhUX04C+BiGM2RlwQKsi6rEJ5yX2gxNehmzKxPxqGzSRaw4D0 6ad5X2gVM/oi7bO8OeT8Eibi1tyy5cQhJt6Tm4stdZwwtDazxcOepYo530qivCzfuYa6 4+TrWKHPD6hmf/J4wj/FijY7ofcsaxCOOMf0Ln6ErAWUpsL0E9yp97lKF9q2twMpNx6w O7gS12HTImc/rpPEPlS3z7HVSP2zi4xmGw9QKjpy0GFZvFve6ghMkEk4W7qUjv2hDgvX AGVHGI54p7N6QGW8UCoDMrM8K7NcyXY/BRN/lkaPF+NQvdSkI2lwBULw2pNildozDkjk t/JQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:feedback-id :content-transfer-encoding:mime-version:message-id:date:subject:to :from:dmarc-filter:delivered-to; bh=xKFvINveV2bgq95kPCVI6ZmCT5YfvyXlPQpRkV22v2M=; fh=flMKfU26Zf2bCSWDpkELM+XX9P5dENvjDCVykGrzV2k=; b=nOdPqVf4+rlW/sERG3QDI1B00Rg+ckGg8svVCdYW3NvR6woCd1jIAWKRADRshx43uG Pfai7BT60KbkG/ZzS/rYIhBABo1WbT20jvj35Gj1wm8fN1CMHfGORGoY4zViIj2mIjVv hBPB2LGmTF3GtfVdWAxf4rx9AiB8kx/l0k4eNcxIFl4ncu/caCM86EvdMHMtrndQH+Yx F0Wr6kcmUS/fJRpufLJG9YATrYBtcuJrK3YzzalGLRjONpOYea3RZClxpdgFysL92sHW H3j5TRAJCIBjChyS7ryh1dbJy9eFE1DCAJVZVuBGjwzHU+ku7b4E4w2yZ1+5Pty9LEV1 +BDw== ARC-Authentication-Results: i=1; mx.google.com; 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 (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id v13-20020aa7d80d000000b0052c06fad1c4si977132edq.474.2023.08.31.05.27.28 for <ouuuleilei@gmail.com> (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 31 Aug 2023 05:27:29 -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; 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 589953857BB2 for <ouuuleilei@gmail.com>; Thu, 31 Aug 2023 12:26:56 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from smtpbg150.qq.com (smtpbg150.qq.com [18.132.163.193]) by sourceware.org (Postfix) with ESMTPS id E600E3858D20 for <gcc-patches@gcc.gnu.org>; Thu, 31 Aug 2023 12:26:25 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org E600E3858D20 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=rivai.ai Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=rivai.ai X-QQ-mid: bizesmtp86t1693484779thz9u8di Received: from rios-cad121.hadoop.rioslab.org ( [58.60.1.9]) by bizesmtp.qq.com (ESMTP) with id ; Thu, 31 Aug 2023 20:26:18 +0800 (CST) X-QQ-SSF: 01400000000000C0F000000A0000000 X-QQ-FEAT: KvvwR/hcPA1unM3GJWMfoP6EqusWgSBcc9LoIHsyEgAfi9IbvMR/QhNR86iEH irB+e8/7/Vn/JeHtbgVk7RYRelnKcWZy0X9MuH5U06U9oQ/JWEBOc1vi2cADi/rl8JP66C8 h3MGF8Uimnh2nxWwf/I0SgCMTPPvS5ML62cKYbriITpkwmDYludfOaDabESqCAtW7IGsVyY 8J89YXB5jikh9EIvkKpWHjsaiuVnZpmtjRY9t0vvIqiavcLO/8ZNJqiOSR0qscOUxB5HDeW Co3S3qs15zJFGr3UDJ4d+ri32XrURx+vCfBDP2SUUpC85e3CoY7NAXPc0RFiMB6Lbg8ejjs exCAHtvAuTG0qvMkUicwbPt1UwSsq0gwCzrLYTqeBLthgU7ExUpOSYODXqOLqQz5rlwfHt5 nVeBb0xbFow= X-QQ-GoodBg: 2 X-BIZMAIL-ID: 16942614664947358962 From: Lehua Ding <lehua.ding@rivai.ai> To: gcc-patches@gcc.gnu.org Subject: [PATCH V4 0/3] RISC-V: Add an experimental vector calling convention Date: Thu, 31 Aug 2023 20:26:15 +0800 Message-Id: <20230831122618.3516601-1-lehua.ding@rivai.ai> X-Mailer: git-send-email 2.36.3 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-QQ-SENDSIZE: 520 Feedback-ID: bizesmtp:rivai.ai:qybglogicsvrgz:qybglogicsvrgz6a-0 X-Spam-Status: No, score=-5.0 required=5.0 tests=BAYES_00, KAM_ASCII_DIVIDERS, KAM_DMARC_STATUS, KAM_SHORT, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_HELO_PASS, SPF_PASS, TXREP autolearn=no 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 <gcc-patches.gcc.gnu.org> List-Unsubscribe: <https://gcc.gnu.org/mailman/options/gcc-patches>, <mailto:gcc-patches-request@gcc.gnu.org?subject=unsubscribe> List-Archive: <https://gcc.gnu.org/pipermail/gcc-patches/> List-Post: <mailto:gcc-patches@gcc.gnu.org> List-Help: <mailto:gcc-patches-request@gcc.gnu.org?subject=help> List-Subscribe: <https://gcc.gnu.org/mailman/listinfo/gcc-patches>, <mailto:gcc-patches-request@gcc.gnu.org?subject=subscribe> Cc: kito.cheng@gmail.com, juzhe.zhong@rivai.ai Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" <gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org> X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1775747569215201288 X-GMAIL-MSGID: 1775747569215201288 |
Series |
RISC-V: Add an experimental vector calling convention
|
|
Message
Lehua Ding
Aug. 31, 2023, 12:26 p.m. UTC
V4 change: Rebasing. Hi RISC-V folks, This patch implement the proposal of RISC-V vector calling convention[1] and this feature can be enabled by `--param=riscv-vector-abi` option. Currently, all vector type arguments and return values are pass by reference. With this patch, these arguments and return values can pass through vector registers. Currently only vector types defined in the RISC-V Vector Extension Intrinsic Document[2] are supported. GNU-ext vector types are unsupported for now since the corresponding proposal was not presented. The proposal introduce a new calling convention variant, functions which follow this variant need follow the bellow vector register convention. | Name | ABI Mnemonic | Meaning | Preserved across calls? ================================================================================= | v0 | | Argument register | No | v1-v7 | | Callee-saved registers | Yes | v8-v23 | | Argument registers | No | v24-v31 | | Callee-saved registers | Yes If a functions follow this vector calling convention, then the function symbole must be annotated with .variant_cc directive[3] (used to indicate that it is a calling convention variant). This implementation split into three parts, each part corresponds to a sub-patch. - Part-1: Select suitable vector regsiters for vector type arguments and return values according to the proposal. - Part-2: Allocate frame area for callee-saved vector registers and save/restore them in prologue and epilogue. - Part-3: Generate .variant_cc directive for vector function in assembly code. [1] https://github.com/riscv-non-isa/riscv-elf-psabi-doc/pull/389 [2] https://github.com/riscv-non-isa/rvv-intrinsic-doc/blob/master/rvv-intrinsic-rfc.md#type-system [3] https://github.com/riscv-non-isa/riscv-asm-manual/blob/master/riscv-asm.md#pseudo-ops Best, Lehua Lehua Ding (3): RISC-V: Part-1: Select suitable vector registers for vector type args and returns RISC-V: Part-2: Save/Restore vector registers which need to be preversed RISC-V: Part-3: Output .variant_cc directive for vector function gcc/config/riscv/riscv-protos.h | 4 + gcc/config/riscv/riscv-sr.cc | 12 +- gcc/config/riscv/riscv-vector-builtins.cc | 10 + gcc/config/riscv/riscv.cc | 477 ++++++++++++++++-- gcc/config/riscv/riscv.h | 40 ++ gcc/config/riscv/riscv.md | 43 +- gcc/config/riscv/riscv.opt | 5 + .../riscv/rvv/base/abi-call-args-1-run.c | 127 +++++ .../riscv/rvv/base/abi-call-args-1.c | 197 ++++++++ .../riscv/rvv/base/abi-call-args-2-run.c | 34 ++ .../riscv/rvv/base/abi-call-args-2.c | 27 + .../riscv/rvv/base/abi-call-args-3-run.c | 260 ++++++++++ .../riscv/rvv/base/abi-call-args-3.c | 116 +++++ .../riscv/rvv/base/abi-call-args-4-run.c | 145 ++++++ .../riscv/rvv/base/abi-call-args-4.c | 111 ++++ .../riscv/rvv/base/abi-call-error-1.c | 11 + .../riscv/rvv/base/abi-call-return-run.c | 127 +++++ .../riscv/rvv/base/abi-call-return.c | 197 ++++++++ .../riscv/rvv/base/abi-call-variant_cc.c | 39 ++ .../rvv/base/abi-callee-saved-1-fixed-1.c | 86 ++++ .../rvv/base/abi-callee-saved-1-fixed-2.c | 86 ++++ .../base/abi-callee-saved-1-save-restore.c | 85 ++++ .../riscv/rvv/base/abi-callee-saved-1-zcmp.c | 85 ++++ .../riscv/rvv/base/abi-callee-saved-1.c | 88 ++++ .../base/abi-callee-saved-2-save-restore.c | 108 ++++ .../riscv/rvv/base/abi-callee-saved-2-zcmp.c | 107 ++++ .../riscv/rvv/base/abi-callee-saved-2.c | 117 +++++ 27 files changed, 2695 insertions(+), 49 deletions(-) create mode 100644 gcc/testsuite/gcc.target/riscv/rvv/base/abi-call-args-1-run.c create mode 100644 gcc/testsuite/gcc.target/riscv/rvv/base/abi-call-args-1.c create mode 100644 gcc/testsuite/gcc.target/riscv/rvv/base/abi-call-args-2-run.c create mode 100644 gcc/testsuite/gcc.target/riscv/rvv/base/abi-call-args-2.c create mode 100644 gcc/testsuite/gcc.target/riscv/rvv/base/abi-call-args-3-run.c create mode 100644 gcc/testsuite/gcc.target/riscv/rvv/base/abi-call-args-3.c create mode 100644 gcc/testsuite/gcc.target/riscv/rvv/base/abi-call-args-4-run.c create mode 100644 gcc/testsuite/gcc.target/riscv/rvv/base/abi-call-args-4.c create mode 100644 gcc/testsuite/gcc.target/riscv/rvv/base/abi-call-error-1.c create mode 100644 gcc/testsuite/gcc.target/riscv/rvv/base/abi-call-return-run.c create mode 100644 gcc/testsuite/gcc.target/riscv/rvv/base/abi-call-return.c create mode 100644 gcc/testsuite/gcc.target/riscv/rvv/base/abi-call-variant_cc.c create mode 100644 gcc/testsuite/gcc.target/riscv/rvv/base/abi-callee-saved-1-fixed-1.c create mode 100644 gcc/testsuite/gcc.target/riscv/rvv/base/abi-callee-saved-1-fixed-2.c create mode 100644 gcc/testsuite/gcc.target/riscv/rvv/base/abi-callee-saved-1-save-restore.c create mode 100644 gcc/testsuite/gcc.target/riscv/rvv/base/abi-callee-saved-1-zcmp.c create mode 100644 gcc/testsuite/gcc.target/riscv/rvv/base/abi-callee-saved-1.c create mode 100644 gcc/testsuite/gcc.target/riscv/rvv/base/abi-callee-saved-2-save-restore.c create mode 100644 gcc/testsuite/gcc.target/riscv/rvv/base/abi-callee-saved-2-zcmp.c create mode 100644 gcc/testsuite/gcc.target/riscv/rvv/base/abi-callee-saved-2.c