Mesa (main): clc: add simple llvm initialise API

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Thu Apr 14 22:00:15 UTC 2022


Module: Mesa
Branch: main
Commit: b518020f64851ed4a8bd1cd0aafe4a2ab711b722
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=b518020f64851ed4a8bd1cd0aafe4a2ab711b722

Author: Dave Airlie <airlied at gmail.com>
Date:   Wed Oct 13 11:18:37 2021 +1000

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 at collabora.com>
Reviewed-by: Jesse Natalie <jenatali at microsoft.com>
Reviewed-by: Icecream95 <ixn at disroot.org>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/15937>

---

 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 ddc6a40f29e..189152c5849 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<::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();
+}
diff --git a/src/compiler/clc/clc_helpers.h b/src/compiler/clc/clc_helpers.h
index cbad142efeb..0ad0990f074 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,



More information about the mesa-commit mailing list