Path: blob/21.2-virgl/src/compiler/nir/nir_deref.h
4546 views
/*1* Copyright © 2018 Intel Corporation2*3* Permission is hereby granted, free of charge, to any person obtaining a4* copy of this software and associated documentation files (the "Software"),5* to deal in the Software without restriction, including without limitation6* the rights to use, copy, modify, merge, publish, distribute, sublicense,7* and/or sell copies of the Software, and to permit persons to whom the8* Software is furnished to do so, subject to the following conditions:9*10* The above copyright notice and this permission notice (including the next11* paragraph) shall be included in all copies or substantial portions of the12* Software.13*14* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR15* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,16* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL17* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER18* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING19* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS20* IN THE SOFTWARE.21*/2223#ifndef NIR_DEREF_H24#define NIR_DEREF_H2526#include "nir.h"27#include "nir_builder.h"2829#ifdef __cplusplus30extern "C" {31#endif3233typedef struct {34/** Short path so we can keep it on the stack most of the time. */35nir_deref_instr *_short_path[7];3637/** A null-terminated array view of a deref chain38*39* The first element of this array will be the variable dereference40* followed by every deref_instr on the path to the final one. The last41* element in the array is a NULL pointer which acts as a terminator.42*/43nir_deref_instr **path;44} nir_deref_path;4546typedef struct {47nir_deref_instr *instr;48nir_deref_path *_path;49} nir_deref_and_path;5051void nir_deref_path_init(nir_deref_path *path,52nir_deref_instr *deref, void *mem_ctx);53void nir_deref_path_finish(nir_deref_path *path);5455unsigned nir_deref_instr_get_const_offset(nir_deref_instr *deref,56glsl_type_size_align_func size_align);5758nir_ssa_def *nir_build_deref_offset(nir_builder *b, nir_deref_instr *deref,59glsl_type_size_align_func size_align);6061nir_deref_path *nir_get_deref_path(void *mem_ctx, nir_deref_and_path *deref);6263typedef enum {64nir_derefs_do_not_alias = 0,65nir_derefs_equal_bit = (1 << 0),66nir_derefs_may_alias_bit = (1 << 1),67nir_derefs_a_contains_b_bit = (1 << 2),68nir_derefs_b_contains_a_bit = (1 << 3),69} nir_deref_compare_result;7071nir_deref_compare_result nir_compare_deref_paths(nir_deref_path *a_path, nir_deref_path *b_path);72nir_deref_compare_result nir_compare_derefs(nir_deref_instr *a, nir_deref_instr *b);73nir_deref_compare_result nir_compare_derefs_and_paths(void *mem_ctx,74nir_deref_and_path *a,75nir_deref_and_path *b);7677#ifdef __cplusplus78} /* extern "C" */79#endif8081#endif /* NIR_DEREF_H */828384