nir: Add an "exact" bit to nir_alu_instr
authorJason Ekstrand <jason.ekstrand@intel.com>
Thu, 17 Mar 2016 17:50:27 +0000 (10:50 -0700)
committerJason Ekstrand <jason.ekstrand@intel.com>
Wed, 23 Mar 2016 23:26:34 +0000 (16:26 -0700)
Reviewed-by: Francisco Jerez <currojerez@riseup.net>
src/compiler/nir/nir.h
src/compiler/nir/nir_clone.c
src/compiler/nir/nir_print.c

index 02acbfc9d732718374e577ad0436cf82f89ae4f8..76a511c2d4f3985cc25a6ff3de0a5bc396e5a2d9 100644 (file)
@@ -718,6 +718,17 @@ extern const nir_op_info nir_op_infos[nir_num_opcodes];
 typedef struct nir_alu_instr {
    nir_instr instr;
    nir_op op;
+
+   /** Indicates that this ALU instruction generates an exact value
+    *
+    * This is kind of a mixture of GLSL "precise" and "invariant" and not
+    * really equivalent to either.  This indicates that the value generated by
+    * this operation is high-precision and any code transformations that touch
+    * it must ensure that the resulting value is bit-for-bit identical to the
+    * original.
+    */
+   bool exact;
+
    nir_alu_dest dest;
    nir_alu_src src[];
 } nir_alu_instr;
index a721552f6a62a0faee8aca1ae99054fd85a2d334..7d2e3835258d241f5c1dfd94454924ccf738aa92 100644 (file)
@@ -312,6 +312,7 @@ static nir_alu_instr *
 clone_alu(clone_state *state, const nir_alu_instr *alu)
 {
    nir_alu_instr *nalu = nir_alu_instr_create(state->ns, alu->op);
+   nalu->exact = alu->exact;
 
    __clone_dst(state, &nalu->instr, &nalu->dest.dest, &alu->dest.dest);
    nalu->dest.saturate = alu->dest.saturate;
index d3d5b84a0243368198b3d2f2e7b203ebec712b4c..c295c192c2a02e0fb30eb256ec5cb57a8a4db25b 100644 (file)
@@ -207,6 +207,8 @@ print_alu_instr(nir_alu_instr *instr, print_state *state)
    print_alu_dest(&instr->dest, state);
 
    fprintf(fp, " = %s", nir_op_infos[instr->op].name);
+   if (instr->exact)
+      fprintf(fp, "!");
    if (instr->dest.saturate)
       fprintf(fp, ".sat");
    fprintf(fp, " ");