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

Specify the Name Mangling Rule for Vector Function Decorated with OpenMP #455

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions riscv-cc.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -428,6 +428,10 @@ NOTE: `setjmp`/`longjmp` follow the standard calling convention, which clobbers
all vector registers. Hence, the standard vector calling convention variant
won't disrupt the `jmp_buf` ABI.

NOTE: Vector functions corresponding to scalar functions which are decorated with
the OpenMP `declare simd` pragma need to obey an additional name mangling rule.
For more details, see <<Name Mangling for Vector Function>>.

=== ILP32E Calling Convention

IMPORTANT: RV32E is not a ratified base ISA and so we cannot guarantee the
Expand Down
112 changes: 112 additions & 0 deletions riscv-elf.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,118 @@ type-name = identifier-nondigit *identifier-char
identifier-nondigit = ALPHA / "_"
identifier-char = identifier-nondigit / "_"
----

== Name Mangling for Vector Function

This section describes how to name vector functions corresponding to scalar
functions which are decorated with `#pragma omp declare simd`. The order of the
vector function parameters should be the same as that of the original scalar
function.

Name mangling rule for vector functions.

[source,abnf]
----
mangled-vector-name := "_ZGV" <isa> <mask> <len> <parameters> "_" <func-name>

<isa> := "r" <lmul>

<lmul> := "1" | "2" | "4" | "8" (LMUL in turn is 1, 2, 4, 8)
| "h" | "q" | "e" (LMUL in turn is 1/2, 1/4, 1/8)

<mask> := "N" (No mask, default for no inbranch clause)
| "M" (Mask, for inbranch clause)

<len> := SIMDLEN (VLS Mode, the number of elements processed at a time)
| "x" (VLA Mode)

<parameters> := <parameter> { <parameter> }

<parameter> := <parameter_type> [ <alignment> ]

<parameter_type> := "v"
| "l" | "l" <number>
| "R" | "R" <number>
| "L" | "L" <number>
| "U" | "U" <number>
| "ls" <pos>
| "Rs" <pos>
| "Ls" <pos>
| "Us" <pos>
| "u"

<number> := "n" <X> // if linear step is negative
| <Y>

<pos> := <X>

<X> := integral number greater than or equal to 1

<Y> := integral number greater than or equal to 2

<alignment> := [ "a" <X> ] // specified by aligned clause

<func-name> := the orignal name of the scalar function
----

=== Description of the parameter_type token

"v":: Vector parameter, default value for no linear or uniform clause.

"l" | "l" <number>:: This parameter is specified by the linear clause with a
compile-time constant, and its type must be either an integral type or a pointer
type. `number` is the value of the compile-time constant step, or it is an empty
string if the constant step is 1. Additionally, the base type of this parameter
must be an integral type.

"R" | "R" <number>:: This parameter is specified by the linear clause with a
compile-time constant. It has a ref modifier and its type must be reference type.
`number` is the value of the compile-time constant step, or it is an empty
string if the constant step is 1. Additionally, the base type of this parameter
must be an integral type.

"L" | "L" <number>:: This parameter is specified by the linear clause with a
compile-time constant. It has either a val modifier or no modifier and its type
must be reference type. `number` is the value of the compile-time constant step,
or it is an empty string if the constant step is 1. Additionally, the base type
of this parameter must be an integral type.

"U" | "U" <number>:: This parameter is specified by the linear clause with a
compile-time constant. It has a uval modifier and its type must be reference type.
`number` is the value of the compile-time constant step, or it is an empty
string if the constant step is 1. Additionally, the base type of this parameter
must be an integral type.

"ls" <pos>:: This parameter is specified by the linear clause with a
loop-independent, runtime-invariant step parameter specified in the uniform clause.
Its type must be either an integral type or a pointer type. `pos' is the position
(starting from 0) of the step parameter in the function parameter list.
Additionally, both the base type of this parameter and the step parameter must be
integral types.

"Rs" <pos>:: This parameter is specified by the linear clause with a
loop-independent, runtime-invariant step parameter specified in the uniform clause.
It has a ref modifier and its type must be reference type. `pos' is the position
(starting from 0) of the step parameter in the function parameter list.
Additionally, both the base type of this parameter and the step parameter must be
integral types.

"Ls" <pos>:: This parameter is specified by the linear clause with a
loop-independent, runtime-invariant step parameter specified in the uniform clause.
It has either a val modifier or no modifier and its type must be reference type.
`pos' is the position (starting from 0) of the step parameter in the function
parameter list. Additionally, both the base type of this parameter and the step
parameter must be integral types.

"Us" <pos>:: This parameter is specified by the linear clause with a
loop-independent, runtime-invariant step parameter specified in the uniform clause.
It has a uval modifier and its type must be reference type. `pos' is the position
(starting from 0) of the step parameter in the function parameter list.
Additionally, both the base type of this parameter and the step parameter must be
integral types.

"u":: Uniform parameter, specified by uniform clause.

== ELF Object Files

The ELF object file format for RISC-V follows the
Expand Down