//LLVM includes #include "llvm/Analysis/Passes.h" // Local includes #include "JIT.h" using namespace ast; using namespace llvm; using namespace llvm::orc; namespace jit{ std::unique_ptr JITObjects::TheFPM = std::make_unique(AstObjects::TheModule.get()); std::unique_ptr JITObjects::TheJIT = std::unique_ptr(nullptr); std::map> JITObjects::FunctionProtos{}; void InitializeModule(void) { // Open a new module. AstObjects::TheModule = llvm::make_unique("my cool jit", getGlobalContext()); AstObjects::TheModule->setDataLayout(JITObjects::TheJIT->getTargetMachine().createDataLayout()); } Function *getFunction(std::string Name) { // First, see if the function has already been added to the current module. if (auto *F = AstObjects::TheModule->getFunction(Name)) return F; // If not, check whether we can codegen the declaration from some existing // prototype. auto FI = JITObjects::FunctionProtos.find(Name); if (FI != JITObjects::FunctionProtos.end()) return FI->second->codegen(); // If no existing prototype exists, return null. return nullptr; } }