Skip to content
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

Add CORE-V headers #88

Closed
wants to merge 10 commits into from
Closed

Conversation

PaoloS02
Copy link
Contributor

@PaoloS02 PaoloS02 commented Nov 9, 2023

This is a reviewed version of the pull request #78

Add header files for all CORE-V extensions that have C builtin functions.
The definitions of existing builtin functions are also adjusted accordingly.

#if defined(__riscv_xcvalu)

#define __DEFAULT_FN_ATTRS __attribute__((__always_inline__, __nodebug__))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This isn't a special symbol, so __DEFAULT_FN_ATTRS does also need to be added to each declaration rather than just defined here.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Each definition should also be static inline (or, as appears to be the case for other targets' definitions, static __inline__)

@PaoloS02 PaoloS02 force-pushed the add-headers branch 2 times, most recently from 768675b to e0bf48a Compare November 22, 2023 01:46
…ons.

This patch changes the C API headers that were added for the CORE-V ISA
extensions so that they follow the standard described for RISC-V here:

https://github.com/riscv-non-isa/riscv-c-api-doc/blob/master/riscv-c-api.md#intrinsic-functions

The C API headers must provide a uniform interface for instrinsic
functions that is compatible with any compiler that supports them.

In the wrapper of a C API intrinsic function definition any compiler
can implement the functionality differently, whether it is with an existing
instrinsic function, or with inline assembly etc...

The user code that adds a C API RISC-V header is agnostic to the
implementation and is then compatible with any compiler that has the header.

The RISC-V intrinsic functions have
- the common prefix '__riscv_' to avoid name collision with other targets.
- a vendor specific prefix if they belong to a vendor specific extension.
- the name of the function.
- the type of the function: this is typically used to distinguish
  different versions of the same intrinsic function that differ only for
  the type of one or more operands.

Another convention is to use the type 'long' instead of integer types
like int32_t or uint32_t as the type 'long' will be set to the
current XLEN.

According to these conventions the CORE-V intrinsic functions are
now redefined like:

long __riscv_cv_name_type(long op1, long op2) {
  return __builtin_riscv_cv_name_type(op1, op2);
}
…t arguments.

This patch adds macros in the C API header files instead of wrapped
calls for those intrinsics which use const arguments.
This change affects the intrinsics for:

SIMD:

- add_h
- sub_h
- cplxmul_r
- cplxmul_i
- subrotmj
- shuffle_xhi
- extract[u]_[h/b]
- insert_[h/b]

Bitmanip:

- bitrev

It also changes the type of the immediate argument of extract and shuffle.sci
to const in the clang intrinsics definitions.
This is done to separate the tests for the internal implementation
of the CORE-V intrinsics from the tests for C API interfaces of the
same.
@ChunyuLiao
Copy link
Contributor

I see some testcases failed,
image

@PaoloS02 PaoloS02 changed the title Add CORE-V headers [REVIEWED] Add CORE-V headers Dec 8, 2023
@PaoloS02
Copy link
Contributor Author

PaoloS02 commented Jan 7, 2024

Implemented in new patches.

@PaoloS02 PaoloS02 closed this Jan 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants