I'm trying to make subroutines in ISA, right now, I've managed to do it with a one level stack this way:
v_mov_b32 v1, 128 //do something
s_setpc_b64 s[32:33] //return to caller
s_addc_u32 s33,s33,0 //calculate return address
s_branch @subRoutine //call the subroutine
It's working well, but only with 1 level nesting. I've figured out that using s_movrel or LDS I can make a small stack to expand it.
Then I've found a thing called branch-stack along with the instructions:
s_cbranch_i_fork cond, addr
s_cbranch_join s0 // s0: Saved CSP value.
But it crashed (as expected) since I absolutely don't know what is that 'CSP value'.
If anyone can explain how to use this branch-stack the elegant way, I'd be really thankful.