Re: [Mesa-dev] [PATCH 6/6] glsl: Generate IR for switch statements

2011-06-28 Thread Dan McCabe
On 06/28/2011 09:12 AM, Paul Berry wrote: On 27 June 2011 17:35, Keith Packard wrote: I'd write the simplest possible code that works now and then consider optimizing it later. This has the advantage that you can get a bunch of tests working and then use those to validate a later, more complica

Re: [Mesa-dev] [PATCH 6/6] glsl: Generate IR for switch statements

2011-06-28 Thread Paul Berry
On 27 June 2011 17:35, Keith Packard wrote: > I'd write the simplest possible code that works now and then consider > optimizing it later. This has the advantage that you can get a bunch of > tests working and then use those to validate a later, more complicated, > implementation. I heartily supp

Re: [Mesa-dev] [PATCH 6/6] glsl: Generate IR for switch statements

2011-06-27 Thread Dan McCabe
On 06/27/2011 05:35 PM, Keith Packard wrote: On Mon, 27 Jun 2011 17:23:30 -0700, Dan McCabe wrote: Since I am just about to start modifying the IR generation, I'm open to suggestion. I'd write the simplest possible code that works now and then consider optimizing it later. This has the advant

Re: [Mesa-dev] [PATCH 6/6] glsl: Generate IR for switch statements

2011-06-27 Thread Dan McCabe
On 06/27/2011 04:40 PM, Kenneth Graunke wrote: Here's another case that I'm not sure you're handling correctly...conditional breaks: switch (expr) { case c0: case c1: stmt0; case c2: case c3: stmt1; break; case c4: stmt2; if (foo) break; stmt3;// happens

Re: [Mesa-dev] [PATCH 6/6] glsl: Generate IR for switch statements

2011-06-27 Thread Keith Packard
On Mon, 27 Jun 2011 17:23:30 -0700, Dan McCabe wrote: > Since I am just about to start modifying the IR generation, I'm open to > suggestion. I'd write the simplest possible code that works now and then consider optimizing it later. This has the advantage that you can get a bunch of tests worki

Re: [Mesa-dev] [PATCH 6/6] glsl: Generate IR for switch statements

2011-06-27 Thread Dan McCabe
On 06/27/2011 05:15 PM, Kenneth Graunke wrote: On 06/24/2011 05:11 PM, Dan McCabe wrote: Looking at a translation of my canonical example: switch (expr) { case c0: case c1: stmt0; case c2: case c3: stmt1; break; case c4: default: stmt2; } We can

Re: [Mesa-dev] [PATCH 6/6] glsl: Generate IR for switch statements

2011-06-27 Thread Kenneth Graunke
On 06/24/2011 05:11 PM, Dan McCabe wrote: Looking at a translation of my canonical example: switch (expr) { case c0: case c1: stmt0; case c2: case c3: stmt1; break; case c4: default: stmt2; } We can translated this into: int test_val_tmp = ex

Re: [Mesa-dev] [PATCH 6/6] glsl: Generate IR for switch statements

2011-06-27 Thread Kenneth Graunke
Here's another case that I'm not sure you're handling correctly...conditional breaks: switch (expr) { case c0: case c1: stmt0; case c2: case c3: stmt1; break; case c4: stmt2; if (foo) break; stmt3;// happens if !foo case c5: default: stmt4;// h

Re: [Mesa-dev] [PATCH 6/6] glsl: Generate IR for switch statements

2011-06-27 Thread Ian Romanick
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 On 06/24/2011 05:11 PM, Dan McCabe wrote: > On 06/24/2011 01:17 PM, Dan McCabe wrote: >> 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! He

Re: [Mesa-dev] [PATCH 6/6] glsl: Generate IR for switch statements

2011-06-24 Thread Dan McCabe
On 06/24/2011 01:17 PM, Dan McCabe wrote: 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++) { switc

Re: [Mesa-dev] [PATCH 6/6] glsl: Generate IR for switch statements

2011-06-24 Thread Dan McCabe
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) {

Re: [Mesa-dev] [PATCH 6/6] glsl: Generate IR for switch statements

2011-06-20 Thread Ian Romanick
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 On 06/17/2011 05:43 PM, Dan McCabe wrote: > Beware! Here be dragons! > > Up until now modyfing the GLSL compiler has been pretty straightforward. > This is where things get interesting. > > Switch statement processing leverages infrastructure that wa

[Mesa-dev] [PATCH 6/6] glsl: Generate IR for switch statements

2011-06-17 Thread Dan McCabe
Beware! Here be dragons! Up until now modyfing the GLSL compiler has been pretty straightforward. This is where things get interesting. Switch statement processing leverages infrastructure that was previously created (specifically for break statements, which are encountered in both loops and swit