InsertPointGuard definition moved to CompilerHelper.h

This commit is contained in:
Paweł Bylica 2014-10-16 13:34:02 +02:00
parent 8eea4752b2
commit 72a6fe4b60
3 changed files with 25 additions and 23 deletions

View file

@ -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;
};
}
}
}

View file

@ -9,7 +9,6 @@
#include <libevm/FeeStructure.h>
#include "Type.h"
#include "Utils.h"
#include "Ext.h"
namespace dev

View file

@ -26,28 +26,6 @@ static_assert(sizeof(i256) == 32, "Wrong i265 size");
u256 llvm2eth(i256);
i256 eth2llvm(u256);
struct InsertPointGuard
{
InsertPointGuard(llvm::IRBuilder<>& _builder) :
m_builder(_builder),
m_insertBB(m_builder.GetInsertBlock()),
m_insertPt(m_builder.GetInsertPoint())
{}
~InsertPointGuard()
{
m_builder.SetInsertPoint(m_insertBB, m_insertPt);
}
private:
llvm::IRBuilder<>& m_builder;
llvm::BasicBlock* m_insertBB;
llvm::BasicBlock::iterator m_insertPt;
InsertPointGuard(const InsertPointGuard&) = delete;
void operator=(InsertPointGuard) = delete;
};
#define ANY_PUSH PUSH1: \
case Instruction::PUSH2: \
case Instruction::PUSH3: \