1 /* 2 * Copyright © 2018 Intel Corporation 3 * 4 * Permission is hereby granted, free of charge, to any person obtaining a 5 * copy of this software and associated documentation files (the "Software"), 6 * to deal in the Software without restriction, including without limitation 7 * the rights to use, copy, modify, merge, publish, distribute, sublicense, 8 * and/or sell copies of the Software, and to permit persons to whom the 9 * Software is furnished to do so, subject to the following conditions: 10 * 11 * The above copyright notice and this permission notice (including the next 12 * paragraph) shall be included in all copies or substantial portions of the 13 * Software. 14 * 15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 18 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 20 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 21 * IN THE SOFTWARE. 22 */ 23 24 #ifndef NIR_DEREF_H 25 #define NIR_DEREF_H 26 27 #include "nir.h" 28 #include "nir_builder.h" 29 30 #ifdef __cplusplus 31 extern "C" { 32 #endif 33 34 typedef struct { 35 /** Short path so we can keep it on the stack most of the time. */ 36 nir_deref_instr *_short_path[7]; 37 38 /** A null-terminated array view of a deref chain 39 * 40 * The first element of this array will be the variable dereference 41 * followed by every deref_instr on the path to the final one. The last 42 * element in the array is a NULL pointer which acts as a terminator. 43 */ 44 nir_deref_instr **path; 45 } nir_deref_path; 46 47 void nir_deref_path_init(nir_deref_path *path, 48 nir_deref_instr *deref, void *mem_ctx); 49 void nir_deref_path_finish(nir_deref_path *path); 50 51 unsigned nir_deref_instr_get_const_offset(nir_deref_instr *deref, 52 glsl_type_size_align_func size_align); 53 54 nir_ssa_def *nir_build_deref_offset(nir_builder *b, nir_deref_instr *deref, 55 glsl_type_size_align_func size_align); 56 57 typedef enum { 58 nir_derefs_do_not_alias = 0, 59 nir_derefs_equal_bit = (1 << 0), 60 nir_derefs_may_alias_bit = (1 << 1), 61 nir_derefs_a_contains_b_bit = (1 << 2), 62 nir_derefs_b_contains_a_bit = (1 << 3), 63 } nir_deref_compare_result; 64 65 nir_deref_compare_result nir_compare_deref_paths(nir_deref_path *a_path, nir_deref_path *b_path); 66 nir_deref_compare_result nir_compare_derefs(nir_deref_instr *a, nir_deref_instr *b); 67 68 #ifdef __cplusplus 69 } /* extern "C" */ 70 #endif 71 72 #endif /* NIR_DEREF_H */ 73