nir: Remove some unused fields from nir_variable
[mesa.git] / src / compiler / nir / nir_clone.c
index 7d2e3835258d241f5c1dfd94454924ccf738aa92..be89426b88dcab61a252d1650a0b32becdcdedb4 100644 (file)
@@ -114,7 +114,7 @@ nir_constant_clone(const nir_constant *c, nir_variable *nvar)
 {
    nir_constant *nc = ralloc(nvar, nir_constant);
 
-   nc->value = c->value;
+   memcpy(nc->values, c->values, sizeof(nc->values));
    nc->num_elements = c->num_elements;
    nc->elements = ralloc_array(nvar, nir_constant *, c->num_elements);
    for (unsigned i = 0; i < c->num_elements; i++) {
@@ -179,6 +179,7 @@ clone_register(clone_state *state, const nir_register *reg)
    add_remap(state, nreg, reg);
 
    nreg->num_components = reg->num_components;
+   nreg->bit_size = reg->bit_size;
    nreg->num_array_elems = reg->num_array_elems;
    nreg->index = reg->index;
    nreg->name = ralloc_strdup(nreg, reg->name);
@@ -359,7 +360,8 @@ static nir_load_const_instr *
 clone_load_const(clone_state *state, const nir_load_const_instr *lc)
 {
    nir_load_const_instr *nlc =
-      nir_load_const_instr_create(state->ns, lc->def.num_components);
+      nir_load_const_instr_create(state->ns, lc->def.num_components,
+                                  lc->def.bit_size);
 
    memcpy(&nlc->value, &lc->value, sizeof(nlc->value));
 
@@ -372,7 +374,8 @@ static nir_ssa_undef_instr *
 clone_ssa_undef(clone_state *state, const nir_ssa_undef_instr *sa)
 {
    nir_ssa_undef_instr *nsa =
-      nir_ssa_undef_instr_create(state->ns, sa->def.num_components);
+      nir_ssa_undef_instr_create(state->ns, sa->def.num_components,
+                                 sa->def.bit_size);
 
    add_remap(state, &nsa->def, &sa->def);
 
@@ -520,7 +523,7 @@ clone_block(clone_state *state, struct exec_list *cf_list, const nir_block *blk)
    /* We need this for phi sources */
    add_remap(state, nblk, blk);
 
-   nir_foreach_instr(blk, instr) {
+   nir_foreach_instr(instr, blk) {
       if (instr->type == nir_instr_type_phi) {
          /* Phi instructions are a bit of a special case when cloning because
           * we don't want inserting the instruction to automatically handle
@@ -679,7 +682,7 @@ nir_shader_clone(void *mem_ctx, const nir_shader *s)
    clone_state state;
    init_clone_state(&state, true);
 
-   nir_shader *ns = nir_shader_create(mem_ctx, s->stage, s->options);
+   nir_shader *ns = nir_shader_create(mem_ctx, s->stage, s->options, NULL);
    state.ns = ns;
 
    clone_var_list(&state, &ns->uniforms, &s->uniforms);
@@ -698,7 +701,7 @@ nir_shader_clone(void *mem_ctx, const nir_shader *s)
     * functions of other functions and we don't know what order the functions
     * will have in the list.
     */
-   nir_foreach_function(s, fxn) {
+   nir_foreach_function(fxn, s) {
       nir_function *nfxn = remap_global(&state, fxn);
       nfxn->impl = clone_function_impl(&state, fxn->impl);
       nfxn->impl->function = nfxn;
@@ -707,10 +710,10 @@ nir_shader_clone(void *mem_ctx, const nir_shader *s)
    clone_reg_list(&state, &ns->registers, &s->registers);
    ns->reg_alloc = s->reg_alloc;
 
-   ns->info = s->info;
-   ns->info.name = ralloc_strdup(ns, ns->info.name);
-   if (ns->info.label)
-      ns->info.label = ralloc_strdup(ns, ns->info.label);
+   *ns->info = *s->info;
+   ns->info->name = ralloc_strdup(ns, ns->info->name);
+   if (ns->info->label)
+      ns->info->label = ralloc_strdup(ns, ns->info->label);
 
    ns->num_inputs = s->num_inputs;
    ns->num_uniforms = s->num_uniforms;