Skip to content

Commit dc8a059

Browse files
authored
[Driver][SYCL][FPGA] Improve help output for aoc with -fsycl-help (#2446)
aoc provides a way to emit SYCL FPGA specific options with the -help via the -sycl option. Augment the the help output behaviors to allow for an additional option that can be used with the tools.
1 parent 998c97f commit dc8a059

File tree

2 files changed

+13
-8
lines changed

2 files changed

+13
-8
lines changed

clang/lib/Driver/Driver.cpp

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1788,20 +1788,21 @@ llvm::Triple Driver::MakeSYCLDeviceTriple(StringRef TargetArch) const {
17881788
// Print the help from any of the given tools which are used for AOT
17891789
// compilation for SYCL
17901790
void Driver::PrintSYCLToolHelp(const Compilation &C) const {
1791-
SmallVector<std::tuple<llvm::Triple, StringRef, StringRef>, 4> HelpArgs;
1791+
SmallVector<std::tuple<llvm::Triple, StringRef, StringRef, StringRef>, 4>
1792+
HelpArgs;
17921793
// Populate the vector with the tools and help options
17931794
if (Arg *A = C.getArgs().getLastArg(options::OPT_fsycl_help_EQ)) {
17941795
StringRef AV(A->getValue());
17951796
llvm::Triple T;
17961797
if (AV == "gen" || AV == "all")
17971798
HelpArgs.push_back(std::make_tuple(MakeSYCLDeviceTriple("spir64_gen"),
1798-
"ocloc", "--help"));
1799+
"ocloc", "--help", ""));
17991800
if (AV == "fpga" || AV == "all")
1800-
HelpArgs.push_back(
1801-
std::make_tuple(MakeSYCLDeviceTriple("spir64_fpga"), "aoc", "-help"));
1801+
HelpArgs.push_back(std::make_tuple(MakeSYCLDeviceTriple("spir64_fpga"),
1802+
"aoc", "-help", "-sycl"));
18021803
if (AV == "x86_64" || AV == "all")
18031804
HelpArgs.push_back(std::make_tuple(MakeSYCLDeviceTriple("spir64_x86_64"),
1804-
"opencl-aot", "--help"));
1805+
"opencl-aot", "--help", ""));
18051806
if (HelpArgs.empty()) {
18061807
C.getDriver().Diag(diag::err_drv_unsupported_option_argument)
18071808
<< A->getOption().getName() << AV;
@@ -1814,7 +1815,8 @@ void Driver::PrintSYCLToolHelp(const Compilation &C) const {
18141815
llvm::outs() << "Emitting help information for " << std::get<1>(HA) << '\n'
18151816
<< "Use triple of '" << std::get<0>(HA).normalize() <<
18161817
"' to enable ahead of time compilation\n";
1817-
std::vector<StringRef> ToolArgs = { std::get<1>(HA), std::get<2>(HA) };
1818+
std::vector<StringRef> ToolArgs = {std::get<1>(HA), std::get<2>(HA),
1819+
std::get<3>(HA)};
18181820
SmallString<128> ExecPath(
18191821
C.getDefaultToolChain().GetProgramPath(std::get<1>(HA).data()));
18201822
auto ToolBinary = llvm::sys::findProgramByName(ExecPath);
@@ -1824,7 +1826,10 @@ void Driver::PrintSYCLToolHelp(const Compilation &C) const {
18241826
}
18251827
// do not run the tools with -###.
18261828
if (C.getArgs().hasArg(options::OPT__HASH_HASH_HASH)) {
1827-
llvm::errs() << "\"" << ExecPath << "\" \"" << ToolArgs[1] << "\"\n";
1829+
llvm::errs() << "\"" << ExecPath << "\" \"" << ToolArgs[1] << "\"";
1830+
if (!ToolArgs[2].empty())
1831+
llvm::errs() << " \"" << ToolArgs[2] << "\"";
1832+
llvm::errs() << "\n";
18281833
continue;
18291834
}
18301835
// Run the Tool.

clang/test/Driver/sycl.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@
7575
// SYCL-HELP-BADARG: unsupported argument 'foo' to option 'fsycl-help='
7676
// SYCL-HELP-GEN: Emitting help information for ocloc
7777
// SYCL-HELP-GEN: Use triple of 'spir64_gen-unknown-unknown-sycldevice' to enable ahead of time compilation
78-
// SYCL-HELP-FPGA-OUT: "[[DIR]]{{[/\\]+}}aoc" "-help"
78+
// SYCL-HELP-FPGA-OUT: "[[DIR]]{{[/\\]+}}aoc" "-help" "-sycl"
7979
// SYCL-HELP-FPGA: Emitting help information for aoc
8080
// SYCL-HELP-FPGA: Use triple of 'spir64_fpga-unknown-unknown-sycldevice' to enable ahead of time compilation
8181
// SYCL-HELP-CPU: Emitting help information for opencl-aot

0 commit comments

Comments
 (0)