gen6_resolve_implied_move(p, &header, inst->base_mrf);
- brw_MOV(p, retype(brw_message_reg(inst->base_mrf + 1), BRW_REGISTER_TYPE_D),
- offset);
+ if (devinfo->gen >= 6) {
+ if (offset.file == BRW_IMMEDIATE_VALUE) {
+ brw_MOV(p, retype(brw_message_reg(inst->base_mrf + 1),
+ BRW_REGISTER_TYPE_D),
+ brw_imm_d(offset.ud >> 4));
+ } else {
+ brw_SHR(p, retype(brw_message_reg(inst->base_mrf + 1),
+ BRW_REGISTER_TYPE_D),
+ offset, brw_imm_d(4));
+ }
+ } else {
+ brw_MOV(p, retype(brw_message_reg(inst->base_mrf + 1),
+ BRW_REGISTER_TYPE_D),
+ offset);
+ }
uint32_t msg_type;
unsigned const_offset = instr->const_index[0];
src_reg offset;
- if (!has_indirect) {
- offset = brw_imm_ud(const_offset / 16);
+ if (devinfo->gen <= 6) {
+ if (!has_indirect) {
+ offset = brw_imm_ud(const_offset & ~15);
+ } else {
+ offset = get_nir_src(instr->src[1], nir_type_int, 1);
+ }
} else {
- offset = src_reg(this, glsl_type::uint_type);
- emit(SHR(dst_reg(offset), get_nir_src(instr->src[1], nir_type_int, 1),
- brw_imm_ud(4u)));
+ if (!has_indirect) {
+ offset = brw_imm_ud(const_offset / 16);
+ } else {
+ offset = src_reg(this, glsl_type::uint_type);
+ emit(SHR(dst_reg(offset), get_nir_src(instr->src[1], nir_type_int, 1),
+ brw_imm_ud(4u)));
+ }
}
src_reg packed_consts = src_reg(this, glsl_type::vec4_type);
emit_before(block, inst, ADD(dst_reg(index), *reladdr,
brw_imm_d(reg_offset)));
- /* Pre-gen6, the message header uses byte offsets instead of vec4
+ /* Pre-gen7, the message header uses byte offsets instead of vec4
* (16-byte) offset units.
*/
- if (devinfo->gen < 6) {
+ if (devinfo->gen < 7) {
emit_before(block, inst, MUL(dst_reg(index), index, brw_imm_d(16)));
}
emit_before(block, inst, MOV(dst_reg(offset), brw_imm_d(reg_offset)));
return offset;
} else {
- int message_header_scale = devinfo->gen < 6 ? 16 : 1;
+ int message_header_scale = devinfo->gen < 7 ? 16 : 1;
return brw_imm_d(reg_offset * message_header_scale);
}
}