- .gitlab-ci/meson-build.sh
- LLVM_VERSION=8 .gitlab-ci/meson-build.sh
-meson-clover-old-llvm:
- extends:
- - meson-clover
- - .use-x86_build_old
- variables:
- UNWIND: "disabled"
- DRI_LOADERS: >
- -D glx=disabled
- -D egl=disabled
- -D gbm=disabled
- -D platforms=[]
- GALLIUM_DRIVERS: "i915,r600"
- script:
- - LLVM_VERSION=3.9 .gitlab-ci/meson-build.sh
- - LLVM_VERSION=4.0 .gitlab-ci/meson-build.sh
- - LLVM_VERSION=5.0 .gitlab-ci/meson-build.sh
- - LLVM_VERSION=6.0 .gitlab-ci/meson-build.sh
- - LLVM_VERSION=7 .gitlab-ci/meson-build.sh
-
meson-vulkan:
extends: .meson-build
variables:
]
endif
-with_opencl_spirv = _opencl != 'disabled' and get_option('opencl-spirv')
-if with_amd_vk or with_gallium_radeonsi or with_opencl_spirv
+if with_amd_vk or with_gallium_radeonsi or with_gallium_opencl
_llvm_version = '>= 8.0.0'
elif with_gallium_swr
_llvm_version = '>= 6.0.0'
error('The OpenCL "Clover" state tracker requires LLVM, but LLVM is disabled.')
endif
+with_opencl_spirv = _opencl != 'disabled' and get_option('opencl-spirv')
if with_opencl_spirv
chosen_llvm_version_array = dep_llvm.version().split('.')
chosen_llvm_version_major = chosen_llvm_version_array[0].to_int()
emit_code(const ::llvm::Module &mod) {
::llvm::SmallVector<char, 1024> data;
::llvm::raw_svector_ostream os { data };
- compat::write_bitcode_to_file(mod, os);
+ ::llvm::WriteBitcodeToFile(mod, os);
return { os.str().begin(), os.str().end() };
}
}
auto mod = ::llvm::parseBitcodeFile(::llvm::MemoryBufferRef(
as_string(m.secs[0].data), " "), ctx);
- compat::handle_module_error(mod, [&](const std::string &s) {
- fail(r_log, error(CL_INVALID_PROGRAM), s);
+ if (::llvm::Error err = mod.takeError()) {
+ ::llvm::handleAllErrors(std::move(err), [&](::llvm::ErrorInfoBase &eib) {
+ fail(r_log, error(CL_INVALID_PROGRAM), eib.message());
});
+ }
return std::unique_ptr< ::llvm::Module>(std::move(*mod));
}
// type that is not a power of two bytes in size must be
// aligned to the next larger power of two.
// This rule applies to built-in types only, not structs or unions."
- const unsigned arg_store_size = dl.getTypeStoreSize(arg_type);
const unsigned arg_api_size = dl.getTypeAllocSize(arg_type);
- const auto target_type = compat::get_abi_type(arg_type, mod);
- const unsigned target_size = dl.getTypeStoreSize(target_type);
- const unsigned target_align = dl.getABITypeAlignment(target_type);
+ const unsigned target_size = dl.getTypeStoreSize(arg_type);
+ const unsigned target_align = dl.getABITypeAlignment(arg_type);
const auto type_name = get_argument_metadata(f, arg,
"kernel_arg_type");
const auto access_qual = get_argument_metadata(
f, arg, "kernel_arg_access_qual");
args.emplace_back(get_image_type(type_name, access_qual),
- arg_store_size, target_size,
+ target_size, target_size,
target_align, module::argument::zero_ext);
} else if (type_name == "__llvm_image_size") {
const unsigned address_space =
cast< ::llvm::PointerType>(actual_type)->getAddressSpace();
- if (address_space == compat::target_address_space(
- c.getTarget(), clang::LangAS::opencl_local)) {
+ const auto &map = c.getTarget().getAddressSpaceMap();
+ const auto offset =
+ static_cast<unsigned>(clang::LangAS::opencl_local);
+ if (address_space == map[offset]) {
args.emplace_back(module::argument::local, arg_api_size,
target_size, target_align,
module::argument::zero_ext);
std::unique_ptr<TargetMachine> tm {
t->createTargetMachine(target.triple, target.cpu, "", {},
- ::llvm::None, compat::default_code_model,
+ ::llvm::None, ::llvm::None,
::llvm::CodeGenOpt::Default) };
if (!tm)
fail(r_log, build_error(),
tm->Options.MCOptions.AsmVerbose =
(ft == compat::CGFT_AssemblyFile);
- if (compat::add_passes_to_emit_file(*tm, pm, os, ft))
+ if (tm->addPassesToEmitFile(pm, os, nullptr, ft))
fail(r_log, build_error(), "TargetMachine can't emit this file");
pm.run(mod);
const target &target) {
std::string log;
try {
- std::unique_ptr< ::llvm::Module> cmod { compat::clone_module(mod) };
+ std::unique_ptr< ::llvm::Module> cmod { ::llvm::CloneModule(mod) };
return as_string(emit_code(*cmod, target,
compat::CGFT_AssemblyFile, log));
} catch (...) {
#include "util/algorithm.hpp"
#include <llvm/Config/llvm-config.h>
-#if LLVM_VERSION_MAJOR < 4
-#include <llvm/Bitcode/ReaderWriter.h>
-#else
-#include <llvm/Bitcode/BitcodeReader.h>
-#include <llvm/Bitcode/BitcodeWriter.h>
-#endif
#include <llvm/IR/LLVMContext.h>
#include <llvm/Linker/Linker.h>
#include <llvm/Transforms/IPO.h>
#include <llvm/Transforms/Utils/Cloning.h>
#include <llvm/Target/TargetMachine.h>
-#if LLVM_VERSION_MAJOR >= 4
-#include <llvm/Support/Error.h>
-#else
-#include <llvm/Support/ErrorOr.h>
-#endif
#include <llvm/IR/LegacyPassManager.h>
#include <llvm/Analysis/TargetLibraryInfo.h>
#include <clang/Basic/TargetInfo.h>
#include <clang/Frontend/CompilerInstance.h>
-#if LLVM_VERSION_MAJOR >= 8
-#include <clang/Basic/CodeGenOptions.h>
-#else
-#include <clang/Frontend/CodeGenOptions.h>
-#endif
-
#if LLVM_VERSION_MAJOR >= 10
#include <llvm/Support/CodeGen.h>
#endif
typedef ::llvm::TargetMachine::CodeGenFileType CodeGenFileType;
#endif
- template<typename T, typename AS>
- unsigned target_address_space(const T &target, const AS lang_as) {
- const auto &map = target.getAddressSpaceMap();
-#if LLVM_VERSION_MAJOR >= 5
- return map[static_cast<unsigned>(lang_as)];
-#else
- return map[lang_as - clang::LangAS::Offset];
-#endif
- }
-
#if LLVM_VERSION_MAJOR >= 10
const clang::InputKind ik_opencl = clang::Language::OpenCL;
-#elif LLVM_VERSION_MAJOR >= 5
- const clang::InputKind ik_opencl = clang::InputKind::OpenCL;
-#else
- const clang::InputKind ik_opencl = clang::IK_OpenCL;
-#endif
-
-#if LLVM_VERSION_MAJOR >= 5
- const clang::LangStandard::Kind lang_opencl10 = clang::LangStandard::lang_opencl10;
-#else
- const clang::LangStandard::Kind lang_opencl10 = clang::LangStandard::lang_opencl;
-#endif
-
- inline void
- add_link_bitcode_file(clang::CodeGenOptions &opts,
- const std::string &path) {
-#if LLVM_VERSION_MAJOR >= 5
- clang::CodeGenOptions::BitcodeFileToLink F;
-
- F.Filename = path;
- F.PropagateAttrs = true;
- F.LinkFlags = ::llvm::Linker::Flags::None;
- opts.LinkBitcodeFiles.emplace_back(F);
-#else
- opts.LinkBitcodeFiles.emplace_back(::llvm::Linker::Flags::None, path);
-#endif
- }
-
-#if LLVM_VERSION_MAJOR >= 6
- const auto default_code_model = ::llvm::None;
-#else
- const auto default_code_model = ::llvm::CodeModel::Default;
-#endif
-
- template<typename M, typename F> void
- handle_module_error(M &mod, const F &f) {
-#if LLVM_VERSION_MAJOR >= 4
- if (::llvm::Error err = mod.takeError())
- ::llvm::handleAllErrors(std::move(err), [&](::llvm::ErrorInfoBase &eib) {
- f(eib.message());
- });
#else
- if (!mod)
- f(mod.getError().message());
-#endif
- }
-
- template<typename T> void
- set_diagnostic_handler(::llvm::LLVMContext &ctx,
- T *diagnostic_handler, void *data) {
-#if LLVM_VERSION_MAJOR >= 6
- ctx.setDiagnosticHandlerCallBack(diagnostic_handler, data);
-#else
- ctx.setDiagnosticHandler(diagnostic_handler, data);
-#endif
- }
-
- inline std::unique_ptr< ::llvm::Module>
- clone_module(const ::llvm::Module &mod)
- {
-#if LLVM_VERSION_MAJOR >= 7
- return ::llvm::CloneModule(mod);
-#else
- return ::llvm::CloneModule(&mod);
-#endif
- }
-
- template<typename T> void
- write_bitcode_to_file(const ::llvm::Module &mod, T &os)
- {
-#if LLVM_VERSION_MAJOR >= 7
- ::llvm::WriteBitcodeToFile(mod, os);
-#else
- ::llvm::WriteBitcodeToFile(&mod, os);
-#endif
- }
-
- template<typename TM, typename PM, typename OS, typename FT>
- bool add_passes_to_emit_file(TM &tm, PM &pm, OS &os, FT &ft)
- {
-#if LLVM_VERSION_MAJOR >= 7
- return tm.addPassesToEmitFile(pm, os, nullptr, ft);
-#else
- return tm.addPassesToEmitFile(pm, os, ft);
+ const clang::InputKind ik_opencl = clang::InputKind::OpenCL;
#endif
- }
template<typename T> inline bool
create_compiler_invocation_from_args(clang::CompilerInvocation &cinv,
cinv, copts.data(), copts.data() + copts.size(), diag);
#endif
}
-
- template<typename T, typename M>
- T get_abi_type(const T &arg_type, const M &mod) {
-#if LLVM_VERSION_MAJOR >= 7
- return arg_type;
-#else
- ::llvm::DataLayout dl(&mod);
- const unsigned arg_store_size = dl.getTypeStoreSize(arg_type);
- return !arg_type->isIntegerTy() ? arg_type :
- dl.getSmallestLegalIntType(mod.getContext(), arg_store_size * 8);
-#endif
- }
}
}
}
};
const clc_version_lang_std cl_version_lang_stds[] = {
- { 100, compat::lang_opencl10},
+ { 100, clang::LangStandard::lang_opencl10},
{ 110, clang::LangStandard::lang_opencl11},
{ 120, clang::LangStandard::lang_opencl12},
{ 200, clang::LangStandard::lang_opencl20},
create_context(std::string &r_log) {
init_targets();
std::unique_ptr<LLVMContext> ctx { new LLVMContext };
- compat::set_diagnostic_handler(*ctx, diagnostic_handler, &r_log);
+
+ ctx->setDiagnosticHandlerCallBack(diagnostic_handler, &r_log);
return ctx;
}
// attribute will prevent Clang from creating illegal uses of
// barrier() (e.g. Moving barrier() inside a conditional that is
// no executed by all threads) during its optimizaton passes.
- if (use_libclc)
- compat::add_link_bitcode_file(c.getCodeGenOpts(),
- LIBCLC_LIBEXECDIR + dev.ir_target() + ".bc");
+ if (use_libclc) {
+ clang::CodeGenOptions::BitcodeFileToLink F;
+
+ F.Filename = LIBCLC_LIBEXECDIR + dev.ir_target() + ".bc";
+ F.PropagateAttrs = true;
+ F.LinkFlags = ::llvm::Linker::Flags::None;
+ c.getCodeGenOpts().LinkBitcodeFiles.emplace_back(F);
+ }
// undefine __IMAGE_SUPPORT__ for device without image support
if (!dev.image_support())