[cfe-dev] stack-less model on small devices
Alireza.Moshtaghi at microchip.com
Alireza.Moshtaghi at microchip.com
Wed Apr 23 12:21:24 PDT 2008
Hi
I am using clang/llvm to implement a c compiler for an 8-bit
microprocessor. I apologize for the lengthy email, but I think it is
necessary to give a background of what I'm doing and then ask my
questions.
Stack operations are not practical on this device because the memory is
composed of small pieces that are not contiguous in address space. So we
have to sacrifice recursion and play some tricks in llvm to implement
things like reentrancy, function pointers, varargs, etc.
At a high level:
1) Function frames are statically allocated at link time and they
contain the local variables, input arguments, return address, etc.
2) Auto variables behave like static local variables except for
initialization (which must take place in the function preamble)
3) Parameters behave like local variables except for initialization
(which must take place in the caller)
4) Global and Static local variables behave no different than standard c
Accordingly, I need to modify the front-end to generate the llvm-bitcode
such that correct storage class/name-mangles are selected for variables.
I modified CGDecl.cpp in the two functions below and so far everything
works fine:
CodeGenFunction::EmitParmDecl() {same as in EmitStaticBlockVarDecl();
except for initialization; also mangle the name differently}
CodeGenFunction::EmitLocalBlockVarDecl() {same as
EmitStaticBlockVarDecl(); except generate the initialization code; also
mangle the name differently}
Questions:
1) Do I need to do any special housekeeping? Or the above modifications
are enough?
2) These modifications are in contrast with most microprocessors but are
useful for many small devices (including the one I am working on), how
should I go about incorporating these changes in the clang code base?
3) How can I acquire access privilege to be able to checkin to the clang
code base?
Thanks
Ali.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20080423/3c56023a/attachment.html>
More information about the cfe-dev
mailing list