167 Commits

Author SHA1 Message Date
4vtomat
29f11e4fb7 [RISCV] Bump vector crypto to v1.0 RC2
Differential Revision: https://reviews.llvm.org/D158067
2023-08-17 21:19:59 -07:00
Yeting Kuo
818e76d6f2 [RISCV] Add MC layer support for Zicfilp.
This adds extension Zicfilp and support pseudo instruction lpad.

Reviewed By: craig.topper

Differential Revision: https://reviews.llvm.org/D157362
2023-08-16 08:52:51 +08:00
Jianjian GUAN
f808788487 [RISCV] Remove experimental for zihintntl
Since zihintntl is ratified now, we could remove the experimental prefix and change its version to 1.0.

Reviewed By: asb

Differential Revision: https://reviews.llvm.org/D151547
2023-08-10 17:04:49 +08:00
Alex Bradbury
8acb8a143f [RISCV] Make Zcf and Zcd imply the F and D extensions respectively
This was an omission in the spec that has now been addressed
https://github.com/riscv/riscv-code-size-reduction/pull/224.

Differential Revision: https://reviews.llvm.org/D156314
2023-08-02 10:40:38 +01:00
melonedo
afb9c04a5a [RISCV] Add support for XCVbi extension in CV32E40P
Implement XCVbi intrinsics for CV32E40P according to the specification.

This commit is part of a patch-set to upstream the 7 vendor specific extensions of CV32E40P.

Contributors: @CharKeaney, @jeremybennett, @lewis-revill, @liaolucy, Nandni Jamnadas, @paolos, @simoncook, @xmj.

bf2ad26b4ff856aab9a62ad168e6bdefeedc374f originally commited.
e4777dc4b9cb371971523cc603e1b8a5c7255e7e reverted due to test failures caused by a merge conflict marker in llvm/test/CodeGen/RISCV/attributes that was accidentally checked in.
This commit removed the conflict marker and recommitted.

Reviewed By: craig.topper

Differential Revision: https://reviews.llvm.org/D154412
2023-07-28 21:54:10 +08:00
melonedo
e4777dc4b9 Revert "[RISCV] Add support for XCVbi extension in CV32E40P"
This reverts commit bf2ad26b4ff856aab9a62ad168e6bdefeedc374f as it
checked in merge conflict markers.
2023-07-28 19:28:20 +08:00
melonedo
bf2ad26b4f [RISCV] Add support for XCVbi extension in CV32E40P
Implement XCVbi intrinsics for CV32E40P according to the specification.

This commit is part of a patch-set to upstream the 7 vendor specific extensions of CV32E40P.

Contributors: @CharKeaney, @jeremybennett, @lewis-revill, @liaolucy, Nandni Jamnadas, @PaoloS, @simoncook, @xmj.

Reviewed By: craig.topper

Differential Revision: https://reviews.llvm.org/D154412
2023-07-28 17:36:57 +08:00
melonedo
3c0604b224 [RISCV] Add support for XCVsimd extension in CV32E40P
Implement XCVsimd intrinsics for CV32E40P according to the specification.

This commit is part of a patch-set to upstream the 7 vendor specific extensions of CV32E40P.

Contributors: @CharKeaney, @jeremybennett, @lewis-revill, @liaolucy, Nandni Jamnadas, @PaoloS, @simoncook, @xmj.

Reviewed By: craig.topper

Differential Revision: https://reviews.llvm.org/D153721
2023-07-28 16:52:32 +08:00
Jun Sha (Joshua)
e56bf13317 [RISCV] Remove some instructions from Zvfbfwma by implying Zfbfmin according to the latest spec
According to the latest spec, Zvfbfwma requires Zvfbfmin and Zvfbfmin requires Zfbfmin, with FLH/FSH/FMV.H.X/HMV.X.H removed from Zvfbfwma.

Reviewed By: asb

Differential Revision: https://reviews.llvm.org/D155916
2023-07-28 15:52:03 +08:00
Qihan Cai
092e60a3fc [RISCV] Add support for XCValu extension in CV32E40P
Implement XCValu intrinsics for CV32E40P according to the specification.

