Reputation: 435
I'm so new for compilers and currently started clang. I would like to parse openmp pragma lines with clang and my question is is it possible? in fact i saw lots of presentation about supporting openmp however i couldn't find any example about how to parse? if you have or know useful example, could you send me?
thanks lot
Upvotes: 1
Views: 1043
Reputation: 435
I found finally. Currently Clang only supports omp parallel directive, moreover almost without clause :)
in order to use it, i used these parameters:
clang -Xclang -ast-dump -Xpreprocessor -fopenmp yoursourcefile.c
and i could see omp statement in the ast.
OMPParallelDirective 0xd09a09c <line:6:13, col:25>
-CapturedStmt 0xd09a088 <line:7:5, col:18>
Upvotes: 0
Reputation: 1140
Take a look at Polly. It supports OpenMP and is based on llvm. Polly generates LLVM IR annotated with GOMP library calls and it is easy to write your own pass to get a handle on these calls.
If you really need the pragma information in the frontend, you will need to dig into the code to get a handle on the pragmas. In any case you do not need to write your own parser.
Detailed information about how Polly handles OpenMP pragmas can be found in this document.
Upvotes: 2