@@ -451,13 +451,44 @@ const char *const Runtimes = R"(
451451)" ;
452452
453453llvm::Expected<std::unique_ptr<Interpreter>>
454- Interpreter::create (std::unique_ptr<CompilerInstance> CI) {
454+ Interpreter::create (std::unique_ptr<CompilerInstance> CI,
455+ std::unique_ptr<CompilerInstance> DeviceCI) {
455456 llvm::Error Err = llvm::Error::success ();
456457 auto Interp =
457458 std::unique_ptr<Interpreter>(new Interpreter (std::move (CI), Err));
458459 if (Err)
459460 return std::move (Err);
460461
462+ if (DeviceCI) {
463+ // auto DeviceLLVMCtx = std::make_unique<llvm::LLVMContext>();
464+ // auto DeviceTSCtx =
465+ // std::make_unique<llvm::orc::ThreadSafeContext>(std::move(DeviceLLVMCtx));
466+
467+ // llvm::Error DeviceErr = llvm::Error::success();
468+ // llvm::ErrorAsOutParameter EAO(&DeviceErr);
469+
470+ // auto DeviceAct = std::make_unique<IncrementalAction>(
471+ // *DeviceCI, *DeviceTSCtx->getContext(), DeviceErr, *Interp);
472+
473+ // if (DeviceErr)
474+ // return std::move(DeviceErr);
475+
476+ // DeviceCI->ExecuteAction(*DeviceAct);
477+ DeviceCI->ExecuteAction (*Interp->Act );
478+
479+ llvm::IntrusiveRefCntPtr<llvm::vfs::InMemoryFileSystem> IMVFS =
480+ std::make_unique<llvm::vfs::InMemoryFileSystem>();
481+
482+ auto DeviceParser = std::make_unique<IncrementalCUDADeviceParser>(
483+ std::move (DeviceCI), *Interp->getCompilerInstance (), IMVFS, Err,
484+ Interp->PTUs );
485+
486+ if (Err)
487+ return std::move (Err);
488+
489+ Interp->DeviceParser = std::move (DeviceParser);
490+ }
491+
461492 // Add runtime code and set a marker to hide it from user code. Undo will not
462493 // go through that.
463494 auto PTU = Interp->Parse (Runtimes);
@@ -481,20 +512,7 @@ Interpreter::createWithCUDA(std::unique_ptr<CompilerInstance> CI,
481512 OverlayVFS->pushOverlay (IMVFS);
482513 CI->createFileManager (OverlayVFS);
483514
484- auto Interp = Interpreter::create (std::move (CI));
485- if (auto E = Interp.takeError ())
486- return std::move (E);
487-
488- llvm::Error Err = llvm::Error::success ();
489- auto DeviceParser = std::make_unique<IncrementalCUDADeviceParser>(
490- std::move (DCI), *(*Interp)->getCompilerInstance (), IMVFS, Err,
491- (*Interp)->PTUs );
492- if (Err)
493- return std::move (Err);
494-
495- (*Interp)->DeviceParser = std::move (DeviceParser);
496-
497- return Interp;
515+ return Interpreter::create (std::move (CI), std::move (DCI));
498516}
499517
500518const CompilerInstance *Interpreter::getCompilerInstance () const {
0 commit comments