[LLVMdev] Support for per-loop pragma
devang.patel at gmail.com
Wed Jun 2 09:37:23 PDT 2010
On Tue, Jun 1, 2010 at 5:42 PM, Junjie Gu <jgu222 at gmail.com> wrote:
> 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 ..
> #pragma p2...
> for (...)
> The llvm IR would be
> llvm.pragma (metadata..) // for p1
> llvm.pragma (metadata..) // for p2
> llvm IR for "for (...)"
This approach assumes that these two llvm.pragma intrinsics and the
llvm IR for "for (...)" always stay together in same order all the
time. This ordering is extremely hard to maintain. Using attached
metadata, as suggested by others, is much better alternative.
> 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)
> less obvious.
> 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.
> LLVM Developers mailing list
> LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu
More information about the llvm-dev