[cfe-dev] Add new compilation directives to clang?

Eli Friedman eli.friedman at gmail.com
Thu Jul 30 12:19:25 PDT 2009


On Thu, Jul 30, 2009 at 10:38 AM, zhunan<zhunansjtu at gmail.com> wrote:
> Hi,all
>
> I just develop some programs which need a new compilation directives,it
> just like OpenMP's directives(#pragma omp parallel for),
>
> for example,I want Clang to recognize "#pragma GCB i" and then change i
> to idx_i when it generate LLVM IR.
>
> what should I do to archieve this?

Roughly, you add parsing code to lib/Parse/ParsePragma.cpp, add an
action to include/clang/Parse/Action.h, add some representation in the
AST, add a handler to Sema to create the necessary AST node, and make
CodeGen handle the new AST node.

I'm not sure I quite follow what you're trying to do, though.

-Eli



More information about the cfe-dev mailing list