https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91113

            Bug ID: 91113
           Summary: add declare_simd_variant attribute support
           Product: gcc
           Version: 10.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: nsz at gcc dot gnu.org
  Target Milestone: ---

to declare vector functions on aarch64 for one simd architecture only,
support for the openmp 5.0 declare variant syntax is required, but
full support for the omp declare variant pragma is excessive.
(for the aarch64 use-case, see user defined vector functions in
https://developer.arm.com/docs/101129/latest )

I suggest introducing an attribute in gcc that can handle a subset
of omp declare variant pragma and works in c and fortran declarations
for declare simd functions.

I think the syntax and semantics for the attribute should follow
the proposal for clang (without the clang_ prefix):
http://lists.llvm.org/pipermail/llvm-dev/2019-June/132987.html

```
declare_simd_variant
  (<variant-func-id>, <simd clauses>{, <context selector clauses>})

<variant-func-id>:= The name of a function variant that is a base
                    language identifier, or, for C++, a template-id.

<simd clauses> := <simdlen>, <mask>{, <optional simd clauses>}

<simdlen> := simdlen(<positive number>) | simdlen("scalable")

<mask>    := inbranch | notinbranch

<optional simd clauses> := <linear clause> 
                         | <uniform clause>
                         | <align clause>  | {,<optional simd clauses>}

<linear clause>  := linear_ref(<var>,<step>)
                  | linear_var(<var>, <step>)
                  | linear_uval(<var>, <step>)
                  | linear(<var>, <step>)

<step> := <var> | <non zero number>

<uniform clause> := uniform(<var>)

<align clause>   := align(<var>, <positive number>)

<var> := Name of a parameter in the scalar function declaration/definition

<non zero number> := ... | -2 | -1 | 1 | 2 | ...

<positive number> := 1 | 2 | 3 | ...

<context selector clauses> := {<isa>}{,} {<arch>}

<isa> := isa(target-specific-value)

<arch> := arch(target-specific-value)
```

example usage:
```
__attribute__(declare_simd_variant("vfoo", simdlen(2), notinbranch,
isa("simd"))
double foo(double x);

float64x2_t vfoo(float64x2_t vx);
```

should be equivalent to the openmp 5.0 code
```
#pragma omp declare variant(vfoo) \
  match(construct={simd(simdlen(2), notinbranch)}, device={isa("simd")})
double foo(double x);

float64x2_t vfoo(float64x2_t vx);
```

Reply via email to