| 1 |
//===--- OrcIncrementalExecutor.h - Orc Incremental Execution ---*- C++ -*-===// |
| 2 |
// |
| 3 |
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
| 4 |
// See https://llvm.org/LICENSE.txt for license information. |
| 5 |
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
| 6 |
// |
| 7 |
//===----------------------------------------------------------------------===// |
| 8 |
// |
| 9 |
// This file implements an Orc-based incremental code execution. |
| 10 |
// |
| 11 |
//===----------------------------------------------------------------------===// |
| 12 |
|
| 13 |
#ifndef LLVM_CLANG_LIB_INTERPRETER_ORCINCREMENTALEXECUTOR_H |
| 14 |
#define LLVM_CLANG_LIB_INTERPRETER_ORCINCREMENTALEXECUTOR_H |
| 15 |
|
| 16 |
#include "clang/Interpreter/IncrementalExecutor.h" |
| 17 |
|
| 18 |
#include "llvm/ADT/DenseMap.h" |
| 19 |
#include "llvm/ADT/StringRef.h" |
| 20 |
#include "llvm/ExecutionEngine/Orc/Core.h" |
| 21 |
#include "llvm/ExecutionEngine/Orc/ExecutionUtils.h" |
| 22 |
#include "llvm/ExecutionEngine/Orc/Layer.h" |
| 23 |
#include "llvm/ExecutionEngine/Orc/Shared/ExecutorAddress.h" |
| 24 |
#include "llvm/ExecutionEngine/Orc/SimpleRemoteEPC.h" |
| 25 |
#include "llvm/Support/Error.h" |
| 26 |
|
| 27 |
#include <cstdint> |
| 28 |
#include <memory> |
| 29 |
|
| 30 |
namespace llvm { |
| 31 |
class Error; |
| 32 |
namespace orc { |
| 33 |
class JITTargetMachineBuilder; |
| 34 |
class LLJIT; |
| 35 |
class LLJITBuilder; |
| 36 |
class ThreadSafeContext; |
| 37 |
} // namespace orc |
| 38 |
} // namespace llvm |
| 39 |
|
| 40 |
namespace clang { |
| 41 |
|
| 42 |
struct PartialTranslationUnit; |
| 43 |
|
| 44 |
class OrcIncrementalExecutor : public IncrementalExecutor { |
| 45 |
std::unique_ptr<llvm::orc::LLJIT> Jit; |
| 46 |
llvm::orc::ThreadSafeContext &TSCtx; |
| 47 |
|
| 48 |
llvm::DenseMap<const PartialTranslationUnit *, llvm::orc::ResourceTrackerSP> |
| 49 |
ResourceTrackers; |
| 50 |
|
| 51 |
protected: |
| 52 |
OrcIncrementalExecutor(llvm::orc::ThreadSafeContext &TSC); |
| 53 |
|
| 54 |
public: |
| 55 |
OrcIncrementalExecutor(llvm::orc::ThreadSafeContext &TSC, |
| 56 |
llvm::orc::LLJITBuilder &JITBuilder, llvm::Error &Err); |
| 57 |
~OrcIncrementalExecutor() override; |
| 58 |
|
| 59 |
llvm::Error addModule(PartialTranslationUnit &PTU) override; |
| 60 |
llvm::Error removeModule(PartialTranslationUnit &PTU) override; |
| 61 |
llvm::Error runCtors() const override; |
| 62 |
llvm::Error cleanUp() override; |
| 63 |
llvm::Expected<llvm::orc::ExecutorAddr> |
| 64 |
getSymbolAddress(llvm::StringRef Name, |
| 65 |
SymbolNameKind NameKind) const override; |
| 66 |
llvm::Error LoadDynamicLibrary(const char *name) override; |
| 67 |
}; |
| 68 |
|
| 69 |
} // end namespace clang |
| 70 |
|
| 71 |
#endif // LLVM_CLANG_LIB_INTERPRETER_ORCINCREMENTALEXECUTOR_H |