Re: [PATCH v2 2/6] riscv: Deduplicate IRQ stack switching

Sami Tolvanen
2023-08-24T19:03:50Z

Hi Clément,

On Thu, Aug 24, 2023 at 1:12 AM Clément Léger <cleger@rivosinc.com> wrote:
>
> Some defines for stack frame offsets could be added in asm-offsets for
> the offsets:
>
> DEFINE(STACKFRAME_SIZE_ON_STACK, ALIGN(sizeof(struct stackframe),
> STACK_ALIGN));
> OFFSET(STACKFRAME_FP, stackframe, fp);
> OFFSET(STACKFRAME_RA, stackframe, ra);
>
> And you can probably increment the stack at once (saving two addi in
> prologue/epilogue) for both RA and FP and reuse the asm-offsets defines:
>
> addi sp, sp, -STACKFRAME_SIZE_ON_STACK
> REG_S ra, STACKFRAME_RA(sp)
> REG_S s0, STACKFRAME_FP(sp)
> addi s0, sp, STACKFRAME_SIZE_ON_STACK

Thanks for taking a look!

I just copied the existing inline assembly here, but I do agree that
defining stack frame offsets and avoiding the extra addis is a cleaner
approach. I'll change this in v3.

Sami