pan/midgard: Sketch static analysis to uniform count

This one is a little tricky, but the idea is that:

   r16-r23 are always uniforms

   r8-r15 are sometimes work, sometimes uniforms...
      ...but as work, they are always written before use
      ...and as uniforms, they are never written before use

So we use that heuristic to determine the count to feed the machine.
We'll record work register use in the next commit.

Signed-off-by: Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
This commit is contained in:
Alyssa Rosenzweig 2019-08-21 15:18:40 -07:00
parent 58fc260312
commit b9fb63859e
1 changed files with 27 additions and 0 deletions

View File

@ -114,6 +114,12 @@ prefix_for_bits(unsigned bits)
}
}
/* For static analysis to ensure all registers are written at least once before
* use along the source code path (TODO: does this break done for complex CF?)
*/
uint16_t midg_ever_written = 0;
static void
print_reg(unsigned reg, unsigned bits)
{
@ -124,6 +130,27 @@ print_reg(unsigned reg, unsigned bits)
is_embedded_constant_half = (bits < 32);
}
unsigned uniform_reg = 23 - reg;
bool is_uniform = false;
/* For r8-r15, it could be a work or uniform. We distinguish based on
* the fact work registers are ALWAYS written before use, but uniform
* registers are NEVER written before use. */
if ((reg >= 8 && reg < 16) && !(midg_ever_written & (1 << reg)))
is_uniform = true;
/* r16-r23 are always uniform */
if (reg >= 16 && reg <= 23)
is_uniform = true;
/* Update the uniform count appropriately */
if (is_uniform)
midg_stats.uniform_count =
MAX2(uniform_reg + 1, midg_stats.uniform_count);
char prefix = prefix_for_bits(bits);
if (prefix)