summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNeil Roberts <[email protected]>2018-03-21 20:34:37 +0100
committerNeil Roberts <[email protected]>2018-04-17 20:57:36 +0200
commite7b2c125c3f3df43b032e398d900e2ac7f91398a (patch)
tree217fd4ba7c8916c0b911d22c81f27550cb8a9f6a
parent6e22ad6edc34dc07a08b41a781f1c37ff3c536e7 (diff)
nir/builder: Add a nir_imm_floatN_t helper
This lets you easily build float immediates just given the bit size. If we have this single place here to handle this then it will be easier to add support for 16-bit floats later. Reviewed-by: Jason Ekstrand <[email protected]>
-rw-r--r--src/compiler/nir/nir_builder.h13
1 files changed, 13 insertions, 0 deletions
diff --git a/src/compiler/nir/nir_builder.h b/src/compiler/nir/nir_builder.h
index d699b5ee1bf..02a9dbfb040 100644
--- a/src/compiler/nir/nir_builder.h
+++ b/src/compiler/nir/nir_builder.h
@@ -228,6 +228,19 @@ nir_imm_double(nir_builder *build, double x)
}
static inline nir_ssa_def *
+nir_imm_floatN_t(nir_builder *build, double x, unsigned bit_size)
+{
+ switch (bit_size) {
+ case 32:
+ return nir_imm_float(build, x);
+ case 64:
+ return nir_imm_double(build, x);
+ }
+
+ unreachable("unknown float immediate bit size");
+}
+
+static inline nir_ssa_def *
nir_imm_vec4(nir_builder *build, float x, float y, float z, float w)
{
nir_const_value v;