summaryrefslogtreecommitdiffstats
path: root/src/compiler
diff options
context:
space:
mode:
authorJason Ekstrand <[email protected]>2016-03-25 10:34:17 -0700
committerJason Ekstrand <[email protected]>2016-03-28 18:32:48 -0700
commit77e2ac1da731f10d823ed9f477cc6898039dcec4 (patch)
treedced271db57daed63d8dd7970cbf0617b7886c7a /src/compiler
parentda422663a6cacefcfae6be39154ab7598072cafa (diff)
nir/builder: Add a helper for building fdot instructions
Reviewed-by: Rob Clark <[email protected]>
Diffstat (limited to 'src/compiler')
-rw-r--r--src/compiler/nir/nir_builder.h17
1 files changed, 17 insertions, 0 deletions
diff --git a/src/compiler/nir/nir_builder.h b/src/compiler/nir/nir_builder.h
index b245f48c96d..4df79f58a7e 100644
--- a/src/compiler/nir/nir_builder.h
+++ b/src/compiler/nir/nir_builder.h
@@ -305,6 +305,23 @@ nir_swizzle(nir_builder *build, nir_ssa_def *src, unsigned swiz[4],
nir_imov_alu(build, alu_src, num_components);
}
+/* Selects the right fdot given the number of components in each source. */
+static inline nir_ssa_def *
+nir_fdot(nir_builder *build, nir_ssa_def *src0, nir_ssa_def *src1)
+{
+ assert(src0->num_components == src1->num_components);
+ switch (src0->num_components) {
+ case 1: return nir_fmul(build, src0, src1);
+ case 2: return nir_fdot2(build, src0, src1);
+ case 3: return nir_fdot3(build, src0, src1);
+ case 4: return nir_fdot4(build, src0, src1);
+ default:
+ unreachable("bad component size");
+ }
+
+ return NULL;
+}
+
static inline nir_ssa_def *
nir_channel(nir_builder *b, nir_ssa_def *def, unsigned c)
{