-
Notifications
You must be signed in to change notification settings - Fork 42
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Function attribute for standard fixed-length vector calling convention variant #68
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -318,6 +318,57 @@ __attribute__((target("arch=+v"))) int foo(void) { return 0; } | |
__attribute__((target("arch=+zbb"))) int foo(void) { return 1; } | ||
``` | ||
|
||
### `__attribute__((riscv_vls_cc))` | ||
|
||
Supported Syntaxes: | ||
| Style | Syntax | | ||
| ------ | --------------------------------------------------------------------- | | ||
| GNU | `__attribute__((riscv_vls_cc)))`, `__attribute__((riscv_vls_cc(N))))``*` | | ||
| C++11 | `[[riscv::vls_cc]]`, `[[riscv::vls_cc(N)]]``*` | | ||
| C23 | `[[riscv::vls_cc]]`, `[[riscv::vls_cc(N)]]``*` | | ||
|
||
`*` N is the the `ABI_LEN`. | ||
|
||
Functions declared with this attribute will utilize the standard fixed-length | ||
vector calling convention variant instead of the default calling convention | ||
defined by the ABI. This variant aims to pass fixed-length vectors via vector | ||
registers, if possible, rather than through general-purpose registers. | ||
|
||
The attribute can accept an optional unsigned integer argument within the value | ||
range of `[32, 65536]`, which must be a power of two. This argument specifies | ||
the `ABI_VLEN`. If not provided, the default value is set to 128. However, this | ||
default value can be changed via command-line options or pragma directives. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Where are the command line options or pragma defined? |
||
|
||
```c | ||
// foo uses the standard fixed-length vector calling convention variant with the | ||
// default ABI_VLEN, which is 128. | ||
void foo __attribute__((riscv_vls_cc)); | ||
// bar uses the standard fixed-length vector calling convention variant with | ||
// ABI_VLEN=256. | ||
void bar __attribute__((riscv_vls_cc(256))); | ||
``` | ||
|
||
One constraint on `ABI_VLEN` is that it must be larger than or equal to the | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. " |
||
minimal `VLEN`, as specified by the `-march` option through the `zvl*b` extension, | ||
pragma directives, or the target attribute. | ||
|
||
```c | ||
// foo is declared to use the standard fixed-length vector calling convention variant | ||
// with ABI_VLEN=256. Compilation will succeed with -march=rv64gcv_zvl256b, as it | ||
// supports VLEN of 256. However, compiling with -march=rv64gcv will result in an error, | ||
// because rv64gcv's VLEN is 128, which is less than the specified ABI_VLEN of 256. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This disagrees with the preceding paragraph that says ABI_VLEN must be larger or equal than the minimval VLEN. |
||
void foo __attribute__((riscv_vls_cc(256))); | ||
|
||
// bar uses the standard fixed-length vector calling convention variant with | ||
// ABI_VLEN=256 and also specifies the minimal VLEN as 256 using the target | ||
// attribute. | ||
void bar __attribute__((riscv_vls_cc(256))) __attribute__((target("arch=+zvl256b"))); | ||
``` | ||
|
||
NOTE: Invoking a function with an incorrect `ABI_VLEN` will cause parameters to | ||
be passed incorrectly. Users should ensure the consistency of `ABI_VLEN`, | ||
especially when using a non-default `ABI_VLEN`. | ||
|
||
## Intrinsic Functions | ||
|
||
Intrinsic functions (or intrinsics or built-ins) are expanded into instruction sequences by compilers. | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is set to
->is