i965/fs: Make register file enum 0 be the undefined register file.

In 6d874d0ee1, I checked whether a
register that had been stored was BAD_FILE (as opposed to a legitimate
GRF), but actually the unset register was ARF NULL because it had been
memset to 0.  Finding BAD_FILE for unset values in debugging was my
intention with that file, so make it the case more often by
rearranging the enum.  There was only one place we relied on the magic
enum register_file to hardware register file correspondance anyway.
This commit is contained in:
Eric Anholt 2011-11-23 10:13:39 -08:00
parent c6abde211f
commit a3b8c5ed5b
2 changed files with 25 additions and 8 deletions

View File

@ -48,13 +48,13 @@ extern "C" {
#include "glsl/ir.h"
enum register_file {
ARF = BRW_ARCHITECTURE_REGISTER_FILE,
GRF = BRW_GENERAL_REGISTER_FILE,
MRF = BRW_MESSAGE_REGISTER_FILE,
IMM = BRW_IMMEDIATE_VALUE,
BAD_FILE,
ARF,
GRF,
MRF,
IMM,
FIXED_HW_REG, /* a struct brw_reg */
UNIFORM, /* prog_data->params[reg] */
BAD_FILE
};
class fs_reg {
@ -159,7 +159,7 @@ public:
struct brw_reg fixed_hw_reg;
int smear; /* -1, or a channel of the reg to smear to all channels. */
/** Value for file == BRW_IMMMEDIATE_FILE */
/** Value for file == IMM */
union {
int32_t i;
uint32_t u;

View File

@ -573,6 +573,23 @@ fs_visitor::generate_pull_constant_load(fs_inst *inst, struct brw_reg dst)
}
}
static uint32_t brw_file_from_reg(fs_reg *reg)
{
switch (reg->file) {
case ARF:
return BRW_ARCHITECTURE_REGISTER_FILE;
case GRF:
return BRW_GENERAL_REGISTER_FILE;
case MRF:
return BRW_MESSAGE_REGISTER_FILE;
case IMM:
return BRW_IMMEDIATE_VALUE;
default:
assert(!"not reached");
return BRW_GENERAL_REGISTER_FILE;
}
}
static struct brw_reg
brw_reg_from_fs_reg(fs_reg *reg)
{
@ -583,9 +600,9 @@ brw_reg_from_fs_reg(fs_reg *reg)
case ARF:
case MRF:
if (reg->smear == -1) {
brw_reg = brw_vec8_reg(reg->file, reg->reg, 0);
brw_reg = brw_vec8_reg(brw_file_from_reg(reg), reg->reg, 0);
} else {
brw_reg = brw_vec1_reg(reg->file, reg->reg, reg->smear);
brw_reg = brw_vec1_reg(brw_file_from_reg(reg), reg->reg, reg->smear);
}
brw_reg = retype(brw_reg, reg->type);
if (reg->sechalf)