mesa/src/gallium/auxiliary/gallivm/lp_bld_coro.h

77 lines
3.2 KiB
C

/**************************************************************************
*
* Copyright 2019 Red Hat.
* All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*
**************************************************************************/
#ifndef LP_BLD_CORO_H
#define LP_BLD_CORO_H
#include <stdbool.h>
#include "pipe/p_compiler.h"
#include "gallivm/lp_bld.h"
struct gallivm_state;
LLVMValueRef lp_build_coro_id(struct gallivm_state *gallivm);
LLVMValueRef lp_build_coro_size(struct gallivm_state *gallivm);
LLVMValueRef lp_build_coro_begin(struct gallivm_state *gallivm,
LLVMValueRef coro_id, LLVMValueRef mem_ptr);
LLVMValueRef lp_build_coro_free(struct gallivm_state *gallivm,
LLVMValueRef coro_id, LLVMValueRef coro_hdl);
void lp_build_coro_end(struct gallivm_state *gallivm,
LLVMValueRef coro_hdl);
void lp_build_coro_resume(struct gallivm_state *gallivm, LLVMValueRef coro_hdl);
void lp_build_coro_destroy(struct gallivm_state *gallivm, LLVMValueRef coro_hdl);
LLVMValueRef lp_build_coro_done(struct gallivm_state *gallivm, LLVMValueRef coro_hdl);
LLVMValueRef lp_build_coro_suspend(struct gallivm_state *gallivm, bool last);
LLVMValueRef lp_build_coro_alloc(struct gallivm_state *gallivm, LLVMValueRef id);
LLVMValueRef lp_build_coro_begin_alloc_mem(struct gallivm_state *gallivm, LLVMValueRef coro_id);
LLVMValueRef lp_build_coro_alloc_mem_array(struct gallivm_state *gallivm,
LLVMValueRef coro_hdl_ptr, LLVMValueRef coro_idx,
LLVMValueRef coro_num_hdls);
void lp_build_coro_free_mem(struct gallivm_state *gallivm, LLVMValueRef coro_id, LLVMValueRef coro_hdl);
struct lp_build_coro_suspend_info {
LLVMBasicBlockRef suspend;
LLVMBasicBlockRef cleanup;
};
void lp_build_coro_suspend_switch(struct gallivm_state *gallivm,
const struct lp_build_coro_suspend_info *sus_info,
LLVMBasicBlockRef resume_block,
bool final_suspend);
void lp_build_coro_add_malloc_hooks(struct gallivm_state *gallivm);
void lp_build_coro_declare_malloc_hooks(struct gallivm_state *gallivm);
#endif