|
|
@ -11,6 +11,7 @@ namespace eth |
|
|
|
namespace jit |
|
|
|
{ |
|
|
|
|
|
|
|
/// Base class for compiler helpers like Memory, GasMeter, etc.
|
|
|
|
class CompilerHelper |
|
|
|
{ |
|
|
|
protected: |
|
|
@ -26,6 +27,30 @@ protected: |
|
|
|
llvm::IRBuilder<>& m_builder; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
/// Saves the insert point of the IR builder and restores it when destructed
|
|
|
|
struct InsertPointGuard |
|
|
|
{ |
|
|
|
InsertPointGuard(llvm::IRBuilder<>& _builder) : |
|
|
|
m_builder(_builder), |
|
|
|
m_insertBB(m_builder.GetInsertBlock()), |
|
|
|
m_insertPt(m_builder.GetInsertPoint()) |
|
|
|
{} |
|
|
|
|
|
|
|
InsertPointGuard(const InsertPointGuard&) = delete; |
|
|
|
void operator=(InsertPointGuard) = delete; |
|
|
|
|
|
|
|
~InsertPointGuard() |
|
|
|
{ |
|
|
|
m_builder.SetInsertPoint(m_insertBB, m_insertPt); |
|
|
|
} |
|
|
|
|
|
|
|
private: |
|
|
|
llvm::IRBuilder<>& m_builder; |
|
|
|
llvm::BasicBlock* m_insertBB; |
|
|
|
llvm::BasicBlock::iterator m_insertPt; |
|
|
|
}; |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|