This is a commit of the patch-set to upstream the 7 vendor specific extensions of CV32E40P.

Contributors: @CharKeaney, Nandni Jamnadas, Serkan Muhcu, @jeremybennett, @lewis-revill, @liaolucy, @simoncook, @xmj

Reviewed By: craig.topper

Differential Revision: https://reviews.llvm.org/D153748
2023-07-28 11:37:31 +08:00
Craig Topper
02c11c5aed [RISCV] Remove stale TODOs from RISCVISAInfo.cpp. NFC
Q extension does not require RV64.
E extenion is not incompatible with F or D extensions.
2023-07-25 17:47:48 -07:00
Craig Topper
3055c5815a [RISCV] Upgrade Zvfh version to 1.0 and move out of experimental state.
This has been ratified according to https://wiki.riscv.org/display/HOME/Recently+Ratified+Extensions

Differential Revision: https://reviews.llvm.org/D155668
2023-07-19 10:03:57 -07:00
Simon Cook
4083ecfd7f [RISCV] Cleanups in CORE-V (xcv) extensions
This is a mostly NFC change cleaning up and clarifying components of the
in-tree CORE-V (xcv*) extensions following discussions on the remaining
extensions.

This makes the following changes to the xcbitmanip and xcvmac support:

1. Add missing extensions from RISCVISAInfo, such that they can be
   supported in clang's -march option.
2. Clarify the extension version number is 1.0.0 in documentation.
3. Clarify the extensions are by OpenHW Group, and the capitilization
   of the CORE-V extension family.
4. Add CORE-V to extension name in RISCVFeatures, both to be consistent
   with other vendors, and also better distinguish e.g. CORE-V bit
   manipulation vs RISC-V's standard Zb extensions.

Differential Revision: https://reviews.llvm.org/D155283
2023-07-14 18:21:08 +01:00
Craig Topper
0aecddcee9 [RISCV] Add Zce extension.
According to the spec, Zce is an alias for Zca, Zcb, Zcmp, and Zcmt.
If F is enabled on RV32 it also includes Zcf.

This patch adds the Zce and the implication rule which unfortunately
requires custom handling for adding Zcf.

I've also made all the Zc* extensions imply Zca.

I've also added an error for Zcf without RV32.

Reviewed By: asb

Differential Revision: https://reviews.llvm.org/D153742
2023-07-13 12:22:06 -07:00
Alex Bradbury
29f630a1dd [RISCV][MC] MC layer support for the experimental zacas extension
This implements the v1.0-rc1 draft extension.

amocas.d on RV32 and amocas.q have the restriction that rd and rs2 must
be even registers. I've opted to implement this restriction in
RISCVAsmParser::validateInstruction even though for codegen we'll need a
new register class and can then remove this validation. This also
sidesteps, for now, the issue of amocas.d being different on rv32 vs
rv64.

See <https://github.com/riscv-non-isa/riscv-c-api-doc/issues/37> for the
issue of needing an agreed asm register constraint for register pairs.

Differential Revision: https://reviews.llvm.org/D149248
2023-07-10 08:26:31 +01:00
Craig Topper
b4609b4106 [RISCV] Mark zvkn* and zvks* extensions as enabled when all their subextensions are.
These extensions don't contain any instructions on their own, they
are just aliases for a set of extensions. We should set the preprocessor
define anytime all the sub-extensions are supported.

Reviewed By: kito-cheng, eopXD

Differential Revision: https://reviews.llvm.org/D154171
2023-06-29 20:58:55 -07:00
4vtomat
02f94a655f [RISCV] Bump vector crypto to v1.0.0-rc1
Differential Revision: https://reviews.llvm.org/D153836
2023-06-28 19:53:07 -07:00
Alex Bradbury
6101d720cb [RISCV] Relax rules for ordering s/z/x prefixed extensions in ISA naming strings
This was discussed somewhat in D148315. As it stands, we require in
RISCVISAInfo::parseArchString (used for e.g. -march parsing in Clang)
that extensions are given in the order of z, then s, then x prefixed
extensions (after the standard single-letter extensions). However, we
recently (in D148315) moved to that order from z/x/s as the canonical
ordering was changed in the spec. In addition, recent GCC seems to
require z* extensions before s*.

