[LLVMdev] Support for per-loop pragma
jgu222 at gmail.com
Tue Jun 1 17:42:01 PDT 2010
I'd like to add a pragma support in llvm. I am thinking about using a
llvm intrinsic to represent each pragma, such as
llvm.pragma (metadata, ...)
where metadata describes a pragma. So if an application has:
#pragma p1 ..
The llvm IR would be
llvm.pragma (metadata..) // for p1
llvm.pragma (metadata..) // for p2
llvm IR for "for (...)"
In this way, the pragma handling is quite general (for example, it can
be used to support frequency hint for a branch, etc).
And it should be easy for any frontend to generate.
A possible issue might be that optimizations might make the
association between pragmas and their loops (in this case)
Any suggestions/ideas ?
On Wed, May 19, 2010 at 4:31 PM, Junjie Gu <jgu222 at gmail.com> wrote:
> Hi Chris,
> Thanks. I will see what I can do for this.
> On Wed, May 19, 2010 at 3:45 PM, Chris Lattner <clattner at apple.com> wrote:
>> On May 19, 2010, at 2:38 PM, Junjie Gu wrote:
>>> Many compilers support per-loop pragma, such as loop unrolling (ie
>>> #pragma unroll=2). Is there any LLVM project/effort going on
>>> in this area ? What is the expected way for implementing per-loop
>>> pragma, or general pragma ? Suggestions/comments ?
>> Hi Junjie,
>> I don't know of anyone working on it, but it seems like a natural application of the metadata support in mainline:
>> We'd want to tag something, perhaps the backedge branches with metadata, then have the loop canonicalization passes preserve them.
More information about the llvm-dev