On 06/20/2011 03:50 PM, Ian Romanick wrote:
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On 06/17/2011 05:43 PM, Dan McCabe wrote:
Beware! Here be dragons!


I think this will generate the wrong code for:

        for (i = 0; i<  10; i++) {
                switch (i) {
                        default: continue;
                }
        }

It seems like that will generate some approximation of:

        for (i = 0; i<  10; i++) {
                do {
                        continue;
                        break;
                } while (true);
        }

Right?  This is why I had originally tracked loops and switch-statements
in a single stack.  In this situation, you'd want to set a "do a
continue" flag in the switch-statement and emit a break (from the
switch).  Something like:


        for (i = 0; i<  10; i++) {
                bool do_cont = false;

                do {
                        do_cont = true;
                        break;
                        break;
                } while (true);

                if (do_cont)
                        continue;
        }


Yikes! Looks like you tripped over one of those dragons :(.

Using a do_cont variable (or similar device) feels kludgey to me. I've been mulling this over for the last couple of days while I did other things and I think the right way to do this might be to get rid of the use of "loop" altogether.

But the devil is in the details, which I haven't worked out yet. Going back to the unified loop/switch stack might be needed, though.

cheers, danm

_______________________________________________
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev

Reply via email to