roadrunner  2.6.0
Fast simulator for SBML models
LLJit.h
1 //
2 // Created by Ciaran on 25/10/2021.
3 //
4 
5 #ifndef ROADRUNNER_LLJIT_H
6 #define ROADRUNNER_LLJIT_H
7 
8 #define NOMINMAX
9 
10 #include "SBMLModelObjectCache.h"
11 
12 #ifdef _MSC_VER
13 #pragma warning(disable: 4146)
14 #pragma warning(disable: 4141)
15 #pragma warning(disable: 4267)
16 #pragma warning(disable: 4624)
17 #endif
18 
19 #include <llvm/IRReader/IRReader.h>
20 #include "llvm/Jit.h"
21 #include "llvm/ExecutionEngine/Orc/LLJIT.h"
22 #include "llvm/Support/SourceMgr.h"
23 
24 #ifdef _MSC_VER
25 #pragma warning(default: 4146)
26 #pragma warning(default: 4141)
27 #pragma warning(default: 4267)
28 #pragma warning(default: 4624)
29 #endif
30 
31 using namespace rr;
32 
33 namespace rrllvm {
34 
35  class SBMLModelObjectCache;
36 
42  class LLJit : public Jit {
43  public:
44 
45  LLJit() = default;
46 
47  ~LLJit() override = default;
48 
49  std::string mangleName(const std::string &unmangledName) const override;
50 
51  explicit LLJit(std::uint32_t options);
52 
53  void mapFunctionsToJitSymbols() override;
54 
55  std::uint64_t lookupFunctionAddress(const std::string &name) override;
56 
57  void addObjectFile(rrOwningBinary owningObject) override;
58 
59  const llvm::DataLayout &getDataLayout() const override;
60 
61  void addModule(llvm::Module *M) override;
62 
63  void addModule() override;
64 
65  void addObjectFile(std::unique_ptr<llvm::MemoryBuffer> obj) override;
66 
67  void addObjectFile(std::unique_ptr<llvm::object::ObjectFile> objectFile) override;
68 
69  void addModule(llvm::orc::ThreadSafeModule tsm);
70 
71  void addModule(std::unique_ptr<llvm::Module> M, std::unique_ptr<llvm::LLVMContext> ctx) override;
72 
81  std::unique_ptr<llvm::MemoryBuffer> getCompiledModelFromCache(const std::string& sbmlMD5) override;
82 
83  llvm::orc::LLJIT *getLLJitNonOwning();
84 
85  void addIRModule();
86 
90  std::string dump();
91 
92  friend std::ostream& operator<<(std::ostream& os, LLJit* llJit);
93 
94  std::string getModuleAsString(std::string sbmlMD5) override;
95 
96 
97  private:
98 
99 // void mapFunctionToAbsoluteSymbol(const std::string &funcName, std::uint64_t funcAddress);
100 
101  std::unique_ptr<llvm::orc::LLJIT> llJit;
102  llvm::TargetMachine* targetMachineNonOwning = nullptr;
103  };
104 
105 }
106 
107 #endif //ROADRUNNER_LLJIT_H
superclass of all Jit types.
Definition: Jit.h:150
Thin layer around the llvm::orc::LLJit.
Definition: LLJit.h:42