Debian Codegraph @

src/gallium/auxiliary/gallivm/lp_bld_coro.h

raw symbols SCIP
1 /**************************************************************************
2 *
3 * Copyright 2019 Red Hat.
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 "Software"),
8 * to deal in the Software without restriction, including without limitation
9 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
10 * and/or sell copies of the Software, and to permit persons to whom the
11 * Software is furnished to do so, subject to the following conditions:
12 *
13 * The above copyright notice and this permission notice shall be included
14 * in all copies or substantial portions of the Software.
15 *
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
17 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
19 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 * SOFTWARE.
23 *
24 **************************************************************************/
25
26 #ifndef LP_BLD_CORO_H
27 #define LP_BLD_CORO_H
28
29 #include <stdbool.h>
30 #include "lp_bld_intr.h"
31
32 #ifdef __cplusplus
33 extern "C" {
34 #endif
35
36 struct gallivm_state;
37 LLVMValueRef lp_build_coro_id(struct gallivm_state *gallivm);
38
39 LLVMValueRef lp_build_coro_size(struct gallivm_state *gallivm);
40
41 LLVMValueRef lp_build_coro_begin(struct gallivm_state *gallivm,
42 LLVMValueRef coro_id, LLVMValueRef mem_ptr);
43
44 LLVMValueRef lp_build_coro_free(struct gallivm_state *gallivm,
45 LLVMValueRef coro_id, LLVMValueRef coro_hdl);
46
47 void lp_build_coro_end(struct gallivm_state *gallivm,
48 LLVMValueRef coro_hdl);
49
50 void lp_build_coro_resume(struct gallivm_state *gallivm, LLVMValueRef coro_hdl);
51
52 void lp_build_coro_destroy(struct gallivm_state *gallivm, LLVMValueRef coro_hdl);
53
54 LLVMValueRef lp_build_coro_done(struct gallivm_state *gallivm, LLVMValueRef coro_hdl);
55
56 LLVMValueRef lp_build_coro_suspend(struct gallivm_state *gallivm, bool last);
57
58 LLVMValueRef lp_build_coro_alloc(struct gallivm_state *gallivm, LLVMValueRef id);
59
60 LLVMValueRef lp_build_coro_begin_alloc_mem(struct gallivm_state *gallivm, LLVMValueRef coro_id);
61
62 LLVMValueRef lp_build_coro_alloc_mem_array(struct gallivm_state *gallivm,
63 LLVMValueRef coro_hdl_ptr, LLVMValueRef coro_idx,
64 LLVMValueRef coro_num_hdls);
65 void lp_build_coro_free_mem(struct gallivm_state *gallivm, LLVMValueRef coro_id, LLVMValueRef coro_hdl);
66
67 struct lp_build_coro_suspend_info {
68 LLVMBasicBlockRef suspend;
69 LLVMBasicBlockRef cleanup;
70 };
71
72 void lp_build_coro_suspend_switch(struct gallivm_state *gallivm,
73 const struct lp_build_coro_suspend_info *sus_info,
74 LLVMBasicBlockRef resume_block,
75 bool final_suspend);
76
77 void lp_build_coro_add_malloc_hooks(struct gallivm_state *gallivm);
78 void lp_build_coro_declare_malloc_hooks(struct gallivm_state *gallivm);
79
80 static inline void lp_build_coro_add_presplit(LLVMValueRef coro)
81 {
82 #if LLVM_VERSION_MAJOR >= 15
83 lp_add_function_attr(coro, -1, LP_FUNC_ATTR_PRESPLITCORO);
84 #else
85 LLVMAddTargetDependentFunctionAttr(coro, "coroutine.presplit", "0");
86 #endif
87 }
88
89 #ifdef __cplusplus
90 }
91 #endif
92
93 #endif