Path: blob/21.2-virgl/src/gallium/auxiliary/gallivm/lp_bld_ir_common.h
4565 views
/**************************************************************************1*2* Copyright 2011-2012 Advanced Micro Devices, Inc.3* Copyright 2009 VMware, Inc.4* All Rights Reserved.5*6* Permission is hereby granted, free of charge, to any person obtaining a7* copy of this software and associated documentation files (the8* "Software"), to deal in the Software without restriction, including9* without limitation the rights to use, copy, modify, merge, publish,10* distribute, sub license, and/or sell copies of the Software, and to11* permit persons to whom the Software is furnished to do so, subject to12* the following conditions:13*14* The above copyright notice and this permission notice (including the15* next paragraph) shall be included in all copies or substantial portions16* of the Software.17*18* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS19* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF20* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.21* IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS BE LIABLE FOR22* ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,23* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE24* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.25*26**************************************************************************/2728#ifndef LP_BLD_IR_COMMON_H29#define LP_BLD_IR_COMMON_H3031#ifdef __cplusplus32extern "C" {33#endif3435#include "gallivm/lp_bld.h"36#include "gallivm/lp_bld_limits.h"3738/* SM 4.0 says that subroutines can nest 32 deep and39* we need one more for our main function */40#define LP_MAX_NUM_FUNCS 334142enum lp_exec_mask_break_type {43LP_EXEC_MASK_BREAK_TYPE_LOOP,44LP_EXEC_MASK_BREAK_TYPE_SWITCH45};4647struct lp_exec_mask {48struct lp_build_context *bld;4950boolean has_mask;51boolean ret_in_main;5253LLVMTypeRef int_vec_type;5455LLVMValueRef exec_mask;5657LLVMValueRef ret_mask;58LLVMValueRef cond_mask;59LLVMValueRef switch_mask; /* current switch exec mask */60LLVMValueRef cont_mask;61LLVMValueRef break_mask;6263struct function_ctx {64int pc;65LLVMValueRef ret_mask;6667LLVMValueRef cond_stack[LP_MAX_TGSI_NESTING];68int cond_stack_size;6970/* keep track if break belongs to switch or loop */71enum lp_exec_mask_break_type break_type_stack[LP_MAX_TGSI_NESTING];72enum lp_exec_mask_break_type break_type;7374struct {75LLVMValueRef switch_val;76LLVMValueRef switch_mask;77LLVMValueRef switch_mask_default;78boolean switch_in_default;79unsigned switch_pc;80} switch_stack[LP_MAX_TGSI_NESTING];81int switch_stack_size;82LLVMValueRef switch_val;83LLVMValueRef switch_mask_default; /* reverse of switch mask used for default */84boolean switch_in_default; /* if switch exec is currently in default */85unsigned switch_pc; /* when used points to default or endswitch-1 */8687LLVMValueRef loop_limiter;88LLVMBasicBlockRef loop_block;89LLVMValueRef break_var;90struct {91LLVMBasicBlockRef loop_block;92LLVMValueRef cont_mask;93LLVMValueRef break_mask;94LLVMValueRef break_var;95} loop_stack[LP_MAX_TGSI_NESTING];96int loop_stack_size;97int bgnloop_stack_size;9899} *function_stack;100int function_stack_size;101};102103void lp_exec_mask_function_init(struct lp_exec_mask *mask, int function_idx);104void lp_exec_mask_init(struct lp_exec_mask *mask, struct lp_build_context *bld);105void lp_exec_mask_fini(struct lp_exec_mask *mask);106void lp_exec_mask_store(struct lp_exec_mask *mask,107struct lp_build_context *bld_store,108LLVMValueRef val,109LLVMValueRef dst_ptr);110void lp_exec_mask_update(struct lp_exec_mask *mask);111void lp_exec_bgnloop_post_phi(struct lp_exec_mask *mask);112void lp_exec_bgnloop(struct lp_exec_mask *mask, bool load_mask);113void lp_exec_endloop(struct gallivm_state *gallivm,114struct lp_exec_mask *mask);115void lp_exec_mask_cond_push(struct lp_exec_mask *mask,116LLVMValueRef val);117void lp_exec_mask_cond_invert(struct lp_exec_mask *mask);118void lp_exec_mask_cond_pop(struct lp_exec_mask *mask);119void lp_exec_continue(struct lp_exec_mask *mask);120121void lp_exec_break(struct lp_exec_mask *mask, int *pc, bool break_always);122123#ifdef __cplusplus124}125#endif126127#endif128129130