Lines Matching defs:deref

44                     nir_deref_instr *deref, void *mem_ctx)
46 assert(deref != NULL);
59 for (nir_deref_instr *d = deref; d; d = nir_deref_instr_parent(d)) {
82 for (nir_deref_instr *d = deref; d; d = nir_deref_instr_parent(d)) {
103 * Recursively removes unused deref instructions
111 /* If anyone is using this deref, leave it alone */
157 nir_deref_instr_has_complex_use(nir_deref_instr *deref,
160 nir_foreach_use(use_src, &deref->dest.ssa) {
167 /* A var deref has no sources */
170 /* If a deref shows up in an array index or something like that, it's
176 /* Anything that isn't a basic struct or array deref is considered to
238 nir_foreach_if_use(use, &deref->dest.ssa)
253 nir_deref_instr_array_stride(nir_deref_instr *deref)
255 switch (deref->deref_type) {
258 const struct glsl_type *arr_type = nir_deref_instr_parent(deref)->type;
269 return nir_deref_instr_array_stride(nir_deref_instr_parent(deref));
271 return deref->cast.ptr_stride;
304 nir_deref_instr_get_const_offset(nir_deref_instr *deref,
308 nir_deref_path_init(&path, deref, NULL);
328 unreachable("Unsupported deref type");
338 nir_build_deref_offset(nir_builder *b, nir_deref_instr *deref,
342 nir_deref_path_init(&path, deref, NULL);
344 nir_ssa_def *offset = nir_imm_intN_t(b, 0, deref->dest.ssa.bit_size);
367 unreachable("Unsupported deref type");
423 nir_deref_instr *deref = nir_instr_as_deref(instr);
424 if (deref->deref_type == nir_deref_type_cast)
428 if (deref->deref_type == nir_deref_type_var) {
429 parent_modes = deref->var->data.mode;
431 assert(deref->parent.is_ssa);
433 nir_instr_as_deref(deref->parent.ssa->parent_instr);
437 deref->modes = parent_modes;
477 /* We're at either the tail or the divergence point between the two deref
478 * paths. Look to see if either contains cast or a ptr_as_array deref. If
484 * case where we have exactly one ptr_as_array deref in the chain after the
554 unreachable("Invalid deref type");
576 is_interface_struct_deref(const nir_deref_instr *deref)
578 if (deref->deref_type == nir_deref_type_struct) {
579 assert(glsl_type_is_struct_or_ifc(nir_deref_instr_parent(deref)->type));
665 * just assume nit_opt_deref will combine them and compare the deref
704 nir_deref_path *nir_get_deref_path(void *mem_ctx, nir_deref_and_path *deref)
706 if (!deref->_path) {
707 deref->_path = ralloc(mem_ctx, nir_deref_path);
708 nir_deref_path_init(deref->_path, deref->instr, mem_ctx);
710 return deref->_path;
732 rematerialize_deref_in_block(nir_deref_instr *deref,
735 if (deref->instr.block == state->block)
736 return deref;
742 struct hash_entry *cached = _mesa_hash_table_search(state->cache, deref);
748 nir_deref_instr_create(b->shader, deref->deref_type);
749 new_deref->modes = deref->modes;
750 new_deref->type = deref->type;
752 if (deref->deref_type == nir_deref_type_var) {
753 new_deref->var = deref->var;
755 nir_deref_instr *parent = nir_src_as_deref(deref->parent);
760 nir_src_copy(&new_deref->parent, &deref->parent);
764 switch (deref->deref_type) {
771 new_deref->cast.ptr_stride = deref->cast.ptr_stride;
776 assert(!nir_src_as_deref(deref->arr.index));
777 nir_src_copy(&new_deref->arr.index, &deref->arr.index);
781 new_deref->strct.index = deref->strct.index;
785 unreachable("Invalid deref instruction type");
789 deref->dest.ssa.num_components,
790 deref->dest.ssa.bit_size,
802 nir_deref_instr *deref = nir_src_as_deref(*src);
803 if (!deref)
806 nir_deref_instr *block_deref = rematerialize_deref_in_block(deref, state);
807 if (block_deref != deref) {
810 nir_deref_instr_remove_if_unused(deref);
819 * This pass re-materializes deref instructions in every block in which it is
820 * used. After this pass has been run, every use of a deref will be of a
821 * deref in the same block as the use. Also, all unused derefs will be
844 /* If a deref is used in a phi, we can't rematerialize it, as the new
974 * somehow disagrees with the smaller alignment further up the deref chain.
982 /* If we've gotten here, we have a parent deref with an align_mul at least
984 * information on this deref. There are two cases to consider here:
986 * 1. We can chase the deref all the way back to the variable. In this
989 * calculations, our knowledge from the deref walk is better than the
995 * get here is if something further up the deref chain has a cast with
998 * provided us with two conflicting alignments in the deref chain,
1002 * away the alignment information on this deref. However, to be "nice" to
1045 * If we know from something higher up the deref chain that the deref has a
1051 opt_restrict_deref_modes(nir_deref_instr *deref)
1053 if (deref->deref_type == nir_deref_type_var) {
1054 assert(deref->modes == deref->var->data.mode);
1058 nir_deref_instr *parent = nir_src_as_deref(deref->parent);
1059 if (parent == NULL || parent->modes == deref->modes)
1062 assert(parent->modes & deref->modes);
1063 deref->modes &= parent->modes;
1102 /* Recursively crawl the deref tree and clean up types */
1163 /* If this deref still contains useful alignment information, we don't want
1196 opt_deref_ptr_as_array(nir_builder *b, nir_deref_instr *deref)
1198 assert(deref->deref_type == nir_deref_type_ptr_as_array);
1200 nir_deref_instr *parent = nir_deref_instr_parent(deref);
1202 if (nir_src_is_const(deref->arr.index) &&
1203 nir_src_as_int(deref->arr.index) == 0) {
1204 /* If it's a ptr_as_array deref with an index of 0, it does nothing
1208 * The source of a ptr_as_array deref always has a deref_type of
1218 nir_ssa_def_rewrite_uses(&deref->dest.ssa,
1220 nir_instr_remove(&deref->instr);
1230 assert(deref->arr.index.is_ssa);
1232 deref->arr.in_bounds &= parent->arr.in_bounds;
1235 deref->arr.index.ssa);
1237 deref->deref_type = parent->deref_type;
1238 nir_instr_rewrite_src(&deref->instr, &deref->parent, parent->parent);
1239 nir_instr_rewrite_src(&deref->instr, &deref->arr.index,
1256 /* It has to be a cast of another deref */
1307 nir_deref_instr *deref = nir_src_as_deref(load->src[0]);
1315 if (is_vector_bitcast_deref(deref, read_mask, false)) {
1319 nir_deref_instr *parent = nir_src_as_deref(deref->parent);
1348 nir_deref_instr *deref = nir_src_as_deref(store->src[0]);
1355 if (is_vector_bitcast_deref(deref, write_mask, true)) {
1361 nir_deref_instr *parent = nir_src_as_deref(deref->parent);
1391 nir_deref_instr *deref = nir_src_as_deref(intrin->src[0]);
1392 if (deref == NULL)
1397 if (nir_deref_mode_must_be(deref, modes))
1400 if (!nir_deref_mode_may_be(deref, modes))
1432 nir_deref_instr *deref = nir_instr_as_deref(instr);
1434 if (opt_restrict_deref_modes(deref))
1437 switch (deref->deref_type) {
1439 if (opt_deref_ptr_as_array(&b, deref))
1444 if (opt_deref_cast(&b, deref))