diff --git a/riscv-cc.adoc b/riscv-cc.adoc index f6ab1882..0bf6cd32 100644 --- a/riscv-cc.adoc +++ b/riscv-cc.adoc @@ -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 <>. + === ILP32E Calling Convention IMPORTANT: RV32E is not a ratified base ISA and so we cannot guarantee the diff --git a/riscv-elf.adoc b/riscv-elf.adoc index 9d4ea27f..e2abf4c3 100644 --- a/riscv-elf.adoc +++ b/riscv-elf.adoc @@ -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" "_" + + := "r" + + := "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) + + := "N" (No mask, default for no inbranch clause) + | "M" (Mask, for inbranch clause) + + := SIMDLEN (VLS Mode, the number of elements processed at a time) + | "x" (VLA Mode) + + := { } + + := [ ] + + := "v" + | "l" | "l" + | "R" | "R" + | "L" | "L" + | "U" | "U" + | "ls" + | "Rs" + | "Ls" + | "Us" + | "u" + + := "n" // if linear step is negative + | + + := + + := integral number greater than or equal to 1 + + := integral number greater than or equal to 2 + + := [ "a" ] // specified by aligned clause + + := 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" :: 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" :: 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" :: 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" :: 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" :: 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" :: 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" :: 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" :: 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