Fabcoin Core  0.16.2
P2P Digital Currency
BasicBlock.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include <vector>
4 
5 #include "Common.h"
6 #include "CompilerHelper.h"
7 
8 namespace dev
9 {
10 namespace eth
11 {
12 namespace jit
13 {
14 using namespace evmjit;
15 using instr_idx = uint64_t;
16 
17 class RuntimeManager;
18 
20 {
21 public:
22  explicit LocalStack(IRBuilder& _builder, RuntimeManager& _runtimeManager);
23 
25  void push(llvm::Value* _value);
26 
28  llvm::Value* pop();
29 
31  void dup(size_t _index);
32 
35  void swap(size_t _index);
36 
37  ssize_t size() const { return static_cast<ssize_t>(m_local.size()) - m_globalPops; }
38  ssize_t minSize() const { return m_minSize; }
39  ssize_t maxSize() const { return m_maxSize; }
40 
42  void finalize();
43 
44 private:
46  llvm::Value* get(size_t _index);
47 
49  void set(size_t _index, llvm::Value* _value);
50 
51  llvm::Function* getStackPrepareFunc();
52 
55  std::vector<llvm::Value*> m_input;
56 
58  std::vector<llvm::Value*> m_local;
59 
60  llvm::CallInst* m_sp = nullptr;
61 
62  ssize_t m_globalPops = 0;
63  ssize_t m_minSize = 0;
64  ssize_t m_maxSize = 0;
65 };
66 
68 {
69 public:
70  explicit BasicBlock(instr_idx _firstInstrIdx, code_iterator _begin, code_iterator _end, llvm::Function* _mainFunc);
71 
72  llvm::BasicBlock* llvm() { return m_llvmBB; }
73 
74  instr_idx firstInstrIdx() const { return m_firstInstrIdx; }
75  code_iterator begin() const { return m_begin; }
76  code_iterator end() const { return m_end; }
77 
78 private:
79  instr_idx const m_firstInstrIdx = 0;
80  code_iterator const m_begin = {};
81  code_iterator const m_end = {};
82 
83  llvm::BasicBlock* const m_llvmBB;
84 };
85 
86 }
87 }
88 }
Adapted from code found on http://stackoverflow.com/questions/180947/base64-decode-snippet-in-c Origi...
Definition: Arith256.cpp:15
llvm::BasicBlock *const m_llvmBB
Reference to the LLVM BasicBlock.
Definition: BasicBlock.h:83
void swap(dev::eth::Watch &_a, dev::eth::Watch &_b)
Definition: Interface.h:284
instr_idx firstInstrIdx() const
Definition: BasicBlock.h:74
byte const * code_iterator
Definition: Common.h:11
Base class for compiler helpers like Memory, GasMeter, etc.
Config::Value_type Value
ssize_t size() const
Definition: BasicBlock.h:37
uint64_t instr_idx
Definition: BasicBlock.h:15
llvm::BasicBlock * llvm()
Definition: BasicBlock.h:72
code_iterator begin() const
Definition: BasicBlock.h:75
std::vector< llvm::Value * > m_local
Local stack items that has not been pushed to global stack. First item is just above global stack...
Definition: BasicBlock.h:58
ssize_t maxSize() const
Definition: BasicBlock.h:39
code_iterator end() const
Definition: BasicBlock.h:76
llvm::IRBuilder<> IRBuilder
std::vector< llvm::Value * > m_input
Items fetched from global stack.
Definition: BasicBlock.h:55
ssize_t minSize() const
Definition: BasicBlock.h:38