73 Commits

Author SHA1 Message Date
quic_hchandel
163935a48d
[RISCV] Add Qualcomm uC Xqcilo (Large Offset Load Store) extension (#123881)
This extension adds eight 48 bit load store instructions.

The current spec can be found at:
https://github.com/quic/riscv-unified-db/releases/latest

This patch adds assembler only support.

---------

Co-authored-by: Harsh Chandel <hchandel@qti.qualcomm.com>
2025-01-23 10:14:25 +05:30
quic_hchandel
171d3edd05
[RISCV] Add Qualcomm uC Xqciint (Interrupts) extension (#122256)
This extension adds eleven instructions to accelerate interrupt
servicing.

The current spec can be found at:
https://github.com/quic/riscv-unified-db/releases/latest

This patch adds assembler only support.

---------

Co-authored-by: Harsh Chandel <hchandel@qti.qualcomm.com>
2025-01-13 16:36:05 +05:30
quic_hchandel
737d6ca44d
[RISCV] Add Qualcomm uC Xqcicm (Conditional Move) extension (#121752)
The Qualcomm uC Xqcicm extension adds 13 conditional move instructions.

The current spec can be found at:
https://github.com/quic/riscv-unified-db/releases/latest

This patch adds assembler only support.

---------

Co-authored-by: Harsh Chandel <hchandel@qti.qualcomm.com>
2025-01-07 08:25:00 +05:30
Sudharsan Veeravalli
532a2691bc
[RISCV] Add Qualcomm uC Xqcicli (Conditional Load Immediate) extension (#121292)
This extension adds 12 instructions that conditionally load an immediate
value.

The current spec can be found at:
https://github.com/quic/riscv-unified-db/releases/latest

This patch adds assembler only support.
2025-01-03 06:33:27 +05:30
quic_hchandel
1557eeda73
[RISCV] Add Qualcomm uC Xqciac (Load-Store Adress calculation) extension (#121037)
This extension adds 3 instructions that perform load-store address
calculation.

The current spec can be found at:
https://github.com/quic/riscv-unified-db/releases/latest

This patch adds assembler only support.

---------

Co-authored-by: Harsh Chandel <hchandel@qti.qualcomm.com>
Co-authored-by: Sudharsan Veeravalli <quic_svs@quicinc.com>
2024-12-29 11:14:12 +05:30
Sudharsan Veeravalli
668d9688ac
[RISCV] Add Qualcomm uC Xqcilsm (Load Store Multiple) extension (#119823)
This extension adds 6 instructions that can do multi-word load/store.

The current spec can be found at:
https://github.com/quic/riscv-unified-db/releases/latest

This patch adds assembler only support.
2024-12-14 00:06:58 +05:30
quic_hchandel
0614c601b4
[RISCV] Add Qualcomm uC Xqcics(Conditional Select) extension (#119504)
The Qualcomm uC Xqcics extension adds 8 conditional select instructions.

The current spec can be found at:
https://github.com/quic/riscv-unified-db/releases/latest

This patch adds assembler only support.

---------

Co-authored-by: Harsh Chandel <hchandel@qti.qualcomm.com>
2024-12-12 11:12:09 +05:30
Sudharsan Veeravalli
6881c6d2a6
[RISCV] Add Qualcomm uC Xqcia (Arithmetic) extension (#118113)
This extension adds 11 instructions that perform integer arithmetic.

The current spec can be found at:
https://github.com/quic/riscv-unified-db/releases/latest

This patch adds assembler only support.
2024-12-01 17:06:22 +05:30
Sudharsan Veeravalli
8fcbba82d6
[RISCV] Add Qualcomm uC Xqcisls (Scaled Load Store) extension (#117987)
This extension adds 8 load/store instructions with a scaled index
addressing mode.

The current spec can be found at:
https://github.com/quic/riscv-unified-db/releases/latest

This patch adds assembler only support.
2024-11-29 10:26:00 +05:30
Sudharsan Veeravalli
c4645ffeda
[RISCV] Add Qualcomm uC Xqcicsr (CSR) extension (#117169)
The Qualcomm uC Xqcicsr extension adds 2 instructions that can read and
write CSRs.

The current spec can be found at:
https://github.com/quic/riscv-unified-db/releases/latest

This patch adds assembler only support.
2024-11-28 12:46:15 +05:30
Jim Lin
956361ca08
[RISCV] Zabha/Zacas implies Zaamo (#115694)
The Zabha/Zacas extension depends upon the Zaamo extension. 
Ref: https://github.com/riscv/riscv-isa-manual/blob/main/src/zacas.adoc
https://github.com/riscv/riscv-isa-manual/blob/main/src/zabha.adoc.
2024-11-12 15:49:34 +08:00
Craig Topper
94e7d9c0bf [RISCV] Remove Zvk* dependency checks from RISCVISAInfo::checkDependency.
The Zvk* extensions now imply Zve32x or Zve64x so it shouldn't be
possible to fail these dependency checks.
2024-10-29 13:57:23 -07:00
Piyou Chen
a2994ded60
[RISCV] Fix RISCVBitPositions typo (#110953)
This patch updates  `{"zve64x", 0, 63},` into `{"zve64f", 0, 63},`.

Base on
https://github.com/riscv-non-isa/riscv-c-api-doc/blob/main/src/c-api.adoc#extension-bitmask-definitions
2024-10-03 14:34:44 +08:00
Kazu Hirata
33e7cd6ff2
[llvm] Prefer StringRef::substr to StringRef::slice (NFC) (#105943)
S.substr(N) is simpler than S.slice(N, StringRef::npos) and
S.slice(N, S.size()). Also, substr is probably better recognizable
than slice thanks to std::string_view::substr.
2024-08-25 11:30:49 -07:00
Craig Topper
371f936c45 [RISCV] Make extension names lower case in RISCVISAInfo::checkDependency() error messages. 2024-08-19 00:22:28 -07:00
Craig Topper
10a4f1ef9e [RISCV] Add helper functions to exploit similarity of some RISCVISAInfo::checkDependency() error strings. NFC 2024-08-19 00:22:28 -07:00
Craig Topper
d489b7ccb7 [RISCV] Merge some ISA error reporting together and make some errors more precise.
Loop over the extension names that have the same error message.

Print the name of Zvk* extensions instead of 'zvk*'.
2024-08-19 00:22:28 -07:00
Pengcheng Wang
a80a90e34b
[RISCV][MC] Support experimental extensions Zvbc32e and Zvkgs (#103709)
These two extensions add addtional instructions for carryless
multiplication with 32-bits elements and Vector-Scalar GCM
instructions.

Please see https://github.com/riscv/riscv-isa-manual/pull/1306.
2024-08-19 11:50:32 +08:00
Piyou Chen
82f52d9c42
[RISCV] Support new groupid/bitmask for cpu_model (#101632)
The spec can be found at
https://github.com/riscv-non-isa/riscv-c-api-doc/pull/74.

1. Add the new extension GroupID/Bitmask with latest hwprobe key.
2. Update the `initRISCVFeature `
3. Update `EmitRISCVCpuSupports` due to not only group0 now.
2024-08-08 14:42:41 +08:00
Philip Reames
d1e28e2a7b
[RISCV] Support __builtin_cpu_init and __builtin_cpu_supports (#99700)
This implements the __builtin_cpu_init and __builtin_cpu_supports
builtin routines based on the compiler runtime changes in
https://github.com/llvm/llvm-project/pull/85790.

This is inspired by https://github.com/llvm/llvm-project/pull/85786.
Major changes are a) a restriction in scope to only the builtins (which
have a much narrower user interface), and the avoidance of false
generality. This change deliberately only handles group 0 extensions
(which happen to be all defined ones today), and avoids the tblgen
changes from that review.

I don't have an environment in which I can actually test this, but @BeMg
has been kind enough to report that this appears to work as expected.

Before this can make it into a release, we need a change such as
https://github.com/llvm/llvm-project/pull/99958. The gcc docs claim that
cpu_support can be called by "normal" code without calling the cpu_init
routine because the init routine will have been called by a high
priority constructor. Our current compiler-rt mechanism does not do
this.
2024-07-23 08:48:28 -07:00
Shao-Ce SUN
cd6750fa5f
[RISCV][NFC] Add a newline when using --print-enabled-extensions (#98425)
The `--print-enabled-extensions` has been introduced in the
https://github.com/llvm/llvm-project/pull/98207 , but it seems to be
missing a newline in the end.
2024-07-11 12:43:14 +08:00
R
3c5f929ad0
[RISCV] Add QingKe "XW" compressed opcode extension (#97925)
This extension consists of 8 additional 16-bit compressed forms for
existing standard load/store opcodes.

These opcodes are found in some RISC-V microcontrollers from WCH /
Nanjing Qinheng Microelectronics.

As discussed in the Discourse forums, this uses incompatible extension
and opcode names vs the vendor binary toolchain. The chosen names
instead follow the conventions for other vendor extensions listed on the
"riscv-non-isa" project.
2024-07-11 11:10:02 +08:00
Michael Maitland
eee5d2d37c
[RISCV] Add ability to list extensions enabled for a target (#98207)
bb83a3d introduced `--print-enabled-extensions` command line option for
AArch64. This patch introduces RISC-V support for this option. This patch
adds documentation for this option.

`riscvExtensionsHelp` is renamed to `printSupportedExtensions` to by
synonymous with AArch64 and so it is clear what that function does.
2024-07-10 15:39:08 -04:00
Craig Topper
66470112d6
[RISCV] Don't expose any constructors of RISCVISAInfo publicly. (#98249)
lld was using RISCVISAInfo(unsigned XLen,
RISCVISAUtils::OrderedExtensionMap &Exts). This required a call to
RISCVISAInfo::postProcessAndChecking to validate the RISCVISAInfo that
was created. This exposes too much about RISCVISAInfo to lld.

Replace with a new RISCVISAInfo::createFromExtMap that is responsible
for creating the object and calling postProcessAndChecking.
2024-07-09 19:35:25 -07:00
Craig Topper
7aa906dda5 [RISCV] Merge the Arch and Exts variables in RISCVISAInfo::parseArchString. NFC 2024-07-03 12:11:47 -07:00
Craig Topper
c156d42185
[RISCV] Remove SeenExtMap from RISCVISAInfo::parseArchString. (#97506)
Use the Exts map directly instead of adding to a temporary MapVector
first.

There are a couple functional change from this.
-If an unknown extension is duplicated, we will now print an error for
it being unknown instead of an error for it being duplicated. 
-If an unknown extension is followed by an underscore with no extension after
it, we will error for the unknown extension instead of the dangling
underscore.

These don't seem like serious changes to me. I've updated tests
accordingly.
2024-07-03 11:49:08 -07:00
Craig Topper
c785eaec37
[RISCV] Add wrapper function for getStringError in RISCVISAInfo. NFC (#97478)
We use the same error code for all errors. Add a wrapper so we don't
have to repeat it.
2024-07-02 22:10:31 -07:00
Craig Topper
87de49753d
[RISCV] Remove IgnoreUnknown from RISCVISAInfo::parseArchString. (#97372)
This isn't used in tree, and thus I don't know what the expectations for
its behavior really are. The original usage of this feature has been replaced
by parseNormalizedArchString.
2024-07-02 09:39:59 -07:00
Craig Topper
299d3ddc61 [RISCV] Simplify some control flow in RISCVISAInfo::parseArchString. NFC
Merge handling of the baseline ISA into the switch that checks if
the baseline is valid.

Invert a condition to allow a better early out to reduce curly braces.
2024-07-01 18:22:33 -07:00
Craig Topper
08969ca159 [RISCV] Remove RISCVISAInfo::addExtension. NFC
We can edit the map directly at the caller. Many of the callers
already directly call contains or erase on the map. So there's no
good reason to have a wrapper for adding to the map.
2024-07-01 16:52:50 -07:00
Craig Topper
0e93801770 [RISCV] Speed up RISCVISAInfo::updateImplication.
We don't need to use a SmallSetVector to keep track of the worklist.
We only insert into the worklist if the extension is not already
in the Exts map. We immediately add it the Exts map at the same
time we add it to the worklist. If we encounter the extension again
it will already be in Exts so we won't try to add it to the worklist
again. We can just use a SmallVector for the Worklist.
2024-06-28 23:37:05 -07:00
Craig Topper
f906e3dd62 [RISCV] Fold processSingleLetterExtension/processMultiLetterExtension into RISCVISAInfo::parseArchString.
The end of both functions was very similar. Merging reduces the
duplication.

I'm planning to make additional changes to this code soon.
2024-06-27 15:04:17 -07:00
Craig Topper
4026b26342 [RISCV] Use StringRef instead of string_view in RISCVISAInfo. NFC
This is the only use of string_view in the file. Switch to StringRef
for consistency.
2024-06-26 23:05:51 -07:00
Craig Topper
bd488c1247 [RISCV] Use StringRef::starts_with(char) instead of starts_with(StringRef). NFC 2024-06-24 23:03:08 -07:00
Jay Foad
d4a0154902
[llvm-project] Fix typo "seperate" (#95373) 2024-06-13 20:20:27 +01:00
Jerry Zhang Jian
01921bd4f1
[RISCV] Fix typo zamo -> zaamo (#93792)
Signed-off-by: Jerry Zhang Jian <jerry.zhangjian@sifive.com>
2024-05-30 19:18:33 +08:00
Craig Topper
7c265e9f57 [RISCV] Replace std::optional::value() with operator*. NFC 2024-05-24 09:27:57 -07:00
Alex Bradbury
83f065d582 [RISCV] static_assert SupportedProfiles and SupportedExperimentalProfiles are sorted
Just as we do for the arrays of extension names.
2024-05-15 21:34:07 +01:00
Alex Bradbury
891d687137
[RISCV] Gate unratified profiles behind -menable-experimental-extensions (#92167)
As discussed in the last sync-up call, because these profiles are not
yet finalised they shouldn't be exposed to users unless they opt-in to
them (much like experimental extensions). We may later want to add a
more specific flag, but reusing `-menable-experimental-extensions`
solves the immediate problem.

This is implemented using the new support for marking profiles s
experimental added in #91993 to move the unratified profiles to
RISCVExperimentalProfile and making the necessary changes to logic in
RISCVISAInfo to handle this.
2024-05-15 21:09:43 +01:00
VincentWu
844355a8cb
[RISC-V] remove I ext when E ext has been enabled (#92070)
After patch https://github.com/llvm/llvm-project/pull/88805

`I` Ext will be added automatically when we running the command like 
`./build/bin/llc -mtriple=riscv32 -mattr=+e -target-abi ilp32e
-verify-machineinstrs llvm/test/CodeGen/RISCV/zcmp-additional-stack.ll`

it will generate 
```
	.text
	.attribute	4, 16
	.attribute	5, "rv32i2p1_e2pe"
	.file	"zcmp-additional-stack.ll"
	.globl	func                            # -- Begin function func
	.p2align	1
	.type	func,@function
```

This patch reset the I ext in FeatureBit when `+e` has been specify
2024-05-15 08:26:45 +10:00
Craig Topper
30aa49cbc2 [RISCV] Remove the pre-split from RISCVISAInfo::parseArchString. NFCI
We can extract each extension as we process them without much
complexity.
2024-05-10 15:31:44 -07:00
Craig Topper
7237bef5da [RISCV] Use map::count instead of hasExtension in computeDefaultABI. NFC
hasExtension checks if the extension name is a known extension name.
That should always be true for the extensions listed here so we can
skip that check.
2024-05-10 12:20:24 -07:00
Craig Topper
d8f8ac8f5f
[RISCV] Don't pre-split before the loop in parseNormalizedArchString. (#91684)
We can extract each extension as we process them without much
complexity.

I changed the error message for cases where there are double underscores
or a trailing underscore. I think this is an improvement over the
previous error.
2024-05-10 08:59:56 -07:00
Craig Topper
e069bb7fd8 [RISCV] Use map::count instead of hasExtension in RISCVISAInfo::updateCombination. NFC
hasExtension check isSupportedExtension before the map lookup. All
of the extensions we check for in updateCombination should be valid
extension names so we can bypass that to save some time.
2024-05-09 20:14:44 -07:00
Craig Topper
1aaab334c5
[RISCV] Don't use std::vector<std::string> for split extensions in RISCVISAInfo::parseArchString. NFC (#91538)
We can use a SmallVector<StringRef>.

Adjust the code so we check for empty strings in the loop instead of
making a copy of the vector returned from StringRef::split.

This overlaps with #91532 which also removed the std::vector, but
that PR may be more controversial.
2024-05-08 17:22:18 -07:00
Craig Topper
2c20995781
[RISCV] Detect duplicate extensions in parseNormalizedArchString. (#91416)
This detects the same extension name being added twice. Mostly I'm
worried about the case that the same string appears with two different
versions. We will only preserve one of the versions.

We could allow the same version to be repeated, but that doesn't seem
useful at the moment.

I've updated addExtension to use map::emplace instead of
map::operator[]. This means we only keep the first version if there are
duplicates. Previously we kept the last version, but that shouldn't matter
now that we don't allow duplicates. parseArchString already doesn't allow
duplicates.
2024-05-07 20:56:55 -07:00
Craig Topper
6cba93f25d [RISCV] Add partial validation of S and X extension names to RISCVISAInfo::parseNormalizedArchString.
Extensions starting with 's' or 'x' should always be followed by an
alphabetical character.  I don't know of any crashes from this currently,
but it seemed better to be defensive.
2024-05-07 12:16:55 -07:00
Craig Topper
0faf494200
[RISCV] Make parseArchString only accept [a-z0-9_]. (#90879)
Similar change was recently made to parseNormalizedArchString.
2024-05-03 09:29:27 -07:00
Craig Topper
7a6847e001
[RISCV] Add partial validation of Z extension name to RISCVISAInfo::parseNormalizedArchString (#90895)
If 'z' is given as the complete extension name or with a digit after it,
it will crash in the extension map compare function. Check for these
cases and give an error.
2024-05-03 09:29:11 -07:00
Craig Topper
5445a35d6e
[RISCV] Detect empty extension name after parsing MajorVersion in parseNormalizedArchString. (#90790)
If the string is just a version, we will end up adding an empty string
as an extension which crashes in the compare function for the std::map.
2024-05-02 10:08:35 -07:00