From ce61606e03e9274b3fd104ae0ebb588795915498 Mon Sep 17 00:00:00 2001 From: jnk0le Date: Fri, 27 Oct 2023 23:08:05 +0200 Subject: [PATCH 01/19] mark prestacked incopatibilities --- riscv-c-api.md | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/riscv-c-api.md b/riscv-c-api.md index 0103dce..2d80f9e 100644 --- a/riscv-c-api.md +++ b/riscv-c-api.md @@ -183,7 +183,7 @@ The compiler won't generate the prologue/epilogue for those functions with `naked` attributes. This attribute is usually used when you want to write a function with an inline assembly body. -This attribute is incompatible with the `interrupt` attribute. +This attribute is incompatible with the `interrupt` and `prestacked` attribute. NOTE: Be aware that compilers might have further restrictions on naked functions. Please consult your compiler's manual for more information. @@ -204,6 +204,10 @@ function declares more than one mode or an undefined mode. This attribute is incompatible with the `naked` attribute. +### `__attribute__((prestacked(""))` + +This attribute is incompatible with the `naked` attribute. + ## Intrinsic Functions Intrinsic functions (or intrinsics or built-ins) are expanded into instruction sequences by compilers. From 1072a44f9feab40686d1d483c5027be361ea5ade Mon Sep 17 00:00:00 2001 From: jnk0le Date: Sat, 28 Oct 2023 00:55:58 +0200 Subject: [PATCH 02/19] add usage examples for prestacked attribute --- riscv-c-api.md | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/riscv-c-api.md b/riscv-c-api.md index 2d80f9e..62d21a0 100644 --- a/riscv-c-api.md +++ b/riscv-c-api.md @@ -208,6 +208,24 @@ This attribute is incompatible with the `naked` attribute. This attribute is incompatible with the `naked` attribute. +#### usage examples + +psABI with F extension, caller saved: +`__attribute__((prestacked("x5-x7,x10-x17,x28-x31,f0-f7,f10-f17,f28-f31,fcsr")))` + +optimization for `noreturn` functions (psABI with F extension): +`__attribute__((noreturn, prestacked("x1,x5-x31,f0-f31,fcsr")))` + +standard risc-v irq, ilp32e, caller saved and `ra`: +`__attribute__((interrupt, prestacked("x1,x5-x7,x10-x15")))` + +standard risc-v irq with simplified range (e.g. shadow register file): +`__attribute__((interrupt, prestacked("x8-x15")))` + +custom irq controller, F + P extensions (`ra`,`a0`,`a1` pushed on stack, shadow registers +where bit 2 of register operand is set): +`__attribute__((prestacked("x4-x7,x10,x11,x12-x15,x20-x23,x28-x31,fcsr,vxsat")))` + ## Intrinsic Functions Intrinsic functions (or intrinsics or built-ins) are expanded into instruction sequences by compilers. From d80c59d96f46808de28a76e0f86b87f9a5ef4d36 Mon Sep 17 00:00:00 2001 From: jnk0le Date: Sat, 28 Oct 2023 00:57:37 +0200 Subject: [PATCH 03/19] use markdown newlines --- 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 62d21a0..5b1f7de 100644 --- a/riscv-c-api.md +++ b/riscv-c-api.md @@ -210,20 +210,20 @@ This attribute is incompatible with the `naked` attribute. #### usage examples -psABI with F extension, caller saved: +psABI with F extension, caller saved:\ `__attribute__((prestacked("x5-x7,x10-x17,x28-x31,f0-f7,f10-f17,f28-f31,fcsr")))` -optimization for `noreturn` functions (psABI with F extension): +optimization for `noreturn` functions (psABI with F extension):\ `__attribute__((noreturn, prestacked("x1,x5-x31,f0-f31,fcsr")))` -standard risc-v irq, ilp32e, caller saved and `ra`: +standard risc-v irq, ilp32e, caller saved and `ra`:\ `__attribute__((interrupt, prestacked("x1,x5-x7,x10-x15")))` -standard risc-v irq with simplified range (e.g. shadow register file): +standard risc-v irq with simplified range (e.g. shadow register file):\ `__attribute__((interrupt, prestacked("x8-x15")))` custom irq controller, F + P extensions (`ra`,`a0`,`a1` pushed on stack, shadow registers -where bit 2 of register operand is set): +where bit 2 of register operand is set):\ `__attribute__((prestacked("x4-x7,x10,x11,x12-x15,x20-x23,x28-x31,fcsr,vxsat")))` ## Intrinsic Functions From 8a6e1067909521e9a83176a3fbb942be4a31463a Mon Sep 17 00:00:00 2001 From: jnk0le Date: Sun, 29 Oct 2023 01:23:12 +0200 Subject: [PATCH 04/19] added descripion of prestacked annotation --- riscv-c-api.md | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/riscv-c-api.md b/riscv-c-api.md index 5b1f7de..163ea03 100644 --- a/riscv-c-api.md +++ b/riscv-c-api.md @@ -206,6 +206,36 @@ This attribute is incompatible with the `naked` attribute. ### `__attribute__((prestacked(""))` +The prestacked attribute instructs the compiler which registers can be +used without saving/restoring them. It enables efficient use of +custom interrupt controllers that stack some of the architectural registers. +Without the need for compiler builds with a custom attributes. + +If used together with `interrupt` attribute, `prestacked` annotation overrides +its register preservation functionality. + +`` is a string literal, listing all registers available for use +in a given function, with a following syntax rules: + +- no whitespaces +- raw register names rather than ABI mnemonics +- register range cover all registers between and including specified ("x4-x6" +is equivalent to "x4,x5,x6") +- registers/ranges are separated by comma +- annotated callee saved registers have to be properly handled as a temporary ones +- CSRs taking part in calling conventions are also subject to this mechanism +- registers must be sorted (integer, floating point, vector, custom, then by +lowest numbered) +- CSRs must be put after the architectural regfiles, those don’t have to be sorted +- shall not imply `interrupt` attribute + +NOTE: strict syntax rules allow better portability across compilers and ABIs. + +Annotated functions should be callable by regular code, to support auxiliary purposes + +NOTE: if `x1` (aka `ra`) is included in the list then a special return +mechanism must be used (e.g. `mret` from `interrupt` attribute) + This attribute is incompatible with the `naked` attribute. #### usage examples From 8ac4f1ce0015b1fcc526b266b5253e83ea84880a Mon Sep 17 00:00:00 2001 From: jnk0le Date: Sun, 29 Oct 2023 02:16:31 +0200 Subject: [PATCH 05/19] additional prestacked use case example and a bit of rationale behind auxiliary use cases --- riscv-c-api.md | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/riscv-c-api.md b/riscv-c-api.md index 163ea03..7f71afa 100644 --- a/riscv-c-api.md +++ b/riscv-c-api.md @@ -229,11 +229,11 @@ lowest numbered) - CSRs must be put after the architectural regfiles, those don’t have to be sorted - shall not imply `interrupt` attribute -NOTE: strict syntax rules allow better portability across compilers and ABIs. +NOTE: Strict syntax rules allow better portability across compilers and ABIs. -Annotated functions should be callable by regular code, to support auxiliary purposes +To support auxiliary purposes, annotated functions should be callable by regular code. -NOTE: if `x1` (aka `ra`) is included in the list then a special return +NOTE: If `x1` (aka `ra`) is included in the list then a special return mechanism must be used (e.g. `mret` from `interrupt` attribute) This attribute is incompatible with the `naked` attribute. @@ -243,9 +243,6 @@ This attribute is incompatible with the `naked` attribute. psABI with F extension, caller saved:\ `__attribute__((prestacked("x5-x7,x10-x17,x28-x31,f0-f7,f10-f17,f28-f31,fcsr")))` -optimization for `noreturn` functions (psABI with F extension):\ -`__attribute__((noreturn, prestacked("x1,x5-x31,f0-f31,fcsr")))` - standard risc-v irq, ilp32e, caller saved and `ra`:\ `__attribute__((interrupt, prestacked("x1,x5-x7,x10-x15")))` @@ -256,6 +253,20 @@ custom irq controller, F + P extensions (`ra`,`a0`,`a1` pushed on stack, shadow where bit 2 of register operand is set):\ `__attribute__((prestacked("x4-x7,x10,x11,x12-x15,x20-x23,x28-x31,fcsr,vxsat")))` +optimization for `noreturn` functions (psABI with F extension):\ +`__attribute__((noreturn, prestacked("x1,x5-x31,f0-f31,fcsr")))` + +NOTE: Compilers are intentionally preserving full prologues, of `noreturn` functions, to +allow backtracing and throwing exceptions. Which leads to stack and codespace +bloating. Prestacked annotation can be abused to get rid of the prologues stacking +without the risk of underflowing the stack as would happen with `naked` attribute. + +pure assembly function (FP compute kernel) using only subset of caller saved +registers (`a0` argument not modified during execution):\ +`__attribute__((prestacked("x5,x11-x15,f8-f11,v0,v1,v8-v31,fcsr,vl,vtype,vstart")))` + +NOTE: This use case is necessary for efficient IPRA compilations. Beneficial even without IPRA. + ## Intrinsic Functions Intrinsic functions (or intrinsics or built-ins) are expanded into instruction sequences by compilers. From 0a07aa2d5db8a6828c3bd08bf0224bc79c90a668 Mon Sep 17 00:00:00 2001 From: jnk0le Date: Sun, 29 Oct 2023 02:19:33 +0200 Subject: [PATCH 06/19] use markdown note blocks instead of adoc ones --- 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 7f71afa..01b66c0 100644 --- a/riscv-c-api.md +++ b/riscv-c-api.md @@ -256,7 +256,7 @@ where bit 2 of register operand is set):\ optimization for `noreturn` functions (psABI with F extension):\ `__attribute__((noreturn, prestacked("x1,x5-x31,f0-f31,fcsr")))` -NOTE: Compilers are intentionally preserving full prologues, of `noreturn` functions, to +> **_NOTE:_** Compilers are intentionally preserving full prologues, of `noreturn` functions, to allow backtracing and throwing exceptions. Which leads to stack and codespace bloating. Prestacked annotation can be abused to get rid of the prologues stacking without the risk of underflowing the stack as would happen with `naked` attribute. @@ -265,7 +265,7 @@ pure assembly function (FP compute kernel) using only subset of caller saved registers (`a0` argument not modified during execution):\ `__attribute__((prestacked("x5,x11-x15,f8-f11,v0,v1,v8-v31,fcsr,vl,vtype,vstart")))` -NOTE: This use case is necessary for efficient IPRA compilations. Beneficial even without IPRA. +> **_NOTE:_** This use case is necessary for efficient IPRA compilations. Beneficial even without IPRA. ## Intrinsic Functions From 814056e9ad08506c931eed4fb33b1e25bb90e18e Mon Sep 17 00:00:00 2001 From: jnk0le Date: Sun, 29 Oct 2023 02:20:59 +0200 Subject: [PATCH 07/19] use markdown note blocks for all notes --- 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 01b66c0..ed03d47 100644 --- a/riscv-c-api.md +++ b/riscv-c-api.md @@ -229,11 +229,11 @@ lowest numbered) - CSRs must be put after the architectural regfiles, those don’t have to be sorted - shall not imply `interrupt` attribute -NOTE: Strict syntax rules allow better portability across compilers and ABIs. +> **_NOTE:_** Strict syntax rules allow better portability across compilers and ABIs. To support auxiliary purposes, annotated functions should be callable by regular code. -NOTE: If `x1` (aka `ra`) is included in the list then a special return +> **_NOTE:_** If `x1` (aka `ra`) is included in the list then a special return mechanism must be used (e.g. `mret` from `interrupt` attribute) This attribute is incompatible with the `naked` attribute. From 964e69c3f47ce56ec282d01cdb8e0197886d0e5f Mon Sep 17 00:00:00 2001 From: jnk0le Date: Sun, 29 Oct 2023 02:21:47 +0200 Subject: [PATCH 08/19] typo --- 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 ed03d47..edb705c 100644 --- a/riscv-c-api.md +++ b/riscv-c-api.md @@ -233,7 +233,7 @@ lowest numbered) To support auxiliary purposes, annotated functions should be callable by regular code. -> **_NOTE:_** If `x1` (aka `ra`) is included in the list then a special return +> **_NOTE:_** If `x1` (aka `ra`) is included in the list, then a special return mechanism must be used (e.g. `mret` from `interrupt` attribute) This attribute is incompatible with the `naked` attribute. From 11506f6d06cd284fa499cedb7e3ab510f1f14cdf Mon Sep 17 00:00:00 2001 From: jnk0le Date: Sun, 29 Oct 2023 02:27:37 +0200 Subject: [PATCH 09/19] correct the fp range as f8/9 is fs0/1 it can be used like that, but typically caller saved regs are used first --- 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 edb705c..3b20dc2 100644 --- a/riscv-c-api.md +++ b/riscv-c-api.md @@ -263,7 +263,7 @@ without the risk of underflowing the stack as would happen with `naked` attribut pure assembly function (FP compute kernel) using only subset of caller saved registers (`a0` argument not modified during execution):\ -`__attribute__((prestacked("x5,x11-x15,f8-f11,v0,v1,v8-v31,fcsr,vl,vtype,vstart")))` +`__attribute__((prestacked("x5,x11-x15,f10-f13,v0,v1,v8-v31,fcsr,vl,vtype,vstart")))` > **_NOTE:_** This use case is necessary for efficient IPRA compilations. Beneficial even without IPRA. From dca1cd965d10b2fa000d7e52f6ecef172604e487 Mon Sep 17 00:00:00 2001 From: jnk0le Date: Sun, 29 Oct 2023 02:48:36 +0200 Subject: [PATCH 10/19] typo --- 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 3b20dc2..3be4cac 100644 --- a/riscv-c-api.md +++ b/riscv-c-api.md @@ -258,7 +258,7 @@ optimization for `noreturn` functions (psABI with F extension):\ > **_NOTE:_** Compilers are intentionally preserving full prologues, of `noreturn` functions, to allow backtracing and throwing exceptions. Which leads to stack and codespace -bloating. Prestacked annotation can be abused to get rid of the prologues stacking +bloating. Prestacked annotation can be abused to get rid of the prologue stacking without the risk of underflowing the stack as would happen with `naked` attribute. pure assembly function (FP compute kernel) using only subset of caller saved From 31246ba4be99ad3db0de71ef82c2b14c5fac0e47 Mon Sep 17 00:00:00 2001 From: jnk0le Date: Wed, 1 Nov 2023 00:20:55 +0100 Subject: [PATCH 11/19] use ilp32 instead of psABI --- 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 3be4cac..59db44e 100644 --- a/riscv-c-api.md +++ b/riscv-c-api.md @@ -240,7 +240,7 @@ This attribute is incompatible with the `naked` attribute. #### usage examples -psABI with F extension, caller saved:\ +ilp32 with F extension, caller saved:\ `__attribute__((prestacked("x5-x7,x10-x17,x28-x31,f0-f7,f10-f17,f28-f31,fcsr")))` standard risc-v irq, ilp32e, caller saved and `ra`:\ @@ -253,7 +253,7 @@ custom irq controller, F + P extensions (`ra`,`a0`,`a1` pushed on stack, shadow where bit 2 of register operand is set):\ `__attribute__((prestacked("x4-x7,x10,x11,x12-x15,x20-x23,x28-x31,fcsr,vxsat")))` -optimization for `noreturn` functions (psABI with F extension):\ +optimization for `noreturn` functions (ilp32 with F extension):\ `__attribute__((noreturn, prestacked("x1,x5-x31,f0-f31,fcsr")))` > **_NOTE:_** Compilers are intentionally preserving full prologues, of `noreturn` functions, to From 7fea87e1db38bec9e112131928953cf012933289 Mon Sep 17 00:00:00 2001 From: jnk0le Date: Thu, 2 Nov 2023 19:09:18 +0100 Subject: [PATCH 12/19] ilp32f covers F extension --- 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 59db44e..6313c53 100644 --- a/riscv-c-api.md +++ b/riscv-c-api.md @@ -240,7 +240,7 @@ This attribute is incompatible with the `naked` attribute. #### usage examples -ilp32 with F extension, caller saved:\ +ilp32f, caller saved:\ `__attribute__((prestacked("x5-x7,x10-x17,x28-x31,f0-f7,f10-f17,f28-f31,fcsr")))` standard risc-v irq, ilp32e, caller saved and `ra`:\ From a90dc72737e90aa40eb560c99aba759664cd4f4d Mon Sep 17 00:00:00 2001 From: jnk0le Date: Wed, 8 Nov 2023 02:34:55 +0100 Subject: [PATCH 13/19] ilp32 with F is ilp32f --- 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 fd29055..0914e1f 100644 --- a/riscv-c-api.md +++ b/riscv-c-api.md @@ -253,7 +253,7 @@ custom irq controller, F + P extensions (`ra`,`a0`,`a1` pushed on stack, shadow where bit 2 of register operand is set):\ `__attribute__((prestacked("x4-x7,x10,x11,x12-x15,x20-x23,x28-x31,fcsr,vxsat")))` -optimization for `noreturn` functions (ilp32 with F extension):\ +optimization for `noreturn` functions (ilp32f):\ `__attribute__((noreturn, prestacked("x1,x5-x31,f0-f31,fcsr")))` > **_NOTE:_** Compilers are intentionally preserving full prologues, of `noreturn` functions, to From eaeaadc77a65aaf9ed955e5c3fd136e2850c6d48 Mon Sep 17 00:00:00 2001 From: jnk0le Date: Mon, 29 Apr 2024 01:14:18 +0200 Subject: [PATCH 14/19] move non syntax rule to more appropriate place --- 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 0914e1f..d02e937 100644 --- a/riscv-c-api.md +++ b/riscv-c-api.md @@ -211,6 +211,7 @@ used without saving/restoring them. It enables efficient use of custom interrupt controllers that stack some of the architectural registers. Without the need for compiler builds with a custom attributes. +It shall not imply `interrupt` attribute. If used together with `interrupt` attribute, `prestacked` annotation overrides its register preservation functionality. @@ -227,7 +228,6 @@ is equivalent to "x4,x5,x6") - registers must be sorted (integer, floating point, vector, custom, then by lowest numbered) - CSRs must be put after the architectural regfiles, those don’t have to be sorted -- shall not imply `interrupt` attribute > **_NOTE:_** Strict syntax rules allow better portability across compilers and ABIs. From 11e1ab6ca915c1d19b9e2a4d48a0978f29fa3231 Mon Sep 17 00:00:00 2001 From: jnk0le Date: Mon, 29 Apr 2024 01:20:12 +0200 Subject: [PATCH 15/19] additional rule to forbid register ranges redundant to regular specifiers --- riscv-c-api.md | 1 + 1 file changed, 1 insertion(+) diff --git a/riscv-c-api.md b/riscv-c-api.md index d02e937..e530ce2 100644 --- a/riscv-c-api.md +++ b/riscv-c-api.md @@ -222,6 +222,7 @@ in a given function, with a following syntax rules: - raw register names rather than ABI mnemonics - register range cover all registers between and including specified ("x4-x6" is equivalent to "x4,x5,x6") +- register range must span at least 3 consecutive registers - registers/ranges are separated by comma - annotated callee saved registers have to be properly handled as a temporary ones - CSRs taking part in calling conventions are also subject to this mechanism From 18635f6da0b8ad8a680ff5b5e962d48d7eb76747 Mon Sep 17 00:00:00 2001 From: jnk0le Date: Mon, 29 Apr 2024 01:37:52 +0200 Subject: [PATCH 16/19] additional rule for unannotated arguments compilers must not error out or break code, but can ignore the potential optimization of recycling unmodified arg regs --- riscv-c-api.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/riscv-c-api.md b/riscv-c-api.md index e530ce2..de81200 100644 --- a/riscv-c-api.md +++ b/riscv-c-api.md @@ -229,6 +229,8 @@ is equivalent to "x4,x5,x6") - registers must be sorted (integer, floating point, vector, custom, then by lowest numbered) - CSRs must be put after the architectural regfiles, those don’t have to be sorted +- argument registers that are passed but not included in the list, can be assumed +to be unmodified after return from an annotated function > **_NOTE:_** Strict syntax rules allow better portability across compilers and ABIs. @@ -263,7 +265,7 @@ bloating. Prestacked annotation can be abused to get rid of the prologue stackin without the risk of underflowing the stack as would happen with `naked` attribute. pure assembly function (FP compute kernel) using only subset of caller saved -registers (`a0` argument not modified during execution):\ +registers (`a0` argument not modified):\ `__attribute__((prestacked("x5,x11-x15,f10-f13,v0,v1,v8-v31,fcsr,vl,vtype,vstart")))` > **_NOTE:_** This use case is necessary for efficient IPRA compilations. Beneficial even without IPRA. From 374bed8b5d3afea8d5838979d9b0239fa4f4dcc7 Mon Sep 17 00:00:00 2001 From: jnk0le Date: Mon, 29 Apr 2024 01:38:48 +0200 Subject: [PATCH 17/19] reshuffle to maintain logical order --- 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 de81200..7bccc17 100644 --- a/riscv-c-api.md +++ b/riscv-c-api.md @@ -215,6 +215,11 @@ It shall not imply `interrupt` attribute. If used together with `interrupt` attribute, `prestacked` annotation overrides its register preservation functionality. +To support auxiliary purposes, annotated functions should be callable by regular code. + +> **_NOTE:_** If `x1` (aka `ra`) is included in the list, then a special return +mechanism must be used (e.g. `mret` from `interrupt` attribute) + `` is a string literal, listing all registers available for use in a given function, with a following syntax rules: @@ -234,11 +239,6 @@ to be unmodified after return from an annotated function > **_NOTE:_** Strict syntax rules allow better portability across compilers and ABIs. -To support auxiliary purposes, annotated functions should be callable by regular code. - -> **_NOTE:_** If `x1` (aka `ra`) is included in the list, then a special return -mechanism must be used (e.g. `mret` from `interrupt` attribute) - This attribute is incompatible with the `naked` attribute. #### usage examples From d64a143e1c739090a8e6f3b6d3686a3723241a82 Mon Sep 17 00:00:00 2001 From: jnk0le Date: Mon, 29 Apr 2024 02:07:16 +0200 Subject: [PATCH 18/19] turn one of the sample irq's into CLIC this attribute has been implemented as `interrupt("SiFive-CLIC-preemptible")` Should be renamed into "CLIC-preemptible" after freeze complets --- 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 7bccc17..86e17bf 100644 --- a/riscv-c-api.md +++ b/riscv-c-api.md @@ -249,8 +249,8 @@ ilp32f, caller saved:\ standard risc-v irq, ilp32e, caller saved and `ra`:\ `__attribute__((interrupt, prestacked("x1,x5-x7,x10-x15")))` -standard risc-v irq with simplified range (e.g. shadow register file):\ -`__attribute__((interrupt, prestacked("x8-x15")))` +preemptible CLIC irq with simplified range (e.g. shadow register file):\ +`__attribute__((interrupt("CLIC-preemptible"), prestacked("x8-x15")))` custom irq controller, F + P extensions (`ra`,`a0`,`a1` pushed on stack, shadow registers where bit 2 of register operand is set):\ From f65b82c38f942566df118c33150a5e32c14b6b12 Mon Sep 17 00:00:00 2001 From: jnk0le Date: Sat, 8 Jun 2024 15:41:40 +0200 Subject: [PATCH 19/19] it's the job of caller to preserve callee saved registers when annotated --- 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 86e17bf..c890fff 100644 --- a/riscv-c-api.md +++ b/riscv-c-api.md @@ -229,7 +229,7 @@ in a given function, with a following syntax rules: is equivalent to "x4,x5,x6") - register range must span at least 3 consecutive registers - registers/ranges are separated by comma -- annotated callee saved registers have to be properly handled as a temporary ones +- annotated callee saved registers have to be properly handled as a temporary ones by caller - CSRs taking part in calling conventions are also subject to this mechanism - registers must be sorted (integer, floating point, vector, custom, then by lowest numbered)