clc: add simple llvm initialise API
authorDave Airlie <airlied@gmail.com>
Wed, 13 Oct 2021 01:18:37 +0000 (11:18 +1000)
committerMarge Bot <emma+marge@anholt.net>
Thu, 14 Apr 2022 21:19:56 +0000 (21:19 +0000)
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>

src/compiler/clc/clc_helpers.cpp
src/compiler/clc/clc_helpers.h

index ddc6a40..189152c 100644 (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();
+}
index cbad142..0ad0990 100644 (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,