My recollection of the history here is that we thought keeping -march as
close to the rules for ISA naming strings as possible would simplify
things, as there's an existing spec to point to. My feeling is that now
we've had incompatible changes, and an incompatibility with GCC there's
no real benefit to sticking to this restriction, and it risks making it
much more painful than it needs to be to copy a -march= string between
GCC and Clang.

This patch removes all ordering restrictions so you can freely mix x/s/z
extensions.

To be very explicit, this doesn't change our behaviour when emitting a
canonically ordered extension string (e.g. in build attributes). We of
course sort according to the canonical order (as we understand it) in
that case.

Differential Revision: https://reviews.llvm.org/D149246
2023-06-27 13:32:11 +01:00
Garvit Gupta
4c37d30e22 [RISCV] Add support for custom instructions for Sifive S76.
Support for below instruction is added
1. CFLUSH.D.L1
2. CDISCARD.D.L1
3. CEASE

Additionally, Zihintpause extension is added to sifive s76 for pause
instruction.

Spec - https://sifive.cdn.prismic.io/sifive/767804da-53b2-4893-97d5-b7c030ae0a94_s76mc_core_complex_manual_21G3.pdf

Reviewed By: craig.topper

Differential Revision: https://reviews.llvm.org/D153370
2023-06-26 11:36:00 -07:00
Craig Topper
f2d16b368f [RISCV] Use binary search on the extension tables in RISCVISAInfo.cpp. NFC
After D153170 the tables are now sorted by extension name so we can use that to
avoid a linear search.

Reviewed By: asb, MaskRay

Differential Revision: https://reviews.llvm.org/D153598
2023-06-23 17:23:12 -07:00
Craig Topper
076759f068 Revert "[RISCV] Implement support for bf16 truncate/extend on hard FP targets"
This was committed with D153598 merged into it. Reverting to recommit as separate patches.

This reverts commit 690b1c847f0b188202a86dc25a0a76fd8c4618f4.
2023-06-23 17:23:12 -07:00
Alex Bradbury
690b1c847f [RISCV] Implement support for bf16 truncate/extend on hard FP targets
For the same reasons as D151284, this requires custom lowering of the
truncate libcall on hard float ABIs (the normal libcall code path is
used on soft ABIs).

The extend operation is implemented by a shift just as in the standard
legalisation, but needs to be custom lowered because i32 isn't a legal
type on RV64.

This patch aims to make the minimal changes that result in correct
codegen for the bfloat.ll tests.

Differential Revision: https://reviews.llvm.org/D151663
2023-06-23 14:18:59 +01:00
Craig Topper
e4a93d80f4 [RISCV] Sort the extensions in SupportedExtensions and SupportedExperimentalExtensions.
As the extension list continues to grow it probably makes sense
to use a binary search rather than linear search. Sorting the strings
will make this possible.

This also avoids any question about where to add new strings in
the tables.

Reviewed By: asb

Differential Revision: https://reviews.llvm.org/D153170
2023-06-22 11:25:47 -07:00
Craig Topper
08f1aa8728 [RISCV] Move Zca/Zcb/Zcd/Zcf/Zcmp/Zcmt out of experimental status.
According to https://wiki.riscv.org/display/HOME/Recently+Ratified+Extensions
these were ratified in April 2023.

Reviewed By: VincentWu

Differential Revision: https://reviews.llvm.org/D153161
2023-06-22 09:22:58 -07:00
Craig Topper
61e91988bc [RISCV] Add errors for mixing Zcmp with C/Zcd and D.
We already had an error for Zcmt though it appears to be untested
Add similar one for Zcmp along with tests for both.

Factor the code to share the strings as much as possible.

Reviewed By: VincentWu

