nir/spirv: pull out logic for getting builtin locations
[mesa.git] / src / glsl / lower_instructions.cpp
index 8f8303241e2a40e4233e040d1b01e6faac3351c7..845cfff36480c661726c0057e2bf58e28f054fde 100644 (file)
  * Converts double trunc, ceil, floor, round to fract
  */
 
-#include "main/core.h" /* for M_LOG2E */
+#include "c99_math.h"
 #include "program/prog_instruction.h" /* for swizzle */
 #include "glsl_types.h"
 #include "ir.h"
@@ -199,7 +199,7 @@ lower_instructions_visitor::sub_to_add_neg(ir_expression *ir)
 void
 lower_instructions_visitor::div_to_mul_rcp(ir_expression *ir)
 {
-   assert(ir->operands[1]->type->is_float());
+   assert(ir->operands[1]->type->is_float() || ir->operands[1]->type->is_double());
 
    /* New expression for the 1.0 / op1 */
    ir_rvalue *expr;
@@ -327,7 +327,7 @@ lower_instructions_visitor::mod_to_floor(ir_expression *ir)
    /* Don't generate new IR that would need to be lowered in an additional
     * pass.
     */
-   if (lowering(DIV_TO_MUL_RCP) && ir->type->is_float())
+   if (lowering(DIV_TO_MUL_RCP) && (ir->type->is_float() || ir->type->is_double()))
       div_to_mul_rcp(div_expr);
 
    ir_expression *const floor_expr =
@@ -645,7 +645,7 @@ lower_instructions_visitor::dfrexp_sig_to_arith(ir_expression *ir)
       new(ir) ir_variable(bvec, "is_not_zero", ir_var_temporary);
    ir_rvalue *results[4] = {NULL};
 
-   ir_constant *dzero = new(ir) ir_constant(0.0d, vec_elem);
+   ir_constant *dzero = new(ir) ir_constant(0.0, vec_elem);
    i.insert_before(is_not_zero);
    i.insert_before(
          assign(is_not_zero,
@@ -717,7 +717,7 @@ lower_instructions_visitor::dfrexp_exp_to_arith(ir_expression *ir)
       new(ir) ir_variable(bvec, "is_not_zero", ir_var_temporary);
    ir_variable *high_words =
       new(ir) ir_variable(uvec, "high_words", ir_var_temporary);
-   ir_constant *dzero = new(ir) ir_constant(0.0d, vec_elem);
+   ir_constant *dzero = new(ir) ir_constant(0.0, vec_elem);
    ir_constant *izero = new(ir) ir_constant(0, vec_elem);
 
    ir_rvalue *absval = abs(ir->operands[0]);
@@ -1014,7 +1014,8 @@ lower_instructions_visitor::visit_leave(ir_expression *ir)
    case ir_binop_div:
       if (ir->operands[1]->type->is_integer() && lowering(INT_DIV_TO_MUL_RCP))
         int_div_to_mul_rcp(ir);
-      else if (ir->operands[1]->type->is_float() && lowering(DIV_TO_MUL_RCP))
+      else if ((ir->operands[1]->type->is_float() ||
+                ir->operands[1]->type->is_double()) && lowering(DIV_TO_MUL_RCP))
         div_to_mul_rcp(ir);
       break;