Implement LLVM Intrinsics in C/LLVM IR

Hello,

I am basically working on a static analysis project on LLVM IR, and the problem is that I will need to simulate the execution of a few LLVM Intrinsic, such as llvm.bswap.i160, and llvm.ctlz.i256.

I am wondering if there has been some already implemented sample code, regarding these intrinsics? Either C or LLVM IR. Thanks a lot!

Best,

Of course, in this sense they are not platform-dependent. I just want to write a semantics-correct version of such intrinsics and let my static analyzer goes smoothly.

Have you looked at these?

https://llvm.org/docs/LangRef.html

https://llvm.org/docs/ExtendingLLVM.html

Thank you Ryan. Yes, I am aware of them. Just wondering whether there exists a already implemented version of those intrinsics.

So basically I am analyzing a program of LLVM IR with a static analysis tool. And since that tool cannot figure out the meaning of the intrinsics (e.g., llvm.bswap.i256), I will need to “manually” add a function implementation of such intrinsic and let it calls my function. Am I missed something?

Best,

Did you look into http://llvm.org/doxygen/IntrinsicLowering_8h_source.html ?