-
Notifications
You must be signed in to change notification settings - Fork 42
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Prestacked annotation proposal #53
base: main
Are you sure you want to change the base?
Conversation
and a bit of rationale behind auxiliary use cases
it can be used like that, but typically caller saved regs are used first
I found the a similar command line flag in GCC for ARC: As I don't see why we would have different ISRs with different prestacked register lists, I would prefer a command line switch over a function attribute. |
Signed-off-by: jnk0le <[email protected]>
Command line flag does prevent the auxiliary uses as well as e.g. extra shadow registers registers at highest nesting level. |
Do you have a link to an MCU datasheet that describes such an ISR behavior (different register banking behavior on ISR entry based on nesting level)? To avoid copy-paste mistakes and to improve portability you would probably not use the
...and then we already have a global configuration that can be controlled via command line flags (here Also, I'm not convinced that full flexibility for all possible HW stacking schemes is really needed, because I believe that features should be derived from available HW. |
ch32v307 has 8 nesting levels with shadow registers only on the 3 lowest levels (should be on highest IMO) Also c2000 arch has shadow regfile of floating point registers designated for HPIs, but being a typical CISC, it switches it by separate instructions, emmited by compiler interrupt (HPI) attribute. Even though those could be switched automatically. Also many other archs (like ARM32 FIQ/IRQ and clones) that are stabilised by compiler attributes and central governance.
I think that the vendors could provide those definitions in device specific headers e.g.
Those will bind any given core to the ABI it was designed for. (i.e. there could appear an IPRA optimized ABI, or just getting rid of Also, note that the shadow registers (and decoding them) are quite expensive and typical DSP code doesn't need that many registers (3p3z irq is like ~6-7 regs total (gcc compiled)). So vendors are likely to seek for balance. |
+1 for unified attribute for modeling that, I am tired to maintain Also I would prefer using attribute over command line since some low level run time stuffs may support different HW platform, typically that will support different platform in different files
|
So they have three sets of shadow registers for caller-saved registers.
Afaik ARM7 has shadow registers, but only one set of them (per exception type).
"there could appear" -> does not exist |
Is there a way to avoid this? In there we have:
I would claim that the ISR HW-ABI would fit there as well. The reason, why I don't like function attributes is, that they have be set for each ISR, although there is no evidence that we need two ISRs with different attributes. And this could lead again to subtle issues (resulting in forum questions with responses like "check if all your ISRs have the correct function attributes set"). |
Main issue with CLIC is that in addition to Nothing can be done about it.
I don't quite understand, WCH PFIC similarly to NVIC (which appears more frequently in their headers than "PFIC" BTW) allows to configure any numbers of (vectored) handlers to any available nesting level. So if SPI and I2C handlers are configured to 3rd nesting level, TIM3 and TIM4 are configured at 4th nesting level, the attributes look like this:
PIC32 should have more sets (cover all GPRs, amount is implementation specific)
I think that the vendors don't want to find themselves in WCH situation with a new stacker or shadow regs. Also adding to compiler alias lists means:
|
The preserving (like in ARM FIQ) shadow registers can be also shared by software |
I have a different understanding of that mechanism.
The HPE mechanism supports to interrupt up to three interrupts until it runs out of shadow registers. So in your example TIM3 and TIM4 can use the same prestacked/HPE attribute. So in your example you would use preventive SW-stacking for IRQs with high priorities. Better solutions would be:
PIC32 defines After seeing this, I'm fine with the function attribute approach.
I don't know the backstory of the WCH situation. That said, my concerns are properly addressed and I'm fine with this PR. |
compilers must not error out or break code, but can ignore the potential optimization of recycling unmodified arg regs
this attribute has been implemented as `interrupt("SiFive-CLIC-preemptible")` Should be renamed into "CLIC-preemptible" after freeze complets
Also, the CLIC has already been extended with hardware stacking. [1] https://arxiv.org/pdf/2311.08320 |
Corner case for "IPRA" alt usage: annotation doesn't cover stack passed arguments, which are caller saved (documented on arm and defacto on risc-v) |
for further rationale see: https://discourse.llvm.org/t/rfc-prestacked-annotation-to-solve-risc-v-interrupt-stacking-mess/74120