Differential Revision: https://reviews.llvm.org/D153159
2023-06-21 00:10:37 -07:00
Piyou Chen
fc4350cb43 [NFC][RISCV] rename findFirstNonVersionCharacter with findLastNonVersionCharacter
Reviewed By: craig.topper

Differential Revision: https://reviews.llvm.org/D152506
2023-06-13 23:55:34 -07:00
Eric Gouriou
c5a88fe3d0 [RISC-V] Zvk update to 0.9.7, Zvknc/Zvksc
Update the RISC-V Zvk (vector cryptography) extension support from 0.5
to version 0.9.7 (2023-05-31), per
    <https://github.com/riscv/riscv-crypto/releases/download/v20230531/riscv-crypto-spec-vector.pdf>

Differences:
     - Zvbc is dropped from Zvkn and Zvks, and by extension
       from Zvkng and Zvksg;
     - new combo extensions Zvknc and Zvksc are introduced,
      adding Zvbc to Zvkn and Zvks;
     - the experimentatl extensions are tagged as "0.9",
       from the earlier "0.5".

Reviewed By: 4vtomat

Differential Revision: https://reviews.llvm.org/D152117
2023-06-12 15:43:08 -07:00
Piyou Chen
eabf1d367f [RISCV] check pointer before dereference
Encountered ASAN crash and found it dereference without check pointer.

Reviewed By: kito-cheng, eklepilkina

Differential Revision: https://reviews.llvm.org/D151716
2023-05-31 21:35:07 -07:00
Craig Topper
a5e5eea29c Revert "[RISCV] Add Zvfhmin extension for clang."
This reverts commit 35a0079238ce9fc36cdc8c6a2895eb5538bf7b4a.

The backend support is not present yet. The intrinsics will crash
the compiler if compiled to assembly or binary.
2023-05-31 10:17:11 -07:00
Jianjian GUAN
35a0079238 [RISCV] Add Zvfhmin extension for clang.
This patch adds the Zvfhmin extension for clang.

Reviewed By: craig.topper, michaelmaitland

Differential Revision: https://reviews.llvm.org/D150253
2023-05-31 14:31:11 +08:00
Alex Bradbury
033690fffe [RISCV] Make zfbfmin imply the F extension
Our current approach is that if one extension requires another, we make
LLVM treat it as implied. My initial zfbfmin patch failed to do this for
the F extension (documented as a requirement of zfbfmin). This patch
fixes that.

Differential Revision: https://reviews.llvm.org/D151096
2023-05-23 10:10:11 +01:00
Alex Bradbury
a1455de74d [RISCV][MC] Add support for experimental Zvfbfwma extension
Provides MC layer support for Zvfbfwma: vector BF16 widening mul-add.

As currently specified, Zvfbfwma does not appear to have a dependency on
Zvfbfmin or Zfbfmin.

Differential Revision: https://reviews.llvm.org/D147612
2023-05-19 15:37:26 +01:00
Alex Bradbury
b18a819664 [RISCV][MC] Add support for experimental Zvfbfmin extension
Provides MC layer support for Zfbfmin: vector BF16 conversions.

Zvfbfmin does not appear to have a dependency on Zfbfmin as currently
specified.

Differential Revision: https://reviews.llvm.org/D147611
2023-05-19 15:26:25 +01:00
Alex Bradbury
35ff5eba16 [RISCV][MC] Add support for experimental Zfbfmin extension
Provides MC layer support for Zfbfmin: scalar BF16 conversions.

As documented, this extension includes FLH, FSH, FMV.H.X, and FMH.X.H as
defined in Zfh/Zfhmin, but doesn't require either extension.

No Zfbfinxmin has been defined (though you would expect one in the
future, for symmetry with Zfhinxmin). See issue
https://github.com/riscv/riscv-bfloat16/issues/27.

Differential Revision: https://reviews.llvm.org/D147610
2023-05-19 15:17:56 +01:00
Craig Topper
57a9522f87 [RISCV] Remove redundant F and D extension implication from V. NFC
We recently added implications for F and D to Zve32f and Zve64d
which V implies. So these have become redundant.
2023-05-10 10:00:59 -07:00
Jianjian GUAN
7ab9478560 [RISCV] Make Zvfh depend on Zfhmin.
According to the v spec, the Zvfh extension depends on the Zve32f and Zfhmin extensions.

