nir: Make load_const SSA-only
authorJason Ekstrand <jason.ekstrand@intel.com>
Tue, 16 Dec 2014 01:32:56 +0000 (17:32 -0800)
committerJason Ekstrand <jason.ekstrand@intel.com>
Thu, 15 Jan 2015 15:20:22 +0000 (07:20 -0800)
As it was, we weren't ever using load_const in a non-SSA way.  This allows
us to substantially simplify the load_const instruction.  If we ever need a
non-SSA constant load, we can do a load_const and an imov.

Reviewed-by: Connor Abbott <cwabbott0@gmail.com>
16 files changed:
src/glsl/nir/glsl_to_nir.cpp
src/glsl/nir/nir.c
src/glsl/nir/nir.h
src/glsl/nir/nir_from_ssa.c
src/glsl/nir/nir_lower_atomics.c
src/glsl/nir/nir_lower_io.c
src/glsl/nir/nir_lower_locals_to_regs.c
src/glsl/nir/nir_lower_variables.c
src/glsl/nir/nir_opt_constant_folding.c
src/glsl/nir/nir_opt_cse.c
src/glsl/nir/nir_opt_dce.c
src/glsl/nir/nir_print.c
src/glsl/nir/nir_search.c
src/glsl/nir/nir_validate.c
src/mesa/drivers/dri/i965/brw_fs.h
src/mesa/drivers/dri/i965/brw_fs_nir.cpp

index 78070afe8e5017ceada4ea29d6468204c63ea060..d0737d01db16a3dc5581a0d193f37f834c7e41a8 100644 (file)
@@ -776,7 +776,6 @@ get_instr_dest(nir_instr *instr)
    nir_alu_instr *alu_instr;
    nir_intrinsic_instr *intrinsic_instr;
    nir_tex_instr *tex_instr;
