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