From 564d108bc427f589b342d225c8916afff5194c93 Mon Sep 17 00:00:00 2001 From: Piyou Chen Date: Mon, 5 Aug 2024 23:58:28 -0700 Subject: [PATCH 01/15] Support version selection --- riscv-c-api.md | 45 ++++++++++++++++++++++++++++++++++++++------- 1 file changed, 38 insertions(+), 7 deletions(-) diff --git a/riscv-c-api.md b/riscv-c-api.md index 0b4129b..f015869 100644 --- a/riscv-c-api.md +++ b/riscv-c-api.md @@ -299,8 +299,12 @@ Each `TARGET-CLONES-ATTR-STRING` defines a distinguished version of the function The syntax of `` describes below: ``` -TARGET-CLONES-ATTR-STRING := 'arch=' EXTENSIONS - | 'default' +TARGET-CLONES-ATTR-STRING := ATTR-STRING + | ';' TARGET-VERSION-ATTR-STRING + +ATTR-STRING := 'arch=' EXTENSIONS + | 'default' + | 'Priority=' DIGIT EXTENSIONS := ',' | @@ -313,13 +317,15 @@ VERSION := [0-9]+ 'p' [0-9]+ | [1-9][0-9]* | +DIGIT := [0-9]+ + EXTENSION-NAME := Naming rule is defined in RISC-V ISA manual ``` For example, the following `foo` function will have three versions but share the same function signature. ```c -__attribute__((target_clones("arch=+v", "default", "arch=+zbb"))) +__attribute__((target_clones("arch=+v;Priority=2", "default", "arch=+zbb;Priority=1"))) int foo(int a) { return a + 5; @@ -331,6 +337,8 @@ int bar() { } ``` +The `Priority` accepts a digit as the version priority during Version Selection. If `Priority` doesn't exist, then the priority of version defaults to zero. + It makes the compiler trigger the [function multi-version](#function-multi-version) when there exist more than one version for the same function signature. ### `__attribute__((target_version("")))` @@ -342,8 +350,13 @@ Each `TARGET-VERSION-ATTR-STRING` defines a distinguished version of the functio The syntax of `` describes below: ``` -TARGET-VERSION-ATTR-STRING := 'arch=' EXTENSIONS - | 'default' + +TARGET-VERSION-ATTR-STRING := ATTR-STRING + | ';' TARGET-VERSION-ATTR-STRING + +ATTR-STRING := 'arch=' EXTENSIONS + | 'default' + | 'Priority=' DIGIT EXTENSIONS := ',' | @@ -356,19 +369,21 @@ VERSION := [0-9]+ 'p' [0-9]+ | [1-9][0-9]* | +DIGIT := [0-9]+ + EXTENSION-NAME := Naming rule is defined in RISC-V ISA manual ``` For example, the following foo function has three versions. ```c -__attribute__((target_version("arch=+v"))) +__attribute__((target_version("arch=+v;Priority=1"))) int foo(int a) { return a + 5; } -__attribute__((target_version("arch=+zbb"))) +__attribute__((target_version("arch=+zbb;Priority=2"))) int foo(int a) { return a + 5; @@ -386,6 +401,8 @@ int bar() { } ``` +The `Priority` accepts a digit as the version priority during Version Selection. If `Priority` doesn't exist, then the priority of version defaults to zero. + It makes the compiler trigger the [function multi-version](#function-multi-version) when there exist more than one version for the same function signature. ### riscv_vector_cc @@ -708,3 +725,17 @@ statements, including both RISC-V specific and common operand modifiers. Function multi-versioning(FMV) provides an approach to selecting the appropriate function according to the runtime environment. The final binary may contain all versions of the function, with the compiler generating all supported versions and the runtime selecting the appropriate one. This feature is triggered by `target_version/target_clones` function attribute. + +### Version Selection + +The process of selecting the appropriate function version during function multi-versioning follows these guidelines: + +1. The implementation of the selection algorithm is platform-specific. +2. Once a version is selected, it remains in use for the entire duration of the process. +3. Only versions whose required features are all available in the runtime environment are eligible for selection. + +The version selection process applies the following rules in order: + +1. Among the eligible versions, select the one with the highest priority. +2. If multiple versions are equally priority, select the one that was declared first. +3. If no other suitable versions are found, fall back to the "default" version. From 249c7fa3c9516a83a1faf7c8795d863ce0348d31 Mon Sep 17 00:00:00 2001 From: Piyou Chen Date: Mon, 19 Aug 2024 02:42:38 -0700 Subject: [PATCH 02/15] are equally -> have equal --- riscv-c-api.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/riscv-c-api.md b/riscv-c-api.md index f015869..5fc06d1 100644 --- a/riscv-c-api.md +++ b/riscv-c-api.md @@ -737,5 +737,5 @@ The process of selecting the appropriate function version during function multi- The version selection process applies the following rules in order: 1. Among the eligible versions, select the one with the highest priority. -2. If multiple versions are equally priority, select the one that was declared first. +2. If multiple versions have equal priority, select the one that was declared first. 3. If no other suitable versions are found, fall back to the "default" version. From 2b9c6a4fb599daa2a3a8568c8cdc134f0f5fb59f Mon Sep 17 00:00:00 2001 From: Piyou Chen Date: Mon, 19 Aug 2024 03:20:10 -0700 Subject: [PATCH 03/15] Priority -> priority --- riscv-c-api.md | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/riscv-c-api.md b/riscv-c-api.md index 5fc06d1..73deaa8 100644 --- a/riscv-c-api.md +++ b/riscv-c-api.md @@ -304,7 +304,7 @@ TARGET-CLONES-ATTR-STRING := ATTR-STRING ATTR-STRING := 'arch=' EXTENSIONS | 'default' - | 'Priority=' DIGIT + | 'priority=' DIGIT EXTENSIONS := ',' | @@ -325,7 +325,7 @@ EXTENSION-NAME := Naming rule is defined in RISC-V ISA manual For example, the following `foo` function will have three versions but share the same function signature. ```c -__attribute__((target_clones("arch=+v;Priority=2", "default", "arch=+zbb;Priority=1"))) +__attribute__((target_clones("arch=+v;priority=2", "default", "arch=+zbb;priority=1"))) int foo(int a) { return a + 5; @@ -337,7 +337,7 @@ int bar() { } ``` -The `Priority` accepts a digit as the version priority during Version Selection. If `Priority` doesn't exist, then the priority of version defaults to zero. +The `priority` accepts a digit as the version priority during Version Selection. If `priority` doesn't exist, then the priority of version defaults to zero. It makes the compiler trigger the [function multi-version](#function-multi-version) when there exist more than one version for the same function signature. @@ -356,7 +356,7 @@ TARGET-VERSION-ATTR-STRING := ATTR-STRING ATTR-STRING := 'arch=' EXTENSIONS | 'default' - | 'Priority=' DIGIT + | 'priority=' DIGIT EXTENSIONS := ',' | @@ -377,13 +377,13 @@ EXTENSION-NAME := Naming rule is defined in RISC-V ISA manual For example, the following foo function has three versions. ```c -__attribute__((target_version("arch=+v;Priority=1"))) +__attribute__((target_version("arch=+v;priority=1"))) int foo(int a) { return a + 5; } -__attribute__((target_version("arch=+zbb;Priority=2"))) +__attribute__((target_version("arch=+zbb;priority=2"))) int foo(int a) { return a + 5; @@ -401,7 +401,7 @@ int bar() { } ``` -The `Priority` accepts a digit as the version priority during Version Selection. If `Priority` doesn't exist, then the priority of version defaults to zero. +The `priority` accepts a digit as the version priority during Version Selection. If `priority` doesn't exist, then the priority of version defaults to zero. It makes the compiler trigger the [function multi-version](#function-multi-version) when there exist more than one version for the same function signature. From bfbc7936d3c268a17f7bdba7d7943828aaade3fd Mon Sep 17 00:00:00 2001 From: Piyou Chen Date: Mon, 19 Aug 2024 03:21:25 -0700 Subject: [PATCH 04/15] Make Version Selection as hypelink --- riscv-c-api.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/riscv-c-api.md b/riscv-c-api.md index 73deaa8..86fb099 100644 --- a/riscv-c-api.md +++ b/riscv-c-api.md @@ -337,7 +337,7 @@ int bar() { } ``` -The `priority` accepts a digit as the version priority during Version Selection. If `priority` doesn't exist, then the priority of version defaults to zero. +The `priority` accepts a digit as the version priority during [Version Selection](#version-selection). If `priority` doesn't exist, then the priority of version defaults to zero. It makes the compiler trigger the [function multi-version](#function-multi-version) when there exist more than one version for the same function signature. @@ -401,7 +401,7 @@ int bar() { } ``` -The `priority` accepts a digit as the version priority during Version Selection. If `priority` doesn't exist, then the priority of version defaults to zero. +The `priority` accepts a digit as the version priority during [Version Selection](#version-selection). If `priority` doesn't exist, then the priority of version defaults to zero. It makes the compiler trigger the [function multi-version](#function-multi-version) when there exist more than one version for the same function signature. From b96ead91c0d71eb7ae9f8334d22b42b782a1d54e Mon Sep 17 00:00:00 2001 From: Piyou Chen Date: Thu, 22 Aug 2024 23:04:20 -0700 Subject: [PATCH 05/15] Update --- riscv-c-api.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/riscv-c-api.md b/riscv-c-api.md index 86fb099..f843609 100644 --- a/riscv-c-api.md +++ b/riscv-c-api.md @@ -300,7 +300,7 @@ The syntax of `` describes below: ``` TARGET-CLONES-ATTR-STRING := ATTR-STRING - | ';' TARGET-VERSION-ATTR-STRING + | ';' TARGET-CLONES-ATTR-STRING ATTR-STRING := 'arch=' EXTENSIONS | 'default' @@ -337,7 +337,7 @@ int bar() { } ``` -The `priority` accepts a digit as the version priority during [Version Selection](#version-selection). If `priority` doesn't exist, then the priority of version defaults to zero. +The `priority` accepts a digit as the version priority during [Version Selection](#version-selection). If `priority` isn't specified, then the priority of version defaults to zero. It makes the compiler trigger the [function multi-version](#function-multi-version) when there exist more than one version for the same function signature. @@ -401,7 +401,7 @@ int bar() { } ``` -The `priority` accepts a digit as the version priority during [Version Selection](#version-selection). If `priority` doesn't exist, then the priority of version defaults to zero. +The `priority` accepts a digit as the version priority during [Version Selection](#version-selection). If `priority` isn't specified, then the priority of version defaults to zero. It makes the compiler trigger the [function multi-version](#function-multi-version) when there exist more than one version for the same function signature. From 3430d1891cb7679b5ba26e13ca79a367861dd2ff Mon Sep 17 00:00:00 2001 From: Piyou Chen Date: Thu, 22 Aug 2024 23:17:45 -0700 Subject: [PATCH 06/15] Make default doesn't accept other attr --- riscv-c-api.md | 65 ++++++++++++++++++++++++++++---------------------- 1 file changed, 37 insertions(+), 28 deletions(-) diff --git a/riscv-c-api.md b/riscv-c-api.md index f843609..b0a00d8 100644 --- a/riscv-c-api.md +++ b/riscv-c-api.md @@ -299,27 +299,31 @@ Each `TARGET-CLONES-ATTR-STRING` defines a distinguished version of the function The syntax of `` describes below: ``` -TARGET-CLONES-ATTR-STRING := ATTR-STRING - | ';' TARGET-CLONES-ATTR-STRING +TARGET-CLONES-ATTR-STRING := DEFAULT-ATTR-STRING + | ATTR-STRINGS -ATTR-STRING := 'arch=' EXTENSIONS - | 'default' - | 'priority=' DIGIT +ATTR-STRINGS := ATTR-STRING + | ';' ATTR-STRINGS -EXTENSIONS := ',' - | +DEFAULT-ATTR-STRING := 'default' -EXTENSION := +ATTR-STRING := 'arch=' EXTENSIONS + | 'priority=' DIGIT -OP := '+' +EXTENSIONS := ',' + | -VERSION := [0-9]+ 'p' [0-9]+ - | [1-9][0-9]* - | +EXTENSION := + +OP := '+' -DIGIT := [0-9]+ +VERSION := [0-9]+ 'p' [0-9]+ + | [1-9][0-9]* + | + +DIGIT := [0-9]+ -EXTENSION-NAME := Naming rule is defined in RISC-V ISA manual +EXTENSION-NAME := Naming rule is defined in RISC-V ISA manual ``` For example, the following `foo` function will have three versions but share the same function signature. @@ -350,28 +354,31 @@ Each `TARGET-VERSION-ATTR-STRING` defines a distinguished version of the functio The syntax of `` describes below: ``` +TARGET-VERSION-ATTR-STRING := DEFAULT-ATTR-STRING + | ATTR-STRINGS -TARGET-VERSION-ATTR-STRING := ATTR-STRING - | ';' TARGET-VERSION-ATTR-STRING +DEFAULT-ATTR-STRING := 'default' -ATTR-STRING := 'arch=' EXTENSIONS - | 'default' - | 'priority=' DIGIT +ATTR-STRINGS := ATTR-STRING + | ';' ATTR-STRINGS -EXTENSIONS := ',' - | +ATTR-STRING := 'arch=' EXTENSIONS + | 'priority=' DIGIT -EXTENSION := +EXTENSIONS := ',' + | -OP := '+' +EXTENSION := -VERSION := [0-9]+ 'p' [0-9]+ - | [1-9][0-9]* - | +OP := '+' -DIGIT := [0-9]+ +VERSION := [0-9]+ 'p' [0-9]+ + | [1-9][0-9]* + | -EXTENSION-NAME := Naming rule is defined in RISC-V ISA manual +DIGIT := [0-9]+ + +EXTENSION-NAME := Naming rule is defined in RISC-V ISA manual ``` For example, the following foo function has three versions. @@ -403,6 +410,8 @@ int bar() { The `priority` accepts a digit as the version priority during [Version Selection](#version-selection). If `priority` isn't specified, then the priority of version defaults to zero. +The `default` version does not accept the priority. + It makes the compiler trigger the [function multi-version](#function-multi-version) when there exist more than one version for the same function signature. ### riscv_vector_cc From 07143ead1ee0720aff33016c28ab26bdb3caa615 Mon Sep 17 00:00:00 2001 From: Piyou Chen Date: Thu, 12 Sep 2024 21:28:12 -0700 Subject: [PATCH 07/15] implementation-specific instead of platform-specific --- riscv-c-api.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/riscv-c-api.md b/riscv-c-api.md index b0a00d8..f25901e 100644 --- a/riscv-c-api.md +++ b/riscv-c-api.md @@ -739,7 +739,7 @@ This feature is triggered by `target_version/target_clones` function attribute. The process of selecting the appropriate function version during function multi-versioning follows these guidelines: -1. The implementation of the selection algorithm is platform-specific. +1. The implementation of the selection algorithm is implementation-specific. 2. Once a version is selected, it remains in use for the entire duration of the process. 3. Only versions whose required features are all available in the runtime environment are eligible for selection. From c1d932926e26289422a65d95a4b6cc2591c026b5 Mon Sep 17 00:00:00 2001 From: Piyou Chen Date: Thu, 12 Sep 2024 21:31:08 -0700 Subject: [PATCH 08/15] Make rule more flexibility on equal priority --- riscv-c-api.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/riscv-c-api.md b/riscv-c-api.md index f25901e..f31b5ee 100644 --- a/riscv-c-api.md +++ b/riscv-c-api.md @@ -746,5 +746,5 @@ The process of selecting the appropriate function version during function multi- The version selection process applies the following rules in order: 1. Among the eligible versions, select the one with the highest priority. -2. If multiple versions have equal priority, select the one that was declared first. +2. If multiple versions have equal priority, select one based on an implementation-defined heuristic. 3. If no other suitable versions are found, fall back to the "default" version. From a99cb0e77b64cac2a4aaac3af0cb96249be6c373 Mon Sep 17 00:00:00 2001 From: Piyou Chen Date: Thu, 12 Sep 2024 21:41:38 -0700 Subject: [PATCH 09/15] Make BNF change more friendly for review --- riscv-c-api.md | 38 +++++++++++++++++++------------------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/riscv-c-api.md b/riscv-c-api.md index f31b5ee..d991713 100644 --- a/riscv-c-api.md +++ b/riscv-c-api.md @@ -310,20 +310,20 @@ DEFAULT-ATTR-STRING := 'default' ATTR-STRING := 'arch=' EXTENSIONS | 'priority=' DIGIT -EXTENSIONS := ',' - | +DIGIT := [0-9]+ -EXTENSION := +EXTENSIONS := ',' + | -OP := '+' +EXTENSION := -VERSION := [0-9]+ 'p' [0-9]+ - | [1-9][0-9]* - | +OP := '+' -DIGIT := [0-9]+ - -EXTENSION-NAME := Naming rule is defined in RISC-V ISA manual +VERSION := [0-9]+ 'p' [0-9]+ + | [1-9][0-9]* + | + +EXTENSION-NAME := Naming rule is defined in RISC-V ISA manual ``` For example, the following `foo` function will have three versions but share the same function signature. @@ -365,20 +365,20 @@ ATTR-STRINGS := ATTR-STRING ATTR-STRING := 'arch=' EXTENSIONS | 'priority=' DIGIT -EXTENSIONS := ',' - | +DIGIT := [0-9]+ -EXTENSION := +EXTENSIONS := ',' + | -OP := '+' +EXTENSION := -VERSION := [0-9]+ 'p' [0-9]+ - | [1-9][0-9]* - | +OP := '+' -DIGIT := [0-9]+ +VERSION := [0-9]+ 'p' [0-9]+ + | [1-9][0-9]* + | -EXTENSION-NAME := Naming rule is defined in RISC-V ISA manual +EXTENSION-NAME := Naming rule is defined in RISC-V ISA manual ``` For example, the following foo function has three versions. From 88261f11b4536982848f75c10b76a7ddebdf6742 Mon Sep 17 00:00:00 2001 From: Piyou Chen Date: Thu, 12 Sep 2024 22:42:30 -0700 Subject: [PATCH 10/15] Support minus for priority syntax --- riscv-c-api.md | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/riscv-c-api.md b/riscv-c-api.md index d991713..55e8f50 100644 --- a/riscv-c-api.md +++ b/riscv-c-api.md @@ -310,7 +310,8 @@ DEFAULT-ATTR-STRING := 'default' ATTR-STRING := 'arch=' EXTENSIONS | 'priority=' DIGIT -DIGIT := [0-9]+ +DIGIT := '-' [0-9]+ + | [0-9]+ EXTENSIONS := ',' | @@ -365,7 +366,8 @@ ATTR-STRINGS := ATTR-STRING ATTR-STRING := 'arch=' EXTENSIONS | 'priority=' DIGIT -DIGIT := [0-9]+ +DIGIT := '-' [0-9]+ + | [0-9]+ EXTENSIONS := ',' | From 2dda32303c0dd258e619287e1eb2799e194919a4 Mon Sep 17 00:00:00 2001 From: Piyou Chen Date: Fri, 13 Sep 2024 00:23:23 -0700 Subject: [PATCH 11/15] Force priority must with arch string --- riscv-c-api.md | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/riscv-c-api.md b/riscv-c-api.md index 55e8f50..9f4d761 100644 --- a/riscv-c-api.md +++ b/riscv-c-api.md @@ -307,8 +307,13 @@ ATTR-STRINGS := ATTR-STRING DEFAULT-ATTR-STRING := 'default' -ATTR-STRING := 'arch=' EXTENSIONS - | 'priority=' DIGIT +ATTR-STRING := ARCH-ATTR ';' PRIORITY-ATTR + | PRIORITY-ATTR ';' ARCH-ATTR + | ARCH-ATTR + +ARCH-ATTR := 'arch=' EXTENSIONS + +PRIORITY-ATTR := 'priority=' DIGIT DIGIT := '-' [0-9]+ | [0-9]+ @@ -363,8 +368,13 @@ DEFAULT-ATTR-STRING := 'default' ATTR-STRINGS := ATTR-STRING | ';' ATTR-STRINGS -ATTR-STRING := 'arch=' EXTENSIONS - | 'priority=' DIGIT +ATTR-STRING := ARCH-ATTR ';' PRIORITY-ATTR + | PRIORITY-ATTR ';' ARCH-ATTR + | ARCH-ATTR + +ARCH-ATTR := 'arch=' EXTENSIONS + +PRIORITY-ATTR := 'priority=' DIGIT DIGIT := '-' [0-9]+ | [0-9]+ From e667006f6286b25c33b1e0e18d12b8d7fc874aac Mon Sep 17 00:00:00 2001 From: Piyou Chen Date: Fri, 13 Sep 2024 00:28:51 -0700 Subject: [PATCH 12/15] Simplify 'default' in BNF --- riscv-c-api.md | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/riscv-c-api.md b/riscv-c-api.md index 9f4d761..dbaaefe 100644 --- a/riscv-c-api.md +++ b/riscv-c-api.md @@ -299,14 +299,12 @@ Each `TARGET-CLONES-ATTR-STRING` defines a distinguished version of the function The syntax of `` describes below: ``` -TARGET-CLONES-ATTR-STRING := DEFAULT-ATTR-STRING +TARGET-CLONES-ATTR-STRING := 'default' | ATTR-STRINGS ATTR-STRINGS := ATTR-STRING | ';' ATTR-STRINGS -DEFAULT-ATTR-STRING := 'default' - ATTR-STRING := ARCH-ATTR ';' PRIORITY-ATTR | PRIORITY-ATTR ';' ARCH-ATTR | ARCH-ATTR @@ -360,11 +358,9 @@ Each `TARGET-VERSION-ATTR-STRING` defines a distinguished version of the functio The syntax of `` describes below: ``` -TARGET-VERSION-ATTR-STRING := DEFAULT-ATTR-STRING +TARGET-VERSION-ATTR-STRING := 'default' | ATTR-STRINGS -DEFAULT-ATTR-STRING := 'default' - ATTR-STRINGS := ATTR-STRING | ';' ATTR-STRINGS From 53ac78fbd3f1e946daae3e451f40bf3e3c40873e Mon Sep 17 00:00:00 2001 From: Piyou Chen Date: Tue, 17 Sep 2024 20:46:25 -0700 Subject: [PATCH 13/15] DIGIT -> DIGITS --- riscv-c-api.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/riscv-c-api.md b/riscv-c-api.md index dbaaefe..19bdca6 100644 --- a/riscv-c-api.md +++ b/riscv-c-api.md @@ -311,9 +311,9 @@ ATTR-STRING := ARCH-ATTR ';' PRIORITY-ATTR ARCH-ATTR := 'arch=' EXTENSIONS -PRIORITY-ATTR := 'priority=' DIGIT +PRIORITY-ATTR := 'priority=' DIGITS -DIGIT := '-' [0-9]+ +DIGITS := '-' [0-9]+ | [0-9]+ EXTENSIONS := ',' @@ -370,10 +370,10 @@ ATTR-STRING := ARCH-ATTR ';' PRIORITY-ATTR ARCH-ATTR := 'arch=' EXTENSIONS -PRIORITY-ATTR := 'priority=' DIGIT +PRIORITY-ATTR := 'priority=' DIGITS -DIGIT := '-' [0-9]+ - | [0-9]+ +DIGITS := '-' [0-9]+ + | [0-9]+ EXTENSIONS := ',' | From 464e6bb57ca26ccc8ac79091d33ab0620a3bc564 Mon Sep 17 00:00:00 2001 From: Piyou Chen Date: Tue, 17 Sep 2024 20:55:22 -0700 Subject: [PATCH 14/15] Reuse the same BNF form between target version and target clone --- riscv-c-api.md | 34 +--------------------------------- 1 file changed, 1 insertion(+), 33 deletions(-) diff --git a/riscv-c-api.md b/riscv-c-api.md index 19bdca6..7bad9ec 100644 --- a/riscv-c-api.md +++ b/riscv-c-api.md @@ -355,39 +355,7 @@ The `target_version` attribute is used to create one version of a function. Func Each `TARGET-VERSION-ATTR-STRING` defines a distinguished version of the function. If there is more than one version for the same function, it must have `default` one that indicating the translation unit scope build attributes. -The syntax of `` describes below: - -``` -TARGET-VERSION-ATTR-STRING := 'default' - | ATTR-STRINGS - -ATTR-STRINGS := ATTR-STRING - | ';' ATTR-STRINGS - -ATTR-STRING := ARCH-ATTR ';' PRIORITY-ATTR - | PRIORITY-ATTR ';' ARCH-ATTR - | ARCH-ATTR - -ARCH-ATTR := 'arch=' EXTENSIONS - -PRIORITY-ATTR := 'priority=' DIGITS - -DIGITS := '-' [0-9]+ - | [0-9]+ - -EXTENSIONS := ',' - | - -EXTENSION := - -OP := '+' - -VERSION := [0-9]+ 'p' [0-9]+ - | [1-9][0-9]* - | - -EXTENSION-NAME := Naming rule is defined in RISC-V ISA manual -``` +The syntax of `` is the same as described above for ``. For example, the following foo function has three versions. From cb3e69c2ebd3667a3735595966b8dc992a9e654e Mon Sep 17 00:00:00 2001 From: Piyou Chen Date: Sun, 6 Oct 2024 21:23:54 -0700 Subject: [PATCH 15/15] Drop negative symbol from DIGITS --- riscv-c-api.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/riscv-c-api.md b/riscv-c-api.md index 7bad9ec..763ef2b 100644 --- a/riscv-c-api.md +++ b/riscv-c-api.md @@ -313,8 +313,7 @@ ARCH-ATTR := 'arch=' EXTENSIONS PRIORITY-ATTR := 'priority=' DIGITS -DIGITS := '-' [0-9]+ - | [0-9]+ +DIGITS := [0-9]+ EXTENSIONS := ',' |