Generating LLVM code for 'lambda', 'define'

限于喜欢 提交于 2019-12-03 03:47:13

问题


So I now have a fairly complete LISP (scheme) interpreter written in haskell. Just for fun I want to try to have it compile down to LLVM. Most of the code generation seems pretty straight forward, but I'm at a loss as to how to generate code for a lambda expression (kind of important in lisp ;) ) and how to manage the heap when I encounter a define expression.

How might I generated code for these expressions?

Note: I can generate code for the body of the lambda expression, What is confusing me is how to "put" that code somewhere and make it callable.


回答1:


See Lennart's blog post: http://augustss.blogspot.com/2009/06/more-llvm-recently-someone-asked-me-on.html

Look at the compileFunction function. In particular, newFunction in the LLVM core: http://hackage.haskell.org/packages/archive/llvm/0.9.1.2/doc/html/LLVM-Core.html#g:23



来源:https://stackoverflow.com/questions/6360737/generating-llvm-code-for-lambda-define

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!