Reviewed By: craig.topper

Differential Revision: https://reviews.llvm.org/D150016
2023-05-10 09:46:19 +08:00
WuXinlong
6b55e9117e [RISCV] Add MC support of RISCV zcmp Extension
This patch add the instructions of zcmp extension.

Instructions in zcmp extension try to optimise `mv` inst and the prologue & epilogue in functions

co-author: @Scott Egerton, @ZirconLiu, @Lukacma, @Heda Chen, @luxufan, @heyiliang, @liaochunyu

Reviewed By: craig.topper

Differential Revision: https://reviews.llvm.org/D132819
2023-05-08 14:29:50 +08:00
Craig Topper
728b8a1398 [RISCV] Make zve32f imply F and zve64d imply D.
The 1.0 vector spec PDF has text that says that Zve32f is compatible
with F or Zfinx and that Zve64d is compatible with D and Zdinx.
The references to *inx were removed from the spec in the github repository in
October 2021. The 1.0 pdf was made in September 2021.

Relevant commit 6fedb869e2

Reviewed By: jacquesguan

Differential Revision: https://reviews.llvm.org/D150021
2023-05-06 23:17:16 -07:00
WuXinlong
9f0d725744 [RISCV] Add MC support of RISCV zcmt Extension
This patch add the instructions of zcmt extension.
[[ https://github.com/riscv/riscv-code-size-reduction/releases/tag/v1.0.0-RC5.7 | spac is here ]]
Which includes two instructions (cm.jt&cm.jalt) and a CSR Reg JVT

co-author: @Scott Egerton

Reviewed By: kito-cheng, craig.topper

Differential Revision: https://reviews.llvm.org/D133863
2023-05-03 22:06:37 +08:00
4vtomat
74c1fa60b5 [RISCV] Add Smaia and Ssaia extensions support
This patch implements 1.0-RC3:
https://github.com/riscv/riscv-aia/releases/download/1.0-RC3/riscv-interrupts-1.0-RC3.pdf

Differential Revision: https://reviews.llvm.org/D148066
2023-05-01 22:30:08 -07:00
Craig Topper
3ce3ee6169 [RISCV] Make Zicntr and Zihpm imply Zicsr.
Zicntr and Zihpm are names for groups of CSRs so they should imply
that CSRs exist.

Reviewed By: asb, kito-cheng

Differential Revision: https://reviews.llvm.org/D148962
2023-04-26 10:11:14 -07:00
Craig Topper
236898f619 [RISCV] Accept zicntr and zihpm command line options
This change adds the definition of the two extensions, but does not either a) make any register definitions conditional on them or b) enabled the extensions by default.

This is somewhat analogous to https://reviews.llvm.org/D143953, but with some key differences.  The best discussion I can find on status is here: https://github.com/riscv/riscv-profiles/issues/43.  These were removed between document version 2.1 and 2.2, but were not defined as new extensions in 2.2.  That addition came later - in March 2022.

According to https://drive.google.com/file/d/1qa57pePesOiDOrNzxuuGFhCL4Rbi9AYB/view these were ratified in March 2023.

Reviewed By: asb, reames

Differential Revision: https://reviews.llvm.org/D144215
2023-04-26 10:11:07 -07:00
Alex Bradbury
52b51ee0d4 [RISCV][NFC] Remove outdated TODOs about extension versions in RISCVISAInfo
As was documented in D147183, we don't currently intend to support
multiple versions of specifications simultaneously. While external
circumstances might mean exceptions to this are needed, the TODOs about
reflecting version numbers in the feature strings no longer make sense.
2023-04-26 09:58:57 +01:00
Eric Gouriou
ca554ad7c2 [RISCV] NFC tweaks in extension descriptions, sorting
NFC changes in RISCISAInfo and RISCFeatures, and matching updates to the
MC tests.

