Mesa (master): vc4: Abstract out the field-merging logic for instructions.
Eric Anholt
anholt at kemper.freedesktop.org
Wed Oct 8 15:53:41 UTC 2014
Module: Mesa
Branch: master
Commit: 48af7426f295a02ea68c4b460e006c289b10192c
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=48af7426f295a02ea68c4b460e006c289b10192c
Author: Eric Anholt <eric at anholt.net>
Date: Thu Oct 2 23:22:03 2014 -0700
vc4: Abstract out the field-merging logic for instructions.
I'm going to be doing the same logic for some more fields next.
---
src/gallium/drivers/vc4/vc4_qpu.c | 28 +++++++++++++++++-----------
1 file changed, 17 insertions(+), 11 deletions(-)
diff --git a/src/gallium/drivers/vc4/vc4_qpu.c b/src/gallium/drivers/vc4/vc4_qpu.c
index bf385e3..27fc309 100644
--- a/src/gallium/drivers/vc4/vc4_qpu.c
+++ b/src/gallium/drivers/vc4/vc4_qpu.c
@@ -185,23 +185,29 @@ qpu_m_alu2(enum qpu_op_mul op,
return inst;
}
+static uint64_t
+merge_fields(uint64_t merge,
+ uint64_t add, uint64_t mul,
+ uint64_t mask, uint64_t ignore)
+{
+ if ((add & mask) == ignore)
+ return (merge & ~mask) | (mul & mask);
+ else if ((mul & mask) == ignore)
+ return (merge & ~mask) | (add & mask);
+ else {
+ assert((add & mask) == (mul & mask));
+ return merge;
+ }
+}
+
uint64_t
qpu_inst(uint64_t add, uint64_t mul)
{
uint64_t merge = ((add & ~QPU_WADDR_MUL_MASK) |
(mul & ~QPU_WADDR_ADD_MASK));
- /* If either one has no signal field, then use the other's signal field.
- * (since QPU_SIG_NONE != 0).
- */
- if (QPU_GET_FIELD(add, QPU_SIG) == QPU_SIG_NONE)
- merge = (merge & ~QPU_SIG_MASK) | (mul & QPU_SIG_MASK);
- else if (QPU_GET_FIELD(mul, QPU_SIG) == QPU_SIG_NONE)
- merge = (merge & ~QPU_SIG_MASK) | (add & QPU_SIG_MASK);
- else {
- assert(QPU_GET_FIELD(add, QPU_SIG) ==
- QPU_GET_FIELD(mul, QPU_SIG));
- }
+ merge = merge_fields(merge, add, mul, QPU_SIG_MASK,
+ QPU_SET_FIELD(QPU_SIG_NONE, QPU_SIG));
return merge;
}
More information about the mesa-commit
mailing list