Hello!
Im trying to build a backend for a ‘C’ Frontend.
I have a doubt about Stack allocation for variables. Let me explain with the same example
%p = alloca i32, align 4
store i32 2, i32* %p
%b = load i32* %p, align 4
%c = add nsw i32 %a, %b
will emit following Machine code
%SP = SUBri %SP, 4 ; Prologue
%R1 = MOVLOi16 2
STR %R1, %SP, 0; mem:ST4[%p]
%R0 = ADDri %R0, 2
%SP = ADDri %SP, 4 ; Epilogue
Here, “p” is allocated on a STACK (represented by SP)
My Backend architecture doesnt have a STACK. So,i need to store the variables in general purpose registers. But all the targets i have seen implement a STACK…,and i tried modifying the code in FRAMELOWERING.cpp but there were many errors i cant even keep track of.
My Question is if it is possible to totally eliminate the Stack? Because it seems that FRAMELOWERING.cpp has all methods defined using a stack.
If it is Possible,Please suggest me how. It would be really helpful if you can send some sample codes too.
Thank you,
Avinash