[cfe-dev] Clang for source level loop transformation

Zheng Wang jason.wangz at gmail.com
Wed Apr 6 07:05:01 PDT 2011


Hello,

I would like to use clang  to build a source level tool that generates
OpenCL code.

Basically, the idea is that given an annotation of a loop, the tool can
convert the loop to an OpenCL kernel.

For example, a C program with an pragma annotation will look like:

#pragma opencl parallel for private(v1, v2)
for (...)
{
   ...
}

and the tool will read the source code in, parse the source and generate an
OpenCL kernel as a C-like program.

I am wondering whether the CLANG AST can keep information about the loop,
such as the loop index, the loop boundary, and statements of the loop body?

I don't know whether I need to go into the LLVM bitcode level to retrieve
such information. However, I generally don't want to go to such a low level.

If anyone can point out whether there is an example that I can refer to, it
will be fantastic.

Thanks!

Cheers,
Zheng
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20110406/2fc58d2b/attachment.html>


More information about the cfe-dev mailing list