[clang] [llvm] Reland - [Driver][SYCL] Add initial SYCL offload compilation support … (PR #117268)
Michael Toguchi via cfe-commits
cfe-commits at lists.llvm.org
Fri Nov 22 10:13:34 PST 2024
================
@@ -0,0 +1,179 @@
+//===--- SYCL.cpp - SYCL Tool and ToolChain Implementations -----*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+#include "SYCL.h"
+#include "CommonArgs.h"
+#include "llvm/Support/Path.h"
+
+using namespace clang::driver;
+using namespace clang::driver::toolchains;
+using namespace clang::driver::tools;
+using namespace clang;
+using namespace llvm::opt;
+
+SYCLInstallationDetector::SYCLInstallationDetector(
+ const Driver &D, const llvm::Triple &HostTriple,
+ const llvm::opt::ArgList &Args)
+ : D(D) {}
+
+void SYCLInstallationDetector::AddSYCLIncludeArgs(
+ const ArgList &DriverArgs, ArgStringList &CC1Args) const {
+ if (DriverArgs.hasArg(clang::driver::options::OPT_nobuiltininc))
+ return;
+
+ // Add the SYCL header search locations in the specified order.
+ // ../include/sycl/stl_wrappers
+ // ../include
+ SmallString<128> IncludePath(D.Dir);
+ llvm::sys::path::append(IncludePath, "..");
+ llvm::sys::path::append(IncludePath, "include");
+ // This is used to provide our wrappers around STL headers that provide
+ // additional functions/template specializations when the user includes those
+ // STL headers in their programs (e.g., <complex>).
+ SmallString<128> STLWrappersPath(IncludePath);
+ llvm::sys::path::append(STLWrappersPath, "sycl");
+ llvm::sys::path::append(STLWrappersPath, "stl_wrappers");
+ CC1Args.push_back("-internal-isystem");
+ CC1Args.push_back(DriverArgs.MakeArgString(STLWrappersPath));
+ CC1Args.push_back("-internal-isystem");
+ CC1Args.push_back(DriverArgs.MakeArgString(IncludePath));
+}
+
+// Unsupported options for SYCL device compilation.
+static std::vector<OptSpecifier> getUnsupportedOpts() {
+ std::vector<OptSpecifier> UnsupportedOpts = {
+ options::OPT_fsanitize_EQ, // -fsanitize
+ options::OPT_fcf_protection_EQ, // -fcf-protection
+ options::OPT_fprofile_generate,
+ options::OPT_fprofile_generate_EQ,
+ options::OPT_fno_profile_generate, // -f[no-]profile-generate
+ options::OPT_ftest_coverage,
+ 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_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_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_EQ};
+ return UnsupportedOpts;
+}
+
+SYCLToolChain::SYCLToolChain(const Driver &D, const llvm::Triple &Triple,
+ const ToolChain &HostTC, const ArgList &Args)
+ : ToolChain(D, Triple, Args), HostTC(HostTC),
+ SYCLInstallation(D, Triple, Args) {
+ // Lookup binaries into the driver directory, this is used to discover any
+ // dependent SYCL offload compilation tools.
+ getProgramPaths().push_back(getDriver().Dir);
+
+ // Diagnose unsupported options only once.
+ for (OptSpecifier Opt : getUnsupportedOpts()) {
+ if (const Arg *A = Args.getLastArg(Opt)) {
+ // All sanitizer options are not currently supported, except
+ // AddressSanitizer.
----------------
mdtoguchi wrote:
Right - I will remove this special casing until the support is upstreamed.
https://github.com/llvm/llvm-project/pull/117268
More information about the cfe-commits
mailing list