[LLVMdev] Nested functions

Vladimir Merzliakov wanderer at rsu.ru
Mon Nov 22 12:21:02 PST 2004


>> I use this method with filtering unused in nested function args and local 
>> vars
>> in my YAFL frontend (not finished :(( - at this moment generate LLVM 
>> bytecode but doesn't have all runtime suport code writed)
>
> So do you mean you pass static links for parent function stack frames as 
> arguments?  How do you generate them?
>
Sorry, I must more careful read text.
I use diff. method.
All definitions in my YAFL parsed program AST have set of references to 
expressions where it used.
All expressions know what function body contain it.
All functions know what function contain it (if nested).

I iterate by nested functions in deep and cache information about used 
declarations from parent function:
args, locals, used grantparent declarations.
Declaration used iff declaration used in code current processed nested 
function or in it nested function bodies
or in it parent(grantparents) nested functions called from (it or it nested 
functions).

Collect this information for non-nested function and all it nested functions
i genereted LLVM code for function and all nested functions adding 
additional args to nested function for used declarations from parent 
function.

Sorry for maybe not clear algorithm but it work for me.

Vladimir





More information about the llvm-dev mailing list