From: Kito Cheng <kito.cheng@gmail.com>
To: Mary Bennett <mary.bennett@embecosm.com>
Cc: gcc-patches@gcc.gnu.org
Subject: Re: [PATCH v3 3/3] RISC-V: Add support for XCVbi extension in CV32E40P
Date: Tue, 5 Dec 2023 23:24:19 +0800 [thread overview]
Message-ID: <CA+yXCZCOTUJH7WL-+DjJagCCg5ThXPUWArqorHDsA1ukL7MRKA@mail.gmail.com> (raw)
In-Reply-To: <20231128131615.3986922-4-mary.bennett@embecosm.com>
On Tue, Nov 28, 2023 at 9:17 PM Mary Bennett <mary.bennett@embecosm.com> wrote:
>
> Spec: github.com/openhwgroup/core-v-sw/blob/master/specifications/corev-builtin-spec.md
>
> Contributors:
> Mary Bennett <mary.bennett@embecosm.com>
> Nandni Jamnadas <nandni.jamnadas@embecosm.com>
> Pietra Ferreira <pietra.ferreira@embecosm.com>
> Charlie Keaney
> Jessica Mills
> Craig Blackmore <craig.blackmore@embecosm.com>
> Simon Cook <simon.cook@embecosm.com>
> Jeremy Bennett <jeremy.bennett@embecosm.com>
> Helene Chelin <helene.chelin@embecosm.com>
>
> gcc/ChangeLog:
> * common/config/riscv/riscv-common.cc: Create XCVbi extension
> support.
> * config/riscv/riscv.opt: Likewise.
> * config/riscv/corev.md: Implement cv_branch<mode> pattern
> for cv.beqimm and cv.bneimm.
> * config/riscv/riscv.md: Add CORE-V branch immediate to RISC-V
> branch instruction pattern.
> * 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 | 4 ++
> 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, 178 insertions(+)
> 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 c8c0d0a2252..125f8fb71f7 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},
> @@ -1678,6 +1679,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 92bf0b5d6a6..f6a1f916d7e 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
It's not builtin I think? maybe just "XCVBI Instructions"
> +(define_insn "cv_branch<mode>"
"*cv_branch<mode>"
> + [(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"
And then duplicate content of "*branch<mode>" here.
> + [(set_attr "type" "branch")
> + (set_attr "mode" "none")])
> diff --git a/gcc/config/riscv/predicates.md b/gcc/config/riscv/predicates.md
> index ff213e5f8a3..dfe0db02ac1 100644
> --- a/gcc/config/riscv/predicates.md
> +++ b/gcc/config/riscv/predicates.md
> @@ -406,6 +406,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 935eeb7fd8e..467cd09d8b0 100644
> --- a/gcc/config/riscv/riscv.md
> +++ b/gcc/config/riscv/riscv.md
> @@ -2647,6 +2647,10 @@
> (pc)))]
> ""
I would prefer to put (!TARGET_XCVBI || !equality_operator
(operands[1], <MODE>mode)) here,
The intention of that is dispatch == and != to cv_branch if it is enabled.
> {
> + if (TARGET_XCVBI && const_int5s_operand (operands[3], SImode)
> + && (GET_CODE (operands[1]) == EQ || GET_CODE (operands[1]) == NE))
> + return "cv.b%C1imm\t%2,%3,%0";
then this is not necessary, just use cv_branch,
and I guess this can't not handle long branches well, you may need
something like that:
if (get_attr_length (insn) == 12)
return "cv.b%N1\t%2,%z3,1f; jump\t%l0,ra; 1:";
> +
> if (get_attr_length (insn) == 12)
> return "b%N1\t%2,%z3,1f; jump\t%l0,ra; 1:";
next prev parent reply other threads:[~2023-12-05 15:24 UTC|newest]
Thread overview: 32+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-11-08 11:09 [PATCH 0/3] RISC-V: Support CORE-V XCVELW and XCVBI extensions Mary Bennett
2023-11-08 11:09 ` [PATCH 1/3] RISC-V: Add support for XCVelw extension in CV32E40P Mary Bennett
2023-11-09 17:11 ` Jeff Law
2023-11-08 11:09 ` [PATCH 2/3] RISC-V: Update XCValu constraints to match other vendors Mary Bennett
2023-11-10 1:08 ` Jeff Law
2023-11-08 11:09 ` [PATCH 3/3] RISC-V: Add support for XCVbi extension in CV32E40P Mary Bennett
2023-11-10 20:24 ` Jeff Law
2023-11-13 13:35 ` [PATCH v2 0/3] RISC-V: Support CORE-V XCVELW and XCVBI extensions Mary Bennett
2023-11-13 13:35 ` [PATCH v2 1/3] RISC-V: Add support for XCVelw extension in CV32E40P Mary Bennett
2023-11-13 13:35 ` [PATCH v2 2/3] RISC-V: Update XCValu constraints to match other vendors Mary Bennett
2023-11-13 13:35 ` [PATCH v2 3/3] RISC-V: Add support for XCVbi extension in CV32E40P Mary Bennett
2023-11-13 14:41 ` Kito Cheng
2023-11-13 19:14 ` Patrick O'Neill
2023-11-28 13:16 ` [PATCH v3 0/3] RISC-V: Support CORE-V XCVELW and XCVBI extensions Mary Bennett
2023-11-28 13:16 ` [PATCH v3 1/3] RISC-V: Add support for XCVelw extension in CV32E40P Mary Bennett
2023-12-05 15:11 ` Kito Cheng
2023-11-28 13:16 ` [PATCH v3 2/3] RISC-V: Update XCValu constraints to match other vendors Mary Bennett
2023-12-05 15:11 ` Kito Cheng
2023-11-28 13:16 ` [PATCH v3 3/3] RISC-V: Add support for XCVbi extension in CV32E40P Mary Bennett
2023-12-05 15:24 ` Kito Cheng [this message]
2023-12-12 19:32 ` [PATCH v4 0/3] RISC-V: Support CORE-V XCVELW and XCVBI extensions Mary Bennett
2023-12-12 19:32 ` [PATCH v4 1/3] RISC-V: Add support for XCVelw extension in CV32E40P Mary Bennett
2023-12-15 22:01 ` Jeff Law
2023-12-12 19:32 ` [PATCH v4 2/3] RISC-V: Update XCValu constraints to match other vendors Mary Bennett
2023-12-15 23:11 ` Jeff Law
2023-12-12 19:32 ` [PATCH v4 3/3] RISC-V: Add support for XCVbi extension in CV32E40P Mary Bennett
2023-12-15 23:21 ` Jeff Law
2024-01-08 13:14 ` [PATCH v5 0/1] RISC-V: Support CORE-V XCVBI extension Mary Bennett
2024-01-08 13:14 ` [PATCH v5 1/1] RISC-V: Add support for XCVbi extension in CV32E40P Mary Bennett
2024-01-09 18:43 ` Jeff Law
2024-01-22 13:30 ` Mary Bennett
2024-03-19 3:34 ` Jeff Law
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=CA+yXCZCOTUJH7WL-+DjJagCCg5ThXPUWArqorHDsA1ukL7MRKA@mail.gmail.com \
--to=kito.cheng@gmail.com \
--cc=gcc-patches@gcc.gnu.org \
--cc=mary.bennett@embecosm.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).