[clang] [HIP][SPIRV] Enable the SPIRV backend instead of the translator through an experimental flag. (PR #162282)
Alex Voicu via cfe-commits
cfe-commits at lists.llvm.org
Fri Oct 10 08:09:52 PDT 2025
================
@@ -175,15 +175,33 @@ void AMDGCN::Linker::constructLinkAndEmitSpirvCommand(
constructLlvmLinkCommand(C, JA, Inputs, LinkedBCFile, Args);
- // Emit SPIR-V binary.
- llvm::opt::ArgStringList TrArgs{
- "--spirv-max-version=1.6",
- "--spirv-ext=+all",
- "--spirv-allow-unknown-intrinsics",
- "--spirv-lower-const-expr",
- "--spirv-preserve-auxdata",
- "--spirv-debug-info-version=nonsemantic-shader-200"};
- SPIRV::constructTranslateCommand(C, *this, JA, Output, LinkedBCFile, TrArgs);
+ bool UseSPIRVBackend = Args.hasFlag(
+ options::OPT_use_experimental_spirv_backend,
+ options::OPT_no_use_experimental_spirv_backend, /*Default=*/false);
+
+ // Emit SPIR-V binary either using the SPIRV backend or the translator.
+ if (UseSPIRVBackend) {
+ llvm::opt::ArgStringList CmdArgs;
+ const char *Triple =
+ C.getArgs().MakeArgString("-triple=spirv64-amd-amdhsa");
+ CmdArgs.append({"-cc1", Triple, "-emit-obj", LinkedBCFile.getFilename(),
----------------
AlexVlx wrote:
I think we should consider invoking `llc` directly here, rather than round-tripping via clang. We will have to pass a number of flags, and possibly gate which args get forwarded.
https://github.com/llvm/llvm-project/pull/162282
More information about the cfe-commits
mailing list