mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-06 00:49:04 +02:00
i965: De-duplicate is_expression_commutative() functions.
Create a backend_inst::is_commutative() method to replace two static functions that did the exact same thing. Signed-off-by: Kenneth Graunke <kenneth@whitecape.org> Reviewed-by: Topi Pohjolainen <topi.pohjolainen@intel.com>
This commit is contained in:
parent
f68a973dfb
commit
db095eb43b
4 changed files with 25 additions and 46 deletions
|
|
@ -108,28 +108,6 @@ is_expression(const fs_inst *const inst)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool
|
|
||||||
is_expression_commutative(const fs_inst *inst)
|
|
||||||
{
|
|
||||||
switch (inst->opcode) {
|
|
||||||
case BRW_OPCODE_AND:
|
|
||||||
case BRW_OPCODE_OR:
|
|
||||||
case BRW_OPCODE_XOR:
|
|
||||||
case BRW_OPCODE_ADD:
|
|
||||||
case BRW_OPCODE_MUL:
|
|
||||||
return true;
|
|
||||||
case BRW_OPCODE_SEL:
|
|
||||||
/* MIN and MAX are commutative. */
|
|
||||||
if (inst->conditional_mod == BRW_CONDITIONAL_GE ||
|
|
||||||
inst->conditional_mod == BRW_CONDITIONAL_L) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
/* fallthrough */
|
|
||||||
default:
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static bool
|
static bool
|
||||||
operands_match(const fs_inst *a, const fs_inst *b)
|
operands_match(const fs_inst *a, const fs_inst *b)
|
||||||
{
|
{
|
||||||
|
|
@ -140,7 +118,7 @@ operands_match(const fs_inst *a, const fs_inst *b)
|
||||||
return xs[0].equals(ys[0]) &&
|
return xs[0].equals(ys[0]) &&
|
||||||
((xs[1].equals(ys[1]) && xs[2].equals(ys[2])) ||
|
((xs[1].equals(ys[1]) && xs[2].equals(ys[2])) ||
|
||||||
(xs[2].equals(ys[1]) && xs[1].equals(ys[2])));
|
(xs[2].equals(ys[1]) && xs[1].equals(ys[2])));
|
||||||
} else if (!is_expression_commutative(a)) {
|
} else if (!a->is_commutative()) {
|
||||||
bool match = true;
|
bool match = true;
|
||||||
for (int i = 0; i < a->sources; i++) {
|
for (int i = 0; i < a->sources; i++) {
|
||||||
if (!xs[i].equals(ys[i])) {
|
if (!xs[i].equals(ys[i])) {
|
||||||
|
|
|
||||||
|
|
@ -768,6 +768,28 @@ backend_reg::is_accumulator() const
|
||||||
fixed_hw_reg.nr == BRW_ARF_ACCUMULATOR;
|
fixed_hw_reg.nr == BRW_ARF_ACCUMULATOR;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool
|
||||||
|
backend_instruction::is_commutative() const
|
||||||
|
{
|
||||||
|
switch (opcode) {
|
||||||
|
case BRW_OPCODE_AND:
|
||||||
|
case BRW_OPCODE_OR:
|
||||||
|
case BRW_OPCODE_XOR:
|
||||||
|
case BRW_OPCODE_ADD:
|
||||||
|
case BRW_OPCODE_MUL:
|
||||||
|
return true;
|
||||||
|
case BRW_OPCODE_SEL:
|
||||||
|
/* MIN and MAX are commutative. */
|
||||||
|
if (conditional_mod == BRW_CONDITIONAL_GE ||
|
||||||
|
conditional_mod == BRW_CONDITIONAL_L) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
/* fallthrough */
|
||||||
|
default:
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
backend_instruction::is_3src() const
|
backend_instruction::is_3src() const
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -94,6 +94,7 @@ struct backend_instruction : public exec_node {
|
||||||
bool is_tex() const;
|
bool is_tex() const;
|
||||||
bool is_math() const;
|
bool is_math() const;
|
||||||
bool is_control_flow() const;
|
bool is_control_flow() const;
|
||||||
|
bool is_commutative() const;
|
||||||
bool can_do_source_mods() const;
|
bool can_do_source_mods() const;
|
||||||
bool can_do_saturate() const;
|
bool can_do_saturate() const;
|
||||||
bool can_do_cmod() const;
|
bool can_do_cmod() const;
|
||||||
|
|
|
||||||
|
|
@ -88,28 +88,6 @@ is_expression(const vec4_instruction *const inst)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool
|
|
||||||
is_expression_commutative(const vec4_instruction *inst)
|
|
||||||
{
|
|
||||||
switch (inst->opcode) {
|
|
||||||
case BRW_OPCODE_AND:
|
|
||||||
case BRW_OPCODE_OR:
|
|
||||||
case BRW_OPCODE_XOR:
|
|
||||||
case BRW_OPCODE_ADD:
|
|
||||||
case BRW_OPCODE_MUL:
|
|
||||||
return true;
|
|
||||||
case BRW_OPCODE_SEL:
|
|
||||||
/* MIN and MAX are commutative. */
|
|
||||||
if (inst->conditional_mod == BRW_CONDITIONAL_GE ||
|
|
||||||
inst->conditional_mod == BRW_CONDITIONAL_L) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
/* fallthrough */
|
|
||||||
default:
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static bool
|
static bool
|
||||||
operands_match(const vec4_instruction *a, const vec4_instruction *b)
|
operands_match(const vec4_instruction *a, const vec4_instruction *b)
|
||||||
{
|
{
|
||||||
|
|
@ -120,7 +98,7 @@ operands_match(const vec4_instruction *a, const vec4_instruction *b)
|
||||||
return xs[0].equals(ys[0]) &&
|
return xs[0].equals(ys[0]) &&
|
||||||
((xs[1].equals(ys[1]) && xs[2].equals(ys[2])) ||
|
((xs[1].equals(ys[1]) && xs[2].equals(ys[2])) ||
|
||||||
(xs[2].equals(ys[1]) && xs[1].equals(ys[2])));
|
(xs[2].equals(ys[1]) && xs[1].equals(ys[2])));
|
||||||
} else if (!is_expression_commutative(a)) {
|
} else if (!a->is_commutative()) {
|
||||||
return xs[0].equals(ys[0]) && xs[1].equals(ys[1]) && xs[2].equals(ys[2]);
|
return xs[0].equals(ys[0]) && xs[1].equals(ys[1]) && xs[2].equals(ys[2]);
|
||||||
} else {
|
} else {
|
||||||
return (xs[0].equals(ys[0]) && xs[1].equals(ys[1])) ||
|
return (xs[0].equals(ys[0]) && xs[1].equals(ys[1])) ||
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue