@@ -451,13 +451,44 @@ const char *const Runtimes = R"(
451
451
)" ;
452
452
453
453
llvm::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) {
455
456
llvm::Error Err = llvm::Error::success ();
456
457
auto Interp =
457
458
std::unique_ptr<Interpreter>(new Interpreter (std::move (CI), Err));
458
459
if (Err)
459
460
return std::move (Err);
460
461
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
+
461
492
// Add runtime code and set a marker to hide it from user code. Undo will not
462
493
// go through that.
463
494
auto PTU = Interp->Parse (Runtimes);
@@ -481,20 +512,7 @@ Interpreter::createWithCUDA(std::unique_ptr<CompilerInstance> CI,
481
512
OverlayVFS->pushOverlay (IMVFS);
482
513
CI->createFileManager (OverlayVFS);
483
514
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));
498
516
}
499
517
500
518
const CompilerInstance *Interpreter::getCompilerInstance () const {
0 commit comments