llvmorg-github-actions[bot] wrote:
<!--LLVM PR SUMMARY COMMENT--> @llvm/pr-subscribers-clang Author: Aditya Sinha (AdityaSinha149) <details> <summary>Changes</summary> This PR adds an `OffloadType` enum (`CUDA`, `HIP`) and `Interpreter::createWithDevice()`, so device setup is chosen in one place. `createWithCUDA()` now forwards to it, so CUDA behaviour and existing callers are unchanged. The HIP case is a no-op until `IncrementalHIPDeviceParser` lands. Assisted by Claude Sonnet 5.5 --- Full diff: https://github.com/llvm/llvm-project/pull/231391.diff 2 Files Affected: - (modified) clang/include/clang/Interpreter/Interpreter.h (+5) - (modified) clang/lib/Interpreter/Interpreter.cpp (+19-6) ``````````diff diff --git a/clang/include/clang/Interpreter/Interpreter.h b/clang/include/clang/Interpreter/Interpreter.h index a598574b417c0..1f3624d0c0331 100644 --- a/clang/include/clang/Interpreter/Interpreter.h +++ b/clang/include/clang/Interpreter/Interpreter.h @@ -46,6 +46,8 @@ class Decl; class IncrementalParser; class IncrementalDeviceParser; +enum class OffloadType { CUDA, HIP }; + /// Create a pre-configured \c CompilerInstance for incremental processing. class IncrementalCompilerBuilder { using DriverCompilationFn = llvm::Error(const driver::Compilation &); @@ -147,6 +149,9 @@ class Interpreter { create(std::unique_ptr<CompilerInstance> CI, std::unique_ptr<IncrementalExecutorBuilder> IEB = nullptr); static llvm::Expected<std::unique_ptr<Interpreter>> + createWithDevice(std::unique_ptr<CompilerInstance> CI, + std::unique_ptr<CompilerInstance> DCI, OffloadType Type); + static llvm::Expected<std::unique_ptr<Interpreter>> createWithCUDA(std::unique_ptr<CompilerInstance> CI, std::unique_ptr<CompilerInstance> DCI); diff --git a/clang/lib/Interpreter/Interpreter.cpp b/clang/lib/Interpreter/Interpreter.cpp index a8e54d62864b5..5e89b50839760 100644 --- a/clang/lib/Interpreter/Interpreter.cpp +++ b/clang/lib/Interpreter/Interpreter.cpp @@ -479,6 +479,13 @@ llvm::Expected<std::unique_ptr<Interpreter>> Interpreter::create( llvm::Expected<std::unique_ptr<Interpreter>> Interpreter::createWithCUDA(std::unique_ptr<CompilerInstance> CI, std::unique_ptr<CompilerInstance> DCI) { + return createWithDevice(std::move(CI), std::move(DCI), OffloadType::CUDA); +} + +llvm::Expected<std::unique_ptr<Interpreter>> +Interpreter::createWithDevice(std::unique_ptr<CompilerInstance> CI, + std::unique_ptr<CompilerInstance> DCI, + OffloadType Type) { // avoid writing fat binary to disk using an in-memory virtual file system llvm::IntrusiveRefCntPtr<llvm::vfs::InMemoryFileSystem> IMVFS = std::make_unique<llvm::vfs::InMemoryFileSystem>(); @@ -515,14 +522,20 @@ Interpreter::createWithCUDA(std::unique_ptr<CompilerInstance> CI, Interp->DeviceCI = std::move(DCI); - auto DeviceParser = std::make_unique<IncrementalCUDADeviceParser>( - *Interp->DeviceCI, *Interp->getCompilerInstance(), - Interp->DeviceAct.get(), IMVFS, Err, Interp->PTUs); + if (Type == OffloadType::HIP) { + // FIXME: HIP device parsing is not supported yet; it should use an + // IncrementalHIPDeviceParser once one exists. + } else { + auto DeviceParser = std::make_unique<IncrementalCUDADeviceParser>( + *Interp->DeviceCI, *Interp->getCompilerInstance(), + Interp->DeviceAct.get(), IMVFS, Err, Interp->PTUs); - if (Err) - return std::move(Err); + if (Err) + return std::move(Err); + + Interp->DeviceParser = std::move(DeviceParser); + } - Interp->DeviceParser = std::move(DeviceParser); return std::move(Interp); } `````````` </details> https://github.com/llvm/llvm-project/pull/231391 _______________________________________________ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
