-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathjit.hpp
More file actions
60 lines (51 loc) · 1.74 KB
/
jit.hpp
File metadata and controls
60 lines (51 loc) · 1.74 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#ifndef JIT_HPP
#define JIT_HPP
#include <algorithm>
#include <cassert>
#include <cctype>
#include <cstdint>
#include <cstdio>
#include <cstdlib>
#include <map>
#include <memory>
#include <string>
#include <utility>
#include <vector>
#include "KaleidoscopeJIT.hpp"
#include "llvm/ADT/APFloat.h"
#include "llvm/ADT/STLExtras.h"
#include "llvm/IR/BasicBlock.h"
#include "llvm/IR/Constants.h"
#include "llvm/IR/DerivedTypes.h"
#include "llvm/IR/Function.h"
#include "llvm/IR/IRBuilder.h"
#include "llvm/IR/Instructions.h"
#include "llvm/IR/LLVMContext.h"
#include "llvm/IR/Module.h"
#include "llvm/IR/Type.h"
#include "llvm/IR/Verifier.h"
#include "llvm/Support/TargetSelect.h"
#include "llvm/Target/TargetMachine.h"
namespace JIT {
// LLVM
//===----------------------------------------------------------------------===//
// Code Generation
//===----------------------------------------------------------------------===//
void init_runtime(const std::string &module_name, const std::string prefix);
void define_log_exp();
void finalize_module(const std::string &Name);
std::function<double(const double *)> get_function(const std::string &Name);
struct Runtime {
static llvm::LLVMContext TheContext;
static llvm::IRBuilder<> Builder;
static std::unique_ptr<llvm::Module> TheModule;
static std::map<std::string, llvm::Value *> NamedValues;
static std::unique_ptr<llvm::orc::KaleidoscopeJIT> TheJIT;
static void InitializeModule(const std::string &module_name);
static llvm::AllocaInst *CreateEntryBlockAlloca(llvm::Function *TheFunction,
const std::string &VarName,
llvm::Type *type);
static llvm::Value *LogErrorV(const char *Str);
};
} // namespace JIT
#endif