GBE: Implement complete register spill policy.
authorZhigang Gong <zhigang.gong@intel.com>
Sun, 26 Jan 2014 06:07:14 +0000 (14:07 +0800)
committerZhigang Gong <zhigang.gong@intel.com>
Mon, 27 Jan 2014 09:40:01 +0000 (17:40 +0800)
commitfbc12676ce1cf01ab4051602268f093e16808823
tree8837a2ad5a651362dd86af457f680530f98e29d1
parente599470f7132097765d3c8ac5521973255c98462
GBE: Implement complete register spill policy.

This patch implement a complete register spill policy.

When it needs to spill a register, we always choose the
register which is in the spill candate map and has
maximum endpoint. One tricky I used here is to merge both
the register's endpoint value and the register itself
into one single key. Then I can use one map to implement a
descending order map according to its value( the instruction
endpoint value). This patch supports to spill both vectors
or non-vectors.

And I move the scratch memory allocation from
instruction selection to register allocation. We may latter
use the internal interval information to reduce the scratch
memory comsumption.

Another big change is that I don't perform the real
spill on the fly. Instead, I move the real spill to the end of
all register allocation. Then spilling all the registers which
in the spillSet at one pass. This has the following advantage:
1. It only needs to loop over all instructions once.
2. When spilling one instruction, we know all the registers' status.
   Then it's easy to know the correct scratch id for each register.
   Actually, the previous implementation has a bug here.

The last part is to avoid the spill instruction restrication.
As ruiling pointed out that the spill instruction(scratch read/write)
doesn't support predication correctly for non-DW data type.

This patch avoids to spill any non-supported type register.

After this patch, both luxrender and opencv examples work fine on
my machine.

Signed-off-by: Zhigang Gong <zhigang.gong@intel.com>
Reviewed-by: Yang, Rong R <rong.r.yang@intel.com>
backend/src/backend/gen_context.cpp
backend/src/backend/gen_insn_selection.cpp
backend/src/backend/gen_insn_selection.hpp
backend/src/backend/gen_reg_allocation.cpp
backend/src/backend/gen_reg_allocation.hpp