[clang] [Clang][SYCL] Add AOT compilation support for Intel GPUs in clang-sycl-linker (PR #133194)
Arvind Sudarsanam via cfe-commits
cfe-commits at lists.llvm.org
Tue May 6 10:12:01 PDT 2025
================
@@ -338,6 +382,87 @@ static Error runSPIRVCodeGen(StringRef File, const ArgList &Args,
return Error::success();
}
+/// Run AOT compilation for Intel CPU.
+/// Calls opencl-aot tool to generate device code for Intel CPU backend.
+/// 'InputFile' is the input SPIR-V file.
+/// 'Args' encompasses all arguments required for linking and wrapping device
+/// code and will be parsed to generate options required to be passed into the
+/// SYCL AOT compilation step.
+static Error runAOTCompileIntelCPU(StringRef InputFile, StringRef OutputFile,
+ const ArgList &Args) {
+ SmallVector<StringRef, 8> CmdArgs;
+ Expected<std::string> OpenCLAOTPath =
+ findProgram(Args, "opencl-aot", {getMainExecutable("opencl-aot")});
+ if (!OpenCLAOTPath)
+ return OpenCLAOTPath.takeError();
+
+ CmdArgs.push_back(*OpenCLAOTPath);
+ CmdArgs.push_back("--device=cpu");
+ StringRef ExtraArgs = Args.getLastArgValue(OPT_opencl_aot_options_EQ);
+ ExtraArgs.split(CmdArgs, " ", /*MaxSplit=*/-1, /*KeepEmpty=*/false);
+ CmdArgs.push_back("-o");
+ CmdArgs.push_back(OutputFile);
+ CmdArgs.push_back(InputFile);
+ if (Error Err = executeCommands(*OpenCLAOTPath, CmdArgs))
+ return Err;
+ return Error::success();
+}
+
+/// Run AOT compilation for Intel GPU
----------------
asudarsa wrote:
```suggestion
/// Run AOT compilation for Intel GPU.
```
https://github.com/llvm/llvm-project/pull/133194
More information about the cfe-commits
mailing list