~mmach/netext73/mesa_2004

« back to all changes in this revision

Viewing changes to src/compiler/nir/nir_deref.c

  • Committer: mmach
  • Date: 2021-03-12 20:48:59 UTC
  • Revision ID: netbit73@gmail.com-20210312204859-i194ujlcu82pq61p
21

Show diffs side-by-side

added added

removed removed

Lines of Context:
334
334
   nir_ssa_def *offset = nir_imm_intN_t(b, 0, deref->dest.ssa.bit_size);
335
335
   for (nir_deref_instr **p = &path.path[1]; *p; p++) {
336
336
      switch ((*p)->deref_type) {
337
 
      case nir_deref_type_array: {
 
337
      case nir_deref_type_array:
 
338
      case nir_deref_type_ptr_as_array: {
338
339
         nir_ssa_def *index = nir_ssa_for_src(b, (*p)->arr.index, 1);
339
340
         int stride = type_get_array_stride((*p)->type, size_align);
340
341
         offset = nir_iadd(b, offset, nir_amul_imm(b, index, stride));
640
641
   return result;
641
642
}
642
643
 
 
644
nir_deref_path *nir_get_deref_path(void *mem_ctx, nir_deref_and_path *deref)
 
645
{
 
646
   if (!deref->_path) {
 
647
      deref->_path = ralloc(mem_ctx, nir_deref_path);
 
648
      nir_deref_path_init(deref->_path, deref->instr, mem_ctx);
 
649
   }
 
650
   return deref->_path;
 
651
}
 
652
 
 
653
nir_deref_compare_result nir_compare_derefs_and_paths(void *mem_ctx,
 
654
                                                      nir_deref_and_path *a,
 
655
                                                      nir_deref_and_path *b)
 
656
{
 
657
   if (a->instr == b->instr) /* nir_compare_derefs has a fast path if a == b */
 
658
      return nir_compare_derefs(a->instr, b->instr);
 
659
 
 
660
   return nir_compare_deref_paths(nir_get_deref_path(mem_ctx, a),
 
661
                                  nir_get_deref_path(mem_ctx, b));
 
662
}
 
663
 
643
664
struct rematerialize_deref_state {
644
665
   bool progress;
645
666
   nir_builder builder;