summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJesse Natalie <jenatali@microsoft.com>2020-11-18 18:34:07 -0800
committerJesse Natalie <jenatali@microsoft.com>2020-12-02 10:13:34 -0800
commit4cfd57dd489bab37ed77bddcfe4bbf55051f5362 (patch)
treed7a05b4858d4d5b7c354a3afbb01b5b9effb4589
parent149a036825ba74f9edd2468430f99ec0e927b845 (diff)
clover/llvm: Work around MSVC quirks
Two things: 1. While instantiating a template where clover::llvm and ::llvm are both resolvable for unscoped llvm, MSVC complains about ambiguity. Resolve by not using namespace clover, leaving only ::llvm as a valid namespace. 2. LLVM headers (specifically Allocator.h) use __declspec(restrict), but Mesa's util headers #define restrict to __restrict for C++. Since __declspec(__restrict) is invalid, make sure we always include Allocator.h first before the util header. 3. Change a uint/int to uint64_t to match the type returned from LLVM. Reviewed-by: Francisco Jerez <currojerez@riseup.net> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/7680>
-rw-r--r--src/gallium/frontends/clover/llvm/codegen/bitcode.cpp4
-rw-r--r--src/gallium/frontends/clover/llvm/codegen/common.cpp7
-rw-r--r--src/gallium/frontends/clover/llvm/codegen/native.cpp11
-rw-r--r--src/gallium/frontends/clover/llvm/invocation.cpp11
-rw-r--r--src/gallium/frontends/clover/llvm/metadata.hpp2
5 files changed, 23 insertions, 12 deletions
diff --git a/src/gallium/frontends/clover/llvm/codegen/bitcode.cpp b/src/gallium/frontends/clover/llvm/codegen/bitcode.cpp
index 413f11031d3..8ea3e57168d 100644
--- a/src/gallium/frontends/clover/llvm/codegen/bitcode.cpp
+++ b/src/gallium/frontends/clover/llvm/codegen/bitcode.cpp
@@ -31,6 +31,8 @@
/// after linking against other bitcode object files.
///
+#include <llvm/Support/Allocator.h>
+
#include "llvm/codegen.hpp"
#include "llvm/compat.hpp"
#include "llvm/metadata.hpp"
@@ -47,7 +49,7 @@
#endif
#include <llvm/Support/raw_ostream.h>
-using namespace clover;
+using clover::module;
using namespace clover::llvm;
namespace {
diff --git a/src/gallium/frontends/clover/llvm/codegen/common.cpp b/src/gallium/frontends/clover/llvm/codegen/common.cpp
index cb2a9f67f35..989d0f3b3e8 100644
--- a/src/gallium/frontends/clover/llvm/codegen/common.cpp
+++ b/src/gallium/frontends/clover/llvm/codegen/common.cpp
@@ -30,6 +30,8 @@
/// understood by pipe drivers.
///
+#include <llvm/Support/Allocator.h>
+
#include "llvm/codegen.hpp"
#include "llvm/metadata.hpp"
@@ -40,7 +42,8 @@
#include <clang/Basic/TargetInfo.h>
-using namespace clover;
+using clover::module;
+using clover::detokenize;
using namespace clover::llvm;
using ::llvm::Module;
@@ -69,7 +72,7 @@ namespace {
module::arg_info create_arg_info(const std::string &arg_name,
const std::string &type_name,
const std::string &type_qualifier,
- const int address_qualifier,
+ const uint64_t address_qualifier,
const std::string &access_qualifier) {
cl_kernel_arg_type_qualifier cl_type_qualifier =
diff --git a/src/gallium/frontends/clover/llvm/codegen/native.cpp b/src/gallium/frontends/clover/llvm/codegen/native.cpp
index dbd7a0c7993..683e966ea59 100644
--- a/src/gallium/frontends/clover/llvm/codegen/native.cpp
+++ b/src/gallium/frontends/clover/llvm/codegen/native.cpp
@@ -27,16 +27,17 @@
/// executable code as an ELF object file.
///
+#include <llvm/Target/TargetMachine.h>
+#include <llvm/Support/TargetRegistry.h>
+#include <llvm/Transforms/Utils/Cloning.h>
+
#include "llvm/codegen.hpp"
#include "llvm/compat.hpp"
#include "llvm/util.hpp"
#include "core/error.hpp"
-#include <llvm/Target/TargetMachine.h>
-#include <llvm/Support/TargetRegistry.h>
-#include <llvm/Transforms/Utils/Cloning.h>
-
-using namespace clover;
+using clover::module;
+using clover::build_error;
using namespace clover::llvm;
using ::llvm::TargetMachine;
diff --git a/src/gallium/frontends/clover/llvm/invocation.cpp b/src/gallium/frontends/clover/llvm/invocation.cpp
index ef0c31cdac5..fe7dfdb07c1 100644
--- a/src/gallium/frontends/clover/llvm/invocation.cpp
+++ b/src/gallium/frontends/clover/llvm/invocation.cpp
@@ -60,7 +60,12 @@
#include "util/algorithm.hpp"
-using namespace clover;
+using clover::module;
+using clover::device;
+using clover::build_error;
+using clover::invalid_build_options_error;
+using clover::map;
+using clover::header_map;
using namespace clover::llvm;
using ::llvm::Function;
@@ -346,13 +351,13 @@ namespace {
#ifdef HAVE_CLOVER_SPIRV
SPIRV::TranslatorOpts
get_spirv_translator_options(const device &dev) {
- const auto supported_versions = spirv::supported_versions();
+ const auto supported_versions = clover::spirv::supported_versions();
const auto maximum_spirv_version =
std::min(static_cast<SPIRV::VersionNumber>(supported_versions.back()),
SPIRV::VersionNumber::MaximumVersion);
SPIRV::TranslatorOpts::ExtensionsStatusMap spirv_extensions;
- for (auto &ext : spirv::supported_extensions()) {
+ for (auto &ext : clover::spirv::supported_extensions()) {
#define EXT(X) if (ext == #X) spirv_extensions.insert({ SPIRV::ExtensionID::X, true });
#include <LLVMSPIRVLib/LLVMSPIRVExtensions.inc>
#undef EXT
diff --git a/src/gallium/frontends/clover/llvm/metadata.hpp b/src/gallium/frontends/clover/llvm/metadata.hpp
index be97a0036fe..e3e58a32ff9 100644
--- a/src/gallium/frontends/clover/llvm/metadata.hpp
+++ b/src/gallium/frontends/clover/llvm/metadata.hpp
@@ -164,7 +164,7 @@ namespace clover {
/// Extract the int metadata node \p name corresponding to the kernel
/// argument given by \p arg.
///
- inline uint
+ inline uint64_t
get_uint_argument_metadata(const ::llvm::Function &f,
const ::llvm::Argument &arg,
const std::string &name) {