freedreno/a3xx/compiler: new compiler
authorRob Clark <robclark@freedesktop.org>
Wed, 29 Jan 2014 22:18:49 +0000 (17:18 -0500)
committerRob Clark <robclark@freedesktop.org>
Mon, 3 Feb 2014 23:26:53 +0000 (18:26 -0500)
commit554f1ac00c43f4503b923e1a129c0039468dcb82
tree1586ab27f83c704013d9f48b96d93434cd9644cc
parentf0e2d7ab4615651b40e37205bed12c9ca92e84f3
freedreno/a3xx/compiler: new compiler

The new compiler generates a dependency graph of instructions, including
a few meta-instructions to handle PHI and preserve some extra
information needed for register assignment, etc.

The depth pass assigned a weight/depth to each node (based on sum of
instruction cycles of a given node and all it's dependent nodes), which
is used to schedule instructions.  The scheduling takes into account the
minimum number of cycles/slots between dependent instructions, etc.
Which was something that could not be handled properly with the original
compiler (which was more of a naive TGSI translator than an actual
compiler).

The register assignment is currently split out as a standalone pass.  I
expect that it will be replaced at some point, once I figure out what to
do about relative addressing (which is currently the only thing that
should cause fallback to old compiler).

There are a couple new debug options for FD_MESA_DEBUG env var:

  optmsgs - enable debug prints in optimizer
  optdump - dump instruction graph in .dot format, for example:

http://people.freedesktop.org/~robclark/a3xx/frag-0000.dot.png
http://people.freedesktop.org/~robclark/a3xx/frag-0000.dot

At this point, thanks to proper handling of instruction scheduling, the
new compiler fixes a lot of things that were broken before, and does not
appear to break anything that was working before[1].  So even though it
is not finished, it seems useful to merge it in it's current state.

[1] Not merged in this commit, because I'm not sure if it really belongs
in mesa tree, but the following commit implements a simple shader
emulator, which I've used to compare the output of the new compiler to
the original compiler (ie. run it on all the TGSI shaders dumped out via
ST_DEBUG=tgsi with various games/apps):

https://github.com/freedreno/mesa/commit/163b6306b1660e05ece2f00d264a8393d99b6f12

Signed-off-by: Rob Clark <robclark@freedesktop.org>
17 files changed:
src/gallium/drivers/freedreno/Makefile.sources
src/gallium/drivers/freedreno/a3xx/disasm-a3xx.c
src/gallium/drivers/freedreno/a3xx/fd3_compiler.c
src/gallium/drivers/freedreno/a3xx/fd3_compiler_old.c
src/gallium/drivers/freedreno/a3xx/fd3_program.c
src/gallium/drivers/freedreno/a3xx/instr-a3xx.h
src/gallium/drivers/freedreno/a3xx/ir3.c
src/gallium/drivers/freedreno/a3xx/ir3.h
src/gallium/drivers/freedreno/a3xx/ir3_cp.c [new file with mode: 0644]
src/gallium/drivers/freedreno/a3xx/ir3_depth.c [new file with mode: 0644]
src/gallium/drivers/freedreno/a3xx/ir3_dump.c [new file with mode: 0644]
src/gallium/drivers/freedreno/a3xx/ir3_flatten.c [new file with mode: 0644]
src/gallium/drivers/freedreno/a3xx/ir3_ra.c [new file with mode: 0644]
src/gallium/drivers/freedreno/a3xx/ir3_sched.c [new file with mode: 0644]
src/gallium/drivers/freedreno/a3xx/ir3_visitor.h [new file with mode: 0644]
src/gallium/drivers/freedreno/freedreno_screen.c
src/gallium/drivers/freedreno/freedreno_util.h