Fabcoin Core  0.16.2
P2P Digital Currency
Compiler.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include "JIT.h"
4 #include "BasicBlock.h"
5 
6 namespace dev
7 {
8 namespace eth
9 {
10 namespace jit
11 {
12 
13 class Compiler
14 {
15 public:
16 
17  struct Options
18  {
21 
23  bool dumpCFG = false;
24  };
25 
26  Compiler(Options const& _options, evm_mode _mode, llvm::LLVMContext& _llvmContext);
27 
28  std::unique_ptr<llvm::Module> compile(code_iterator _begin, code_iterator _end, std::string const& _id);
29 
30 private:
31 
32  std::vector<BasicBlock> createBasicBlocks(code_iterator _begin, code_iterator _end);
33 
34  void compileBasicBlock(BasicBlock& _basicBlock, class RuntimeManager& _runtimeManager, class Arith256& _arith, class Memory& _memory, class Ext& _ext, class GasMeter& _gasMeter);
35 
36  void resolveJumps();
37 
40 
43 
46 
48  llvm::BasicBlock* m_jumpTableBB = nullptr;
49 
51  llvm::Function* m_mainFunc = nullptr;
52 };
53 
54 }
55 }
56 }
Adapted from code found on http://stackoverflow.com/questions/180947/base64-decode-snippet-in-c Origi...
Definition: Arith256.cpp:15
Compiler(Options const &_options, evm_mode _mode, llvm::LLVMContext &_llvmContext)
Definition: Compiler.cpp:33
bool rewriteSwitchToBranches
Rewrite switch instructions to sequences of branches.
Definition: Compiler.h:20
bool dumpCFG
Dump CFG as a .dot file for graphviz.
Definition: Compiler.h:23
llvm::BasicBlock * m_jumpTableBB
Block with a jump table.
Definition: Compiler.h:48
byte const * code_iterator
Definition: Common.h:11
Options const & m_options
Compiler options.
Definition: Compiler.h:39
std::vector< BasicBlock > createBasicBlocks(code_iterator _begin, code_iterator _end)
Definition: Compiler.cpp:41
evm_mode
EVM compatibility mode aka chain mode.
Definition: evm.h:359
void compileBasicBlock(BasicBlock &_basicBlock, class RuntimeManager &_runtimeManager, class Arith256 &_arith, class Memory &_memory, class Ext &_ext, class GasMeter &_gasMeter)
Definition: Compiler.cpp:213
IRBuilder m_builder
Helper class for generating IR.
Definition: Compiler.h:45
std::unique_ptr< llvm::Module > compile(code_iterator _begin, code_iterator _end, std::string const &_id)
Definition: Compiler.cpp:149
evm_mode m_mode
EVM compatibility mode.
Definition: Compiler.h:42
llvm::Function * m_mainFunc
Main program function.
Definition: Compiler.h:51
llvm::IRBuilder<> IRBuilder