Lines Matching refs:deref

31                     nir_deref_instr *deref, void *mem_ctx)
33 assert(deref != NULL);
46 for (nir_deref_instr *d = deref; d; d = nir_deref_instr_parent(d)) {
67 for (nir_deref_instr *d = deref; d; d = nir_deref_instr_parent(d))
85 * Recursively removes unused deref instructions
93 /* If anyone is using this deref, leave it alone */
125 nir_deref_instr_ptr_as_array_stride(nir_deref_instr *deref)
127 switch (deref->deref_type) {
129 return glsl_get_explicit_stride(nir_deref_instr_parent(deref)->type);
131 return nir_deref_instr_ptr_as_array_stride(nir_deref_instr_parent(deref));
133 return deref->cast.ptr_stride;
166 nir_deref_instr_get_const_offset(nir_deref_instr *deref,
170 nir_deref_path_init(&path, deref, NULL);
185 unreachable("Unsupported deref type");
195 nir_build_deref_offset(nir_builder *b, nir_deref_instr *deref,
199 nir_deref_path_init(&path, deref, NULL);
217 unreachable("Unsupported deref type");
270 nir_deref_instr *deref = nir_instr_as_deref(instr);
271 if (deref->deref_type == nir_deref_type_cast)
275 if (deref->deref_type == nir_deref_type_var) {
276 parent_mode = deref->var->data.mode;
278 assert(deref->parent.is_ssa);
280 nir_instr_as_deref(deref->parent.ssa->parent_instr);
284 deref->mode = parent_mode;
360 /* If we can chase the deref all the way back to the variable and
371 * just assume nit_opt_deref will combine them and compare the deref
397 /* We're at either the tail or the divergence point between the two deref
398 * paths. Look to see if either contains a ptr_as_array deref. It it
404 * case where we have exactly one ptr_as_array deref in the chain after the
466 unreachable("Invalid deref type");
515 rematerialize_deref_in_block(nir_deref_instr *deref,
518 if (deref->instr.block == state->block)
519 return deref;
525 struct hash_entry *cached = _mesa_hash_table_search(state->cache, deref);
531 nir_deref_instr_create(b->shader, deref->deref_type);
532 new_deref->mode = deref->mode;
533 new_deref->type = deref->type;
535 if (deref->deref_type == nir_deref_type_var) {
536 new_deref->var = deref->var;
538 nir_deref_instr *parent = nir_src_as_deref(deref->parent);
543 nir_src_copy(&new_deref->parent, &deref->parent, new_deref);
547 switch (deref->deref_type) {
555 assert(!nir_src_as_deref(deref->arr.index));
556 nir_src_copy(&new_deref->arr.index, &deref->arr.index, new_deref);
560 new_deref->strct.index = deref->strct.index;
564 unreachable("Invalid deref instruction type");
568 deref->dest.ssa.num_components,
569 deref->dest.ssa.bit_size,
570 deref->dest.ssa.name);
581 nir_deref_instr *deref = nir_src_as_deref(*src);
582 if (!deref)
585 nir_deref_instr *block_deref = rematerialize_deref_in_block(deref, state);
586 if (block_deref != deref) {
589 nir_deref_instr_remove_if_unused(deref);
598 * This pass re-materializes deref instructions in every block in which it is
599 * used. After this pass has been run, every use of a deref will be of a
600 * deref in the same block as the use. Also, all unused derefs will be
765 opt_deref_ptr_as_array(nir_builder *b, nir_deref_instr *deref)
767 assert(deref->deref_type == nir_deref_type_ptr_as_array);
769 nir_deref_instr *parent = nir_deref_instr_parent(deref);
771 if (nir_src_is_const(deref->arr.index) &&
772 nir_src_as_int(deref->arr.index) == 0) {
773 /* If it's a ptr_as_array deref with an index of 0, it does nothing
776 * The source of a ptr_as_array deref always has a deref_type of
785 nir_ssa_def_rewrite_uses(&deref->dest.ssa,
787 nir_instr_remove(&deref->instr);
797 assert(deref->arr.index.is_ssa);
800 deref->arr.index.ssa);
802 deref->deref_type = parent->deref_type;
803 nir_instr_rewrite_src(&deref->instr, &deref->parent, parent->parent);
804 nir_instr_rewrite_src(&deref->instr, &deref->arr.index,
824 nir_deref_instr *deref = nir_instr_as_deref(instr);
825 switch (deref->deref_type) {
827 if (opt_deref_ptr_as_array(&b, deref))
832 if (opt_deref_cast(&b, deref))