Adding custom pragma's for generating particular LLVM IR

Hi ML readers,

I would first apology if this was already addressed on this ML, but I didn't find information on this topic.

I would like to add custom pragma's that generate particular LLVM IR. Here is an example:

int a, b;

/* ... */

#pragma mypragma shared(a, b)
{
     a = b;
     b++;
}

would result in this (pseudo) LLVM IR:

%1 alloca i32
%2 alloca i32

...

call void @start_callback ()
%3 call i32 @check_callback ( i32 %1 )
%4 call i32 @check_callback ( i32 %2 )
...
call void @end_callback ()

...

Note: All *_callback functions are implemented in a third party library.

I guess that is it quite close to what was implemented for the OpenMP support, but I need something simpler.

Basically, how can I
- Add a pragma that identifies a block (i.e. scope) of code ?
- Add an action that flag some variables as __shared__ in the annotated block ?
- Generate LLVM IR that add specific call-backs at the start and end of the block and on shared variables ?

I hope my explanation is sufficiently clear. Feel free to ask questions if it's not.

Best regards,
Julien.

Hi Julien, as this would all presumably be done in the clang front-end I suggest
you ask on the clang mailing list.

Ciao, Duncan.