-   nir_load_const_instr *load_const_instr;
 
    switch (instr->type) {
       case nir_instr_type_alu:
@@ -794,10 +793,6 @@ get_instr_dest(nir_instr *instr)
          tex_instr = nir_instr_as_tex(instr);
          return &tex_instr->dest;
 
-      case nir_instr_type_load_const:
-         load_const_instr = nir_instr_as_load_const(instr);
-         return &load_const_instr->dest;
-
       default:
          assert(0);
          break;
@@ -910,18 +905,15 @@ nir_visitor::visit(ir_expression *ir)
        */
 
       if (ir->type->base_type == GLSL_TYPE_BOOL) {
-         nir_load_const_instr *const_zero = nir_load_const_instr_create(shader);
-         const_zero->num_components = 1;
+         nir_load_const_instr *const_zero = nir_load_const_instr_create(shader, 1);
          const_zero->value.u[0] = 0;
-         const_zero->dest.is_ssa = true;
-         nir_ssa_def_init(&const_zero->instr, &const_zero->dest.ssa, 1, NULL);
          nir_instr_insert_after_cf_list(this->cf_node_list, &const_zero->instr);
 
          nir_alu_instr *compare = nir_alu_instr_create(shader, nir_op_ine);
          compare->src[0].src.is_ssa = true;
          compare->src[0].src.ssa = &load->dest.ssa;
          compare->src[1].src.is_ssa = true;
-         compare->src[1].src.ssa = &const_zero->dest.ssa;
+         compare->src[1].src.ssa = &const_zero->def;
          for (unsigned i = 0; i < ir->type->vector_elements; i++)
             compare->src[1].swizzle[i] = 0;
          compare->dest.write_mask = (1 << ir->type->vector_elements) - 1;
index a7bf82bd9b8b4e1eb72042007637e8cc949a66f6..10e6d0408b97f9a797a745a74592c695dc52b1db 100644 (file)
@@ -394,14 +394,12 @@ nir_jump_instr_create(void *mem_ctx, nir_jump_type type)
 }
 
 nir_load_const_instr *
-nir_load_const_instr_create(void *mem_ctx)
+nir_load_const_instr_create(void *mem_ctx, unsigned num_components)
 {
    nir_load_const_instr *instr = ralloc(mem_ctx, nir_load_const_instr);
    instr_init(&instr->instr, nir_instr_type_load_const);
 
-   dest_init(&instr->dest);
-   instr->num_components = 0;
-   instr->array_elems = 0;
+   nir_ssa_def_init(&instr->instr, &instr->def, num_components, NULL);
 
    return instr;
 }
@@ -1406,13 +1404,6 @@ visit_texture_dest(nir_tex_instr *instr, nir_foreach_dest_cb cb,
    return cb(&instr->dest, state);
 }
 
-static bool
-visit_load_const_dest(nir_load_const_instr *instr, nir_foreach_dest_cb cb,
-                      void *state)
-{
-   return cb(&instr->dest, state);
-}
-
 static bool
 visit_phi_dest(nir_phi_instr *instr, nir_foreach_dest_cb cb, void *state)
 {
@@ -1441,14 +1432,13 @@ nir_foreach_dest(nir_instr *instr, nir_foreach_dest_cb cb, void *state)
       return visit_intrinsic_dest(nir_instr_as_intrinsic(instr), cb, state);
    case nir_instr_type_tex:
       return visit_texture_dest(nir_instr_as_tex(instr), cb, state);
-   case nir_instr_type_load_const:
-      return visit_load_const_dest(nir_instr_as_load_const(instr), cb, state);
    case nir_instr_type_phi:
       return visit_phi_dest(nir_instr_as_phi(instr), cb, state);
    case nir_instr_type_parallel_copy:
       return visit_parallel_copy_dest(nir_instr_as_parallel_copy(instr),
                                       cb, state);
 
+   case nir_instr_type_load_const:
    case nir_instr_type_ssa_undef:
    case nir_instr_type_call:
    case nir_instr_type_jump:
@@ -1485,13 +1475,14 @@ nir_foreach_ssa_def(nir_instr *instr, nir_foreach_ssa_def_cb cb, void *state)
    case nir_instr_type_alu:
    case nir_instr_type_tex:
    case nir_instr_type_intrinsic:
-   case nir_instr_type_load_const:
    case nir_instr_type_phi:
    case nir_instr_type_parallel_copy: {
       struct foreach_ssa_def_state foreach_state = {cb, state};
       return nir_foreach_dest(instr, nir_ssa_def_visitor, &foreach_state);
    }
 
+   case nir_instr_type_load_const:
+      return cb(&nir_instr_as_load_const(instr)->def, state);
    case nir_instr_type_ssa_undef:
       return cb(&nir_instr_as_ssa_undef(instr)->def, state);
    case nir_instr_type_call:
@@ -1689,12 +1680,7 @@ nir_src_as_const_value(nir_src src)
 
    nir_load_const_instr *load = nir_instr_as_load_const(src.ssa->parent_instr);
 
-   if (load->array_elems == 0)
-      return &load->value;
-   if (load->array_elems == 1)
-      return load->array;
-   else
-      return NULL;
+   return &load->value;
 }
 
 bool
index b33d9c84909c9ddb85fcb58430ba0428c28ba5f2..8ff4087c2400d727f51c19969f83b24debf4fbfa 100644 (file)
@@ -918,22 +918,9 @@ typedef struct {
 typedef struct {
    nir_instr instr;
 
-   union {
-      nir_const_value value;
-      nir_const_value *array;
-   };
-
-   unsigned num_components;
-
-   /**
-    * The number of constant array elements to be copied into the variable. If
-    * this != 0, then value.array holds the array of size array_elems;
-    * otherwise, value.value holds the single vector constant (the more common
-    * case, and the only case for SSA destinations).
-    */
-   unsigned array_elems;
+   nir_const_value value;
 
-   nir_dest dest;
+   nir_ssa_def def;
 } nir_load_const_instr;
 
 typedef enum {
@@ -1280,7 +1267,8 @@ nir_alu_instr *nir_alu_instr_create(void *mem_ctx, nir_op op);
 
 nir_jump_instr *nir_jump_instr_create(void *mem_ctx, nir_jump_type type);
 
-nir_load_const_instr *nir_load_const_instr_create(void *mem_ctx);
+nir_load_const_instr *nir_load_const_instr_create(void *mem_ctx,
+                                                  unsigned num_components);
 
 nir_intrinsic_instr *nir_intrinsic_instr_create(void *mem_ctx,
                                                 nir_intrinsic_op op);
index d3295804b5a6e792c039e0fbc7449028aa682a9c..b644eb506a9698468d087db02b82245b93544615 100644 (file)
@@ -392,6 +392,12 @@ agressive_coalesce_parallel_copy(nir_parallel_copy_instr *pcopy,
       if (!copy->src.is_ssa)
          continue;
 
+      /* Since load_const instructions are SSA only, we can't replace their
+       * destinations with registers and, therefore, can't coalesce them.
+       */
+      if (copy->src.ssa->parent_instr->type == nir_instr_type_load_const)
+         continue;
+
       /* Don't try and coalesce these */
       if (copy->dest.ssa.num_components != copy->src.ssa->num_components)
          continue;
index 6362640226850c8c7c221511ca8b502209e8217b..874c5347634f4976ecce48a45b69a74da1180885 100644 (file)
@@ -63,15 +63,12 @@ lower_instr(nir_intrinsic_instr *instr, nir_function_impl *impl)
    new_instr->const_index[0] =
       (int) instr->variables[0]->var->data.atomic.buffer_index;
 
-   nir_load_const_instr *offset_const = nir_load_const_instr_create(mem_ctx);
-   offset_const->num_components = 1;
+   nir_load_const_instr *offset_const = nir_load_const_instr_create(mem_ctx, 1);
    offset_const->value.u[0] = instr->variables[0]->var->data.atomic.offset;
-   offset_const->dest.is_ssa = true;
-   nir_ssa_def_init(&offset_const->instr, &offset_const->dest.ssa, 1, NULL);
 
    nir_instr_insert_before(&instr->instr, &offset_const->instr);
 
-   nir_ssa_def *offset_def = &offset_const->dest.ssa;
+   nir_ssa_def *offset_def = &offset_const->def;
 
    if (instr->variables[0]->deref.child != NULL) {
       assert(instr->variables[0]->deref.child->deref_type ==
@@ -84,12 +81,8 @@ lower_instr(nir_intrinsic_instr *instr, nir_function_impl *impl)
 
       if (deref_array->deref_array_type == nir_deref_array_type_indirect) {
          nir_load_const_instr *atomic_counter_size =
-               nir_load_const_instr_create(mem_ctx);
-         atomic_counter_size->num_components = 1;
+               nir_load_const_instr_create(mem_ctx, 1);
          atomic_counter_size->value.u[0] = ATOMIC_COUNTER_SIZE;
-         atomic_counter_size->dest.is_ssa = true;
-         nir_ssa_def_init(&atomic_counter_size->instr,
-                          &atomic_counter_size->dest.ssa, 1, NULL);
          nir_instr_insert_before(&instr->instr, &atomic_counter_size->instr);
 
          nir_alu_instr *mul = nir_alu_instr_create(mem_ctx, nir_op_imul);
@@ -98,7 +91,7 @@ lower_instr(nir_intrinsic_instr *instr, nir_function_impl *impl)
          mul->dest.write_mask = 0x1;
          mul->src[0].src = nir_src_copy(deref_array->indirect, mem_ctx);
          mul->src[1].src.is_ssa = true;
-         mul->src[1].src.ssa = &atomic_counter_size->dest.ssa;
+         mul->src[1].src.ssa = &atomic_counter_size->def;
          nir_instr_insert_before(&instr->instr, &mul->instr);
 
          nir_alu_instr *add = nir_alu_instr_create(mem_ctx, nir_op_iadd);
@@ -108,7 +101,7 @@ lower_instr(nir_intrinsic_instr *instr, nir_function_impl *impl)
          add->src[0].src.is_ssa = true;
          add->src[0].src.ssa = &mul->dest.dest.ssa;
          add->src[1].src.is_ssa = true;
-         add->src[1].src.ssa = &offset_const->dest.ssa;
+         add->src[1].src.ssa = &offset_const->def;
          nir_instr_insert_before(&instr->instr, &add->instr);
 
          offset_def = &add->dest.dest.ssa;
index 91ad561fda5effb9e5fe02e6336e308e5c559254..af87c13e17a6a5d0a54ca7e0ee3cfb41ffc5e0f7 100644 (file)
@@ -140,18 +140,14 @@ get_io_offset(nir_deref_var *deref, nir_instr *instr, nir_src *indirect,
 
          if (deref_array->deref_array_type == nir_deref_array_type_indirect) {
             nir_load_const_instr *load_const =
-               nir_load_const_instr_create(state->mem_ctx);
-            load_const->num_components = 1;
+               nir_load_const_instr_create(state->mem_ctx, 1);
             load_const->value.u[0] = size;
-            load_const->dest.is_ssa = true;
-            nir_ssa_def_init(&load_const->instr, &load_const->dest.ssa,
-                             1, NULL);
             nir_instr_insert_before(instr, &load_const->instr);
 
             nir_alu_instr *mul = nir_alu_instr_create(state->mem_ctx,
                                                       nir_op_imul);
             mul->src[0].src.is_ssa = true;
-            mul->src[0].src.ssa = &load_const->dest.ssa;
+            mul->src[0].src.ssa = &load_const->def;
             mul->src[1].src = nir_src_copy(deref_array->indirect,
                                            state->mem_ctx);
             mul->dest.write_mask = 1;
index f0238b09dab086461910fe3f593569d0e5ac9ca5..443549c71b315332d1ce35d85e16d2e9f1ad43eb 100644 (file)
@@ -162,17 +162,14 @@ get_deref_reg_src(nir_deref_var *deref, nir_instr *instr,
 
       if (src.reg.indirect) {
          nir_load_const_instr *load_const =
-            nir_load_const_instr_create(state->mem_ctx);
-         load_const->num_components = 1;
+            nir_load_const_instr_create(state->mem_ctx, 1);
          load_const->value.u[0] = glsl_get_length(parent_type);
-         load_const->dest.is_ssa = true;
-         nir_ssa_def_init(&load_const->instr, &load_const->dest.ssa, 1, NULL);
          nir_instr_insert_before(instr, &load_const->instr);
 
          nir_alu_instr *mul = nir_alu_instr_create(state->mem_ctx, nir_op_imul);
          mul->src[0].src = *src.reg.indirect;
          mul->src[1].src.is_ssa = true;
-         mul->src[1].src.ssa = &load_const->dest.ssa;
+         mul->src[1].src.ssa = &load_const->def;
          mul->dest.write_mask = 1;
          mul->dest.dest.is_ssa = true;
          nir_ssa_def_init(&mul->instr, &mul->dest.dest.ssa, 1, NULL);
index e3d5cde321d6dd4dfe07cd16e3674e768d948d31..ac3b197d8e700f9012e3ecd56da04975c45f57c7 100644 (file)
@@ -621,12 +621,12 @@ get_const_initializer_load(const nir_deref_var *deref,
       tail = tail->child;
    }
 
-   nir_load_const_instr *load = nir_load_const_instr_create(state->mem_ctx);
-   load->array_elems = 0;
-   load->num_components = glsl_get_vector_elements(tail->type);
+   nir_load_const_instr *load =
+      nir_load_const_instr_create(state->mem_ctx,
+                                  glsl_get_vector_elements(tail->type));
 
-   matrix_offset *= load->num_components;
-   for (unsigned i = 0; i < load->num_components; i++) {
+   matrix_offset *= load->def.num_components;
+   for (unsigned i = 0; i < load->def.num_components; i++) {
       switch (glsl_get_base_type(tail->type)) {
       case GLSL_TYPE_FLOAT:
       case GLSL_TYPE_INT:
@@ -977,11 +977,10 @@ nir_lower_variables_impl(nir_function_impl *impl)
 
       if (deref->var->constant_initializer) {
          nir_load_const_instr *load = get_const_initializer_load(deref, &state);
-         load->dest.is_ssa = true;
-         nir_ssa_def_init(&load->instr, &load->dest.ssa,
+         nir_ssa_def_init(&load->instr, &load->def,
                           glsl_get_vector_elements(node->type), NULL);
          nir_instr_insert_before_cf_list(&impl->body, &load->instr);
-         def_stack_push(node, &load->dest.ssa, &state);
+         def_stack_push(node, &load->def, &state);
       }
 
       if (deref->var->data.mode == nir_var_shader_out)
index 3160a3fffb3e841e611383da0fd6ec8e2af87983..6c02582ed01ef0da0e52a9777276e288c50cb64f 100644 (file)
@@ -72,9 +72,8 @@ constant_fold_alu_instr(nir_alu_instr *instr, void *mem_ctx)
    /* We shouldn't have any saturate modifiers in the optimization loop. */
    assert(!instr->dest.saturate);
 
-   dest = nir_load_const_instr_create(mem_ctx);
-   dest->array_elems = 0;
-   dest->num_components = instr->dest.dest.ssa.num_components;
+   dest = nir_load_const_instr_create(mem_ctx,
+                                      instr->dest.dest.ssa.num_components);
 
    switch (instr->op) {
    case nir_op_ineg:
@@ -215,16 +214,11 @@ constant_fold_alu_instr(nir_alu_instr *instr, void *mem_ctx)
       return false;
    }
 
-   dest->dest.is_ssa = true;
-   nir_ssa_def_init(&dest->instr, &dest->dest.ssa,
-                    instr->dest.dest.ssa.num_components,
-                    instr->dest.dest.ssa.name);
-
    nir_instr_insert_before(&instr->instr, &dest->instr);
 
    nir_src new_src = {
       .is_ssa = true,
-      .ssa = &dest->dest.ssa,
+      .ssa = &dest->def,
    };
 
    nir_ssa_def_rewrite_uses(&instr->dest.dest.ssa, new_src, mem_ctx);
index 0ad575c19c10df15ab704c65035e4e3784bc0f10..e7dba1d45813a99f41d426a008e8d875d5796d7f 100644 (file)
@@ -86,11 +86,11 @@ nir_instrs_equal(nir_instr *instr1, nir_instr *instr2)
       nir_load_const_instr *load1 = nir_instr_as_load_const(instr1);
       nir_load_const_instr *load2 = nir_instr_as_load_const(instr2);
 
-      if (load1->num_components != load2->num_components)
+      if (load1->def.num_components != load2->def.num_components)
          return false;
 
       return memcmp(load1->value.f, load2->value.f,
-                    load1->num_components * sizeof load2->value.f) == 0;
+                    load1->def.num_components * sizeof load2->value.f) == 0;
    }
    case nir_instr_type_phi: {
       nir_phi_instr *phi1 = nir_instr_as_phi(instr1);
@@ -168,8 +168,7 @@ nir_instr_get_dest_ssa_def(nir_instr *instr)
       assert(nir_instr_as_alu(instr)->dest.dest.is_ssa);
       return &nir_instr_as_alu(instr)->dest.dest.ssa;
    case nir_instr_type_load_const:
-      assert(nir_instr_as_load_const(instr)->dest.is_ssa);
-      return &nir_instr_as_load_const(instr)->dest.ssa;
+      return &nir_instr_as_load_const(instr)->def;
    case nir_instr_type_phi:
       assert(nir_instr_as_phi(instr)->dest.is_ssa);
       return &nir_instr_as_phi(instr)->dest.ssa;
index 8a7490dc3e08ee19edff0299c7fdcebd02316d7e..9778e9ed6a6a36f9364caf12c953b01ce0925d3c 100644 (file)
@@ -69,7 +69,6 @@ init_instr(nir_instr *instr, struct exec_list *worklist)
    nir_alu_instr *alu_instr;
    nir_intrinsic_instr *intrin_instr;
    nir_tex_instr *tex_instr;
-   nir_load_const_instr *load_const_instr;
 
    instr->live = false;
 
@@ -104,12 +103,6 @@ init_instr(nir_instr *instr, struct exec_list *worklist)
          worklist_push(worklist, instr);
       break;
 
-   case nir_instr_type_load_const:
-      load_const_instr = nir_instr_as_load_const(instr);
-      if (!load_const_instr->dest.is_ssa)
-         worklist_push(worklist, instr);
-      break;
-
    default:
       break;
    }
index 7d60eb11ee8558c35ffff45a6923d1bb253b0201..d7fc4b8722e6bd0fd298020be153bdef395ce7ae 100644 (file)
@@ -505,12 +505,14 @@ print_call_instr(nir_call_instr *instr, print_var_state *state, FILE *fp)
 }
 
 static void
-print_const_value(nir_const_value value, unsigned num_components, FILE *fp)
+print_load_const_instr(nir_load_const_instr *instr, unsigned tabs, FILE *fp)
 {
-   fprintf(fp, "(");
+   print_ssa_def(&instr->def, fp);
+
+   fprintf(fp, " = load_const (");
 
    bool first = true;
-   for (unsigned i = 0; i < num_components; i++) {
+   for (unsigned i = 0; i < instr->def.num_components; i++) {
       if (!first)
          fprintf(fp, ", ");
 
@@ -520,32 +522,10 @@ print_const_value(nir_const_value value, unsigned num_components, FILE *fp)
        * and then print the float in a comment for readability.
        */
 
-      fprintf(fp, "0x%08x /* %f */", value.u[i], value.f[i]);
+      fprintf(fp, "0x%08x /* %f */", instr->value.u[i], instr->value.f[i]);
 
       first = false;
    }
-
-   fprintf(fp, ")");
-}
-
-static void
-print_load_const_instr(nir_load_const_instr *instr, unsigned tabs, FILE *fp)
-{
-   print_dest(&instr->dest, fp);
-
-   fprintf(fp, " = load_const ");
-
-   if (instr->array_elems == 0) {
-      print_const_value(instr->value, instr->num_components, fp);
-   } else {
-      fprintf(fp, "{\n");
-      for (unsigned i = 0; i < instr->array_elems; i++) {
-         print_tabs(tabs + 1, fp);
-         print_const_value(instr->array[i], instr->num_components, fp);
-         fprintf(fp, ", \n");
-      }
-      fprintf(fp, "}");
-   }
 }
 
 static void
index 3930795a041c05e6dd8489167cfe8129bce619c1..f2797b2f5b6f998e09cc4124505d02050fcd261e 100644 (file)
@@ -275,17 +275,15 @@ construct_value(const nir_search_value *value, nir_alu_type type,
 
    case nir_search_value_constant: {
       const nir_search_constant *c = nir_search_value_as_constant(value);
-      nir_load_const_instr *load = nir_load_const_instr_create(mem_ctx);
-      load->dest.is_ssa = true;
-      nir_ssa_def_init(&load->instr, &load->dest.ssa, 1, NULL);
+      nir_load_const_instr *load = nir_load_const_instr_create(mem_ctx, 1);
 
       switch (type) {
       case nir_type_float:
-         load->dest.ssa.name = ralloc_asprintf(mem_ctx, "%f", c->data.f);
+         load->def.name = ralloc_asprintf(mem_ctx, "%f", c->data.f);
          load->value.f[0] = c->data.f;
          break;
       case nir_type_int:
-         load->dest.ssa.name = ralloc_asprintf(mem_ctx, "%d", c->data.i);
+         load->def.name = ralloc_asprintf(mem_ctx, "%d", c->data.i);
          load->value.i[0] = c->data.i;
          break;
       case nir_type_unsigned:
@@ -300,7 +298,7 @@ construct_value(const nir_search_value *value, nir_alu_type type,
 
       nir_alu_src val = {
          .src.is_ssa = true,
-         .src.ssa = &load->dest.ssa,
+         .src.ssa = &load->def,
          .negate = false,
          .abs = false,
          .swizzle = { 0, 0, 0, 0 } /* Splatted scalar */
index f0eb87fd3936a58ae20251ee00ba65804613d2fb..240da02a715f1f8081feaa3e31a266448af7043b 100644 (file)
@@ -411,13 +411,7 @@ validate_call_instr(nir_call_instr *instr, validate_state *state)
 static void
 validate_load_const_instr(nir_load_const_instr *instr, validate_state *state)
 {
-   validate_dest(&instr->dest, state);
-
-   if (instr->array_elems != 0) {
-      assert(!instr->dest.is_ssa);
-      assert(instr->dest.reg.base_offset + instr->array_elems <=
-             instr->dest.reg.reg->num_array_elems);
-   }
+   validate_ssa_def(&instr->def, state);
 }
 
 static void
index e589c9646b5b4be8795aec2aa60c08bb213f07b2..ad3d9866d53f9537087e33f6d431dba106ff43d8 100644 (file)
@@ -583,7 +583,6 @@ public:
    void nir_emit_alu(nir_alu_instr *instr);
    void nir_emit_intrinsic(nir_intrinsic_instr *instr);
    void nir_emit_texture(nir_tex_instr *instr);
-   void nir_emit_load_const(nir_load_const_instr *instr);
    void nir_emit_jump(nir_jump_instr *instr);
    fs_reg get_nir_src(nir_src src);
    fs_reg get_nir_alu_src(nir_alu_instr *instr, unsigned src);
index c218b722f8d1be95193e38a4cb3ba442eae0cfc9..4c08cfdb6ade9526dfb7f4b48e7b3e8c90b6e4b1 100644 (file)
@@ -392,7 +392,9 @@ fs_visitor::nir_emit_instr(nir_instr *instr)
       break;
 
    case nir_instr_type_load_const:
-      nir_emit_load_const(nir_instr_as_load_const(instr));
+      /* We can hit these, but we do nothing now and use them as
+       * immediates later.
+       */
       break;
 
    case nir_instr_type_jump:
@@ -1701,30 +1703,6 @@ fs_visitor::nir_emit_texture(nir_tex_instr *instr)
    emit_percomp(MOV(dest, this->result), (1 << num_components) - 1);
 }
 
-void
-fs_visitor::nir_emit_load_const(nir_load_const_instr *instr)
-{
-   /* Bail on SSA constant loads.  These are used for immediates. */
-   if (instr->dest.is_ssa)
-      return;
-
-   fs_reg dest = get_nir_dest(instr->dest);
-   dest.type = BRW_REGISTER_TYPE_UD;
-   if (instr->array_elems == 0) {
-      for (unsigned i = 0; i < instr->num_components; i++) {
-         emit(MOV(dest, fs_reg(instr->value.u[i])));
-         dest.reg_offset++;
-      }
-   } else {
-      for (unsigned i = 0; i < instr->array_elems; i++) {
-         for (unsigned j = 0; j < instr->num_components; j++) {
-            emit(MOV(dest, fs_reg(instr->array[i].u[j])));
-            dest.reg_offset++;
-         }
-      }
-   }
-}
-
 void
 fs_visitor::nir_emit_jump(nir_jump_instr *instr)
 {