196c5ddc4Srjs/* Copyright (C) 2018 Red Hat 296c5ddc4Srjs * Copyright (C) 2020 Valve Corporation 396c5ddc4Srjs * 496c5ddc4Srjs * Permission is hereby granted, free of charge, to any person obtaining a 596c5ddc4Srjs * copy of this software and associated documentation files (the "Software"), 696c5ddc4Srjs * to deal in the Software without restriction, including without limitation 796c5ddc4Srjs * the rights to use, copy, modify, merge, publish, distribute, sublicense, 896c5ddc4Srjs * and/or sell copies of the Software, and to permit persons to whom the 996c5ddc4Srjs * Software is furnished to do so, subject to the following conditions: 1096c5ddc4Srjs * 1196c5ddc4Srjs * The above copyright notice and this permission notice (including the next 1296c5ddc4Srjs * paragraph) shall be included in all copies or substantial portions of the 1396c5ddc4Srjs * Software. 1496c5ddc4Srjs * 1596c5ddc4Srjs * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 1696c5ddc4Srjs * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 1796c5ddc4Srjs * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 1896c5ddc4Srjs * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 1996c5ddc4Srjs * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 2096c5ddc4Srjs * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 2196c5ddc4Srjs * IN THE SOFTWARE. 2296c5ddc4Srjs */ 2396c5ddc4Srjs 2496c5ddc4Srjs#ifndef _NIR_INTRINSICS_INDICES_ 2596c5ddc4Srjs#define _NIR_INTRINSICS_INDICES_ 2696c5ddc4Srjs 2796c5ddc4Srjs 2896c5ddc4Srjs 2996c5ddc4Srjsstatic inline int 3096c5ddc4Srjsnir_intrinsic_base(const nir_intrinsic_instr *instr) 3196c5ddc4Srjs{ 3296c5ddc4Srjs const nir_intrinsic_info *info = &nir_intrinsic_infos[instr->intrinsic]; 3396c5ddc4Srjs assert(info->index_map[NIR_INTRINSIC_BASE] > 0); 3496c5ddc4Srjs return (int)instr->const_index[info->index_map[NIR_INTRINSIC_BASE] - 1]; 3596c5ddc4Srjs} 3696c5ddc4Srjs 3796c5ddc4Srjsstatic inline void 3896c5ddc4Srjsnir_intrinsic_set_base(nir_intrinsic_instr *instr, int val) 3996c5ddc4Srjs{ 4096c5ddc4Srjs const nir_intrinsic_info *info = &nir_intrinsic_infos[instr->intrinsic]; 4196c5ddc4Srjs assert(info->index_map[NIR_INTRINSIC_BASE] > 0); 4296c5ddc4Srjs instr->const_index[info->index_map[NIR_INTRINSIC_BASE] - 1] = val; 4396c5ddc4Srjs} 4496c5ddc4Srjs 4596c5ddc4Srjsstatic inline bool 4696c5ddc4Srjsnir_intrinsic_has_base(const nir_intrinsic_instr *instr) 4796c5ddc4Srjs{ 4896c5ddc4Srjs const nir_intrinsic_info *info = &nir_intrinsic_infos[instr->intrinsic]; 4996c5ddc4Srjs return info->index_map[NIR_INTRINSIC_BASE] > 0; 5096c5ddc4Srjs} 5196c5ddc4Srjs 5296c5ddc4Srjs 5396c5ddc4Srjsstatic inline unsigned 5496c5ddc4Srjsnir_intrinsic_write_mask(const nir_intrinsic_instr *instr) 5596c5ddc4Srjs{ 5696c5ddc4Srjs const nir_intrinsic_info *info = &nir_intrinsic_infos[instr->intrinsic]; 5796c5ddc4Srjs assert(info->index_map[NIR_INTRINSIC_WRITE_MASK] > 0); 5896c5ddc4Srjs return (unsigned)instr->const_index[info->index_map[NIR_INTRINSIC_WRITE_MASK] - 1]; 5996c5ddc4Srjs} 6096c5ddc4Srjs 6196c5ddc4Srjsstatic inline void 6296c5ddc4Srjsnir_intrinsic_set_write_mask(nir_intrinsic_instr *instr, unsigned val) 6396c5ddc4Srjs{ 6496c5ddc4Srjs const nir_intrinsic_info *info = &nir_intrinsic_infos[instr->intrinsic]; 6596c5ddc4Srjs assert(info->index_map[NIR_INTRINSIC_WRITE_MASK] > 0); 6696c5ddc4Srjs instr->const_index[info->index_map[NIR_INTRINSIC_WRITE_MASK] - 1] = val; 6796c5ddc4Srjs} 6896c5ddc4Srjs 6996c5ddc4Srjsstatic inline bool 7096c5ddc4Srjsnir_intrinsic_has_write_mask(const nir_intrinsic_instr *instr) 7196c5ddc4Srjs{ 7296c5ddc4Srjs const nir_intrinsic_info *info = &nir_intrinsic_infos[instr->intrinsic]; 7396c5ddc4Srjs return info->index_map[NIR_INTRINSIC_WRITE_MASK] > 0; 7496c5ddc4Srjs} 7596c5ddc4Srjs 7696c5ddc4Srjs 7796c5ddc4Srjsstatic inline unsigned 7896c5ddc4Srjsnir_intrinsic_stream_id(const nir_intrinsic_instr *instr) 7996c5ddc4Srjs{ 8096c5ddc4Srjs const nir_intrinsic_info *info = &nir_intrinsic_infos[instr->intrinsic]; 8196c5ddc4Srjs assert(info->index_map[NIR_INTRINSIC_STREAM_ID] > 0); 8296c5ddc4Srjs return (unsigned)instr->const_index[info->index_map[NIR_INTRINSIC_STREAM_ID] - 1]; 8396c5ddc4Srjs} 8496c5ddc4Srjs 8596c5ddc4Srjsstatic inline void 8696c5ddc4Srjsnir_intrinsic_set_stream_id(nir_intrinsic_instr *instr, unsigned val) 8796c5ddc4Srjs{ 8896c5ddc4Srjs const nir_intrinsic_info *info = &nir_intrinsic_infos[instr->intrinsic]; 8996c5ddc4Srjs assert(info->index_map[NIR_INTRINSIC_STREAM_ID] > 0); 9096c5ddc4Srjs instr->const_index[info->index_map[NIR_INTRINSIC_STREAM_ID] - 1] = val; 9196c5ddc4Srjs} 9296c5ddc4Srjs 9396c5ddc4Srjsstatic inline bool 9496c5ddc4Srjsnir_intrinsic_has_stream_id(const nir_intrinsic_instr *instr) 9596c5ddc4Srjs{ 9696c5ddc4Srjs const nir_intrinsic_info *info = &nir_intrinsic_infos[instr->intrinsic]; 9796c5ddc4Srjs return info->index_map[NIR_INTRINSIC_STREAM_ID] > 0; 9896c5ddc4Srjs} 9996c5ddc4Srjs 10096c5ddc4Srjs 10196c5ddc4Srjsstatic inline unsigned 10296c5ddc4Srjsnir_intrinsic_ucp_id(const nir_intrinsic_instr *instr) 10396c5ddc4Srjs{ 10496c5ddc4Srjs const nir_intrinsic_info *info = &nir_intrinsic_infos[instr->intrinsic]; 10596c5ddc4Srjs assert(info->index_map[NIR_INTRINSIC_UCP_ID] > 0); 10696c5ddc4Srjs return (unsigned)instr->const_index[info->index_map[NIR_INTRINSIC_UCP_ID] - 1]; 10796c5ddc4Srjs} 10896c5ddc4Srjs 10996c5ddc4Srjsstatic inline void 11096c5ddc4Srjsnir_intrinsic_set_ucp_id(nir_intrinsic_instr *instr, unsigned val) 11196c5ddc4Srjs{ 11296c5ddc4Srjs const nir_intrinsic_info *info = &nir_intrinsic_infos[instr->intrinsic]; 11396c5ddc4Srjs assert(info->index_map[NIR_INTRINSIC_UCP_ID] > 0); 11496c5ddc4Srjs instr->const_index[info->index_map[NIR_INTRINSIC_UCP_ID] - 1] = val; 11596c5ddc4Srjs} 11696c5ddc4Srjs 11796c5ddc4Srjsstatic inline bool 11896c5ddc4Srjsnir_intrinsic_has_ucp_id(const nir_intrinsic_instr *instr) 11996c5ddc4Srjs{ 12096c5ddc4Srjs const nir_intrinsic_info *info = &nir_intrinsic_infos[instr->intrinsic]; 12196c5ddc4Srjs return info->index_map[NIR_INTRINSIC_UCP_ID] > 0; 12296c5ddc4Srjs} 12396c5ddc4Srjs 12496c5ddc4Srjs 12596c5ddc4Srjsstatic inline unsigned 12696c5ddc4Srjsnir_intrinsic_range_base(const nir_intrinsic_instr *instr) 12796c5ddc4Srjs{ 12896c5ddc4Srjs const nir_intrinsic_info *info = &nir_intrinsic_infos[instr->intrinsic]; 12996c5ddc4Srjs assert(info->index_map[NIR_INTRINSIC_RANGE_BASE] > 0); 13096c5ddc4Srjs return (unsigned)instr->const_index[info->index_map[NIR_INTRINSIC_RANGE_BASE] - 1]; 13196c5ddc4Srjs} 13296c5ddc4Srjs 13396c5ddc4Srjsstatic inline void 13496c5ddc4Srjsnir_intrinsic_set_range_base(nir_intrinsic_instr *instr, unsigned val) 13596c5ddc4Srjs{ 13696c5ddc4Srjs const nir_intrinsic_info *info = &nir_intrinsic_infos[instr->intrinsic]; 13796c5ddc4Srjs assert(info->index_map[NIR_INTRINSIC_RANGE_BASE] > 0); 13896c5ddc4Srjs instr->const_index[info->index_map[NIR_INTRINSIC_RANGE_BASE] - 1] = val; 13996c5ddc4Srjs} 14096c5ddc4Srjs 14196c5ddc4Srjsstatic inline bool 14296c5ddc4Srjsnir_intrinsic_has_range_base(const nir_intrinsic_instr *instr) 14396c5ddc4Srjs{ 14496c5ddc4Srjs const nir_intrinsic_info *info = &nir_intrinsic_infos[instr->intrinsic]; 14596c5ddc4Srjs return info->index_map[NIR_INTRINSIC_RANGE_BASE] > 0; 14696c5ddc4Srjs} 14796c5ddc4Srjs 14896c5ddc4Srjs 14996c5ddc4Srjsstatic inline unsigned 15096c5ddc4Srjsnir_intrinsic_range(const nir_intrinsic_instr *instr) 15196c5ddc4Srjs{ 15296c5ddc4Srjs const nir_intrinsic_info *info = &nir_intrinsic_infos[instr->intrinsic]; 15396c5ddc4Srjs assert(info->index_map[NIR_INTRINSIC_RANGE] > 0); 15496c5ddc4Srjs return (unsigned)instr->const_index[info->index_map[NIR_INTRINSIC_RANGE] - 1]; 15596c5ddc4Srjs} 15696c5ddc4Srjs 15796c5ddc4Srjsstatic inline void 15896c5ddc4Srjsnir_intrinsic_set_range(nir_intrinsic_instr *instr, unsigned val) 15996c5ddc4Srjs{ 16096c5ddc4Srjs const nir_intrinsic_info *info = &nir_intrinsic_infos[instr->intrinsic]; 16196c5ddc4Srjs assert(info->index_map[NIR_INTRINSIC_RANGE] > 0); 16296c5ddc4Srjs instr->const_index[info->index_map[NIR_INTRINSIC_RANGE] - 1] = val; 16396c5ddc4Srjs} 16496c5ddc4Srjs 16596c5ddc4Srjsstatic inline bool 16696c5ddc4Srjsnir_intrinsic_has_range(const nir_intrinsic_instr *instr) 16796c5ddc4Srjs{ 16896c5ddc4Srjs const nir_intrinsic_info *info = &nir_intrinsic_infos[instr->intrinsic]; 16996c5ddc4Srjs return info->index_map[NIR_INTRINSIC_RANGE] > 0; 17096c5ddc4Srjs} 17196c5ddc4Srjs 17296c5ddc4Srjs 17396c5ddc4Srjsstatic inline unsigned 17496c5ddc4Srjsnir_intrinsic_desc_set(const nir_intrinsic_instr *instr) 17596c5ddc4Srjs{ 17696c5ddc4Srjs const nir_intrinsic_info *info = &nir_intrinsic_infos[instr->intrinsic]; 17796c5ddc4Srjs assert(info->index_map[NIR_INTRINSIC_DESC_SET] > 0); 17896c5ddc4Srjs return (unsigned)instr->const_index[info->index_map[NIR_INTRINSIC_DESC_SET] - 1]; 17996c5ddc4Srjs} 18096c5ddc4Srjs 18196c5ddc4Srjsstatic inline void 18296c5ddc4Srjsnir_intrinsic_set_desc_set(nir_intrinsic_instr *instr, unsigned val) 18396c5ddc4Srjs{ 18496c5ddc4Srjs const nir_intrinsic_info *info = &nir_intrinsic_infos[instr->intrinsic]; 18596c5ddc4Srjs assert(info->index_map[NIR_INTRINSIC_DESC_SET] > 0); 18696c5ddc4Srjs instr->const_index[info->index_map[NIR_INTRINSIC_DESC_SET] - 1] = val; 18796c5ddc4Srjs} 18896c5ddc4Srjs 18996c5ddc4Srjsstatic inline bool 19096c5ddc4Srjsnir_intrinsic_has_desc_set(const nir_intrinsic_instr *instr) 19196c5ddc4Srjs{ 19296c5ddc4Srjs const nir_intrinsic_info *info = &nir_intrinsic_infos[instr->intrinsic]; 19396c5ddc4Srjs return info->index_map[NIR_INTRINSIC_DESC_SET] > 0; 19496c5ddc4Srjs} 19596c5ddc4Srjs 19696c5ddc4Srjs 19796c5ddc4Srjsstatic inline unsigned 19896c5ddc4Srjsnir_intrinsic_binding(const nir_intrinsic_instr *instr) 19996c5ddc4Srjs{ 20096c5ddc4Srjs const nir_intrinsic_info *info = &nir_intrinsic_infos[instr->intrinsic]; 20196c5ddc4Srjs assert(info->index_map[NIR_INTRINSIC_BINDING] > 0); 20296c5ddc4Srjs return (unsigned)instr->const_index[info->index_map[NIR_INTRINSIC_BINDING] - 1]; 20396c5ddc4Srjs} 20496c5ddc4Srjs 20596c5ddc4Srjsstatic inline void 20696c5ddc4Srjsnir_intrinsic_set_binding(nir_intrinsic_instr *instr, unsigned val) 20796c5ddc4Srjs{ 20896c5ddc4Srjs const nir_intrinsic_info *info = &nir_intrinsic_infos[instr->intrinsic]; 20996c5ddc4Srjs assert(info->index_map[NIR_INTRINSIC_BINDING] > 0); 21096c5ddc4Srjs instr->const_index[info->index_map[NIR_INTRINSIC_BINDING] - 1] = val; 21196c5ddc4Srjs} 21296c5ddc4Srjs 21396c5ddc4Srjsstatic inline bool 21496c5ddc4Srjsnir_intrinsic_has_binding(const nir_intrinsic_instr *instr) 21596c5ddc4Srjs{ 21696c5ddc4Srjs const nir_intrinsic_info *info = &nir_intrinsic_infos[instr->intrinsic]; 21796c5ddc4Srjs return info->index_map[NIR_INTRINSIC_BINDING] > 0; 21896c5ddc4Srjs} 21996c5ddc4Srjs 22096c5ddc4Srjs 22196c5ddc4Srjsstatic inline unsigned 22296c5ddc4Srjsnir_intrinsic_component(const nir_intrinsic_instr *instr) 22396c5ddc4Srjs{ 22496c5ddc4Srjs const nir_intrinsic_info *info = &nir_intrinsic_infos[instr->intrinsic]; 22596c5ddc4Srjs assert(info->index_map[NIR_INTRINSIC_COMPONENT] > 0); 22696c5ddc4Srjs return (unsigned)instr->const_index[info->index_map[NIR_INTRINSIC_COMPONENT] - 1]; 22796c5ddc4Srjs} 22896c5ddc4Srjs 22996c5ddc4Srjsstatic inline void 23096c5ddc4Srjsnir_intrinsic_set_component(nir_intrinsic_instr *instr, unsigned val) 23196c5ddc4Srjs{ 23296c5ddc4Srjs const nir_intrinsic_info *info = &nir_intrinsic_infos[instr->intrinsic]; 23396c5ddc4Srjs assert(info->index_map[NIR_INTRINSIC_COMPONENT] > 0); 23496c5ddc4Srjs instr->const_index[info->index_map[NIR_INTRINSIC_COMPONENT] - 1] = val; 23596c5ddc4Srjs} 23696c5ddc4Srjs 23796c5ddc4Srjsstatic inline bool 23896c5ddc4Srjsnir_intrinsic_has_component(const nir_intrinsic_instr *instr) 23996c5ddc4Srjs{ 24096c5ddc4Srjs const nir_intrinsic_info *info = &nir_intrinsic_infos[instr->intrinsic]; 24196c5ddc4Srjs return info->index_map[NIR_INTRINSIC_COMPONENT] > 0; 24296c5ddc4Srjs} 24396c5ddc4Srjs 24496c5ddc4Srjs 24596c5ddc4Srjsstatic inline unsigned 24696c5ddc4Srjsnir_intrinsic_column(const nir_intrinsic_instr *instr) 24796c5ddc4Srjs{ 24896c5ddc4Srjs const nir_intrinsic_info *info = &nir_intrinsic_infos[instr->intrinsic]; 24996c5ddc4Srjs assert(info->index_map[NIR_INTRINSIC_COLUMN] > 0); 25096c5ddc4Srjs return (unsigned)instr->const_index[info->index_map[NIR_INTRINSIC_COLUMN] - 1]; 25196c5ddc4Srjs} 25296c5ddc4Srjs 25396c5ddc4Srjsstatic inline void 25496c5ddc4Srjsnir_intrinsic_set_column(nir_intrinsic_instr *instr, unsigned val) 25596c5ddc4Srjs{ 25696c5ddc4Srjs const nir_intrinsic_info *info = &nir_intrinsic_infos[instr->intrinsic]; 25796c5ddc4Srjs assert(info->index_map[NIR_INTRINSIC_COLUMN] > 0); 25896c5ddc4Srjs instr->const_index[info->index_map[NIR_INTRINSIC_COLUMN] - 1] = val; 25996c5ddc4Srjs} 26096c5ddc4Srjs 26196c5ddc4Srjsstatic inline bool 26296c5ddc4Srjsnir_intrinsic_has_column(const nir_intrinsic_instr *instr) 26396c5ddc4Srjs{ 26496c5ddc4Srjs const nir_intrinsic_info *info = &nir_intrinsic_infos[instr->intrinsic]; 26596c5ddc4Srjs return info->index_map[NIR_INTRINSIC_COLUMN] > 0; 26696c5ddc4Srjs} 26796c5ddc4Srjs 26896c5ddc4Srjs 26996c5ddc4Srjsstatic inline unsigned 27096c5ddc4Srjsnir_intrinsic_interp_mode(const nir_intrinsic_instr *instr) 27196c5ddc4Srjs{ 27296c5ddc4Srjs const nir_intrinsic_info *info = &nir_intrinsic_infos[instr->intrinsic]; 27396c5ddc4Srjs assert(info->index_map[NIR_INTRINSIC_INTERP_MODE] > 0); 27496c5ddc4Srjs return (unsigned)instr->const_index[info->index_map[NIR_INTRINSIC_INTERP_MODE] - 1]; 27596c5ddc4Srjs} 27696c5ddc4Srjs 27796c5ddc4Srjsstatic inline void 27896c5ddc4Srjsnir_intrinsic_set_interp_mode(nir_intrinsic_instr *instr, unsigned val) 27996c5ddc4Srjs{ 28096c5ddc4Srjs const nir_intrinsic_info *info = &nir_intrinsic_infos[instr->intrinsic]; 28196c5ddc4Srjs assert(info->index_map[NIR_INTRINSIC_INTERP_MODE] > 0); 28296c5ddc4Srjs instr->const_index[info->index_map[NIR_INTRINSIC_INTERP_MODE] - 1] = val; 28396c5ddc4Srjs} 28496c5ddc4Srjs 28596c5ddc4Srjsstatic inline bool 28696c5ddc4Srjsnir_intrinsic_has_interp_mode(const nir_intrinsic_instr *instr) 28796c5ddc4Srjs{ 28896c5ddc4Srjs const nir_intrinsic_info *info = &nir_intrinsic_infos[instr->intrinsic]; 28996c5ddc4Srjs return info->index_map[NIR_INTRINSIC_INTERP_MODE] > 0; 29096c5ddc4Srjs} 29196c5ddc4Srjs 29296c5ddc4Srjs 29396c5ddc4Srjsstatic inline unsigned 29496c5ddc4Srjsnir_intrinsic_reduction_op(const nir_intrinsic_instr *instr) 29596c5ddc4Srjs{ 29696c5ddc4Srjs const nir_intrinsic_info *info = &nir_intrinsic_infos[instr->intrinsic]; 29796c5ddc4Srjs assert(info->index_map[NIR_INTRINSIC_REDUCTION_OP] > 0); 29896c5ddc4Srjs return (unsigned)instr->const_index[info->index_map[NIR_INTRINSIC_REDUCTION_OP] - 1]; 29996c5ddc4Srjs} 30096c5ddc4Srjs 30196c5ddc4Srjsstatic inline void 30296c5ddc4Srjsnir_intrinsic_set_reduction_op(nir_intrinsic_instr *instr, unsigned val) 30396c5ddc4Srjs{ 30496c5ddc4Srjs const nir_intrinsic_info *info = &nir_intrinsic_infos[instr->intrinsic]; 30596c5ddc4Srjs assert(info->index_map[NIR_INTRINSIC_REDUCTION_OP] > 0); 30696c5ddc4Srjs instr->const_index[info->index_map[NIR_INTRINSIC_REDUCTION_OP] - 1] = val; 30796c5ddc4Srjs} 30896c5ddc4Srjs 30996c5ddc4Srjsstatic inline bool 31096c5ddc4Srjsnir_intrinsic_has_reduction_op(const nir_intrinsic_instr *instr) 31196c5ddc4Srjs{ 31296c5ddc4Srjs const nir_intrinsic_info *info = &nir_intrinsic_infos[instr->intrinsic]; 31396c5ddc4Srjs return info->index_map[NIR_INTRINSIC_REDUCTION_OP] > 0; 31496c5ddc4Srjs} 31596c5ddc4Srjs 31696c5ddc4Srjs 31796c5ddc4Srjsstatic inline unsigned 31896c5ddc4Srjsnir_intrinsic_cluster_size(const nir_intrinsic_instr *instr) 31996c5ddc4Srjs{ 32096c5ddc4Srjs const nir_intrinsic_info *info = &nir_intrinsic_infos[instr->intrinsic]; 32196c5ddc4Srjs assert(info->index_map[NIR_INTRINSIC_CLUSTER_SIZE] > 0); 32296c5ddc4Srjs return (unsigned)instr->const_index[info->index_map[NIR_INTRINSIC_CLUSTER_SIZE] - 1]; 32396c5ddc4Srjs} 32496c5ddc4Srjs 32596c5ddc4Srjsstatic inline void 32696c5ddc4Srjsnir_intrinsic_set_cluster_size(nir_intrinsic_instr *instr, unsigned val) 32796c5ddc4Srjs{ 32896c5ddc4Srjs const nir_intrinsic_info *info = &nir_intrinsic_infos[instr->intrinsic]; 32996c5ddc4Srjs assert(info->index_map[NIR_INTRINSIC_CLUSTER_SIZE] > 0); 33096c5ddc4Srjs instr->const_index[info->index_map[NIR_INTRINSIC_CLUSTER_SIZE] - 1] = val; 33196c5ddc4Srjs} 33296c5ddc4Srjs 33396c5ddc4Srjsstatic inline bool 33496c5ddc4Srjsnir_intrinsic_has_cluster_size(const nir_intrinsic_instr *instr) 33596c5ddc4Srjs{ 33696c5ddc4Srjs const nir_intrinsic_info *info = &nir_intrinsic_infos[instr->intrinsic]; 33796c5ddc4Srjs return info->index_map[NIR_INTRINSIC_CLUSTER_SIZE] > 0; 33896c5ddc4Srjs} 33996c5ddc4Srjs 34096c5ddc4Srjs 34196c5ddc4Srjsstatic inline unsigned 34296c5ddc4Srjsnir_intrinsic_param_idx(const nir_intrinsic_instr *instr) 34396c5ddc4Srjs{ 34496c5ddc4Srjs const nir_intrinsic_info *info = &nir_intrinsic_infos[instr->intrinsic]; 34596c5ddc4Srjs assert(info->index_map[NIR_INTRINSIC_PARAM_IDX] > 0); 34696c5ddc4Srjs return (unsigned)instr->const_index[info->index_map[NIR_INTRINSIC_PARAM_IDX] - 1]; 34796c5ddc4Srjs} 34896c5ddc4Srjs 34996c5ddc4Srjsstatic inline void 35096c5ddc4Srjsnir_intrinsic_set_param_idx(nir_intrinsic_instr *instr, unsigned val) 35196c5ddc4Srjs{ 35296c5ddc4Srjs const nir_intrinsic_info *info = &nir_intrinsic_infos[instr->intrinsic]; 35396c5ddc4Srjs assert(info->index_map[NIR_INTRINSIC_PARAM_IDX] > 0); 35496c5ddc4Srjs instr->const_index[info->index_map[NIR_INTRINSIC_PARAM_IDX] - 1] = val; 35596c5ddc4Srjs} 35696c5ddc4Srjs 35796c5ddc4Srjsstatic inline bool 35896c5ddc4Srjsnir_intrinsic_has_param_idx(const nir_intrinsic_instr *instr) 35996c5ddc4Srjs{ 36096c5ddc4Srjs const nir_intrinsic_info *info = &nir_intrinsic_infos[instr->intrinsic]; 36196c5ddc4Srjs return info->index_map[NIR_INTRINSIC_PARAM_IDX] > 0; 36296c5ddc4Srjs} 36396c5ddc4Srjs 36496c5ddc4Srjs 36596c5ddc4Srjsstatic inline enum glsl_sampler_dim 36696c5ddc4Srjsnir_intrinsic_image_dim(const nir_intrinsic_instr *instr) 36796c5ddc4Srjs{ 36896c5ddc4Srjs const nir_intrinsic_info *info = &nir_intrinsic_infos[instr->intrinsic]; 36996c5ddc4Srjs assert(info->index_map[NIR_INTRINSIC_IMAGE_DIM] > 0); 37096c5ddc4Srjs return (enum glsl_sampler_dim)instr->const_index[info->index_map[NIR_INTRINSIC_IMAGE_DIM] - 1]; 37196c5ddc4Srjs} 37296c5ddc4Srjs 37396c5ddc4Srjsstatic inline void 37496c5ddc4Srjsnir_intrinsic_set_image_dim(nir_intrinsic_instr *instr, enum glsl_sampler_dim val) 37596c5ddc4Srjs{ 37696c5ddc4Srjs const nir_intrinsic_info *info = &nir_intrinsic_infos[instr->intrinsic]; 37796c5ddc4Srjs assert(info->index_map[NIR_INTRINSIC_IMAGE_DIM] > 0); 37896c5ddc4Srjs instr->const_index[info->index_map[NIR_INTRINSIC_IMAGE_DIM] - 1] = val; 37996c5ddc4Srjs} 38096c5ddc4Srjs 38196c5ddc4Srjsstatic inline bool 38296c5ddc4Srjsnir_intrinsic_has_image_dim(const nir_intrinsic_instr *instr) 38396c5ddc4Srjs{ 38496c5ddc4Srjs const nir_intrinsic_info *info = &nir_intrinsic_infos[instr->intrinsic]; 38596c5ddc4Srjs return info->index_map[NIR_INTRINSIC_IMAGE_DIM] > 0; 38696c5ddc4Srjs} 38796c5ddc4Srjs 38896c5ddc4Srjs 38996c5ddc4Srjsstatic inline bool 39096c5ddc4Srjsnir_intrinsic_image_array(const nir_intrinsic_instr *instr) 39196c5ddc4Srjs{ 39296c5ddc4Srjs const nir_intrinsic_info *info = &nir_intrinsic_infos[instr->intrinsic]; 39396c5ddc4Srjs assert(info->index_map[NIR_INTRINSIC_IMAGE_ARRAY] > 0); 39496c5ddc4Srjs return (bool)instr->const_index[info->index_map[NIR_INTRINSIC_IMAGE_ARRAY] - 1]; 39596c5ddc4Srjs} 39696c5ddc4Srjs 39796c5ddc4Srjsstatic inline void 39896c5ddc4Srjsnir_intrinsic_set_image_array(nir_intrinsic_instr *instr, bool val) 39996c5ddc4Srjs{ 40096c5ddc4Srjs const nir_intrinsic_info *info = &nir_intrinsic_infos[instr->intrinsic]; 40196c5ddc4Srjs assert(info->index_map[NIR_INTRINSIC_IMAGE_ARRAY] > 0); 40296c5ddc4Srjs instr->const_index[info->index_map[NIR_INTRINSIC_IMAGE_ARRAY] - 1] = val; 40396c5ddc4Srjs} 40496c5ddc4Srjs 40596c5ddc4Srjsstatic inline bool 40696c5ddc4Srjsnir_intrinsic_has_image_array(const nir_intrinsic_instr *instr) 40796c5ddc4Srjs{ 40896c5ddc4Srjs const nir_intrinsic_info *info = &nir_intrinsic_infos[instr->intrinsic]; 40996c5ddc4Srjs return info->index_map[NIR_INTRINSIC_IMAGE_ARRAY] > 0; 41096c5ddc4Srjs} 41196c5ddc4Srjs 41296c5ddc4Srjs 41396c5ddc4Srjsstatic inline enum pipe_format 41496c5ddc4Srjsnir_intrinsic_format(const nir_intrinsic_instr *instr) 41596c5ddc4Srjs{ 41696c5ddc4Srjs const nir_intrinsic_info *info = &nir_intrinsic_infos[instr->intrinsic]; 41796c5ddc4Srjs assert(info->index_map[NIR_INTRINSIC_FORMAT] > 0); 41896c5ddc4Srjs return (enum pipe_format)instr->const_index[info->index_map[NIR_INTRINSIC_FORMAT] - 1]; 41996c5ddc4Srjs} 42096c5ddc4Srjs 42196c5ddc4Srjsstatic inline void 42296c5ddc4Srjsnir_intrinsic_set_format(nir_intrinsic_instr *instr, enum pipe_format val) 42396c5ddc4Srjs{ 42496c5ddc4Srjs const nir_intrinsic_info *info = &nir_intrinsic_infos[instr->intrinsic]; 42596c5ddc4Srjs assert(info->index_map[NIR_INTRINSIC_FORMAT] > 0); 42696c5ddc4Srjs instr->const_index[info->index_map[NIR_INTRINSIC_FORMAT] - 1] = val; 42796c5ddc4Srjs} 42896c5ddc4Srjs 42996c5ddc4Srjsstatic inline bool 43096c5ddc4Srjsnir_intrinsic_has_format(const nir_intrinsic_instr *instr) 43196c5ddc4Srjs{ 43296c5ddc4Srjs const nir_intrinsic_info *info = &nir_intrinsic_infos[instr->intrinsic]; 43396c5ddc4Srjs return info->index_map[NIR_INTRINSIC_FORMAT] > 0; 43496c5ddc4Srjs} 43596c5ddc4Srjs 43696c5ddc4Srjs 43796c5ddc4Srjsstatic inline enum gl_access_qualifier 43896c5ddc4Srjsnir_intrinsic_access(const nir_intrinsic_instr *instr) 43996c5ddc4Srjs{ 44096c5ddc4Srjs const nir_intrinsic_info *info = &nir_intrinsic_infos[instr->intrinsic]; 44196c5ddc4Srjs assert(info->index_map[NIR_INTRINSIC_ACCESS] > 0); 44296c5ddc4Srjs return (enum gl_access_qualifier)instr->const_index[info->index_map[NIR_INTRINSIC_ACCESS] - 1]; 44396c5ddc4Srjs} 44496c5ddc4Srjs 44596c5ddc4Srjsstatic inline void 44696c5ddc4Srjsnir_intrinsic_set_access(nir_intrinsic_instr *instr, enum gl_access_qualifier val) 44796c5ddc4Srjs{ 44896c5ddc4Srjs const nir_intrinsic_info *info = &nir_intrinsic_infos[instr->intrinsic]; 44996c5ddc4Srjs assert(info->index_map[NIR_INTRINSIC_ACCESS] > 0); 45096c5ddc4Srjs instr->const_index[info->index_map[NIR_INTRINSIC_ACCESS] - 1] = val; 45196c5ddc4Srjs} 45296c5ddc4Srjs 45396c5ddc4Srjsstatic inline bool 45496c5ddc4Srjsnir_intrinsic_has_access(const nir_intrinsic_instr *instr) 45596c5ddc4Srjs{ 45696c5ddc4Srjs const nir_intrinsic_info *info = &nir_intrinsic_infos[instr->intrinsic]; 45796c5ddc4Srjs return info->index_map[NIR_INTRINSIC_ACCESS] > 0; 45896c5ddc4Srjs} 45996c5ddc4Srjs 46096c5ddc4Srjs 46196c5ddc4Srjsstatic inline unsigned 46296c5ddc4Srjsnir_intrinsic_call_idx(const nir_intrinsic_instr *instr) 46396c5ddc4Srjs{ 46496c5ddc4Srjs const nir_intrinsic_info *info = &nir_intrinsic_infos[instr->intrinsic]; 46596c5ddc4Srjs assert(info->index_map[NIR_INTRINSIC_CALL_IDX] > 0); 46696c5ddc4Srjs return (unsigned)instr->const_index[info->index_map[NIR_INTRINSIC_CALL_IDX] - 1]; 46796c5ddc4Srjs} 46896c5ddc4Srjs 46996c5ddc4Srjsstatic inline void 47096c5ddc4Srjsnir_intrinsic_set_call_idx(nir_intrinsic_instr *instr, unsigned val) 47196c5ddc4Srjs{ 47296c5ddc4Srjs const nir_intrinsic_info *info = &nir_intrinsic_infos[instr->intrinsic]; 47396c5ddc4Srjs assert(info->index_map[NIR_INTRINSIC_CALL_IDX] > 0); 47496c5ddc4Srjs instr->const_index[info->index_map[NIR_INTRINSIC_CALL_IDX] - 1] = val; 47596c5ddc4Srjs} 47696c5ddc4Srjs 47796c5ddc4Srjsstatic inline bool 47896c5ddc4Srjsnir_intrinsic_has_call_idx(const nir_intrinsic_instr *instr) 47996c5ddc4Srjs{ 48096c5ddc4Srjs const nir_intrinsic_info *info = &nir_intrinsic_infos[instr->intrinsic]; 48196c5ddc4Srjs return info->index_map[NIR_INTRINSIC_CALL_IDX] > 0; 48296c5ddc4Srjs} 48396c5ddc4Srjs 48496c5ddc4Srjs 48596c5ddc4Srjsstatic inline unsigned 48696c5ddc4Srjsnir_intrinsic_stack_size(const nir_intrinsic_instr *instr) 48796c5ddc4Srjs{ 48896c5ddc4Srjs const nir_intrinsic_info *info = &nir_intrinsic_infos[instr->intrinsic]; 48996c5ddc4Srjs assert(info->index_map[NIR_INTRINSIC_STACK_SIZE] > 0); 49096c5ddc4Srjs return (unsigned)instr->const_index[info->index_map[NIR_INTRINSIC_STACK_SIZE] - 1]; 49196c5ddc4Srjs} 49296c5ddc4Srjs 49396c5ddc4Srjsstatic inline void 49496c5ddc4Srjsnir_intrinsic_set_stack_size(nir_intrinsic_instr *instr, unsigned val) 49596c5ddc4Srjs{ 49696c5ddc4Srjs const nir_intrinsic_info *info = &nir_intrinsic_infos[instr->intrinsic]; 49796c5ddc4Srjs assert(info->index_map[NIR_INTRINSIC_STACK_SIZE] > 0); 49896c5ddc4Srjs instr->const_index[info->index_map[NIR_INTRINSIC_STACK_SIZE] - 1] = val; 49996c5ddc4Srjs} 50096c5ddc4Srjs 50196c5ddc4Srjsstatic inline bool 50296c5ddc4Srjsnir_intrinsic_has_stack_size(const nir_intrinsic_instr *instr) 50396c5ddc4Srjs{ 50496c5ddc4Srjs const nir_intrinsic_info *info = &nir_intrinsic_infos[instr->intrinsic]; 50596c5ddc4Srjs return info->index_map[NIR_INTRINSIC_STACK_SIZE] > 0; 50696c5ddc4Srjs} 50796c5ddc4Srjs 50896c5ddc4Srjs 50996c5ddc4Srjsstatic inline unsigned 51096c5ddc4Srjsnir_intrinsic_align_mul(const nir_intrinsic_instr *instr) 51196c5ddc4Srjs{ 51296c5ddc4Srjs const nir_intrinsic_info *info = &nir_intrinsic_infos[instr->intrinsic]; 51396c5ddc4Srjs assert(info->index_map[NIR_INTRINSIC_ALIGN_MUL] > 0); 51496c5ddc4Srjs return (unsigned)instr->const_index[info->index_map[NIR_INTRINSIC_ALIGN_MUL] - 1]; 51596c5ddc4Srjs} 51696c5ddc4Srjs 51796c5ddc4Srjsstatic inline void 51896c5ddc4Srjsnir_intrinsic_set_align_mul(nir_intrinsic_instr *instr, unsigned val) 51996c5ddc4Srjs{ 52096c5ddc4Srjs const nir_intrinsic_info *info = &nir_intrinsic_infos[instr->intrinsic]; 52196c5ddc4Srjs assert(info->index_map[NIR_INTRINSIC_ALIGN_MUL] > 0); 52296c5ddc4Srjs instr->const_index[info->index_map[NIR_INTRINSIC_ALIGN_MUL] - 1] = val; 52396c5ddc4Srjs} 52496c5ddc4Srjs 52596c5ddc4Srjsstatic inline bool 52696c5ddc4Srjsnir_intrinsic_has_align_mul(const nir_intrinsic_instr *instr) 52796c5ddc4Srjs{ 52896c5ddc4Srjs const nir_intrinsic_info *info = &nir_intrinsic_infos[instr->intrinsic]; 52996c5ddc4Srjs return info->index_map[NIR_INTRINSIC_ALIGN_MUL] > 0; 53096c5ddc4Srjs} 53196c5ddc4Srjs 53296c5ddc4Srjs 53396c5ddc4Srjsstatic inline unsigned 53496c5ddc4Srjsnir_intrinsic_align_offset(const nir_intrinsic_instr *instr) 53596c5ddc4Srjs{ 53696c5ddc4Srjs const nir_intrinsic_info *info = &nir_intrinsic_infos[instr->intrinsic]; 53796c5ddc4Srjs assert(info->index_map[NIR_INTRINSIC_ALIGN_OFFSET] > 0); 53896c5ddc4Srjs return (unsigned)instr->const_index[info->index_map[NIR_INTRINSIC_ALIGN_OFFSET] - 1]; 53996c5ddc4Srjs} 54096c5ddc4Srjs 54196c5ddc4Srjsstatic inline void 54296c5ddc4Srjsnir_intrinsic_set_align_offset(nir_intrinsic_instr *instr, unsigned val) 54396c5ddc4Srjs{ 54496c5ddc4Srjs const nir_intrinsic_info *info = &nir_intrinsic_infos[instr->intrinsic]; 54596c5ddc4Srjs assert(info->index_map[NIR_INTRINSIC_ALIGN_OFFSET] > 0); 54696c5ddc4Srjs instr->const_index[info->index_map[NIR_INTRINSIC_ALIGN_OFFSET] - 1] = val; 54796c5ddc4Srjs} 54896c5ddc4Srjs 54996c5ddc4Srjsstatic inline bool 55096c5ddc4Srjsnir_intrinsic_has_align_offset(const nir_intrinsic_instr *instr) 55196c5ddc4Srjs{ 55296c5ddc4Srjs const nir_intrinsic_info *info = &nir_intrinsic_infos[instr->intrinsic]; 55396c5ddc4Srjs return info->index_map[NIR_INTRINSIC_ALIGN_OFFSET] > 0; 55496c5ddc4Srjs} 55596c5ddc4Srjs 55696c5ddc4Srjs 55796c5ddc4Srjsstatic inline unsigned 55896c5ddc4Srjsnir_intrinsic_desc_type(const nir_intrinsic_instr *instr) 55996c5ddc4Srjs{ 56096c5ddc4Srjs const nir_intrinsic_info *info = &nir_intrinsic_infos[instr->intrinsic]; 56196c5ddc4Srjs assert(info->index_map[NIR_INTRINSIC_DESC_TYPE] > 0); 56296c5ddc4Srjs return (unsigned)instr->const_index[info->index_map[NIR_INTRINSIC_DESC_TYPE] - 1]; 56396c5ddc4Srjs} 56496c5ddc4Srjs 56596c5ddc4Srjsstatic inline void 56696c5ddc4Srjsnir_intrinsic_set_desc_type(nir_intrinsic_instr *instr, unsigned val) 56796c5ddc4Srjs{ 56896c5ddc4Srjs const nir_intrinsic_info *info = &nir_intrinsic_infos[instr->intrinsic]; 56996c5ddc4Srjs assert(info->index_map[NIR_INTRINSIC_DESC_TYPE] > 0); 57096c5ddc4Srjs instr->const_index[info->index_map[NIR_INTRINSIC_DESC_TYPE] - 1] = val; 57196c5ddc4Srjs} 57296c5ddc4Srjs 57396c5ddc4Srjsstatic inline bool 57496c5ddc4Srjsnir_intrinsic_has_desc_type(const nir_intrinsic_instr *instr) 57596c5ddc4Srjs{ 57696c5ddc4Srjs const nir_intrinsic_info *info = &nir_intrinsic_infos[instr->intrinsic]; 57796c5ddc4Srjs return info->index_map[NIR_INTRINSIC_DESC_TYPE] > 0; 57896c5ddc4Srjs} 57996c5ddc4Srjs 58096c5ddc4Srjs 58196c5ddc4Srjsstatic inline nir_alu_type 58296c5ddc4Srjsnir_intrinsic_src_type(const nir_intrinsic_instr *instr) 58396c5ddc4Srjs{ 58496c5ddc4Srjs const nir_intrinsic_info *info = &nir_intrinsic_infos[instr->intrinsic]; 58596c5ddc4Srjs assert(info->index_map[NIR_INTRINSIC_SRC_TYPE] > 0); 58696c5ddc4Srjs return (nir_alu_type)instr->const_index[info->index_map[NIR_INTRINSIC_SRC_TYPE] - 1]; 58796c5ddc4Srjs} 58896c5ddc4Srjs 58996c5ddc4Srjsstatic inline void 59096c5ddc4Srjsnir_intrinsic_set_src_type(nir_intrinsic_instr *instr, nir_alu_type val) 59196c5ddc4Srjs{ 59296c5ddc4Srjs const nir_intrinsic_info *info = &nir_intrinsic_infos[instr->intrinsic]; 59396c5ddc4Srjs assert(info->index_map[NIR_INTRINSIC_SRC_TYPE] > 0); 59496c5ddc4Srjs instr->const_index[info->index_map[NIR_INTRINSIC_SRC_TYPE] - 1] = val; 59596c5ddc4Srjs} 59696c5ddc4Srjs 59796c5ddc4Srjsstatic inline bool 59896c5ddc4Srjsnir_intrinsic_has_src_type(const nir_intrinsic_instr *instr) 59996c5ddc4Srjs{ 60096c5ddc4Srjs const nir_intrinsic_info *info = &nir_intrinsic_infos[instr->intrinsic]; 60196c5ddc4Srjs return info->index_map[NIR_INTRINSIC_SRC_TYPE] > 0; 60296c5ddc4Srjs} 60396c5ddc4Srjs 60496c5ddc4Srjs 60596c5ddc4Srjsstatic inline nir_alu_type 60696c5ddc4Srjsnir_intrinsic_dest_type(const nir_intrinsic_instr *instr) 60796c5ddc4Srjs{ 60896c5ddc4Srjs const nir_intrinsic_info *info = &nir_intrinsic_infos[instr->intrinsic]; 60996c5ddc4Srjs assert(info->index_map[NIR_INTRINSIC_DEST_TYPE] > 0); 61096c5ddc4Srjs return (nir_alu_type)instr->const_index[info->index_map[NIR_INTRINSIC_DEST_TYPE] - 1]; 61196c5ddc4Srjs} 61296c5ddc4Srjs 61396c5ddc4Srjsstatic inline void 61496c5ddc4Srjsnir_intrinsic_set_dest_type(nir_intrinsic_instr *instr, nir_alu_type val) 61596c5ddc4Srjs{ 61696c5ddc4Srjs const nir_intrinsic_info *info = &nir_intrinsic_infos[instr->intrinsic]; 61796c5ddc4Srjs assert(info->index_map[NIR_INTRINSIC_DEST_TYPE] > 0); 61896c5ddc4Srjs instr->const_index[info->index_map[NIR_INTRINSIC_DEST_TYPE] - 1] = val; 61996c5ddc4Srjs} 62096c5ddc4Srjs 62196c5ddc4Srjsstatic inline bool 62296c5ddc4Srjsnir_intrinsic_has_dest_type(const nir_intrinsic_instr *instr) 62396c5ddc4Srjs{ 62496c5ddc4Srjs const nir_intrinsic_info *info = &nir_intrinsic_infos[instr->intrinsic]; 62596c5ddc4Srjs return info->index_map[NIR_INTRINSIC_DEST_TYPE] > 0; 62696c5ddc4Srjs} 62796c5ddc4Srjs 62896c5ddc4Srjs 62996c5ddc4Srjsstatic inline unsigned 63096c5ddc4Srjsnir_intrinsic_swizzle_mask(const nir_intrinsic_instr *instr) 63196c5ddc4Srjs{ 63296c5ddc4Srjs const nir_intrinsic_info *info = &nir_intrinsic_infos[instr->intrinsic]; 63396c5ddc4Srjs assert(info->index_map[NIR_INTRINSIC_SWIZZLE_MASK] > 0); 63496c5ddc4Srjs return (unsigned)instr->const_index[info->index_map[NIR_INTRINSIC_SWIZZLE_MASK] - 1]; 63596c5ddc4Srjs} 63696c5ddc4Srjs 63796c5ddc4Srjsstatic inline void 63896c5ddc4Srjsnir_intrinsic_set_swizzle_mask(nir_intrinsic_instr *instr, unsigned val) 63996c5ddc4Srjs{ 64096c5ddc4Srjs const nir_intrinsic_info *info = &nir_intrinsic_infos[instr->intrinsic]; 64196c5ddc4Srjs assert(info->index_map[NIR_INTRINSIC_SWIZZLE_MASK] > 0); 64296c5ddc4Srjs instr->const_index[info->index_map[NIR_INTRINSIC_SWIZZLE_MASK] - 1] = val; 64396c5ddc4Srjs} 64496c5ddc4Srjs 64596c5ddc4Srjsstatic inline bool 64696c5ddc4Srjsnir_intrinsic_has_swizzle_mask(const nir_intrinsic_instr *instr) 64796c5ddc4Srjs{ 64896c5ddc4Srjs const nir_intrinsic_info *info = &nir_intrinsic_infos[instr->intrinsic]; 64996c5ddc4Srjs return info->index_map[NIR_INTRINSIC_SWIZZLE_MASK] > 0; 65096c5ddc4Srjs} 65196c5ddc4Srjs 65296c5ddc4Srjs 65396c5ddc4Srjsstatic inline bool 65496c5ddc4Srjsnir_intrinsic_is_swizzled(const nir_intrinsic_instr *instr) 65596c5ddc4Srjs{ 65696c5ddc4Srjs const nir_intrinsic_info *info = &nir_intrinsic_infos[instr->intrinsic]; 65796c5ddc4Srjs assert(info->index_map[NIR_INTRINSIC_IS_SWIZZLED] > 0); 65896c5ddc4Srjs return (bool)instr->const_index[info->index_map[NIR_INTRINSIC_IS_SWIZZLED] - 1]; 65996c5ddc4Srjs} 66096c5ddc4Srjs 66196c5ddc4Srjsstatic inline void 66296c5ddc4Srjsnir_intrinsic_set_is_swizzled(nir_intrinsic_instr *instr, bool val) 66396c5ddc4Srjs{ 66496c5ddc4Srjs const nir_intrinsic_info *info = &nir_intrinsic_infos[instr->intrinsic]; 66596c5ddc4Srjs assert(info->index_map[NIR_INTRINSIC_IS_SWIZZLED] > 0); 66696c5ddc4Srjs instr->const_index[info->index_map[NIR_INTRINSIC_IS_SWIZZLED] - 1] = val; 66796c5ddc4Srjs} 66896c5ddc4Srjs 66996c5ddc4Srjsstatic inline bool 67096c5ddc4Srjsnir_intrinsic_has_is_swizzled(const nir_intrinsic_instr *instr) 67196c5ddc4Srjs{ 67296c5ddc4Srjs const nir_intrinsic_info *info = &nir_intrinsic_infos[instr->intrinsic]; 67396c5ddc4Srjs return info->index_map[NIR_INTRINSIC_IS_SWIZZLED] > 0; 67496c5ddc4Srjs} 67596c5ddc4Srjs 67696c5ddc4Srjs 67796c5ddc4Srjsstatic inline bool 67896c5ddc4Srjsnir_intrinsic_slc_amd(const nir_intrinsic_instr *instr) 67996c5ddc4Srjs{ 68096c5ddc4Srjs const nir_intrinsic_info *info = &nir_intrinsic_infos[instr->intrinsic]; 68196c5ddc4Srjs assert(info->index_map[NIR_INTRINSIC_SLC_AMD] > 0); 68296c5ddc4Srjs return (bool)instr->const_index[info->index_map[NIR_INTRINSIC_SLC_AMD] - 1]; 68396c5ddc4Srjs} 68496c5ddc4Srjs 68596c5ddc4Srjsstatic inline void 68696c5ddc4Srjsnir_intrinsic_set_slc_amd(nir_intrinsic_instr *instr, bool val) 68796c5ddc4Srjs{ 68896c5ddc4Srjs const nir_intrinsic_info *info = &nir_intrinsic_infos[instr->intrinsic]; 68996c5ddc4Srjs assert(info->index_map[NIR_INTRINSIC_SLC_AMD] > 0); 69096c5ddc4Srjs instr->const_index[info->index_map[NIR_INTRINSIC_SLC_AMD] - 1] = val; 69196c5ddc4Srjs} 69296c5ddc4Srjs 69396c5ddc4Srjsstatic inline bool 69496c5ddc4Srjsnir_intrinsic_has_slc_amd(const nir_intrinsic_instr *instr) 69596c5ddc4Srjs{ 69696c5ddc4Srjs const nir_intrinsic_info *info = &nir_intrinsic_infos[instr->intrinsic]; 69796c5ddc4Srjs return info->index_map[NIR_INTRINSIC_SLC_AMD] > 0; 69896c5ddc4Srjs} 69996c5ddc4Srjs 70096c5ddc4Srjs 70196c5ddc4Srjsstatic inline enum gl_access_qualifier 70296c5ddc4Srjsnir_intrinsic_dst_access(const nir_intrinsic_instr *instr) 70396c5ddc4Srjs{ 70496c5ddc4Srjs const nir_intrinsic_info *info = &nir_intrinsic_infos[instr->intrinsic]; 70596c5ddc4Srjs assert(info->index_map[NIR_INTRINSIC_DST_ACCESS] > 0); 70696c5ddc4Srjs return (enum gl_access_qualifier)instr->const_index[info->index_map[NIR_INTRINSIC_DST_ACCESS] - 1]; 70796c5ddc4Srjs} 70896c5ddc4Srjs 70996c5ddc4Srjsstatic inline void 71096c5ddc4Srjsnir_intrinsic_set_dst_access(nir_intrinsic_instr *instr, enum gl_access_qualifier val) 71196c5ddc4Srjs{ 71296c5ddc4Srjs const nir_intrinsic_info *info = &nir_intrinsic_infos[instr->intrinsic]; 71396c5ddc4Srjs assert(info->index_map[NIR_INTRINSIC_DST_ACCESS] > 0); 71496c5ddc4Srjs instr->const_index[info->index_map[NIR_INTRINSIC_DST_ACCESS] - 1] = val; 71596c5ddc4Srjs} 71696c5ddc4Srjs 71796c5ddc4Srjsstatic inline bool 71896c5ddc4Srjsnir_intrinsic_has_dst_access(const nir_intrinsic_instr *instr) 71996c5ddc4Srjs{ 72096c5ddc4Srjs const nir_intrinsic_info *info = &nir_intrinsic_infos[instr->intrinsic]; 72196c5ddc4Srjs return info->index_map[NIR_INTRINSIC_DST_ACCESS] > 0; 72296c5ddc4Srjs} 72396c5ddc4Srjs 72496c5ddc4Srjs 72596c5ddc4Srjsstatic inline enum gl_access_qualifier 72696c5ddc4Srjsnir_intrinsic_src_access(const nir_intrinsic_instr *instr) 72796c5ddc4Srjs{ 72896c5ddc4Srjs const nir_intrinsic_info *info = &nir_intrinsic_infos[instr->intrinsic]; 72996c5ddc4Srjs assert(info->index_map[NIR_INTRINSIC_SRC_ACCESS] > 0); 73096c5ddc4Srjs return (enum gl_access_qualifier)instr->const_index[info->index_map[NIR_INTRINSIC_SRC_ACCESS] - 1]; 73196c5ddc4Srjs} 73296c5ddc4Srjs 73396c5ddc4Srjsstatic inline void 73496c5ddc4Srjsnir_intrinsic_set_src_access(nir_intrinsic_instr *instr, enum gl_access_qualifier val) 73596c5ddc4Srjs{ 73696c5ddc4Srjs const nir_intrinsic_info *info = &nir_intrinsic_infos[instr->intrinsic]; 73796c5ddc4Srjs assert(info->index_map[NIR_INTRINSIC_SRC_ACCESS] > 0); 73896c5ddc4Srjs instr->const_index[info->index_map[NIR_INTRINSIC_SRC_ACCESS] - 1] = val; 73996c5ddc4Srjs} 74096c5ddc4Srjs 74196c5ddc4Srjsstatic inline bool 74296c5ddc4Srjsnir_intrinsic_has_src_access(const nir_intrinsic_instr *instr) 74396c5ddc4Srjs{ 74496c5ddc4Srjs const nir_intrinsic_info *info = &nir_intrinsic_infos[instr->intrinsic]; 74596c5ddc4Srjs return info->index_map[NIR_INTRINSIC_SRC_ACCESS] > 0; 74696c5ddc4Srjs} 74796c5ddc4Srjs 74896c5ddc4Srjs 74996c5ddc4Srjsstatic inline unsigned 75096c5ddc4Srjsnir_intrinsic_driver_location(const nir_intrinsic_instr *instr) 75196c5ddc4Srjs{ 75296c5ddc4Srjs const nir_intrinsic_info *info = &nir_intrinsic_infos[instr->intrinsic]; 75396c5ddc4Srjs assert(info->index_map[NIR_INTRINSIC_DRIVER_LOCATION] > 0); 75496c5ddc4Srjs return (unsigned)instr->const_index[info->index_map[NIR_INTRINSIC_DRIVER_LOCATION] - 1]; 75596c5ddc4Srjs} 75696c5ddc4Srjs 75796c5ddc4Srjsstatic inline void 75896c5ddc4Srjsnir_intrinsic_set_driver_location(nir_intrinsic_instr *instr, unsigned val) 75996c5ddc4Srjs{ 76096c5ddc4Srjs const nir_intrinsic_info *info = &nir_intrinsic_infos[instr->intrinsic]; 76196c5ddc4Srjs assert(info->index_map[NIR_INTRINSIC_DRIVER_LOCATION] > 0); 76296c5ddc4Srjs instr->const_index[info->index_map[NIR_INTRINSIC_DRIVER_LOCATION] - 1] = val; 76396c5ddc4Srjs} 76496c5ddc4Srjs 76596c5ddc4Srjsstatic inline bool 76696c5ddc4Srjsnir_intrinsic_has_driver_location(const nir_intrinsic_instr *instr) 76796c5ddc4Srjs{ 76896c5ddc4Srjs const nir_intrinsic_info *info = &nir_intrinsic_infos[instr->intrinsic]; 76996c5ddc4Srjs return info->index_map[NIR_INTRINSIC_DRIVER_LOCATION] > 0; 77096c5ddc4Srjs} 77196c5ddc4Srjs 77296c5ddc4Srjs 77396c5ddc4Srjsstatic inline nir_memory_semantics 77496c5ddc4Srjsnir_intrinsic_memory_semantics(const nir_intrinsic_instr *instr) 77596c5ddc4Srjs{ 77696c5ddc4Srjs const nir_intrinsic_info *info = &nir_intrinsic_infos[instr->intrinsic]; 77796c5ddc4Srjs assert(info->index_map[NIR_INTRINSIC_MEMORY_SEMANTICS] > 0); 77896c5ddc4Srjs return (nir_memory_semantics)instr->const_index[info->index_map[NIR_INTRINSIC_MEMORY_SEMANTICS] - 1]; 77996c5ddc4Srjs} 78096c5ddc4Srjs 78196c5ddc4Srjsstatic inline void 78296c5ddc4Srjsnir_intrinsic_set_memory_semantics(nir_intrinsic_instr *instr, nir_memory_semantics val) 78396c5ddc4Srjs{ 78496c5ddc4Srjs const nir_intrinsic_info *info = &nir_intrinsic_infos[instr->intrinsic]; 78596c5ddc4Srjs assert(info->index_map[NIR_INTRINSIC_MEMORY_SEMANTICS] > 0); 78696c5ddc4Srjs instr->const_index[info->index_map[NIR_INTRINSIC_MEMORY_SEMANTICS] - 1] = val; 78796c5ddc4Srjs} 78896c5ddc4Srjs 78996c5ddc4Srjsstatic inline bool 79096c5ddc4Srjsnir_intrinsic_has_memory_semantics(const nir_intrinsic_instr *instr) 79196c5ddc4Srjs{ 79296c5ddc4Srjs const nir_intrinsic_info *info = &nir_intrinsic_infos[instr->intrinsic]; 79396c5ddc4Srjs return info->index_map[NIR_INTRINSIC_MEMORY_SEMANTICS] > 0; 79496c5ddc4Srjs} 79596c5ddc4Srjs 79696c5ddc4Srjs 79796c5ddc4Srjsstatic inline nir_variable_mode 79896c5ddc4Srjsnir_intrinsic_memory_modes(const nir_intrinsic_instr *instr) 79996c5ddc4Srjs{ 80096c5ddc4Srjs const nir_intrinsic_info *info = &nir_intrinsic_infos[instr->intrinsic]; 80196c5ddc4Srjs assert(info->index_map[NIR_INTRINSIC_MEMORY_MODES] > 0); 80296c5ddc4Srjs return (nir_variable_mode)instr->const_index[info->index_map[NIR_INTRINSIC_MEMORY_MODES] - 1]; 80396c5ddc4Srjs} 80496c5ddc4Srjs 80596c5ddc4Srjsstatic inline void 80696c5ddc4Srjsnir_intrinsic_set_memory_modes(nir_intrinsic_instr *instr, nir_variable_mode val) 80796c5ddc4Srjs{ 80896c5ddc4Srjs const nir_intrinsic_info *info = &nir_intrinsic_infos[instr->intrinsic]; 80996c5ddc4Srjs assert(info->index_map[NIR_INTRINSIC_MEMORY_MODES] > 0); 81096c5ddc4Srjs instr->const_index[info->index_map[NIR_INTRINSIC_MEMORY_MODES] - 1] = val; 81196c5ddc4Srjs} 81296c5ddc4Srjs 81396c5ddc4Srjsstatic inline bool 81496c5ddc4Srjsnir_intrinsic_has_memory_modes(const nir_intrinsic_instr *instr) 81596c5ddc4Srjs{ 81696c5ddc4Srjs const nir_intrinsic_info *info = &nir_intrinsic_infos[instr->intrinsic]; 81796c5ddc4Srjs return info->index_map[NIR_INTRINSIC_MEMORY_MODES] > 0; 81896c5ddc4Srjs} 81996c5ddc4Srjs 82096c5ddc4Srjs 82196c5ddc4Srjsstatic inline nir_scope 82296c5ddc4Srjsnir_intrinsic_memory_scope(const nir_intrinsic_instr *instr) 82396c5ddc4Srjs{ 82496c5ddc4Srjs const nir_intrinsic_info *info = &nir_intrinsic_infos[instr->intrinsic]; 82596c5ddc4Srjs assert(info->index_map[NIR_INTRINSIC_MEMORY_SCOPE] > 0); 82696c5ddc4Srjs return (nir_scope)instr->const_index[info->index_map[NIR_INTRINSIC_MEMORY_SCOPE] - 1]; 82796c5ddc4Srjs} 82896c5ddc4Srjs 82996c5ddc4Srjsstatic inline void 83096c5ddc4Srjsnir_intrinsic_set_memory_scope(nir_intrinsic_instr *instr, nir_scope val) 83196c5ddc4Srjs{ 83296c5ddc4Srjs const nir_intrinsic_info *info = &nir_intrinsic_infos[instr->intrinsic]; 83396c5ddc4Srjs assert(info->index_map[NIR_INTRINSIC_MEMORY_SCOPE] > 0); 83496c5ddc4Srjs instr->const_index[info->index_map[NIR_INTRINSIC_MEMORY_SCOPE] - 1] = val; 83596c5ddc4Srjs} 83696c5ddc4Srjs 83796c5ddc4Srjsstatic inline bool 83896c5ddc4Srjsnir_intrinsic_has_memory_scope(const nir_intrinsic_instr *instr) 83996c5ddc4Srjs{ 84096c5ddc4Srjs const nir_intrinsic_info *info = &nir_intrinsic_infos[instr->intrinsic]; 84196c5ddc4Srjs return info->index_map[NIR_INTRINSIC_MEMORY_SCOPE] > 0; 84296c5ddc4Srjs} 84396c5ddc4Srjs 84496c5ddc4Srjs 84596c5ddc4Srjsstatic inline nir_scope 84696c5ddc4Srjsnir_intrinsic_execution_scope(const nir_intrinsic_instr *instr) 84796c5ddc4Srjs{ 84896c5ddc4Srjs const nir_intrinsic_info *info = &nir_intrinsic_infos[instr->intrinsic]; 84996c5ddc4Srjs assert(info->index_map[NIR_INTRINSIC_EXECUTION_SCOPE] > 0); 85096c5ddc4Srjs return (nir_scope)instr->const_index[info->index_map[NIR_INTRINSIC_EXECUTION_SCOPE] - 1]; 85196c5ddc4Srjs} 85296c5ddc4Srjs 85396c5ddc4Srjsstatic inline void 85496c5ddc4Srjsnir_intrinsic_set_execution_scope(nir_intrinsic_instr *instr, nir_scope val) 85596c5ddc4Srjs{ 85696c5ddc4Srjs const nir_intrinsic_info *info = &nir_intrinsic_infos[instr->intrinsic]; 85796c5ddc4Srjs assert(info->index_map[NIR_INTRINSIC_EXECUTION_SCOPE] > 0); 85896c5ddc4Srjs instr->const_index[info->index_map[NIR_INTRINSIC_EXECUTION_SCOPE] - 1] = val; 85996c5ddc4Srjs} 86096c5ddc4Srjs 86196c5ddc4Srjsstatic inline bool 86296c5ddc4Srjsnir_intrinsic_has_execution_scope(const nir_intrinsic_instr *instr) 86396c5ddc4Srjs{ 86496c5ddc4Srjs const nir_intrinsic_info *info = &nir_intrinsic_infos[instr->intrinsic]; 86596c5ddc4Srjs return info->index_map[NIR_INTRINSIC_EXECUTION_SCOPE] > 0; 86696c5ddc4Srjs} 86796c5ddc4Srjs 86896c5ddc4Srjs 86996c5ddc4Srjsstatic inline struct nir_io_semantics 87096c5ddc4Srjsnir_intrinsic_io_semantics(const nir_intrinsic_instr *instr) 87196c5ddc4Srjs{ 87296c5ddc4Srjs const nir_intrinsic_info *info = &nir_intrinsic_infos[instr->intrinsic]; 87396c5ddc4Srjs assert(info->index_map[NIR_INTRINSIC_IO_SEMANTICS] > 0); 87496c5ddc4Srjs struct nir_io_semantics res; 87596c5ddc4Srjs STATIC_ASSERT(sizeof(instr->const_index[0]) == sizeof(res)); 87696c5ddc4Srjs memcpy(&res, &instr->const_index[info->index_map[NIR_INTRINSIC_IO_SEMANTICS] - 1], sizeof(res)); 87796c5ddc4Srjs return res; 87896c5ddc4Srjs} 87996c5ddc4Srjs 88096c5ddc4Srjsstatic inline void 88196c5ddc4Srjsnir_intrinsic_set_io_semantics(nir_intrinsic_instr *instr, struct nir_io_semantics val) 88296c5ddc4Srjs{ 88396c5ddc4Srjs const nir_intrinsic_info *info = &nir_intrinsic_infos[instr->intrinsic]; 88496c5ddc4Srjs assert(info->index_map[NIR_INTRINSIC_IO_SEMANTICS] > 0); 88596c5ddc4Srjs val._pad = 0; /* clear padding bits */ 88696c5ddc4Srjs STATIC_ASSERT(sizeof(instr->const_index[0]) == sizeof(val)); 88796c5ddc4Srjs memcpy(&instr->const_index[info->index_map[NIR_INTRINSIC_IO_SEMANTICS] - 1], &val, sizeof(val)); 88896c5ddc4Srjs} 88996c5ddc4Srjs 89096c5ddc4Srjsstatic inline bool 89196c5ddc4Srjsnir_intrinsic_has_io_semantics(const nir_intrinsic_instr *instr) 89296c5ddc4Srjs{ 89396c5ddc4Srjs const nir_intrinsic_info *info = &nir_intrinsic_infos[instr->intrinsic]; 89496c5ddc4Srjs return info->index_map[NIR_INTRINSIC_IO_SEMANTICS] > 0; 89596c5ddc4Srjs} 89696c5ddc4Srjs 89796c5ddc4Srjs 89896c5ddc4Srjsstatic inline nir_rounding_mode 89996c5ddc4Srjsnir_intrinsic_rounding_mode(const nir_intrinsic_instr *instr) 90096c5ddc4Srjs{ 90196c5ddc4Srjs const nir_intrinsic_info *info = &nir_intrinsic_infos[instr->intrinsic]; 90296c5ddc4Srjs assert(info->index_map[NIR_INTRINSIC_ROUNDING_MODE] > 0); 90396c5ddc4Srjs return (nir_rounding_mode)instr->const_index[info->index_map[NIR_INTRINSIC_ROUNDING_MODE] - 1]; 90496c5ddc4Srjs} 90596c5ddc4Srjs 90696c5ddc4Srjsstatic inline void 90796c5ddc4Srjsnir_intrinsic_set_rounding_mode(nir_intrinsic_instr *instr, nir_rounding_mode val) 90896c5ddc4Srjs{ 90996c5ddc4Srjs const nir_intrinsic_info *info = &nir_intrinsic_infos[instr->intrinsic]; 91096c5ddc4Srjs assert(info->index_map[NIR_INTRINSIC_ROUNDING_MODE] > 0); 91196c5ddc4Srjs instr->const_index[info->index_map[NIR_INTRINSIC_ROUNDING_MODE] - 1] = val; 91296c5ddc4Srjs} 91396c5ddc4Srjs 91496c5ddc4Srjsstatic inline bool 91596c5ddc4Srjsnir_intrinsic_has_rounding_mode(const nir_intrinsic_instr *instr) 91696c5ddc4Srjs{ 91796c5ddc4Srjs const nir_intrinsic_info *info = &nir_intrinsic_infos[instr->intrinsic]; 91896c5ddc4Srjs return info->index_map[NIR_INTRINSIC_ROUNDING_MODE] > 0; 91996c5ddc4Srjs} 92096c5ddc4Srjs 92196c5ddc4Srjs 92296c5ddc4Srjsstatic inline unsigned 92396c5ddc4Srjsnir_intrinsic_saturate(const nir_intrinsic_instr *instr) 92496c5ddc4Srjs{ 92596c5ddc4Srjs const nir_intrinsic_info *info = &nir_intrinsic_infos[instr->intrinsic]; 92696c5ddc4Srjs assert(info->index_map[NIR_INTRINSIC_SATURATE] > 0); 92796c5ddc4Srjs return (unsigned)instr->const_index[info->index_map[NIR_INTRINSIC_SATURATE] - 1]; 92896c5ddc4Srjs} 92996c5ddc4Srjs 93096c5ddc4Srjsstatic inline void 93196c5ddc4Srjsnir_intrinsic_set_saturate(nir_intrinsic_instr *instr, unsigned val) 93296c5ddc4Srjs{ 93396c5ddc4Srjs const nir_intrinsic_info *info = &nir_intrinsic_infos[instr->intrinsic]; 93496c5ddc4Srjs assert(info->index_map[NIR_INTRINSIC_SATURATE] > 0); 93596c5ddc4Srjs instr->const_index[info->index_map[NIR_INTRINSIC_SATURATE] - 1] = val; 93696c5ddc4Srjs} 93796c5ddc4Srjs 93896c5ddc4Srjsstatic inline bool 93996c5ddc4Srjsnir_intrinsic_has_saturate(const nir_intrinsic_instr *instr) 94096c5ddc4Srjs{ 94196c5ddc4Srjs const nir_intrinsic_info *info = &nir_intrinsic_infos[instr->intrinsic]; 94296c5ddc4Srjs return info->index_map[NIR_INTRINSIC_SATURATE] > 0; 94396c5ddc4Srjs} 94496c5ddc4Srjs 94596c5ddc4Srjs#endif /* _NIR_INTRINSICS_INDICES_ */