[LLVMdev] Adding custom pragma's for generating particular LLVM IR

Duncan Sands baldrick at free.fr
Mon Apr 22 02:55:13 PDT 2013


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.

On 20/04/13 08:43, Julien Peeters wrote:
> 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.
> _______________________________________________
> LLVM Developers mailing list
> LLVMdev at cs.uiuc.edu         http://llvm.cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev




More information about the llvm-dev mailing list