[llvm-commits] [LLVMdev] [PATCH][RFC] Add llvm.codegen Intrinsic To Support Embedded LLVM IR Code Generation

Yabin Hu yabin.hwu at gmail.com
Fri Apr 27 19:40:32 PDT 2012


Hi LLVMers,

The attached patch adds a new Intrinsic named "llvm.codegen" to support
embedded LLVM IR code generation.  **The 'llvm.codegen' intrinsic uses the
LLVM back ends to generate code for embedded LLVM IR strings. The code
generation target can be same or different to the one of the parent module.


The original motivation inspiring us to add this intrinsic, is to generate
code for heterogeneous platform. A test case in the patch demos this.  In
the test case, on a X86 host, we use this intrinsic to transform an
embedded  LLVM IR into a string of PTX assembly. We can then employ a PTX
 execution engine ( on CUDA Supported GPU) to execute the newly generated
assembly and copy back the result later.


The usage of this intrinsic is not limited to code generation for
heterogeneous platform. It can also help lots of (run-time) optimization
and security problems even when the code generation target is same as the
one of the parent module.


Each call to the intrinsic has two arguments. One is the LLVM IR string.
The other is the name of the target architecture. When running with tools
like llc, lli, etc, this intrinsic transforms the input LLVM IR string  to
a new string of assembly code for the target architecture firstly. Then the
call to the intrinsic is replaced by a pointer to the newly generated
string. After this, we have in our module

** **

We would like to get the community’s feedback on this so as to make sure
this patch is as universally applicable as possible.

Thanks a lot!


best regards,

Yabin Hu
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20120428/a48f97d1/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-Add-llvm.codegen-intrinsic.patch
Type: application/octet-stream
Size: 19664 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20120428/a48f97d1/attachment.obj>


More information about the llvm-commits mailing list