clc: add simple llvm initialise API

This just calls some of the LLVM init functions in a common place

Reviewed-by: Jason Ekstrand <jason.ekstrand@collabora.com>
Reviewed-by: Jesse Natalie <jenatali@microsoft.com>
Reviewed-by: Icecream95 <ixn@disroot.org>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/15937>
This commit is contained in:
Dave Airlie 2021-10-13 11:18:37 +10:00 committed by Marge Bot
parent 63e40adf8c
commit b518020f64
2 changed files with 14 additions and 8 deletions

View File

@ -745,10 +745,7 @@ static std::pair<std::unique_ptr<::llvm::Module>, std::unique_ptr<LLVMContext>>
clc_compile_to_llvm_module(const struct clc_compile_args *args,
const struct clc_logger *logger)
{
LLVMInitializeAllTargets();
LLVMInitializeAllTargetInfos();
LLVMInitializeAllTargetMCs();
LLVMInitializeAllAsmPrinters();
clc_initialize_llvm();
std::string log;
std::unique_ptr<LLVMContext> llvm_ctx { new LLVMContext };
@ -991,10 +988,7 @@ clc_spir_to_spirv(const struct clc_binary *in_spir,
const struct clc_logger *logger,
struct clc_binary *out_spirv)
{
LLVMInitializeAllTargets();
LLVMInitializeAllTargetInfos();
LLVMInitializeAllTargetMCs();
LLVMInitializeAllAsmPrinters();
clc_initialize_llvm();
std::unique_ptr<LLVMContext> llvm_ctx{ new LLVMContext };
::llvm::StringRef spir_ref(static_cast<const char*>(in_spir->data), in_spir->size);
@ -1152,3 +1146,12 @@ clc_free_spirv_binary(struct clc_binary *spvbin)
{
free(spvbin->data);
}
void
clc_initialize_llvm(void)
{
LLVMInitializeAllTargets();
LLVMInitializeAllTargetInfos();
LLVMInitializeAllTargetMCs();
LLVMInitializeAllAsmPrinters();
}

View File

@ -38,6 +38,9 @@
extern "C" {
#endif
void
clc_initialize_llvm(void);
bool
clc_spirv_get_kernels_info(const struct clc_binary *spvbin,
const struct clc_kernel_info **kernels,