aboutsummaryrefslogtreecommitdiff
path: root/mesalib/src/glsl/lower_instructions.cpp
diff options
context:
space:
mode:
authormarha <marha@users.sourceforge.net>2014-05-11 17:43:25 +0200
committermarha <marha@users.sourceforge.net>2014-05-11 17:43:25 +0200
commit26dfcdba6c306d6312c598e4191449302329be68 (patch)
tree2bf56b5a0eb2cc554833fdc6e08f2b59f1bfdabd /mesalib/src/glsl/lower_instructions.cpp
parent2dc2880eacae3d52f4ab4bb5ec43c5bbf50c5c3f (diff)
parentae06feae7876db47ff0e1fde40cf4a324a412037 (diff)
downloadvcxsrv-26dfcdba6c306d6312c598e4191449302329be68.tar.gz
vcxsrv-26dfcdba6c306d6312c598e4191449302329be68.tar.bz2
vcxsrv-26dfcdba6c306d6312c598e4191449302329be68.zip
Merge remote-tracking branch 'origin/released'
Conflicts: mesalib/src/mesa/main/imports.h
Diffstat (limited to 'mesalib/src/glsl/lower_instructions.cpp')
-rw-r--r--mesalib/src/glsl/lower_instructions.cpp58
1 files changed, 58 insertions, 0 deletions
diff --git a/mesalib/src/glsl/lower_instructions.cpp b/mesalib/src/glsl/lower_instructions.cpp
index 49316d002..176070c87 100644
--- a/mesalib/src/glsl/lower_instructions.cpp
+++ b/mesalib/src/glsl/lower_instructions.cpp
@@ -39,6 +39,8 @@
* - MOD_TO_FRACT
* - LDEXP_TO_ARITH
* - BITFIELD_INSERT_TO_BFM_BFI
+ * - CARRY_TO_ARITH
+ * - BORROW_TO_ARITH
*
* SUB_TO_ADD_NEG:
* ---------------
@@ -94,6 +96,14 @@
* Many GPUs implement the bitfieldInsert() built-in from ARB_gpu_shader_5
* with a pair of instructions.
*
+ * CARRY_TO_ARITH:
+ * ---------------
+ * Converts ir_carry into (x + y) < x.
+ *
+ * BORROW_TO_ARITH:
+ * ----------------
+ * Converts ir_borrow into (x < y).
+ *
*/
#include "main/core.h" /* for M_LOG2E */
@@ -127,6 +137,8 @@ private:
void log_to_log2(ir_expression *);
void bitfield_insert_to_bfm_bfi(ir_expression *);
void ldexp_to_arith(ir_expression *);
+ void carry_to_arith(ir_expression *);
+ void borrow_to_arith(ir_expression *);
};
} /* anonymous namespace */
@@ -436,6 +448,42 @@ lower_instructions_visitor::ldexp_to_arith(ir_expression *ir)
this->progress = true;
}
+void
+lower_instructions_visitor::carry_to_arith(ir_expression *ir)
+{
+ /* Translates
+ * ir_binop_carry x y
+ * into
+ * sum = ir_binop_add x y
+ * bcarry = ir_binop_less sum x
+ * carry = ir_unop_b2i bcarry
+ */
+
+ ir_rvalue *x_clone = ir->operands[0]->clone(ir, NULL);
+ ir->operation = ir_unop_i2u;
+ ir->operands[0] = b2i(less(add(ir->operands[0], ir->operands[1]), x_clone));
+ ir->operands[1] = NULL;
+
+ this->progress = true;
+}
+
+void
+lower_instructions_visitor::borrow_to_arith(ir_expression *ir)
+{
+ /* Translates
+ * ir_binop_borrow x y
+ * into
+ * bcarry = ir_binop_less x y
+ * carry = ir_unop_b2i bcarry
+ */
+
+ ir->operation = ir_unop_i2u;
+ ir->operands[0] = b2i(less(ir->operands[0], ir->operands[1]));
+ ir->operands[1] = NULL;
+
+ this->progress = true;
+}
+
ir_visitor_status
lower_instructions_visitor::visit_leave(ir_expression *ir)
{
@@ -482,6 +530,16 @@ lower_instructions_visitor::visit_leave(ir_expression *ir)
ldexp_to_arith(ir);
break;
+ case ir_binop_carry:
+ if (lowering(CARRY_TO_ARITH))
+ carry_to_arith(ir);
+ break;
+
+ case ir_binop_borrow:
+ if (lowering(BORROW_TO_ARITH))
+ borrow_to_arith(ir);
+ break;
+
default:
return visit_continue;
}