i965/fs: Emit MADs from (x + -(y * z)).
[mesa.git] / src / glsl / ir.cpp
index 0ae9b899c0a9f3d39329a1d0c4d07d427d06312f..fe5601a16c7c0dc0f48be31b84443903be83320d 100644 (file)
@@ -46,11 +46,6 @@ bool ir_rvalue::is_negative_one() const
    return false;
 }
 
-bool ir_rvalue::is_basis() const
-{
-   return false;
-}
-
 /**
  * Modify the swizzle make to move one component to another
  *
@@ -1190,49 +1185,6 @@ ir_constant::is_negative_one() const
    return is_value(-1.0, -1);
 }
 
-bool
-ir_constant::is_basis() const
-{
-   if (!this->type->is_scalar() && !this->type->is_vector())
-      return false;
-
-   if (this->type->is_boolean())
-      return false;
-
-   unsigned ones = 0;
-   for (unsigned c = 0; c < this->type->vector_elements; c++) {
-      switch (this->type->base_type) {
-      case GLSL_TYPE_FLOAT:
-        if (this->value.f[c] == 1.0)
-           ones++;
-        else if (this->value.f[c] != 0.0)
-           return false;
-        break;
-      case GLSL_TYPE_INT:
-        if (this->value.i[c] == 1)
-           ones++;
-        else if (this->value.i[c] != 0)
-           return false;
-        break;
-      case GLSL_TYPE_UINT:
-        if (int(this->value.u[c]) == 1)
-           ones++;
-        else if (int(this->value.u[c]) != 0)
-           return false;
-        break;
-      default:
-        /* The only other base types are structures, arrays, samplers, and
-         * booleans.  Samplers cannot be constants, and the others should
-         * have been filtered out above.
-         */
-        assert(!"Should not get here.");
-        return false;
-      }
-   }
-
-   return ones == 1;
-}
-
 bool
 ir_constant::is_uint16_constant() const
 {
@@ -1543,12 +1495,35 @@ ir_swizzle::variable_referenced() const
 }
 
 
+bool ir_variable::temporaries_allocate_names = false;
+
+const char ir_variable::tmp_name[] = "compiler_temp";
+
 ir_variable::ir_variable(const struct glsl_type *type, const char *name,
                         ir_variable_mode mode)
    : ir_instruction(ir_type_variable)
 {
    this->type = type;
-   this->name = ralloc_strdup(this, name);
+
+   if (mode == ir_var_temporary && !ir_variable::temporaries_allocate_names)
+      name = NULL;
+
+   /* The ir_variable clone method may call this constructor with name set to
+    * tmp_name.
+    */
+   assert(name != NULL
+          || mode == ir_var_temporary
+          || mode == ir_var_function_in
+          || mode == ir_var_function_out
+          || mode == ir_var_function_inout);
+   assert(name != ir_variable::tmp_name
+          || mode == ir_var_temporary);
+   if (mode == ir_var_temporary
+       && (name == NULL || name == ir_variable::tmp_name)) {
+      this->name = ir_variable::tmp_name;
+   } else {
+      this->name = ralloc_strdup(this, name);
+   }
 
    this->u.max_ifc_array_access = NULL;