nir: add i2d and u2d opcodes
authorIago Toral Quiroga <itoral@igalia.com>
Tue, 12 Jan 2016 13:03:08 +0000 (14:03 +0100)
committerSamuel Iglesias Gonsálvez <siglesias@igalia.com>
Mon, 11 Apr 2016 06:29:27 +0000 (08:29 +0200)
v2:
- Assert supports_int and don't fallback to nir_fmov (Jason)

Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
src/compiler/nir/glsl_to_nir.cpp
src/compiler/nir/nir_opcodes.py

index 6428b95965fa875fb3f991cacb745435edaa9a8a..0c5cc99981bc2e8152ec211d3903cca5e3a09a81 100644 (file)
@@ -1361,6 +1361,14 @@ nir_visitor::visit(ir_expression *ir)
    case ir_unop_d2i:  result = nir_d2i(&b, srcs[0]);   break;
    case ir_unop_d2u:  result = nir_d2u(&b, srcs[0]);   break;
    case ir_unop_d2b:  result = nir_d2b(&b, srcs[0]);   break;
+   case ir_unop_i2d:
+      assert(supports_ints);
+      result = nir_i2d(&b, srcs[0]);
+      break;
+   case ir_unop_u2d:
+      assert(supports_ints);
+      result = nir_u2d(&b, srcs[0]);
+      break;
    case ir_unop_i2u:
    case ir_unop_u2i:
    case ir_unop_bitcast_i2f:
index 0898abcedfd780d1dfbc2f136e6103179d04660c..f1f12f72bdda53796b39c32ed2666aad481d7138 100644 (file)
@@ -164,6 +164,7 @@ unop_convert("f2u", tuint32, tfloat32, "src0") # Float-to-unsigned conversion
 unop_convert("d2i", tint32, tfloat64, "src0") # Double-to-integer conversion.
 unop_convert("d2u", tuint32, tfloat64, "src0") # Double-to-unsigned conversion.
 unop_convert("i2f", tfloat32, tint32, "src0") # Integer-to-float conversion.
+unop_convert("i2d", tfloat64, tint32, "src0") # Integer-to-double conversion.
 # Float-to-boolean conversion
 unop_convert("f2b", tbool, tfloat32, "src0 != 0.0f")
 unop_convert("d2b", tbool, tfloat64, "src0 != 0.0")
@@ -173,6 +174,7 @@ unop_convert("b2f", tfloat32, tbool, "src0 ? 1.0f : 0.0f")
 unop_convert("i2b", tbool, tint32, "src0 != 0")
 unop_convert("b2i", tint32, tbool, "src0 ? 1 : 0") # Boolean-to-int conversion
 unop_convert("u2f", tfloat32, tuint32, "src0") # Unsigned-to-float conversion.
+unop_convert("u2d", tfloat64, tuint32, "src0") # Unsigned-to-double conversion.
 # double-to-float conversion
 unop_convert("d2f", tfloat32, tfloat64, "src0") # Single to double precision
 unop_convert("f2d", tfloat64, tfloat32, "src0") # Double to single precision