[LLVMdev] Fwd: How to Remove Stack allocation

Avinash Bole boleavinash at gmail.com
Thu Apr 9 00:41:22 PDT 2015


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<def> = SUBri %SP, 4 ; Prologue
%R1<def> = MOVLOi16 2
STR %R1<kill>, %SP, 0; mem:ST4[%p]
%R0<def> = ADDri %R0<kill>, 2
%SP<def> = 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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20150409/ef266c97/attachment.html>


More information about the llvm-dev mailing list