编译器输出语言 - LLVM IR和C [英] Compiler output language - LLVM IR vs C

查看:775
本文介绍了编译器输出语言 - LLVM IR和C的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

对于编写编译器,使用LLVM IR和C作为目标语言的优点和缺点是什么?我知道两个都被使用,我想象最终的机器代码将是类似的,如果我使用clang编译C.那么什么是其他的事情要考虑?

For writing a compiler, what are the advantages and disadvantages of using LLVM IR vs C for a target language? I know both are used, and I imagine that the final machine code would be similar if I were to use clang to compile the C. So what are other things to consider?

推荐答案

我使用LLVM IR为几个编译器后端,并与使用C作为后端的编译器工作。有一件事,我发现给予LLVM IR一个优点是它是打字的。很难做出完全错误的输出,而不会从LLVM库中得到错误。

I've used LLVM IR for a few compiler back ends and have worked with compilers that use C as a back end. One thing that I found that gave the LLVM IR an advantage is that it is typed. It is hard to make completely ill-formed output without getting errors from the LLVM libraries.

这也更容易保持源代码和IR之间的紧密相关调试,在我看来。

It is also easier to keep a close correlation between the source code and the IR for debugging, in my opinion.

此外,你得到所有酷的LLVM命令行工具来分析和处理IR前端发射。

Plus, you get all the cool LLVM command line tools to analyse and process the IR your front end emits.

这篇关于编译器输出语言 - LLVM IR和C的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