From b518020f64851ed4a8bd1cd0aafe4a2ab711b722 Mon Sep 17 00:00:00 2001 From: Dave Airlie Date: Wed, 13 Oct 2021 11:18:37 +1000 Subject: [PATCH] clc: add simple llvm initialise API This just calls some of the LLVM init functions in a common place Reviewed-by: Jason Ekstrand Reviewed-by: Jesse Natalie Reviewed-by: Icecream95 Part-of: --- src/compiler/clc/clc_helpers.cpp | 19 +++++++++++-------- src/compiler/clc/clc_helpers.h | 3 +++ 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/src/compiler/clc/clc_helpers.cpp b/src/compiler/clc/clc_helpers.cpp index ddc6a40..189152c5 100644 --- a/src/compiler/clc/clc_helpers.cpp +++ b/src/compiler/clc/clc_helpers.cpp @@ -745,10 +745,7 @@ static std::pair, std::unique_ptr> 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 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 llvm_ctx{ new LLVMContext }; ::llvm::StringRef spir_ref(static_cast(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(); +} diff --git a/src/compiler/clc/clc_helpers.h b/src/compiler/clc/clc_helpers.h index cbad142..0ad0990 100644 --- a/src/compiler/clc/clc_helpers.h +++ b/src/compiler/clc/clc_helpers.h @@ -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, -- 2.7.4