Merge branch 'mesa_7_5_branch' into mesa_7_6_branch
[mesa.git] / src / gallium / drivers / llvmpipe / lp_bld_flow.h
1 /**************************************************************************
2 *
3 * Copyright 2009 VMware, Inc.
4 * All Rights Reserved.
5 *
6 * Permission is hereby granted, free of charge, to any person obtaining a
7 * copy of this software and associated documentation files (the
8 * "Software"), to deal in the Software without restriction, including
9 * without limitation the rights to use, copy, modify, merge, publish,
10 * distribute, sub license, and/or sell copies of the Software, and to
11 * permit persons to whom the Software is furnished to do so, subject to
12 * the following conditions:
13 *
14 * The above copyright notice and this permission notice (including the
15 * next paragraph) shall be included in all copies or substantial portions
16 * of the Software.
17 *
18 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
19 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
20 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
21 * IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS BE LIABLE FOR
22 * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
23 * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
24 * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
25 *
26 **************************************************************************/
27
28 /**
29 * LLVM control flow build helpers.
30 *
31 * @author Jose Fonseca <jfonseca@vmware.com>
32 */
33
34 #ifndef LP_BLD_FLOW_H
35 #define LP_BLD_FLOW_H
36
37
38 #include <llvm-c/Core.h>
39
40
41 union lp_type;
42
43
44 struct lp_build_mask_context
45 {
46 LLVMBuilderRef builder;
47
48 LLVMTypeRef reg_type;
49
50 LLVMValueRef value;
51
52 LLVMValueRef phi;
53
54 LLVMBasicBlockRef skip_block;
55 };
56
57
58 void
59 lp_build_mask_begin(struct lp_build_mask_context *mask,
60 LLVMBuilderRef builder,
61 union lp_type type,
62 LLVMValueRef value);
63
64 /**
65 * Bitwise AND the mask with the given value, if a previous mask was set.
66 */
67 void
68 lp_build_mask_update(struct lp_build_mask_context *mask,
69 LLVMValueRef value);
70
71 LLVMValueRef
72 lp_build_mask_end(struct lp_build_mask_context *mask);
73
74
75 /**
76 * LLVM's IR doesn't represent for-loops directly. Furthermore it
77 * it requires creating code blocks, branches, phi variables, so it
78 * requires a fair amount of code.
79 *
80 * @sa http://www.llvm.org/docs/tutorial/LangImpl5.html#for
81 */
82 struct lp_build_loop_state
83 {
84 LLVMBasicBlockRef block;
85 LLVMValueRef counter;
86 };
87
88
89 void
90 lp_build_loop_begin(LLVMBuilderRef builder,
91 LLVMValueRef start,
92 struct lp_build_loop_state *state);
93
94
95 void
96 lp_build_loop_end(LLVMBuilderRef builder,
97 LLVMValueRef end,
98 LLVMValueRef step,
99 struct lp_build_loop_state *state);
100
101
102
103 #endif /* !LP_BLD_FLOW_H */