问题描述
有没有一个简单的方法从llvm ir到工作源代码?
Is there an easy way of going from llvm ir to working source code?
具体来说,我想从一些简单的C ++代码开始修改POD (主要是int,float等数组),将其转换为llvm ir,执行一些简单的分析和翻译,然后将其转换回C ++代码?
Specifically, I'd like to start with some simple C++ code that merely modifies PODs (mainly arrays of ints, floats, etc), convert it to llvm ir, perform some simple analysis and translation on it and then convert it back into C++ code?
真的不介意任何名字被改变,我只是希望能够在做机器依赖的优化之前对源代码进行修改。
It don't really mind about any of the names getting mangled, I'd just like to be able to hack about with the source before doing the machine-dependent optimisations.
推荐答案
这里有一个问题...可能无法轻易地将IR表示为语言。
There is an issue here... it might not be possible to easily represent the IR back into the language.
,您可能可以获得某些 表示,但可能较少可读。
I mean, you'll probably be able to get some representation, but it might be less readable.
是的,IR不关心高级语义,没有它...
The issue is that the IR is not concerned with high-level semantic, and without it...
我宁愿建议你学习阅读IR。我可以读一点它没有这么多的努力,我远不是一个llvm专家。
I'd rather advise you to learn to read the IR. I can read a bit of it without that much effort, and I am far from being a llvm expert.
否则,你可以从C的C代码。它不会更加类似于你的C ++代码,但你可能会觉得更好没有ssa和phi节点。
Otherwise, you can C code from the IR. It won't be much more similar to your C++ code, but you'll perhaps feel better without ssa and phi nodes.
这篇关于llvm回到人类可读的源语言?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!