Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

[proposal] Add syntax for expressing priority of FMV target expressions

Open
#403 12 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
5/5
Estimated time
Over a week
Newbie friendliness
25/100
Issue type
Feature
Clarity
Needs clarification
Activity status
Stale
Tech stack
c
Domain
compilers

Research direction

The issue names no implementation files, tests, or entry points. Start by reviewing the proposed target_clone and target_version syntax and the two priority approaches; done means agreeing on a concrete syntax and priority rules, then identifying implementation and test locations.

Written by the indexing model from the issue text.

Description

Summary

This proposal adds support for explicitly expressing the priority of function versions, in the target strings.

Example use case

For the case below, the default ordering has the sve feature as higher priority then dotprod, meaning for a target with both sve and dotprod the sve version would be selected. However, it may be that the dotprod version should be priority in this case.

typedef struct {
  int x;
  int y;
  int z;
  int w;
} Vec4;

[[target_clone("default", "sve")]]
Vec4 dotproduct (Vec4 a, Vec4 b)
{
  // do a dot product
}

[[target_version("dotprod")]]
Vec4 dotproduct (Vec4 a, Vec4 b)
{
  // Use dotprod intrinsics
}

Motivation

This enhancement was a natural result of considering the version priority rules. In specifying the default ordering, cases such as above, arose where the default priority rules would be a poor choice.

Possible solutions

There are several ways to solve this.

1. Add dummy features "priorityA", "priorityB", ...,

These features would have no effect on the versioned function, other than to change how they are ordered.
These versions would be higher priority than any other feature, so would override any default ordering.

Then the above would be:

typedef struct {
  int x;
  int y;
  int z;
  int w;
} Vec4;

[[target_clone("default", "sve")]]
Vec4 dotproduct (Vec4 a, Vec4 b)
{
  // do a dot product
}

[[target_version("dotprod+priorityA")]]
Vec4 dotproduct (Vec4 a, Vec4 b)
{
  // Use dotprod intrinsics
}

Could also use "priority1", "priority2", ...

This is similar to what was done for other targets (https://github.com/riscv-non-isa/riscv-c-api-doc/pull/85/files).

2. Label all the versions of a function

Another option is too support explicitly stating the order of all versions.

Something like:

typedef struct {
  int x;
  int y;
  int z;
  int w;
} Vec4;

[[target_clone("P3:default", "P2:sve")]]
Vec4 dotproduct (Vec4 a, Vec4 b)
{
  // do a dot product
}

[[target_version("P1:dotprod")]]
Vec4 dotproduct (Vec4 a, Vec4 b)
{
  // Use dotprod intrinsics
}

This seems like it introduces many more edge cases and complexity over suggestion 1 with little gain other than explicitness.

Dominant language
Python
Stars
129
Forks
77
Avg merge
8d 12h
Merged PRs (30d)
2

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from ARM-software/acle

All issues in ARM-software/acle

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.