summaryrefslogtreecommitdiffstats
path: root/src/broadcom/qpu/qpu_pack.c
diff options
context:
space:
mode:
authorEric Anholt <[email protected]>2018-01-04 22:47:54 -0800
committerEric Anholt <[email protected]>2018-01-12 21:54:18 -0800
commit2bd378647bebd41338baf9c6a9297a3a72c84e84 (patch)
tree2c9794131a43ce27dd091215d649f4586d29a376 /src/broadcom/qpu/qpu_pack.c
parent5f227ac2104e08ad434c78a472ef9ac21ebdfe73 (diff)
broadcom/vc5: Add support for QPU pack/unpack/disasm of small immediates.
Diffstat (limited to 'src/broadcom/qpu/qpu_pack.c')
-rw-r--r--src/broadcom/qpu/qpu_pack.c63
1 files changed, 63 insertions, 0 deletions
diff --git a/src/broadcom/qpu/qpu_pack.c b/src/broadcom/qpu/qpu_pack.c
index 68df6fe64c4..161e24f0300 100644
--- a/src/broadcom/qpu/qpu_pack.c
+++ b/src/broadcom/qpu/qpu_pack.c
@@ -255,6 +255,69 @@ v3d_qpu_sig_pack(const struct v3d_device_info *devinfo,
return false;
}
+static inline unsigned
+fui( float f )
+{
+ union {float f; unsigned ui;} fi;
+ fi.f = f;
+ return fi.ui;
+}
+
+static const uint32_t small_immediates[] = {
+ 0, 1, 2, 3,
+ 4, 5, 6, 7,
+ 8, 9, 10, 11,
+ 12, 13, 14, 15,
+ -16, -15, -14, -13,
+ -12, -11, -10, -9,
+ -8, -7, -6, -5,
+ -4, -3, -2, -1,
+ 0x3b800000, /* 2.0^-8 */
+ 0x3c000000, /* 2.0^-7 */
+ 0x3c800000, /* 2.0^-6 */
+ 0x3d000000, /* 2.0^-5 */
+ 0x3d800000, /* 2.0^-4 */
+ 0x3e000000, /* 2.0^-3 */
+ 0x3e800000, /* 2.0^-2 */
+ 0x3f000000, /* 2.0^-1 */
+ 0x3f800000, /* 2.0^0 */
+ 0x40000000, /* 2.0^1 */
+ 0x40800000, /* 2.0^2 */
+ 0x41000000, /* 2.0^3 */
+ 0x41800000, /* 2.0^4 */
+ 0x42000000, /* 2.0^5 */
+ 0x42800000, /* 2.0^6 */
+ 0x43000000, /* 2.0^7 */
+};
+
+bool
+v3d_qpu_small_imm_unpack(const struct v3d_device_info *devinfo,
+ uint32_t packed_small_immediate,
+ uint32_t *small_immediate)
+{
+ if (packed_small_immediate >= ARRAY_SIZE(small_immediates))
+ return false;
+
+ *small_immediate = small_immediates[packed_small_immediate];
+ return true;
+}
+
+bool
+v3d_qpu_small_imm_pack(const struct v3d_device_info *devinfo,
+ uint32_t value,
+ uint32_t *packed_small_immediate)
+{
+ STATIC_ASSERT(ARRAY_SIZE(small_immediates) == 48);
+
+ for (int i = 0; i < ARRAY_SIZE(small_immediates); i++) {
+ if (small_immediates[i] == value) {
+ *packed_small_immediate = i;
+ return true;
+ }
+ }
+
+ return false;
+}
bool
v3d_qpu_flags_unpack(const struct v3d_device_info *devinfo,