llvmpipe: Silence "possibly uninitialized value" warning for ssbo_limit.
[mesa.git] / src / gallium / auxiliary / gallivm / lp_bld_ir_common.h
1 /**************************************************************************
2 *
3 * Copyright 2011-2012 Advanced Micro Devices, Inc.
4 * Copyright 2009 VMware, Inc.
5 * All Rights Reserved.
6 *
7 * Permission is hereby granted, free of charge, to any person obtaining a
8 * copy of this software and associated documentation files (the
9 * "Software"), to deal in the Software without restriction, including
10 * without limitation the rights to use, copy, modify, merge, publish,
11 * distribute, sub license, and/or sell copies of the Software, and to
12 * permit persons to whom the Software is furnished to do so, subject to
13 * the following conditions:
14 *
15 * The above copyright notice and this permission notice (including the
16 * next paragraph) shall be included in all copies or substantial portions
17 * of the Software.
18 *
19 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
20 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
21 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
22 * IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS BE LIABLE FOR
23 * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
24 * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
25 * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
26 *
27 **************************************************************************/
28
29 #ifndef LP_BLD_IR_COMMON_H
30 #define LP_BLD_IR_COMMON_H
31
32 #include "gallivm/lp_bld.h"
33 #include "gallivm/lp_bld_limits.h"
34
35 /* SM 4.0 says that subroutines can nest 32 deep and
36 * we need one more for our main function */
37 #define LP_MAX_NUM_FUNCS 33
38
39 enum lp_exec_mask_break_type {
40 LP_EXEC_MASK_BREAK_TYPE_LOOP,
41 LP_EXEC_MASK_BREAK_TYPE_SWITCH
42 };
43
44 struct lp_exec_mask {
45 struct lp_build_context *bld;
46
47 boolean has_mask;
48 boolean ret_in_main;
49
50 LLVMTypeRef int_vec_type;
51
52 LLVMValueRef exec_mask;
53
54 LLVMValueRef ret_mask;
55 LLVMValueRef cond_mask;
56 LLVMValueRef switch_mask; /* current switch exec mask */
57 LLVMValueRef cont_mask;
58 LLVMValueRef break_mask;
59
60 struct function_ctx {
61 int pc;
62 LLVMValueRef ret_mask;
63
64 LLVMValueRef cond_stack[LP_MAX_TGSI_NESTING];
65 int cond_stack_size;
66
67 /* keep track if break belongs to switch or loop */
68 enum lp_exec_mask_break_type break_type_stack[LP_MAX_TGSI_NESTING];
69 enum lp_exec_mask_break_type break_type;
70
71 struct {
72 LLVMValueRef switch_val;
73 LLVMValueRef switch_mask;
74 LLVMValueRef switch_mask_default;
75 boolean switch_in_default;
76 unsigned switch_pc;
77 } switch_stack[LP_MAX_TGSI_NESTING];
78 int switch_stack_size;
79 LLVMValueRef switch_val;
80 LLVMValueRef switch_mask_default; /* reverse of switch mask used for default */
81 boolean switch_in_default; /* if switch exec is currently in default */
82 unsigned switch_pc; /* when used points to default or endswitch-1 */
83
84 LLVMValueRef loop_limiter;
85 LLVMBasicBlockRef loop_block;
86 LLVMValueRef break_var;
87 struct {
88 LLVMBasicBlockRef loop_block;
89 LLVMValueRef cont_mask;
90 LLVMValueRef break_mask;
91 LLVMValueRef break_var;
92 } loop_stack[LP_MAX_TGSI_NESTING];
93 int loop_stack_size;
94 int bgnloop_stack_size;
95
96 } *function_stack;
97 int function_stack_size;
98 };
99
100 void lp_exec_mask_function_init(struct lp_exec_mask *mask, int function_idx);
101 void lp_exec_mask_init(struct lp_exec_mask *mask, struct lp_build_context *bld);
102 void lp_exec_mask_fini(struct lp_exec_mask *mask);
103 void lp_exec_mask_store(struct lp_exec_mask *mask,
104 struct lp_build_context *bld_store,
105 LLVMValueRef val,
106 LLVMValueRef dst_ptr);
107 void lp_exec_mask_update(struct lp_exec_mask *mask);
108 void lp_exec_bgnloop_post_phi(struct lp_exec_mask *mask);
109 void lp_exec_bgnloop(struct lp_exec_mask *mask, bool load_mask);
110 void lp_exec_endloop(struct gallivm_state *gallivm,
111 struct lp_exec_mask *mask);
112 void lp_exec_mask_cond_push(struct lp_exec_mask *mask,
113 LLVMValueRef val);
114 void lp_exec_mask_cond_invert(struct lp_exec_mask *mask);
115 void lp_exec_mask_cond_pop(struct lp_exec_mask *mask);
116 void lp_exec_continue(struct lp_exec_mask *mask);
117
118 void lp_exec_break(struct lp_exec_mask *mask, int *pc, bool break_always);
119
120 #endif