gallivm: use LLVM opaque pointers in lp_bld_coro.c
Acked-by: Marek Olšák <marek.olsak@amd.com> Acked-by: Pierre-Eric Pelloux-Prayer <pierre-eric.pelloux-prayer@amd.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/15893>
This commit is contained in:
@@ -169,8 +169,10 @@ void lp_build_coro_declare_malloc_hooks(struct gallivm_state *gallivm)
|
||||
LLVMTypeRef int32_type = LLVMInt32TypeInContext(gallivm->context);
|
||||
LLVMTypeRef mem_ptr_type = LLVMPointerType(LLVMInt8TypeInContext(gallivm->context), 0);
|
||||
LLVMTypeRef malloc_type = LLVMFunctionType(mem_ptr_type, &int32_type, 1, 0);
|
||||
gallivm->coro_malloc_hook_type = malloc_type;
|
||||
gallivm->coro_malloc_hook = LLVMAddFunction(gallivm->module, "coro_malloc", malloc_type);
|
||||
LLVMTypeRef free_type = LLVMFunctionType(LLVMVoidTypeInContext(gallivm->context), &mem_ptr_type, 1, 0);
|
||||
gallivm->coro_free_hook_type = free_type;
|
||||
gallivm->coro_free_hook = LLVMAddFunction(gallivm->module, "coro_free", free_type);
|
||||
}
|
||||
|
||||
@@ -184,7 +186,10 @@ LLVMValueRef lp_build_coro_begin_alloc_mem(struct gallivm_state *gallivm, LLVMVa
|
||||
LLVMValueRef alloc_mem;
|
||||
|
||||
assert(gallivm->coro_malloc_hook);
|
||||
alloc_mem = LLVMBuildCall(gallivm->builder, gallivm->coro_malloc_hook, &coro_size, 1, "");
|
||||
LLVMTypeRef malloc_type =
|
||||
LLVMFunctionType(mem_ptr_type,
|
||||
(LLVMTypeRef[]){LLVMInt32TypeInContext(gallivm->context)}, 1, 0);
|
||||
alloc_mem = LLVMBuildCall2(gallivm->builder, malloc_type, gallivm->coro_malloc_hook, &coro_size, 1, "");
|
||||
lp_build_endif(&if_state_coro);
|
||||
|
||||
LLVMValueRef phi = LLVMBuildPhi(gallivm->builder, mem_ptr_type, "");
|
||||
@@ -212,7 +217,8 @@ LLVMValueRef lp_build_coro_alloc_mem_array(struct gallivm_state *gallivm,
|
||||
LLVMValueRef alloc_mem;
|
||||
LLVMValueRef alloc_size = LLVMBuildMul(gallivm->builder, coro_num_hdls, coro_size, "");
|
||||
assert(gallivm->coro_malloc_hook);
|
||||
alloc_mem = LLVMBuildCall(gallivm->builder, gallivm->coro_malloc_hook, &alloc_size, 1, "");
|
||||
assert(gallivm->coro_malloc_hook_type);
|
||||
alloc_mem = LLVMBuildCall2(gallivm->builder, gallivm->coro_malloc_hook_type, gallivm->coro_malloc_hook, &alloc_size, 1, "");
|
||||
LLVMBuildStore(gallivm->builder, alloc_mem, coro_hdl_ptr);
|
||||
lp_build_endif(&if_state_coro);
|
||||
|
||||
@@ -223,8 +229,9 @@ void lp_build_coro_free_mem(struct gallivm_state *gallivm, LLVMValueRef coro_id,
|
||||
{
|
||||
LLVMValueRef alloc_mem = lp_build_coro_free(gallivm, coro_id, coro_hdl);
|
||||
|
||||
assert(gallivm->coro_malloc_hook);
|
||||
alloc_mem = LLVMBuildCall(gallivm->builder, gallivm->coro_free_hook, &alloc_mem, 1, "");
|
||||
assert(gallivm->coro_free_hook);
|
||||
assert(gallivm->coro_free_hook_type);
|
||||
alloc_mem = LLVMBuildCall2(gallivm->builder, gallivm->coro_free_hook_type, gallivm->coro_free_hook, &alloc_mem, 1, "");
|
||||
}
|
||||
|
||||
void lp_build_coro_suspend_switch(struct gallivm_state *gallivm, const struct lp_build_coro_suspend_info *sus_info,
|
||||
|
||||
@@ -57,6 +57,9 @@ struct gallivm_state
|
||||
LLVMValueRef coro_malloc_hook;
|
||||
LLVMValueRef coro_free_hook;
|
||||
LLVMValueRef debug_printf_hook;
|
||||
|
||||
LLVMTypeRef coro_malloc_hook_type;
|
||||
LLVMTypeRef coro_free_hook_type;
|
||||
};
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user