@@ -1669,6 +1669,59 @@ void Driver::PrintHelp(bool ShowHidden) const {
1669
1669
/* ShowAllAliases=*/ false );
1670
1670
}
1671
1671
1672
+ llvm::Triple makeDeviceTriple (StringRef subArch) {
1673
+ llvm::Triple TT;
1674
+ TT.setArchName (subArch);
1675
+ TT.setVendor (llvm::Triple::UnknownVendor);
1676
+ TT.setOS (llvm::Triple (llvm::sys::getProcessTriple ()).getOS ());
1677
+ TT.setEnvironment (llvm::Triple::SYCLDevice);
1678
+ return TT;
1679
+ }
1680
+
1681
+ // Print the help from any of the given tools which are used for AOT
1682
+ // compilation for SYCL
1683
+ void Driver::PrintSYCLToolHelp (const Compilation &C) const {
1684
+ SmallVector<std::tuple<llvm::Triple, StringRef, StringRef>, 4 > HelpArgs;
1685
+ // Populate the vector with the tools and help options
1686
+ if (Arg *A = C.getArgs ().getLastArg (options::OPT_fsycl_help_EQ)) {
1687
+ StringRef AV (A->getValue ());
1688
+ llvm::Triple T;
1689
+ if (AV == " gen" || AV == " all" )
1690
+ HelpArgs.push_back (std::make_tuple (makeDeviceTriple (" spir64_gen" ),
1691
+ " ocloc" , " -?" ));
1692
+ if (AV == " fpga" || AV == " all" )
1693
+ HelpArgs.push_back (std::make_tuple (makeDeviceTriple (" spir64_fpga" ),
1694
+ " aoc" , " -help" ));
1695
+ if (AV == " x86_64" || AV == " all" )
1696
+ HelpArgs.push_back (std::make_tuple (makeDeviceTriple (" spir64_x86_64" ),
1697
+ " ioc64" , " -help" ));
1698
+ if (HelpArgs.empty ()) {
1699
+ C.getDriver ().Diag (diag::err_drv_unsupported_option_argument)
1700
+ << A->getOption ().getName () << AV;
1701
+ return ;
1702
+ }
1703
+ }
1704
+
1705
+ // Go through the args and emit the help information for each.
1706
+ for (auto &HA : HelpArgs) {
1707
+ llvm::outs () << " Emitting help information for " << std::get<1 >(HA) << ' \n '
1708
+ << " Use triple of '" << std::get<0 >(HA).normalize () <<
1709
+ " ' to enable ahead of time compilation\n " ;
1710
+ // do not run the tools with -###.
1711
+ if (C.getArgs ().hasArg (options::OPT__HASH_HASH_HASH))
1712
+ continue ;
1713
+ std::vector<StringRef> ToolArgs = { std::get<1 >(HA), std::get<2 >(HA) };
1714
+ StringRef ExecPath (C.getDefaultToolChain ().GetProgramPath (std::get<1 >(HA).data ()));
1715
+ auto ToolBinary = llvm::sys::findProgramByName (ExecPath);
1716
+ if (ToolBinary.getError ()) {
1717
+ C.getDriver ().Diag (diag::err_drv_command_failure) << ExecPath;
1718
+ continue ;
1719
+ }
1720
+ // Run the Tool.
1721
+ llvm::sys::ExecuteAndWait (ToolBinary.get (), ToolArgs);
1722
+ }
1723
+ }
1724
+
1672
1725
void Driver::PrintVersion (const Compilation &C, raw_ostream &OS) const {
1673
1726
// FIXME: The following handlers should use a callback mechanism, we don't
1674
1727
// know what the client would like to do.
@@ -1809,6 +1862,11 @@ bool Driver::HandleImmediateArgs(const Compilation &C) {
1809
1862
return false ;
1810
1863
}
1811
1864
1865
+ if (C.getArgs ().hasArg (options::OPT_fsycl_help_EQ)) {
1866
+ PrintSYCLToolHelp (C);
1867
+ return false ;
1868
+ }
1869
+
1812
1870
if (C.getArgs ().hasArg (options::OPT__version)) {
1813
1871
// Follow gcc behavior and use stdout for --version and stderr for -v.
1814
1872
PrintVersion (C, llvm::outs ());
0 commit comments