summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJesse Natalie <jenatali@microsoft.com>2020-11-18 18:27:07 -0800
committerJesse Natalie <jenatali@microsoft.com>2020-12-02 10:12:27 -0800
commit425cfcafb20ab91669e2a080f4b095111d62969f (patch)
tree7241d80c44f9a79988fde65a7448215dba9d7e21
parent60454a4e990e2469846cfa07cf495a4bf5751207 (diff)
clover: Add opencl-native build flag
This flag controls whether to include native codegen functionality for the AMD backend Reviewed-by: Francisco Jerez <currojerez@riseup.net> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/7680>
-rw-r--r--meson.build5
-rw-r--r--meson_options.txt6
-rw-r--r--src/gallium/frontends/clover/llvm/codegen/native.cpp25
-rw-r--r--src/gallium/frontends/clover/meson.build4
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
@@ -156,6 +156,12 @@ option(
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',
value : [],
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