Is it possible to translate an assembly language to LLVM IR, optimize it and then recompile it to a different architecture?

徘徊边缘 提交于 2019-12-06 19:25:38

问题


Is it possible to translate an assembly language to LLVM IR, optimize it and then recompile it to a different architecture? How would you handle "push"es and "pop"s on the stack in the IR? This is the simplest objection I found, but I'm sure that there're tons like this.

I'm planning to build a dynamic recompiler, and it seems that this would be an excellent solution, since LLVM would automatically optimize my code for the new architecture. Is all this possible with LLVM?

Thanks


回答1:


This is a similar question: Recompile a x86 code with LLVM to some faster one x86

The answer is that LLVM can't do it directly, but could be used as part of a tool that does.




回答2:


It is possible.

But you need to develop some code base the LLVM to implement the process translating the assembly language to LLVM IR. Then the LLVM can help you to optimize and generator for new architecture.

So, the point is you need to develop the translator which can translate the assembly language to LLVM IR. I have seen someone already do that, you can search on the website.



来源:https://stackoverflow.com/questions/8288251/is-it-possible-to-translate-an-assembly-language-to-llvm-ir-optimize-it-and-the

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