On Mon, Dec 3, 2012 at 11:05 AM, Alexey Kravets <mr.kayr...@gmail.com> wrote:
> Hello,
> I am looking for a way to implement source annotation (or something
> similar) for a for loops. Basically, I need some mechanism to mark
> certain for loops in the source code for the GIMPLE optimization
> passes (for C/C++ only currently).
> For example something like this:
>
> int i;
> __attribute__((marked)) // Not compilable by GCC.
> for (i =0; i < 100; i++) {
>    foo (i);
> }
>
> or
>
> int i;
>
> #pragma marked // Can be compiled, but require additional GIMPLE tree nodes.
> for (i =0; i < 100; i++) {
>    foo (i);
> }
>
>
> As far as I know, for loops are lowered to jumps by C front-end and
> natural loops are detected later, so there is no strait way of passing
> such information.
> OpenMP pragmas provides such functionality, but require additional
> GIMPLE nodes to be defined and carried through all optimization
> passes,
> which I would prefer to avoid (if possible). So, is there any strait
> way to implement this?

A natural way would be to attach such information to the on-the side
loop structure tree (cfgloop.h, struct loop).  Unfortunately it is build
quite late, so at the moment you'd have to use a combination of
GIMPLE nodes and later transitioning it to loop struct annotations.
There is, of course, no reason to not at some point in the future
let frontends populate the initial loop tree and keep that up-to-date.

Richard.

>
> Best regards,
> Alexey

Reply via email to