github.com/tinygo-org/tinygo@v0.31.3-0.20240404173401-90b0bf646c27/src/runtime/asm_riscv.S (about) 1 #if __riscv_xlen==64 2 #define REGSIZE 8 3 #define SREG sd 4 #define LREG ld 5 #else 6 #define REGSIZE 4 7 #define SREG sw 8 #define LREG lw 9 #endif 10 11 .section .text.tinygo_scanCurrentStack 12 .global tinygo_scanCurrentStack 13 .type tinygo_scanCurrentStack, %function 14 tinygo_scanCurrentStack: 15 // Push callee-saved registers onto the stack. 16 addi sp, sp, -13*REGSIZE 17 SREG ra, 0*REGSIZE(sp) 18 SREG s11, 1*REGSIZE(sp) 19 SREG s10, 2*REGSIZE(sp) 20 SREG s9, 3*REGSIZE(sp) 21 SREG s8, 4*REGSIZE(sp) 22 SREG s7, 5*REGSIZE(sp) 23 SREG s6, 6*REGSIZE(sp) 24 SREG s5, 7*REGSIZE(sp) 25 SREG s4, 8*REGSIZE(sp) 26 SREG s3, 9*REGSIZE(sp) 27 SREG s2, 10*REGSIZE(sp) 28 SREG s1, 11*REGSIZE(sp) 29 SREG s0, 12*REGSIZE(sp) 30 31 // Scan the stack. 32 mv a0, sp 33 call tinygo_scanstack 34 35 // Restore return address. 36 LREG ra, 0(sp) 37 38 // Restore stack state. 39 addi sp, sp, 13*REGSIZE 40 41 // Return to the caller. 42 ret 43 44 45 .section .text.tinygo_longjmp 46 .global tinygo_longjmp 47 tinygo_longjmp: 48 // Note: the code we jump to assumes a0 is non-zero, which is already the 49 // case because that's the defer frame pointer. 50 lw sp, 0(a0) // jumpSP 51 lw a1, REGSIZE(a0) // jumpPC 52 jr a1