Add bool/int conversion as IR operations.
authorEric Anholt <eric@anholt.net>
Fri, 2 Apr 2010 12:17:08 +0000 (02:17 -1000)
committerIan Romanick <ian.d.romanick@intel.com>
Fri, 2 Apr 2010 18:22:41 +0000 (11:22 -0700)
Fixes constructor-09.glsl and CorrectParse2.frag.

ast_function.cpp
ir.cpp
ir.h
ir_print_visitor.cpp

index 2ca8976d50828f108e024d56f5bcfb1c5d2c7eb9..09b7879185bfd6a461bd4cf82963dc79aff3bae4 100644 (file)
@@ -130,7 +130,7 @@ convert_component(ir_rvalue *src, const glsl_type *desired_type)
         return new ir_expression(ir_unop_f2i, desired_type, src, NULL);
       else {
         assert(b == GLSL_TYPE_BOOL);
-        assert(!"FINISHME: Convert bool to int / uint.");
+        return new ir_expression(ir_unop_f2b, desired_type, src, NULL);
       }
    case GLSL_TYPE_FLOAT:
       switch (b) {
diff --git a/ir.cpp b/ir.cpp
index 674ba10f57e34519395992e59500b252809d4b3a..dd426df566ab074dd25e320542cd4480d4cfb45b 100644 (file)
--- a/ir.cpp
+++ b/ir.cpp
@@ -66,6 +66,8 @@ ir_expression::get_num_operands(void)
       1, /* ir_unop_i2f */
       1, /* ir_unop_f2b */
       1, /* ir_unop_b2f */
+      1, /* ir_unop_i2b */
+      1, /* ir_unop_b2i */
       1, /* ir_unop_u2f */
 
       1, /* ir_unop_trunc */
diff --git a/ir.h b/ir.h
index 58aa63123b413a9401907f85cd05e5f877ef8acd..3caff3624aea1cd27a1da72b96276f78aa67d475 100644 (file)
--- a/ir.h
+++ b/ir.h
@@ -318,6 +318,8 @@ enum ir_expression_operation {
    ir_unop_i2f,      /**< Integer-to-float conversion. */
    ir_unop_f2b,      /**< Float-to-boolean conversion */
    ir_unop_b2f,      /**< Boolean-to-float conversion */
+   ir_unop_i2b,      /**< int-to-boolean conversion */
+   ir_unop_b2i,      /**< Boolean-to-int conversion */
    ir_unop_u2f,      /**< Unsigned-to-float conversion. */
 
    /**
index e3aeb69a1e999bb2cc31179eecfca835644b2496..e1fedd78a9303677720ed4f6e2d6e79636c54b3f 100644 (file)
@@ -102,6 +102,8 @@ void ir_print_visitor::visit(ir_expression *ir)
       "i2f",
       "f2b",
       "b2f",
+      "i2b",
+      "b2i",
       "u2f",
       "trunc",
       "ceil",