ac: add build_alloca with an initializer

combining alloca_undef + BuildStore.

Reviewed-by: Pierre-Eric Pelloux-Prayer <pierre-eric.pelloux-prayer@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/7542>
This commit is contained in:
Marek Olšák
2020-11-10 08:53:02 -05:00
committed by Marge Bot
parent 025bc9e50e
commit d425d765bf
6 changed files with 19 additions and 15 deletions

View File

@@ -3222,6 +3222,13 @@ LLVMValueRef ac_build_alloca(struct ac_llvm_context *ac, LLVMTypeRef type, const
return ptr;
}
LLVMValueRef ac_build_alloca_init(struct ac_llvm_context *ac, LLVMValueRef val, const char *name)
{
LLVMValueRef ptr = ac_build_alloca_undef(ac, LLVMTypeOf(val), name);
LLVMBuildStore(ac->builder, val, ptr);
return ptr;
}
LLVMValueRef ac_cast_ptr(struct ac_llvm_context *ctx, LLVMValueRef ptr, LLVMTypeRef type)
{
int addr_space = LLVMGetPointerAddressSpace(LLVMTypeOf(ptr));