@@ -22,9 +22,9 @@ using namespace clang::driver::tools;
22
22
using namespace clang ;
23
23
using namespace llvm ::opt;
24
24
25
- const char *SYCL::Linker::constructLLVMSpirvCommand (Compilation &C,
26
- const JobAction &JA, const InputInfo &Output, StringRef OutputFilePrefix ,
27
- bool ToBc, const char *InputFileName) const {
25
+ const char *SYCL::Linker::constructLLVMSpirvCommand (
26
+ Compilation &C, const JobAction &JA, const InputInfo &Output,
27
+ StringRef OutputFilePrefix, bool ToBc, const char *InputFileName) const {
28
28
// Construct llvm-spirv command.
29
29
// The output is a bc file or vice versa depending on the -r option usage
30
30
// llvm-spirv -r -o a_kernel.bc a_kernel.spv
@@ -33,7 +33,7 @@ const char *SYCL::Linker::constructLLVMSpirvCommand(Compilation &C,
33
33
const char *OutputFileName = nullptr ;
34
34
if (ToBc) {
35
35
std::string TmpName =
36
- C.getDriver ().GetTemporaryPath (OutputFilePrefix.str () + " -spirv" , " bc" );
36
+ C.getDriver ().GetTemporaryPath (OutputFilePrefix.str () + " -spirv" , " bc" );
37
37
OutputFileName = C.addTempFile (C.getArgs ().MakeArgString (TmpName));
38
38
CmdArgs.push_back (" -r" );
39
39
CmdArgs.push_back (" -o" );
@@ -91,13 +91,13 @@ void SYCL::constructLLVMForeachCommand(Compilation &C, const JobAction &JA,
91
91
SmallString<128 > ForeachPath (C.getDriver ().Dir );
92
92
llvm::sys::path::append (ForeachPath, " llvm-foreach" );
93
93
const char *Foreach = C.getArgs ().MakeArgString (ForeachPath);
94
- C.addCommand (std::make_unique<Command>(
95
- JA, *T, ResponseFileSupport::None (), Foreach, ForeachArgs, None));
94
+ C.addCommand (std::make_unique<Command>(JA, *T, ResponseFileSupport::None (),
95
+ Foreach, ForeachArgs, None));
96
96
}
97
97
98
- const char *SYCL::Linker::constructLLVMLinkCommand (Compilation &C,
99
- const JobAction &JA , const InputInfo &Output , const ArgList &Args ,
100
- StringRef SubArchName, StringRef OutputFilePrefix,
98
+ const char *SYCL::Linker::constructLLVMLinkCommand (
99
+ Compilation &C , const JobAction &JA , const InputInfo &Output ,
100
+ const ArgList &Args, StringRef SubArchName, StringRef OutputFilePrefix,
101
101
const InputInfoList &InputFiles) const {
102
102
ArgStringList CmdArgs;
103
103
// Add the input bc's created by compile step.
@@ -148,10 +148,11 @@ const char *SYCL::Linker::constructLLVMLinkCommand(Compilation &C,
148
148
}
149
149
150
150
void SYCL::Linker::constructLlcCommand (Compilation &C, const JobAction &JA,
151
- const InputInfo &Output, const char *InputFileName) const {
151
+ const InputInfo &Output,
152
+ const char *InputFileName) const {
152
153
// Construct llc command.
153
154
// The output is an object file.
154
- ArgStringList LlcArgs{" -filetype=obj" , " -o" , Output.getFilename (),
155
+ ArgStringList LlcArgs{" -filetype=obj" , " -o" , Output.getFilename (),
155
156
InputFileName};
156
157
SmallString<128 > LlcPath (C.getDriver ().Dir );
157
158
llvm::sys::path::append (LlcPath, " llc" );
@@ -164,12 +165,13 @@ void SYCL::Linker::constructLlcCommand(Compilation &C, const JobAction &JA,
164
165
// a single SPIR-V binary. Input can also be bitcode when specified by
165
166
// the user.
166
167
void SYCL::Linker::ConstructJob (Compilation &C, const JobAction &JA,
167
- const InputInfo &Output,
168
- const InputInfoList &Inputs,
169
- const ArgList &Args,
170
- const char *LinkingOutput) const {
168
+ const InputInfo &Output,
169
+ const InputInfoList &Inputs,
170
+ const ArgList &Args,
171
+ const char *LinkingOutput) const {
171
172
172
- assert ((getToolChain ().getTriple ().isSPIR () || getToolChain ().getTriple ().isNVPTX ()) &&
173
+ assert ((getToolChain ().getTriple ().isSPIR () ||
174
+ getToolChain ().getTriple ().isNVPTX ()) &&
173
175
" Unsupported target" );
174
176
175
177
std::string SubArchName =
@@ -205,9 +207,8 @@ void SYCL::Linker::ConstructJob(Compilation &C, const JobAction &JA,
205
207
Args.hasArg (options::OPT_foffload_static_lib_EQ))
206
208
SpirvInputs.push_back (II);
207
209
else {
208
- const char *LLVMSpirvOutputFile =
209
- constructLLVMSpirvCommand (C, JA, Output, Prefix, true ,
210
- II.getFilename ());
210
+ const char *LLVMSpirvOutputFile = constructLLVMSpirvCommand (
211
+ C, JA, Output, Prefix, true , II.getFilename ());
211
212
SpirvInputs.push_back (InputInfo (types::TY_LLVM_BC, LLVMSpirvOutputFile,
212
213
LLVMSpirvOutputFile));
213
214
}
@@ -225,27 +226,24 @@ static const char *makeExeName(Compilation &C, StringRef Name) {
225
226
return C.getArgs ().MakeArgString (ExeName);
226
227
}
227
228
228
- void SYCL::fpga::BackendCompiler::ConstructJob (Compilation &C,
229
- const JobAction &JA,
230
- const InputInfo &Output,
231
- const InputInfoList &Inputs,
232
- const ArgList &Args,
233
- const char *LinkingOutput) const {
229
+ void SYCL::fpga::BackendCompiler::ConstructJob (
230
+ Compilation &C, const JobAction &JA, const InputInfo &Output,
231
+ const InputInfoList &Inputs, const ArgList &Args,
232
+ const char *LinkingOutput) const {
234
233
assert ((getToolChain ().getTriple ().getArch () == llvm::Triple::spir ||
235
234
getToolChain ().getTriple ().getArch () == llvm::Triple::spir64) &&
236
235
" Unsupported target" );
237
236
238
237
InputInfoList ForeachInputs;
239
238
InputInfoList FPGADepFiles;
240
- ArgStringList CmdArgs{" -o" , Output.getFilename ()};
239
+ ArgStringList CmdArgs{" -o" , Output.getFilename ()};
241
240
for (const auto &II : Inputs) {
242
241
std::string Filename (II.getFilename ());
243
242
if (II.getType () == types::TY_Tempfilelist)
244
243
ForeachInputs.push_back (II);
245
244
if (II.getType () == types::TY_TempAOCOfilelist)
246
245
// Add any FPGA library lists. These come in as special tempfile lists.
247
- CmdArgs.push_back (Args.MakeArgString (Twine (" -library-list=" ) +
248
- Filename));
246
+ CmdArgs.push_back (Args.MakeArgString (Twine (" -library-list=" ) + Filename));
249
247
else if (II.getType () == types::TY_FPGA_Dependencies ||
250
248
II.getType () == types::TY_FPGA_Dependencies_List)
251
249
FPGADepFiles.push_back (II);
@@ -311,10 +309,10 @@ void SYCL::fpga::BackendCompiler::ConstructJob(Compilation &C,
311
309
// Depending on output file designations, set the report folder
312
310
SmallString<128 > ReportOptArg;
313
311
if (Arg *FinalOutput = Args.getLastArg (options::OPT_o, options::OPT__SLASH_o,
314
- options::OPT__SLASH_Fe)) {
312
+ options::OPT__SLASH_Fe)) {
315
313
SmallString<128 > FN (FinalOutput->getValue ());
316
314
llvm::sys::path::replace_extension (FN, " prj" );
317
- const char * FolderName = Args.MakeArgString (FN);
315
+ const char *FolderName = Args.MakeArgString (FN);
318
316
ReportOptArg += FolderName;
319
317
} else {
320
318
// Output directory is based off of the first object name as captured
@@ -339,8 +337,8 @@ void SYCL::fpga::BackendCompiler::ConstructJob(Compilation &C,
339
337
SmallString<128 > ExecPath (
340
338
getToolChain ().GetProgramPath (makeExeName (C, " aoc" )));
341
339
const char *Exec = C.getArgs ().MakeArgString (ExecPath);
342
- auto Cmd = std::make_unique<Command>(
343
- JA, * this , ResponseFileSupport::None (), Exec, CmdArgs, None);
340
+ auto Cmd = std::make_unique<Command>(JA, * this , ResponseFileSupport::None (),
341
+ Exec, CmdArgs, None);
344
342
if (!ForeachInputs.empty ())
345
343
constructLLVMForeachCommand (C, JA, std::move (Cmd), ForeachInputs, Output,
346
344
this , ForeachExt);
@@ -349,15 +347,15 @@ void SYCL::fpga::BackendCompiler::ConstructJob(Compilation &C,
349
347
}
350
348
351
349
void SYCL::gen::BackendCompiler::ConstructJob (Compilation &C,
352
- const JobAction &JA,
353
- const InputInfo &Output,
354
- const InputInfoList &Inputs,
355
- const ArgList &Args,
356
- const char *LinkingOutput) const {
350
+ const JobAction &JA,
351
+ const InputInfo &Output,
352
+ const InputInfoList &Inputs,
353
+ const ArgList &Args,
354
+ const char *LinkingOutput) const {
357
355
assert ((getToolChain ().getTriple ().getArch () == llvm::Triple::spir ||
358
356
getToolChain ().getTriple ().getArch () == llvm::Triple::spir64) &&
359
357
" Unsupported target" );
360
- ArgStringList CmdArgs{" -output" , Output.getFilename ()};
358
+ ArgStringList CmdArgs{" -output" , Output.getFilename ()};
361
359
InputInfoList ForeachInputs;
362
360
for (const auto &II : Inputs) {
363
361
CmdArgs.push_back (" -file" );
@@ -377,21 +375,19 @@ void SYCL::gen::BackendCompiler::ConstructJob(Compilation &C,
377
375
SmallString<128 > ExecPath (
378
376
getToolChain ().GetProgramPath (makeExeName (C, " ocloc" )));
379
377
const char *Exec = C.getArgs ().MakeArgString (ExecPath);
380
- auto Cmd = std::make_unique<Command>(
381
- JA, * this , ResponseFileSupport::None (), Exec, CmdArgs, None);
378
+ auto Cmd = std::make_unique<Command>(JA, * this , ResponseFileSupport::None (),
379
+ Exec, CmdArgs, None);
382
380
if (!ForeachInputs.empty ())
383
381
constructLLVMForeachCommand (C, JA, std::move (Cmd), ForeachInputs, Output,
384
382
this );
385
383
else
386
384
C.addCommand (std::move (Cmd));
387
385
}
388
386
389
- void SYCL::x86_64::BackendCompiler::ConstructJob (Compilation &C,
390
- const JobAction &JA,
391
- const InputInfo &Output,
392
- const InputInfoList &Inputs,
393
- const ArgList &Args,
394
- const char *LinkingOutput) const {
387
+ void SYCL::x86_64::BackendCompiler::ConstructJob (
388
+ Compilation &C, const JobAction &JA, const InputInfo &Output,
389
+ const InputInfoList &Inputs, const ArgList &Args,
390
+ const char *LinkingOutput) const {
395
391
ArgStringList CmdArgs;
396
392
CmdArgs.push_back (Args.MakeArgString (Twine (" -o=" ) + Output.getFilename ()));
397
393
CmdArgs.push_back (" --device=cpu" );
@@ -411,8 +407,8 @@ void SYCL::x86_64::BackendCompiler::ConstructJob(Compilation &C,
411
407
SmallString<128 > ExecPath (
412
408
getToolChain ().GetProgramPath (makeExeName (C, " opencl-aot" )));
413
409
const char *Exec = C.getArgs ().MakeArgString (ExecPath);
414
- auto Cmd = std::make_unique<Command>(
415
- JA, * this , ResponseFileSupport::None (), Exec, CmdArgs, None);
410
+ auto Cmd = std::make_unique<Command>(JA, * this , ResponseFileSupport::None (),
411
+ Exec, CmdArgs, None);
416
412
if (!ForeachInputs.empty ())
417
413
constructLLVMForeachCommand (C, JA, std::move (Cmd), ForeachInputs, Output,
418
414
this );
@@ -429,8 +425,7 @@ SYCLToolChain::SYCLToolChain(const Driver &D, const llvm::Triple &Triple,
429
425
}
430
426
431
427
void SYCLToolChain::addClangTargetOptions (
432
- const llvm::opt::ArgList &DriverArgs,
433
- llvm::opt::ArgStringList &CC1Args,
428
+ const llvm::opt::ArgList &DriverArgs, llvm::opt::ArgStringList &CC1Args,
434
429
Action::OffloadKind DeviceOffloadingKind) const {
435
430
HostTC.addClangTargetOptions (DriverArgs, CC1Args, DeviceOffloadingKind);
436
431
}
@@ -471,8 +466,9 @@ static void parseTargetOpts(StringRef ArgString, const llvm::opt::ArgList &Args,
471
466
// Expects a specific type of option (e.g. -Xsycl-target-backend) and will
472
467
// extract the arguments.
473
468
void SYCLToolChain::TranslateTargetOpt (const llvm::opt::ArgList &Args,
474
- llvm::opt::ArgStringList &CmdArgs, OptSpecifier Opt,
475
- OptSpecifier Opt_EQ) const {
469
+ llvm::opt::ArgStringList &CmdArgs,
470
+ OptSpecifier Opt,
471
+ OptSpecifier Opt_EQ) const {
476
472
for (auto *A : Args) {
477
473
bool OptNoTriple;
478
474
OptNoTriple = A->getOption ().matches (Opt);
@@ -543,8 +539,8 @@ static void addImpliedArgs(const llvm::Triple &Triple,
543
539
CmdArgs.push_back (Args.MakeArgString (BeOpt));
544
540
}
545
541
546
- void SYCLToolChain::TranslateBackendTargetArgs (const llvm::opt::ArgList &Args,
547
- llvm::opt::ArgStringList &CmdArgs) const {
542
+ void SYCLToolChain::TranslateBackendTargetArgs (
543
+ const llvm::opt::ArgList &Args, llvm::opt::ArgStringList &CmdArgs) const {
548
544
// Add any implied arguments before user defined arguments.
549
545
addImpliedArgs (getTriple (), Args, CmdArgs);
550
546
@@ -572,14 +568,14 @@ void SYCLToolChain::TranslateBackendTargetArgs(const llvm::opt::ArgList &Args,
572
568
}
573
569
// Handle -Xsycl-target-backend.
574
570
TranslateTargetOpt (Args, CmdArgs, options::OPT_Xsycl_backend,
575
- options::OPT_Xsycl_backend_EQ);
571
+ options::OPT_Xsycl_backend_EQ);
576
572
}
577
573
578
- void SYCLToolChain::TranslateLinkerTargetArgs (const llvm::opt::ArgList &Args,
579
- llvm::opt::ArgStringList &CmdArgs) const {
574
+ void SYCLToolChain::TranslateLinkerTargetArgs (
575
+ const llvm::opt::ArgList &Args, llvm::opt::ArgStringList &CmdArgs) const {
580
576
// Handle -Xsycl-target-linker.
581
577
TranslateTargetOpt (Args, CmdArgs, options::OPT_Xsycl_linker,
582
- options::OPT_Xsycl_linker_EQ);
578
+ options::OPT_Xsycl_linker_EQ);
583
579
}
584
580
585
581
Tool *SYCLToolChain::buildBackendCompiler () const {
0 commit comments