File indexing completed on 2026-05-10 08:43:53
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013 #ifndef LLVM_EXECUTIONENGINE_ORC_IRCOMPILELAYER_H
0014 #define LLVM_EXECUTIONENGINE_ORC_IRCOMPILELAYER_H
0015
0016 #include "llvm/ADT/STLExtras.h"
0017 #include "llvm/ExecutionEngine/JITSymbol.h"
0018 #include "llvm/ExecutionEngine/Orc/Layer.h"
0019 #include "llvm/Support/Error.h"
0020 #include "llvm/Support/MemoryBuffer.h"
0021 #include <functional>
0022 #include <memory>
0023 #include <mutex>
0024
0025 namespace llvm {
0026
0027 class Module;
0028
0029 namespace orc {
0030
0031 class IRCompileLayer : public IRLayer {
0032 public:
0033 class IRCompiler {
0034 public:
0035 IRCompiler(IRSymbolMapper::ManglingOptions MO) : MO(std::move(MO)) {}
0036 virtual ~IRCompiler();
0037 const IRSymbolMapper::ManglingOptions &getManglingOptions() const {
0038 return MO;
0039 }
0040 virtual Expected<std::unique_ptr<MemoryBuffer>> operator()(Module &M) = 0;
0041
0042 protected:
0043 IRSymbolMapper::ManglingOptions &manglingOptions() { return MO; }
0044
0045 private:
0046 IRSymbolMapper::ManglingOptions MO;
0047 };
0048
0049 using NotifyCompiledFunction = std::function<void(
0050 MaterializationResponsibility &R, ThreadSafeModule TSM)>;
0051
0052 IRCompileLayer(ExecutionSession &ES, ObjectLayer &BaseLayer,
0053 std::unique_ptr<IRCompiler> Compile);
0054
0055 IRCompiler &getCompiler() { return *Compile; }
0056
0057 void setNotifyCompiled(NotifyCompiledFunction NotifyCompiled);
0058
0059 void emit(std::unique_ptr<MaterializationResponsibility> R,
0060 ThreadSafeModule TSM) override;
0061
0062 private:
0063 mutable std::mutex IRLayerMutex;
0064 ObjectLayer &BaseLayer;
0065 std::unique_ptr<IRCompiler> Compile;
0066 const IRSymbolMapper::ManglingOptions *ManglingOpts;
0067 NotifyCompiledFunction NotifyCompiled = NotifyCompiledFunction();
0068 };
0069
0070 }
0071 }
0072
0073 #endif