Skip to content

Commit

Permalink
prestaacked annotation can create custom calling conv
Browse files Browse the repository at this point in the history
  • Loading branch information
jnk0le committed Oct 14, 2023
1 parent 5b48c9c commit f741f33
Showing 1 changed file with 13 additions and 7 deletions.
20 changes: 13 additions & 7 deletions riscv-total-embedded.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -611,16 +611,17 @@ Simplified ranges (e.g. shadow register file):

`\\__attribute__\((prestacked("x8-x15")))`

TEIC irq, range0 + shadow regs of half regfile (where bit 2 is set, covers range1+2):
TEIC irq, range0 + shadow regs of half integer regfile (where bit 2 of operand is set, covers range1+2)
and F + P extensions:

`\\__attribute__\((prestacked("x4-x7,x10,x11,x12-x15,x20-x23,x28-x31")))`
`\\__attribute__\((prestacked("x4-x7,x10,x11,x12-x15,x20-x23,x28-x31,fcsr,vxsat")))`

ch32v003 irq (ilp32e + PFIC HW stacker, assuming `ra` doesn't have some undocumented use)

`\\__attribute__\((interrupt, prestacked("x1,x5-x7,x10-x15")))`

NOTE: unannotated `ra` is assumed as a valid return address, otherwise a special return mechanism must be
used
used (e.g. return by `mret` in `\\__attribute__\((interrupt))`

===== optimization for `noreturn` functions

Expand All @@ -645,10 +646,15 @@ and consequently underflow the stack.

===== functions with partially custom calling conventions

can be
for IPRA

It can be additionally abused to:

- define IPRA clobbers of assembly functions in its C function declarations
(see <<applying IPRA to assembly functions>>)
- certain (premature) optimizations (manually solving 2way IPRA recursion etc.)
- dynamic linked functions with a subset of clobbers.
e.g. functions like `memcpy()`,`strcmp()` etc. don't need to clobber all caller saved registers
so only common clobbers for straightforward, unrolled (?) and vectorized implementations need to be
applied. Requires standardization of cannoical clobbers. (quite unrealistic)

==== IPRA - Inter procedural register allocation

Expand Down Expand Up @@ -678,7 +684,7 @@ possible to just move `ra` and `s0/s1` into caller saved regs.

NOTE: This is also non IPRA optimization (-Oz kind)

- need special assembly directive to annotate such exports from pure assembly code (workaround exist
- need special assembly directive to annotate such exports from pure assembly code (workaround exists
<<applying IPRA to assembly functions>>)

[NOTE]
Expand Down

0 comments on commit f741f33

Please sign in to comment.