- Drop the '.' in the parentheses section of the Zvk extension
  descriptions. This is supported by
<https://www.masterclass.com/articles/period-inside-or-outside-parentheses#>,
- Remove an extraneous space in the description of Zvt,
- Reorder the ImpliedExts.* constant literals in RISCISAInfo.cpp, as
  suggested in <https://reviews.llvm.org/D148483>.

Differential Revision: https://reviews.llvm.org/D148857
2023-04-21 17:39:44 +01:00
Eric Gouriou
cb7dffdc9a [RISCV] Zvk (vector crypto) specification update to 0.5.1 (Zvbb/Zvbc/Zvkt/Zvkng/Zvksg)
Update the Zvk support from 0.3.x to 0.5.1, tracking the extension as
documented in
<https://github.com/riscv/riscv-crypto/releases/download/v20230407/riscv-crypto-spec-vector.pdf>.

- Zvkb is split into Zvbb and Zvbc
- Zvbc (vector carryless multiply) requires 64 bit elements (Zve64x)
- Use the extension descriptions from the specification for Zvbb/Zvbc
- Zvkt is introduced (no instructions, but adds an attribute and macro)
- Zvkn and Zvks both imply Zvkt
- Zvkng and Zvksg are introduced, adding Zvkg (GMAC) to Zvkn and Zvks
- In Zvbb, add vrev.v, vclz.v, vctz.v, vcpop.v, vwsll.{vv,vx,vi}

Differential Revision: https://reviews.llvm.org/D148483
2023-04-20 18:25:19 +01:00
Jun Sha (Joshua)
3f81d25cee [RISCV] Remove 'sx' when parsing arch string to match the latest ISA manual
In order to match the latest ISA manual, we need to remove sx prefix.

Reviewed By: asb

Differential Revision: https://reviews.llvm.org/D148617
2023-04-20 10:32:24 +08:00
Jun Sha (Joshua)
914b38aa4b Revert '[RISCV] Remove 'sx' when parsing arch string to match the latest ISA manual'
This reverts commit fbc63e5658f67036d4ea57940459074d9ecdd2d8
2023-04-20 10:27:02 +08:00
Jun Sha (Joshua)
fbc63e5658 [RISCV] Remove 'sx' when parsing arch string to match the latest ISA manual 2023-04-20 10:19:14 +08:00
Alex Bradbury
c8318b973a [RISCV] Fix canonical ordering of s* vs z* extensions in RISCVISAInfo
As noted in https://reviews.llvm.org/D148315, the ordering logic for
OrderedExtensionMap currently puts s* before z* extensions, but per the
ISA manual the correct order should be z* and then s* (with the
exception of zxm*, which are ordered after s*).

This patch fixes the ordering and adds a TODO for zxm*. The changes are
visible in the test case added in
a35e67fc5be654a7efdfa6125343b90f8960a487 which also demonstrates an
issue with the ordering of single letter extensions (which isn't
addressed in this patch).

This ordering matches the one used by GCC/binutils as well.

Differential Revision: https://reviews.llvm.org/D148615
2023-04-19 07:04:48 +01:00
Alex Bradbury
2a5661c841 [RISCV] Bump Zfa version to 0.2 and correct RISCVUsage description
As of
1f03818281
in the riscv-isa-manual, Zfa is at version 0.2. Reviewing the commit
history for
zfa.tex
<https://github.com/riscv/riscv-isa-manual/commits/master/src/zfa.tex>
there are no relevant changes since 0.1. As such, we can simply
increment the version number.

This change also removes the claim in RISCVUsage that we implement a
"subset of" Zfa, as I believe this is no longer true. That sentence
previously incorrectly claimed we didn't implement fli.{h,s,d} (I
[corrected this a couple of weeks
ago](https://reviews.llvm.org/rG3d969191b277)) but I think should have
removed the "subset of" wording too.

As was noted during the review, we never added Zfa to the release notes.
This is corrected in this patch.

Differential Revision: https://reviews.llvm.org/D148634
2023-04-19 06:27:35 +01:00