How to embed LLVM assembly or intrinsics in C prog

2019-01-23 16:40发布

C compilers allows to embed assembly code in a C program.

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?

1条回答
Fickle 薄情
2楼-- · 2019-01-23 17:08

Right now you can't.

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.

You can even compile the files separately and make sure you perform link-time optimization (LTO), should do the same thing.

查看更多
登录 后发表回答