pan/bi: Add imm_f32 helper
authorAlyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Wed, 16 Dec 2020 15:28:17 +0000 (10:28 -0500)
committerAlyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Wed, 23 Dec 2020 18:29:36 +0000 (13:29 -0500)
Pattern comes up surprisingly often.

Signed-off-by: Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/8215>

src/panfrost/bifrost/compiler.h

index 341ad2d..dcdd9de 100644 (file)
@@ -31,6 +31,7 @@
 #include "bi_opcodes.h"
 #include "compiler/nir/nir.h"
 #include "panfrost/util/pan_ir.h"
+#include "util/u_math.h"
 
 /* Bifrost opcodes are tricky -- the same op may exist on both FMA and
  * ADD with two completely different opcodes, and opcodes can be varying
@@ -450,6 +451,12 @@ bi_imm_u32(uint32_t imm)
 }
 
 static inline bi_index
+bi_imm_f32(float imm)
+{
+        return bi_imm_u32(fui(imm));
+}
+
+static inline bi_index
 bi_null()
 {
         return (bi_index) { .type = BI_INDEX_NULL };