Skip to content

Commit 81ae85e

Browse files
committed
[Comgr][SPIRV] Specify OpenCL 2.0 for SPIRV translation
The current default is OpenCL 1.2, but for now we only handle OpenCL 2.0. Also clarified that the Log output is the command line equivalent Change-Id: I674547380d838f4021b28c746b5e8780e6c43cd6
1 parent eca0494 commit 81ae85e

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

amd/comgr/src/comgr-compiler.cpp

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1901,7 +1901,11 @@ amd_comgr_status_t AMDGPUCompiler::translateSpirvToBitcode() {
19011901
llvm::Module *M;
19021902
std::string Err;
19031903

1904-
if (!llvm::readSpirv(Context, ISS, M, Err)) {
1904+
SPIRV::TranslatorOpts Opts;
1905+
Opts.enableAllExtensions();
1906+
Opts.setDesiredBIsRepresentation(SPIRV::BIsRepresentation::OpenCL20);
1907+
1908+
if (!llvm::readSpirv(Context, Opts, ISS, M, Err)) {
19051909
LogS << "Failed to load SPIR-V as LLVM Module: " << Err << '\n';
19061910
return AMD_COMGR_STATUS_ERROR;
19071911
}
@@ -1928,8 +1932,9 @@ amd_comgr_status_t AMDGPUCompiler::translateSpirvToBitcode() {
19281932
return Status;
19291933
}
19301934

1931-
LogS << "SPIR-V Translation: amd-llvm-spirv -r " << Input->Name << " " <<
1932-
Output->Name << "\n";
1935+
LogS << " SPIR-V Translation: amd-llvm-spirv -r "
1936+
<< "--spirv-target-env=CL2.0 " << Input->Name << " -o " << Output->Name
1937+
<< " (command line equivalent)\n";
19331938
}
19341939

19351940
return AMD_COMGR_STATUS_SUCCESS;

amd/comgr/test-lit/spirv-translator.cl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
// RUN: clang -c -emit-llvm --target=spirv64 %s -o %t.bc
66

77
// COM: Translate LLVM IR to SPIRV format
8-
// RUN: amd-llvm-spirv %t.bc -o %t.spv
8+
// RUN: amd-llvm-spirv --spirv-target-env=CL2.0 %t.bc -o %t.spv
99

1010
// COM: Run Comgr Translator to covert SPIRV back to LLVM IR
1111
// RUN: spirv-translator %t.spv -o %t.translated.bc

0 commit comments

Comments
 (0)