@@ -175,15 +175,33 @@ void AMDGCN::Linker::constructLinkAndEmitSpirvCommand(
175
175
176
176
constructLlvmLinkCommand (C, JA, Inputs, LinkedBCFile, Args);
177
177
178
- // Emit SPIR-V binary.
179
- llvm::opt::ArgStringList TrArgs{
180
- " --spirv-max-version=1.6" ,
181
- " --spirv-ext=+all" ,
182
- " --spirv-allow-unknown-intrinsics" ,
183
- " --spirv-lower-const-expr" ,
184
- " --spirv-preserve-auxdata" ,
185
- " --spirv-debug-info-version=nonsemantic-shader-200" };
186
- SPIRV::constructTranslateCommand (C, *this , JA, Output, LinkedBCFile, TrArgs);
178
+ bool UseSPIRVBackend = Args.hasFlag (
179
+ options::OPT_amdgpu_use_experimental_spirv_backend,
180
+ options::OPT_no_amdgpu_use_experimental_spirv_backend, /* Default=*/ false );
181
+
182
+ // Emit SPIR-V binary either using the SPIRV backend or the translator.
183
+ if (UseSPIRVBackend) {
184
+ llvm::opt::ArgStringList CmdArgs;
185
+ const char *Triple =
186
+ C.getArgs ().MakeArgString (" -triple=spirv64-amd-amdhsa" );
187
+ CmdArgs.append ({" -cc1" , Triple, " -emit-obj" , LinkedBCFile.getFilename (),
188
+ " -o" , Output.getFilename ()});
189
+ const char *Exec = getToolChain ().getDriver ().getClangProgramPath ();
190
+ C.addCommand (std::make_unique<Command>(JA, *this ,
191
+ ResponseFileSupport::None (), Exec,
192
+ CmdArgs, LinkedBCFile, Output));
193
+ } else {
194
+ // Use the SPIRV translator for code gen.
195
+ llvm::opt::ArgStringList TrArgs{
196
+ " --spirv-max-version=1.6" ,
197
+ " --spirv-ext=+all" ,
198
+ " --spirv-allow-unknown-intrinsics" ,
199
+ " --spirv-lower-const-expr" ,
200
+ " --spirv-preserve-auxdata" ,
201
+ " --spirv-debug-info-version=nonsemantic-shader-200" };
202
+ SPIRV::constructTranslateCommand (C, *this , JA, Output, LinkedBCFile,
203
+ TrArgs);
204
+ }
187
205
}
188
206
189
207
// For amdgcn the inputs of the linker job are device bitcode and output is
0 commit comments