i965: Move MRF register asserts out of brw_reg.h
In a later patch we will make BRW_MAX_MRF return a different value depending on the hardware generation, but it is inconvenient to add a gen parameter to the brw_reg functions only for the assertions, so move these to places where we have the hardware generation available. Ken suggested to add the asserts to brw_set_src0 and brw_set_dest since that would make sure that we catch all uses of MRF registers, even those coming from modules that generate native code directly, like blorp. Unfortunately, this is very late in the process which can make things harder to debug, so add asserts to the generator as well. Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
This commit is contained in:
parent
d48ac93066
commit
0858610836
|
@ -146,8 +146,9 @@ brw_set_dest(struct brw_codegen *p, brw_inst *inst, struct brw_reg dest)
|
|||
{
|
||||
const struct brw_device_info *devinfo = p->devinfo;
|
||||
|
||||
if (dest.file != BRW_ARCHITECTURE_REGISTER_FILE &&
|
||||
dest.file != BRW_MESSAGE_REGISTER_FILE)
|
||||
if (dest.file == BRW_MESSAGE_REGISTER_FILE)
|
||||
assert(dest.nr < BRW_MAX_MRF);
|
||||
else if (dest.file != BRW_ARCHITECTURE_REGISTER_FILE)
|
||||
assert(dest.nr < 128);
|
||||
|
||||
gen7_convert_mrf_to_grf(p, &dest);
|
||||
|
@ -309,7 +310,9 @@ brw_set_src0(struct brw_codegen *p, brw_inst *inst, struct brw_reg reg)
|
|||
{
|
||||
const struct brw_device_info *devinfo = p->devinfo;
|
||||
|
||||
if (reg.file != BRW_ARCHITECTURE_REGISTER_FILE)
|
||||
if (reg.file == BRW_MESSAGE_REGISTER_FILE)
|
||||
assert(reg.nr < BRW_MAX_MRF);
|
||||
else if (reg.file != BRW_ARCHITECTURE_REGISTER_FILE)
|
||||
assert(reg.nr < 128);
|
||||
|
||||
gen7_convert_mrf_to_grf(p, ®);
|
||||
|
|
|
@ -53,8 +53,10 @@ brw_reg_from_fs_reg(fs_inst *inst, fs_reg *reg)
|
|||
struct brw_reg brw_reg;
|
||||
|
||||
switch (reg->file) {
|
||||
case GRF:
|
||||
case MRF:
|
||||
assert((reg->reg & ~(1 << 7)) < BRW_MAX_MRF);
|
||||
/* Fallthrough */
|
||||
case GRF:
|
||||
if (reg->stride == 0) {
|
||||
brw_reg = brw_vec1_reg(brw_file_from_reg(reg), reg->reg, 0);
|
||||
} else if (inst->exec_size < 8) {
|
||||
|
@ -1558,6 +1560,7 @@ fs_generator::generate_code(const cfg_t *cfg, int dispatch_width)
|
|||
brw_set_default_acc_write_control(p, inst->writes_accumulator);
|
||||
brw_set_default_exec_size(p, cvt(inst->exec_size) - 1);
|
||||
|
||||
assert(inst->base_mrf + inst->mlen <= BRW_MAX_MRF);
|
||||
assert(inst->mlen <= BRW_MAX_MSG_LENGTH);
|
||||
|
||||
switch (inst->exec_size) {
|
||||
|
|
|
@ -344,10 +344,12 @@ brw_reg(unsigned file,
|
|||
struct brw_reg reg;
|
||||
if (file == BRW_GENERAL_REGISTER_FILE)
|
||||
assert(nr < BRW_MAX_GRF);
|
||||
else if (file == BRW_MESSAGE_REGISTER_FILE)
|
||||
assert((nr & ~(1 << 7)) < BRW_MAX_MRF);
|
||||
else if (file == BRW_ARCHITECTURE_REGISTER_FILE)
|
||||
assert(nr <= BRW_ARF_TIMESTAMP);
|
||||
/* Asserting on the MRF register number requires to know the hardware gen
|
||||
* (gen6 has 24 MRF registers), which we don't know here, so we assert
|
||||
* for that in the generators and in brw_eu_emit.c
|
||||
*/
|
||||
|
||||
reg.type = type;
|
||||
reg.file = file;
|
||||
|
@ -808,7 +810,6 @@ brw_mask_reg(unsigned subnr)
|
|||
static inline struct brw_reg
|
||||
brw_message_reg(unsigned nr)
|
||||
{
|
||||
assert((nr & ~(1 << 7)) < BRW_MAX_MRF);
|
||||
return brw_vec8_reg(BRW_MESSAGE_REGISTER_FILE, nr, 0);
|
||||
}
|
||||
|
||||
|
|
|
@ -46,6 +46,7 @@ vec4_instruction::get_dst(void)
|
|||
break;
|
||||
|
||||
case MRF:
|
||||
assert(((dst.reg + dst.reg_offset) & ~(1 << 7)) < BRW_MAX_MRF);
|
||||
brw_reg = brw_message_reg(dst.reg + dst.reg_offset);
|
||||
brw_reg = retype(brw_reg, dst.type);
|
||||
brw_reg.dw1.bits.writemask = dst.writemask;
|
||||
|
@ -1134,6 +1135,7 @@ vec4_generator::generate_code(const cfg_t *cfg)
|
|||
brw_set_default_mask_control(p, inst->force_writemask_all);
|
||||
brw_set_default_acc_write_control(p, inst->writes_accumulator);
|
||||
|
||||
assert(inst->base_mrf + inst->mlen <= BRW_MAX_MRF);
|
||||
assert(inst->mlen <= BRW_MAX_MSG_LENGTH);
|
||||
|
||||
unsigned pre_emit_nr_insn = p->nr_insn;
|
||||
|
|
Loading…
Reference in New Issue