[clang] [llvm] [Driver][SYCL] Add initial SYCL offload compilation support (PR #107493)
via cfe-commits
cfe-commits at lists.llvm.org
Mon Nov 4 08:40:08 PST 2024
github-actions[bot] wrote:
<!--LLVM CODE FORMAT COMMENT: {clang-format}-->
:warning: C/C++ code formatter, clang-format found issues in your code. :warning:
<details>
<summary>
You can test this locally with the following command:
</summary>
``````````bash
git-clang-format --diff b74e588e1f460eb48ceb1a30cf8ac870b7537dcc b810ae2996e7ac66ee877a1434d3a309335c9600 --extensions h,cpp -- clang/lib/Driver/ToolChains/SYCL.cpp clang/lib/Driver/ToolChains/SYCL.h clang/test/Driver/sycl-offload-jit.cpp clang/include/clang/Driver/Action.h clang/include/clang/Driver/Driver.h clang/include/clang/Driver/ToolChain.h clang/lib/Driver/Action.cpp clang/lib/Driver/Compilation.cpp clang/lib/Driver/Driver.cpp clang/lib/Driver/ToolChain.cpp clang/lib/Driver/ToolChains/Clang.cpp clang/lib/Driver/ToolChains/Gnu.cpp clang/lib/Driver/ToolChains/Gnu.h clang/lib/Driver/ToolChains/Linux.cpp clang/lib/Driver/ToolChains/Linux.h clang/lib/Driver/ToolChains/MSVC.cpp clang/lib/Driver/ToolChains/MSVC.h llvm/include/llvm/TargetParser/Triple.h
``````````
</details>
<details>
<summary>
View the diff from clang-format here.
</summary>
``````````diff
diff --git a/clang/lib/Driver/Driver.cpp b/clang/lib/Driver/Driver.cpp
index 938bf64fb1..9197151171 100644
--- a/clang/lib/Driver/Driver.cpp
+++ b/clang/lib/Driver/Driver.cpp
@@ -1023,9 +1023,8 @@ void Driver::CreateOffloadingDeviceToolChains(Compilation &C,
// SYCL
//
// We need to generate a SYCL toolchain if the user specified -fsycl.
- bool IsSYCL =
- C.getInputArgs().hasFlag(options::OPT_fsycl, options::OPT_fno_sycl,
- false);
+ bool IsSYCL = C.getInputArgs().hasFlag(options::OPT_fsycl,
+ options::OPT_fno_sycl, false);
auto argSYCLIncompatible = [&](OptSpecifier OptId) {
if (!IsSYCL)
@@ -2089,7 +2088,8 @@ void Driver::PrintHelp(bool ShowHidden) const {
}
llvm::Triple Driver::getSYCLDeviceTriple(StringRef TargetArch) const {
- SmallVector<StringRef, 5> SYCLAlias = { "spir", "spir64", "spirv32", "spirv64"};
+ SmallVector<StringRef, 5> SYCLAlias = {"spir", "spir64", "spirv32",
+ "spirv64"};
if (std::find(SYCLAlias.begin(), SYCLAlias.end(), TargetArch) !=
SYCLAlias.end()) {
llvm::Triple TT;
diff --git a/clang/lib/Driver/ToolChains/SYCL.cpp b/clang/lib/Driver/ToolChains/SYCL.cpp
index 0c4dab7c81..241444b713 100644
--- a/clang/lib/Driver/ToolChains/SYCL.cpp
+++ b/clang/lib/Driver/ToolChains/SYCL.cpp
@@ -15,8 +15,7 @@ using namespace clang::driver::tools;
using namespace clang;
using namespace llvm::opt;
-SYCLInstallationDetector::SYCLInstallationDetector(const Driver &D)
- : D(D) {
+SYCLInstallationDetector::SYCLInstallationDetector(const Driver &D) : D(D) {
InstallationCandidates.emplace_back(D.Dir + "/..");
}
@@ -52,7 +51,7 @@ void SYCLInstallationDetector::print(llvm::raw_ostream &OS) const {
// Unsupported options for SYCL device compilation.
static std::vector<OptSpecifier> getUnsupportedOpts() {
std::vector<OptSpecifier> UnsupportedOpts = {
- options::OPT_fsanitize_EQ, // -fsanitize
+ options::OPT_fsanitize_EQ, // -fsanitize
options::OPT_fcf_protection_EQ, // -fcf-protection
options::OPT_fprofile_generate,
options::OPT_fprofile_generate_EQ,
@@ -61,17 +60,17 @@ static std::vector<OptSpecifier> getUnsupportedOpts() {
options::OPT_fno_test_coverage, // -f[no-]test-coverage
options::OPT_fcoverage_mapping,
options::OPT_fno_coverage_mapping, // -f[no-]coverage-mapping
- options::OPT_coverage, // --coverage
+ options::OPT_coverage, // --coverage
options::OPT_fprofile_instr_generate,
options::OPT_fprofile_instr_generate_EQ,
options::OPT_fno_profile_instr_generate, // -f[no-]profile-instr-generate
options::OPT_fprofile_arcs,
options::OPT_fno_profile_arcs, // -f[no-]profile-arcs
- options::OPT_fcreate_profile, // -fcreate-profile
+ options::OPT_fcreate_profile, // -fcreate-profile
options::OPT_fprofile_instr_use,
- options::OPT_fprofile_instr_use_EQ, // -fprofile-instr-use
+ options::OPT_fprofile_instr_use_EQ, // -fprofile-instr-use
options::OPT_forder_file_instrumentation, // -forder-file-instrumentation
- options::OPT_fcs_profile_generate, // -fcs-profile-generate
+ options::OPT_fcs_profile_generate, // -fcs-profile-generate
options::OPT_fcs_profile_generate_EQ};
return UnsupportedOpts;
}
diff --git a/clang/lib/Driver/ToolChains/SYCL.h b/clang/lib/Driver/ToolChains/SYCL.h
index 8ac1b7a9ce..9395478cb0 100644
--- a/clang/lib/Driver/ToolChains/SYCL.h
+++ b/clang/lib/Driver/ToolChains/SYCL.h
@@ -41,9 +41,10 @@ public:
llvm::opt::DerivedArgList *
TranslateArgs(const llvm::opt::DerivedArgList &Args, StringRef BoundArch,
Action::OffloadKind DeviceOffloadKind) const override;
- void addClangTargetOptions(const llvm::opt::ArgList &DriverArgs,
- llvm::opt::ArgStringList &CC1Args,
- Action::OffloadKind DeviceOffloadKind) const override;
+ void
+ addClangTargetOptions(const llvm::opt::ArgList &DriverArgs,
+ llvm::opt::ArgStringList &CC1Args,
+ Action::OffloadKind DeviceOffloadKind) const override;
bool useIntegratedAs() const override { return true; }
bool isPICDefault() const override { return false; }
@@ -59,7 +60,8 @@ public:
CXXStdlibType GetCXXStdlibType(const llvm::opt::ArgList &Args) const override;
void AddSYCLIncludeArgs(const llvm::opt::ArgList &DriverArgs,
llvm::opt::ArgStringList &CC1Args) const override;
- void AddClangSystemIncludeArgs(const llvm::opt::ArgList &DriverArgs,
+ void
+ AddClangSystemIncludeArgs(const llvm::opt::ArgList &DriverArgs,
llvm::opt::ArgStringList &CC1Args) const override;
void AddClangCXXStdlibIncludeArgs(
const llvm::opt::ArgList &Args,
``````````
</details>
https://github.com/llvm/llvm-project/pull/107493
More information about the cfe-commits
mailing list