Module: Mesa
Branch: master
Commit: 425cfcafb20ab91669e2a080f4b095111d62969f
URL:    
http://cgit.freedesktop.org/mesa/mesa/commit/?id=425cfcafb20ab91669e2a080f4b095111d62969f

Author: Jesse Natalie <[email protected]>
Date:   Wed Nov 18 18:27:07 2020 -0800

clover: Add opencl-native build flag

This flag controls whether to include native codegen functionality
for the AMD backend

Reviewed-by: Francisco Jerez <[email protected]>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/7680>

---

 meson.build                                        |  5 ++++-
 meson_options.txt                                  |  6 ++++++
 .../frontends/clover/llvm/codegen/native.cpp       | 25 +++++++++++++++++++---
 src/gallium/frontends/clover/meson.build           |  4 ++++
 4 files changed, 36 insertions(+), 4 deletions(-)

diff --git a/meson.build b/meson.build
index f51bc66cb1b..6d1607c35a3 100644
--- a/meson.build
+++ b/meson.build
@@ -1611,7 +1611,10 @@ else
   dep_llvmspirvlib = null_dep
 endif
 
-if (with_amd_vk or with_gallium_radeonsi or with_gallium_opencl or
+with_opencl_native = _opencl != 'disabled' and get_option('opencl-native')
+
+if (with_amd_vk or with_gallium_radeonsi or
+    (with_gallium_opencl and with_opencl_native) or
     (with_gallium_r600 and with_llvm))
   dep_elf = dependency('libelf', required : false)
   if not dep_elf.found()
diff --git a/meson_options.txt b/meson_options.txt
index 834056041cf..8bc3a228f25 100644
--- a/meson_options.txt
+++ b/meson_options.txt
@@ -155,6 +155,12 @@ option(
   value : false,
   description : 'build gallium "clover" OpenCL frontend with SPIR-V binary 
support.',
 )
+option(
+  'opencl-native',
+  type : 'boolean',
+  value : true,
+  description : 'build gallium "clover" OpenCL frontend with native LLVM 
codegen support.',
+)
 option(
   'static-libclc',
   type : 'array',
diff --git a/src/gallium/frontends/clover/llvm/codegen/native.cpp 
b/src/gallium/frontends/clover/llvm/codegen/native.cpp
index bc07fc3b032..dbd7a0c7993 100644
--- a/src/gallium/frontends/clover/llvm/codegen/native.cpp
+++ b/src/gallium/frontends/clover/llvm/codegen/native.cpp
@@ -36,13 +36,15 @@
 #include <llvm/Support/TargetRegistry.h>
 #include <llvm/Transforms/Utils/Cloning.h>
 
-#include <libelf.h>
-#include <gelf.h>
-
 using namespace clover;
 using namespace clover::llvm;
 using ::llvm::TargetMachine;
 
+#ifdef HAVE_CLOVER_NATIVE
+
+#include <libelf.h>
+#include <gelf.h>
+
 namespace {
    namespace elf {
       std::unique_ptr<Elf, int (*)(Elf *)>
@@ -161,3 +163,20 @@ clover::llvm::print_module_native(const ::llvm::Module 
&mod,
       return "Couldn't output native disassembly: " + log;
    }
 }
+
+#else
+
+module
+clover::llvm::build_module_native(::llvm::Module &mod, const target &target,
+                                  const clang::CompilerInstance &c,
+                                  std::string &r_log) {
+   unreachable("Native codegen support disabled at build time");
+}
+
+std::string
+clover::llvm::print_module_native(const ::llvm::Module &mod,
+                                  const target &target) {
+   unreachable("Native codegen support disabled at build time");
+}
+
+#endif
diff --git a/src/gallium/frontends/clover/meson.build 
b/src/gallium/frontends/clover/meson.build
index d76eb20a830..95a100d005c 100644
--- a/src/gallium/frontends/clover/meson.build
+++ b/src/gallium/frontends/clover/meson.build
@@ -44,6 +44,10 @@ if with_opencl_icd
   clover_cpp_args += '-DHAVE_CLOVER_ICD'
 endif
 
+if with_opencl_native
+  clover_spirv_cpp_args += '-DHAVE_CLOVER_NATIVE'
+endif
+
 if with_opencl_spirv
   clover_spirv_cpp_args += '-DHAVE_CLOVER_SPIRV'
 endif

_______________________________________________
mesa-commit mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/mesa-commit

Reply via email to