i965: Rework IF/ELSE jump target back-patching.
authorKenneth Graunke <kenneth@whitecape.org>
Mon, 16 May 2011 20:40:00 +0000 (13:40 -0700)
committerKenneth Graunke <kenneth@whitecape.org>
Wed, 18 May 2011 06:32:58 +0000 (23:32 -0700)
commitc638180fc715aff84422c1092926120af966d417
tree090a1e05769c22d48d3737f6ffc62ce2ab111fa3
parent5936d96d33e767aa99f6afa92f2a6582ff04df23
i965: Rework IF/ELSE jump target back-patching.

The primary motivation for this is to better support Ivybridge control
flow.  Ivybridge IF instructions need to point to the first instruction
of the ELSE block -and- the ENDIF instruction; the existing code only
supported back-patching one instruction ago.

A second goal is to simplify and centralize the back-patching, hopefully
clarifying the code somewhat.

Previously, brw_ELSE back-patched the IF instruction, and brw_ENDIF
back-patched the previous instruction (IF or ELSE).  With this patch,
brw_ENDIF is responsible for patching both the IF and (optional) ELSE.

To support this, the control flow stack (if_stack) maintains pointers to
both the IF and ELSE instructions.  Unfortunately, in single program
flow (SPF) mode, both were emitted as ADD instructions, and thus
indistinguishable.

To remedy this, this patch simply emits IF and ELSE, rather than ADDs;
brw_ENDIF will convert them to ADDs (the SPF version of back-patching).

Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Eric Anholt <eric@anholt.net>
src/mesa/drivers/dri/i965/brw_eu_emit.c