[LLVMdev] Enhancing TableGen

David A. Greene greened at obbligato.org
Tue Oct 11 14:35:23 PDT 2011


Jakob Stoklund Olesen <stoklund at 2pi.dk> writes:

> On Oct 11, 2011, at 2:03 PM, David Blaikie wrote:
>
>     I'd assume something like:
>    
>         for (x, y) = [(1, 4), (2, 5), (3, 6)] in { ... }
>    
>     Though I don't know a great deal about tablegen syntax. But so
>     long as the lists are separate it seems it'd always be unclear
>     that it was a zip.
>
> +1

Ah yes, I like this idea.  It clarifies exactly how the zip works.  The
problem I see with this is that ( ... ) is a dag in TableGen and that
doesn't really map will onto iteration.  It could be done in the parser
but it would be pretty ugly.

Another thing we need to do is provide some way to declare x and y.
Otherwise TableGen will barf about use before declaration.

Another option:

         for {int x, int y} = [[1, 4], [2, 5], [3, 6]] in { ... }

This re-uses the class body syntax so we can make use of ParseObjectBody
directly.  We'd just create an anonymous class.  I'm not as happy with
the nested list syntax but it fits in the parser very well and supports
iteration directly.

> Nobody actually needs the zip functionality anyway.

In the sense of declaring and iterating separate lists?  Yeah, now that
I see this I agree.

                               -Dave



More information about the llvm-dev mailing list