生成'lambda','define'的LLVM代码, [英] Generating LLVM code for 'lambda', 'define'
问题描述
所以我现在有一个相当完整的LISP(计划)解释器写在haskell。只是为了好玩,我想尝试把它编译到LLVM。大多数代码生成看起来很直接,但我不知道如何生成 lambda
表达式(在lisp中很重要)的代码)和当我遇到 define
表达式时,如何管理堆。
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?
注意:我可以为lambda表达式的主体生成代码,令人困惑的是如何将该代码放置某处,使其可调。
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.
推荐答案
请参阅Lennart的博客文章: http://augustss.blogspot.com/2009/06/more-llvm-recently-someone-asked-me-on.html
See Lennart's blog post: http://augustss.blogspot.com/2009/06/more-llvm-recently-someone-asked-me-on.html
查看 compileFunction
函数。特别是,在LLVM核心中的 newFunction
:http://hackage.haskell.org/packages/archive/llvm/0.9.1.2/doc/html/LLVM-Core.html#g:23
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
这篇关于生成'lambda','define'的LLVM代码,的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!