clover/llvm: Pass device down to compile
authorAaron Watry <awatry@gmail.com>
Sun, 6 Aug 2017 01:41:40 +0000 (20:41 -0500)
committerAaron Watry <awatry@gmail.com>
Tue, 6 Mar 2018 02:09:46 +0000 (20:09 -0600)
We'll need to be able to detect device version to define the appropriate
__OPENCL_VERSION__ header.

v2: Rebase after removing the previous patch (Pierre)
  - Removed "clover: Add device_clc_version to llvm::create_compiler_instance"

Signed-off-by: Aaron Watry <awatry@gmail.com>
Reviewed-by: Pierre Moreau <pierre.morrow@free.fr>
Reviewed-by: Francisco Jerez <currojerez@riseup.net>
src/gallium/state_trackers/clover/llvm/invocation.cpp

index 2635064bec7813badaf254e93eb4609abf2494d7..0bc0cccc6e7ad5bad5f423f3af9f6228b3a2b4b0 100644 (file)
@@ -145,7 +145,7 @@ namespace {
    std::unique_ptr<Module>
    compile(LLVMContext &ctx, clang::CompilerInstance &c,
            const std::string &name, const std::string &source,
-           const header_map &headers, const std::string &target,
+           const header_map &headers, const device &dev,
            const std::string &opts, std::string &r_log) {
       c.getFrontendOpts().ProgramAction = clang::frontend::EmitLLVMOnly;
       c.getHeaderSearchOpts().UseBuiltinIncludes = true;
@@ -189,7 +189,7 @@ namespace {
       // barrier() (e.g. Moving barrier() inside a conditional that is
       // no executed by all threads) during its optimizaton passes.
       compat::add_link_bitcode_file(c.getCodeGenOpts(),
-                                    LIBCLC_LIBEXECDIR + target + ".bc");
+                                    LIBCLC_LIBEXECDIR + dev.ir_target() + ".bc");
 
       // Compile the code
       clang::EmitLLVMOnlyAction act(&ctx);
@@ -211,8 +211,7 @@ clover::llvm::compile_program(const std::string &source,
 
    auto ctx = create_context(r_log);
    auto c = create_compiler_instance(dev, tokenize(opts + " input.cl"), r_log);
-   auto mod = compile(*ctx, *c, "input.cl", source, headers, dev.ir_target(),
-                      opts, r_log);
+   auto mod = compile(*ctx, *c, "input.cl", source, headers, dev, opts, r_log);
 
    if (has_flag(debug::llvm))
       debug::log(".ll", print_module_bitcode(*mod));