如何嵌入LLVM汇编语言或内在函数与Clang的C程序? [英] How to embed LLVM assembly or intrinsics in C program with Clang?
问题描述
C编译器可以嵌入汇编code C程序。
C compilers allows to embed assembly code in a C program.
我是pretty确保锵应该允许嵌入LLVM汇编语言或内在code与C程序。我怎么可以嵌入LLVM汇编在C code吗?
I am pretty sure that Clang should allow embedding LLVM assembly or intrinsic code in C program. How can I embed LLVM assembly in C code?
推荐答案
现在你不能。
您可以,但是,分别在自己的文件写的LLVM汇编函数,将其标记为 alwaysinline
,然后用你的其他文件编译它 - 这应该让你相同的结果。请参见如何首先编译C文件IR然后此相关的问题链接在一起的。
You can, however, write an LLVM assembly function separately in its own file, mark it as alwaysinline
, then compile it with the rest of your files - this should get you the same result. See this related question on how to first compile your C files to IR and then link them together.
您甚至可以单独编译文件,并确保执行链接时优化(LTO)的,应该做的同样的事情。
You can even compile the files separately and make sure you perform link-time optimization (LTO), should do the same thing.
这篇关于如何嵌入LLVM汇编语言或内在函数与Clang的C程序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!