Skip to content

Commit f5bdbc5

Browse files
pjaaskelpvelesko
authored andcommitted
Allow up to v1.2 SPIR-V features + chipStar Extensions
This is to support warp-level primitives (shuffles, ballots) via extensions. The non-extension ones would require v1.3, but it's not supported by any target yet. Allow limited debug info Allow debug info kind that is compatible with llvm-spirv, that is, it is limited to a kind with an intent to avoid emitting DW_OP_LLVM_<op> expressions. Disable SPIR-V extensions except ones needed by chipStar
1 parent 7cbf1a2 commit f5bdbc5

File tree

1 file changed

+19
-7
lines changed

1 file changed

+19
-7
lines changed

clang/lib/Driver/ToolChains/HIPSPV.cpp

+19-7
Original file line numberDiff line numberDiff line change
@@ -96,9 +96,21 @@ void HIPSPV::Linker::constructLinkAndEmitSpirvCommand(
9696
}
9797

9898
// Emit SPIR-V binary.
99-
100-
llvm::opt::ArgStringList TrArgs{"--spirv-max-version=1.1",
101-
"--spirv-ext=+all"};
99+
// We need 1.2 when using warp-level primitivies via sub group extensions.
100+
// Strictly put we'd need 1.3 for the standard non-extension shuffle
101+
// operations, but it's not supported by any target yet.
102+
llvm::opt::ArgStringList TrArgs{
103+
"--spirv-max-version=1.2",
104+
"--spirv-ext=-all"
105+
106+
// TODO: Consider upstreaming -Xspirv-translator found in intel-llvm
107+
// repository and make it work for SPIR-V toolchains so chipStar may
108+
// control extensions it needs (if/when necessary).
109+
110+
// Needed for experimental indirect call support.
111+
",+SPV_INTEL_function_pointers"
112+
// Needed for shuffles below SPIR-V 1.3
113+
",+SPV_INTEL_subgroups"};
102114
InputInfo TrInput = InputInfo(types::TY_LLVM_BC, TempFile, "");
103115
SPIRV::constructTranslateCommand(C, *this, JA, Output, TrInput, TrArgs);
104116
}
@@ -285,8 +297,8 @@ VersionTuple HIPSPVToolChain::computeMSVCVersion(const Driver *D,
285297
void HIPSPVToolChain::adjustDebugInfoKind(
286298
codegenoptions::DebugInfoKind &DebugInfoKind,
287299
const llvm::opt::ArgList &Args) const {
288-
// Debug info generation is disabled for SPIRV-LLVM-Translator
289-
// which currently aborts on the presence of DW_OP_LLVM_convert.
290-
// TODO: Enable debug info when the SPIR-V backend arrives.
291-
DebugInfoKind = codegenoptions::NoDebugInfo;
300+
301+
// Restrict the debug info to a kind compatible with llvm-spirv.
302+
if (DebugInfoKind > codegenoptions::DebugLineTablesOnly)
303+
DebugInfoKind = codegenoptions::DebugLineTablesOnly;
292304
}

0 commit comments

Comments
 (0)