[cfe-dev] Source to source for reduction clause - clang

陳韋任 via cfe-dev cfe-dev at lists.llvm.org
Wed May 17 16:13:32 PDT 2017


Why not change the token kind of "reduction", "[", ... , "]" to
tok::unknown? I suspect tok::comment might do something bad to your
one-line "meta_for reduction[+: var] (int i=0; i<10; i++)".

Regards,
chenwj

2017-05-18 2:25 GMT+08:00 Masoud Ataei via cfe-dev <cfe-dev at lists.llvm.org>:

> Hello,
>
> I am new to clang and this problem may be so easy, but it took lots of my
> time. I am writing a source to source translator by clang for translating
> from my MetaFork language to OpenMP. I want to translate:
> ----------------------------------
> meta_for reduction[+: var] (int i=0; i<10; i++)
>
> to
>
> #pragma omp parallel for reduction (+: var)
>            for (int i=0; i< 10; i++)
> ----------------------------------
> What I did to this point, I defined "meta_for" to be "#pragma omp parallel
> for for" and managed to add a "tok::eod" between two for's in preprocessor.
> So now, I can translate
> ----------------------------------
> meta_for (int i=0; i<10; i++)
>
> to
>
> #pragma omp parallel for
>            for (int i=0; i< 10; i++)
> ----------------------------------
>
> But when I add reduction clause to meta_for, my idea is to comment out
> " reduction[+: var]" and have a complete parallel for loop, also save the
> location of reduction clause and operation and variables for later. But
> when I change the token kind of "reduction", "[", ... , "]" to
> tok::comment. It gives me a weird error.
>
> It says  expected to have ")" after "int" to be matched with "("!!!
>
> can anyone help me on that?
>
> Thank you.
>
> --
> ------
> ----------
> Masoud Ataei (Mr.)
>
>
> _______________________________________________
> cfe-dev mailing list
> cfe-dev at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev
>
>


-- 
Wei-Ren Chen (陳韋任)
Homepage: https://people.cs.nctu.edu.tw/~chenwj
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20170518/c6134618/attachment.html>


More information about the cfe-dev mailing list