[cfe-dev] Define new pragma in Clang

Tobias Grosser tobias at grosser.es
Tue Nov 27 05:21:54 PST 2012


On 11/27/2012 01:56 PM, Tigran wrote:
> Hi,

Hi Tigran,

> I have a similar task as you posted here, (to add a new pragma in clang,
> attach it to the loop and generate a metadata in LLVM IR) and I want to ask
> you if have handled it, please tell me
>
> 1. How can i pass the information from pragma (say a number) to the CodeGen
> class. I have added the handler class and functions, but I cant find a way
> to pass the info from Sema class to CodeGen.

No idea for this one.

> 2. How can I attach the pragma to the specified loop in clang so as after i
> can recover that information in LLVM IR.

This is an interesting question. LLVM-IR does not have explicit loops, 
so attaching information to loops is a little tricky. You could add 
meta-data to the loop header or the loop induction variable, but you 
need to be careful to not loose that information. Another option is to 
not attach the information to the loop, but to the individual statements 
in the loop. The best representation probably depends on what kind of 
information you would like to pass on.

Cheers
Tobi




More information about the cfe-dev mailing list