Make them members of fs_inst/vec4_instruction for use elsewhere.
Also fix the fs version to check that dst.type == src[1].type and for
!saturate.
Reviewed-by: Jason Ekstrand <jason.ekstrand@intel.com>
}
bool
+fs_inst::can_change_types() const
+{
+ return dst.type == src[0].type &&
+ !src[0].abs && !src[0].negate && !saturate &&
+ (opcode == BRW_OPCODE_MOV ||
+ (opcode == BRW_OPCODE_SEL &&
+ dst.type == src[1].type &&
+ predicate != BRW_PREDICATE_NONE &&
+ !src[1].abs && !src[1].negate));
+}
+
+bool
fs_inst::has_side_effects() const
{
return this->eot || backend_instruction::has_side_effects();
opcode == BRW_OPCODE_NOT);
}
-static bool
-can_change_source_types(fs_inst *inst)
-{
- return !inst->src[0].abs && !inst->src[0].negate &&
- inst->dst.type == inst->src[0].type &&
- (inst->opcode == BRW_OPCODE_MOV ||
- (inst->opcode == BRW_OPCODE_SEL &&
- inst->predicate != BRW_PREDICATE_NONE &&
- !inst->src[1].abs && !inst->src[1].negate));
-}
-
bool
fs_visitor::try_copy_propagate(fs_inst *inst, int arg, acp_entry *entry)
{
if (has_source_modifiers &&
entry->dst.type != inst->src[arg].type &&
- !can_change_source_types(inst))
+ !inst->can_change_types())
return false;
if (devinfo->gen >= 8 && (entry->src.negate || entry->src.abs) &&
* type. If we got here, then we can just change the source and
* destination types of the instruction and keep going.
*/
- assert(can_change_source_types(inst));
+ assert(inst->can_change_types());
for (int i = 0; i < inst->sources; i++) {
inst->src[i].type = entry->dst.type;
}
unsigned components_read(unsigned i) const;
int regs_read(int arg) const;
bool can_do_source_mods(const struct brw_device_info *devinfo);
+ bool can_change_types() const;
bool has_side_effects() const;
bool reads_flag() const;
int swizzle, int swizzle_mask);
void reswizzle(int dst_writemask, int swizzle);
bool can_do_source_mods(const struct brw_device_info *devinfo);
+ bool can_change_types() const;
bool reads_flag()
{
return true;
}
+bool
+vec4_instruction::can_change_types() const
+{
+ return dst.type == src[0].type &&
+ !src[0].abs && !src[0].negate && !saturate &&
+ (opcode == BRW_OPCODE_MOV ||
+ (opcode == BRW_OPCODE_SEL &&
+ dst.type == src[1].type &&
+ predicate != BRW_PREDICATE_NONE &&
+ !src[1].abs && !src[1].negate));
+}
+
/**
* Returns how many MRFs an opcode will write over.
*
}
static bool
-can_change_source_types(vec4_instruction *inst)
-{
- return inst->dst.type == inst->src[0].type &&
- !inst->src[0].abs && !inst->src[0].negate && !inst->saturate &&
- (inst->opcode == BRW_OPCODE_MOV ||
- (inst->opcode == BRW_OPCODE_SEL &&
- inst->dst.type == inst->src[1].type &&
- inst->predicate != BRW_PREDICATE_NONE &&
- !inst->src[1].abs && !inst->src[1].negate));
-}
-
-static bool
try_copy_propagate(const struct brw_device_info *devinfo,
vec4_instruction *inst,
int arg, struct copy_entry *entry)
if (has_source_modifiers &&
value.type != inst->src[arg].type &&
- !can_change_source_types(inst))
+ !inst->can_change_types())
return false;
if (has_source_modifiers &&
value.swizzle = composed_swizzle;
if (has_source_modifiers &&
value.type != inst->src[arg].type) {
- assert(can_change_source_types(inst));
+ assert(inst->can_change_types());
for (int i = 0; i < 3; i++) {
inst->src[i].type = value.type;
}