-static void
-add_var_use_intrinsic(nir_intrinsic_instr *instr, struct set *live,
- nir_variable_mode modes)
-{
- unsigned num_vars = nir_intrinsic_infos[instr->intrinsic].num_variables;
-
- switch (instr->intrinsic) {
- case nir_intrinsic_copy_var:
- _mesa_set_add(live, instr->variables[1]->var);
- /* Fall through */
- case nir_intrinsic_store_var: {
- /* The first source in both copy_var and store_var is the destination.
- * If the variable is a local that never escapes the shader, then we
- * don't mark it as live for just a store.
- */
- nir_variable_mode mode = instr->variables[0]->var->data.mode;
- if (!(mode & (nir_var_local | nir_var_global | nir_var_shared)))
- _mesa_set_add(live, instr->variables[0]->var);
- break;
- }
-
- /* This pass can't be used on I/O variables after they've been lowered. */
- case nir_intrinsic_load_input:
- assert(!(modes & nir_var_shader_in));
- break;
- case nir_intrinsic_store_output:
- assert(!(modes & nir_var_shader_out));
- break;
-
- default:
- for (unsigned i = 0; i < num_vars; i++) {
- _mesa_set_add(live, instr->variables[i]->var);
- }
- break;
- }
-}
-
-static void
-add_var_use_call(nir_call_instr *instr, struct set *live)
-{
- if (instr->return_deref != NULL) {
- nir_variable *var = instr->return_deref->var;
- _mesa_set_add(live, var);
- }
-
- for (unsigned i = 0; i < instr->num_params; i++) {
- nir_variable *var = instr->params[i]->var;
- _mesa_set_add(live, var);
- }
-}
-
-static void
-add_var_use_tex(nir_tex_instr *instr, struct set *live)
-{
- if (instr->texture != NULL) {
- nir_variable *var = instr->texture->var;
- _mesa_set_add(live, var);
- }
-
- if (instr->sampler != NULL) {
- nir_variable *var = instr->sampler->var;
- _mesa_set_add(live, var);
- }
-}
-