LLVM 本机代码生成
如何使用llvm生成本机代码?
如果可能的话,可以使用 Haskell 绑定来完成吗?
upd:我的意思是生成不在内存中的代码,我的意思是如何生成代码,例如将其保存到文件中。
How is native code generated using llvm?
If it is possible, can it be done using a Haskell binding?
upd: I mean generate code not in memory, I mean how to generate code and for example save it to file.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
LLVM 是一种编译器基础设施,通过处理其内部语言(由编译器作为文本源或内存中生成)来生成本机代码表示——在将其转换并链接到最终的本机代码之前,通过各种优化和转换。所以,是的,LLVM 可以生成本机代码;事实上,这就是它的主要目的。
Haskell 有一个绑定到 LLVM 库。您可以使用
writeBitcodeToFile< 生成 LLVM 位码文件/代码>
;然后,
llvm-ld
可以将它们链接到本机代码中。LLVM is a compiler infrastructure that generates native code by processing its internal language — produced by compilers as textual source or an in-memory representation — through a wide variety of optimisations and transformations before converting and linking it into the final native code. So, yes, LLVM can generate native code; in fact, that's its primary purpose.
There is a binding to the LLVM library for Haskell. You can produce LLVM bitcode files with
writeBitcodeToFile
;llvm-ld
can then link those into native code.