Browse Source

InsertPointGuard definition moved to CompilerHelper.h

cl-refactor
Paweł Bylica 10 years ago
parent
commit
72a6fe4b60
  1. 25
      evmcc/CompilerHelper.h
  2. 1
      evmcc/GasMeter.cpp
  3. 22
      evmcc/Utils.h

25
evmcc/CompilerHelper.h

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

1
evmcc/GasMeter.cpp

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

22
evmcc/Utils.h

@ -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: \

Loading…
Cancel
Save