nir_foreach_instr(instr, block) { if (instr->type != nir_instr_type_intrinsic) continue; nir_intrinsic_instr *intrin = nir_instr_as_intrinsic(instr); if (intrin->intrinsic != nir_intrinsic_load_deref && intrin->intrinsic != nir_intrinsic_store_deref) continue; nir_deref_instr *deref = nir_src_as_deref(intrin->src[0]); if (!(deref->mode & modes)) continue; if (!deref_has_indirect(nir_src_as_deref(intrin->src[0]))) continue; nir_variable *var = nir_deref_instr_get_variable(deref); /* We set var->mode to 0 to indicate that a variable will be moved * to scratch. Don't assign a scratch location twice. */ if (var->data.mode == 0) continue; unsigned var_size, var_align; size_align(var->type, &var_size, &var_align); if (var_size <= size_threshold) continue; /* Remove it from its list */ exec_node_remove(&var->node); /* Invalid mode used to flag "moving to scratch" */ var->data.mode = 0; var->data.location = ALIGN_POT(shader->scratch_size, var_align); shader->scratch_size = var->data.location + var_size; }
/** * \brief Remove and free an element from the map. */ void intel_resolve_map_remove(struct intel_resolve_map *elem) { exec_node_remove(&elem->link); free(elem); }