mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-23 21:26:42 +00:00
Detemplatify createCall helper
This commit is contained in:
parent
b77a975a33
commit
b6248cc38d
4 changed files with 12 additions and 12 deletions
|
|
@ -35,6 +35,11 @@ llvm::Function* CompilerHelper::getMainFunction()
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
llvm::CallInst* CompilerHelper::createCall(llvm::Function* _func, std::initializer_list<llvm::Value*> const& _args)
|
||||||
|
{
|
||||||
|
return getBuilder().CreateCall(_func, {_args.begin(), _args.size()});
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
RuntimeHelper::RuntimeHelper(RuntimeManager& _runtimeManager):
|
RuntimeHelper::RuntimeHelper(RuntimeManager& _runtimeManager):
|
||||||
CompilerHelper(_runtimeManager.getBuilder()),
|
CompilerHelper(_runtimeManager.getBuilder()),
|
||||||
|
|
|
||||||
|
|
@ -31,12 +31,7 @@ protected:
|
||||||
llvm::IRBuilder<>& m_builder;
|
llvm::IRBuilder<>& m_builder;
|
||||||
llvm::IRBuilder<>& getBuilder() { return m_builder; }
|
llvm::IRBuilder<>& getBuilder() { return m_builder; }
|
||||||
|
|
||||||
template<typename ..._Args>
|
llvm::CallInst* createCall(llvm::Function* _func, std::initializer_list<llvm::Value*> const& _args);
|
||||||
llvm::CallInst* createCall(llvm::Function* _func, _Args*... _args)
|
|
||||||
{
|
|
||||||
llvm::Value* args[] = {_args...};
|
|
||||||
return getBuilder().CreateCall(_func, args);
|
|
||||||
}
|
|
||||||
|
|
||||||
friend class RuntimeHelper;
|
friend class RuntimeHelper;
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -119,7 +119,7 @@ void GasMeter::count(Instruction _inst)
|
||||||
if (!m_checkCall)
|
if (!m_checkCall)
|
||||||
{
|
{
|
||||||
// Create gas check call with mocked block cost at begining of current cost-block
|
// Create gas check call with mocked block cost at begining of current cost-block
|
||||||
m_checkCall = createCall(m_gasCheckFunc, m_runtimeManager.getRuntimePtr(), llvm::UndefValue::get(Type::Word));
|
m_checkCall = createCall(m_gasCheckFunc, {m_runtimeManager.getRuntimePtr(), llvm::UndefValue::get(Type::Word)});
|
||||||
}
|
}
|
||||||
|
|
||||||
m_blockCost += getStepCost(_inst);
|
m_blockCost += getStepCost(_inst);
|
||||||
|
|
@ -127,7 +127,7 @@ void GasMeter::count(Instruction _inst)
|
||||||
|
|
||||||
void GasMeter::count(llvm::Value* _cost)
|
void GasMeter::count(llvm::Value* _cost)
|
||||||
{
|
{
|
||||||
createCall(m_gasCheckFunc, m_runtimeManager.getRuntimePtr(), _cost);
|
createCall(m_gasCheckFunc, {m_runtimeManager.getRuntimePtr(), _cost});
|
||||||
}
|
}
|
||||||
|
|
||||||
void GasMeter::countExp(llvm::Value* _exponent)
|
void GasMeter::countExp(llvm::Value* _exponent)
|
||||||
|
|
|
||||||
|
|
@ -146,18 +146,18 @@ llvm::Function* Memory::createFunc(bool _isStore, llvm::Type* _valueType, GasMet
|
||||||
|
|
||||||
llvm::Value* Memory::loadWord(llvm::Value* _addr)
|
llvm::Value* Memory::loadWord(llvm::Value* _addr)
|
||||||
{
|
{
|
||||||
return createCall(m_loadWord, getRuntimeManager().getRuntimePtr(), _addr);
|
return createCall(m_loadWord, {getRuntimeManager().getRuntimePtr(), _addr});
|
||||||
}
|
}
|
||||||
|
|
||||||
void Memory::storeWord(llvm::Value* _addr, llvm::Value* _word)
|
void Memory::storeWord(llvm::Value* _addr, llvm::Value* _word)
|
||||||
{
|
{
|
||||||
createCall(m_storeWord, getRuntimeManager().getRuntimePtr(), _addr, _word);
|
createCall(m_storeWord, {getRuntimeManager().getRuntimePtr(), _addr, _word});
|
||||||
}
|
}
|
||||||
|
|
||||||
void Memory::storeByte(llvm::Value* _addr, llvm::Value* _word)
|
void Memory::storeByte(llvm::Value* _addr, llvm::Value* _word)
|
||||||
{
|
{
|
||||||
auto byte = m_builder.CreateTrunc(_word, Type::Byte, "byte");
|
auto byte = m_builder.CreateTrunc(_word, Type::Byte, "byte");
|
||||||
createCall(m_storeByte, getRuntimeManager().getRuntimePtr(), _addr, byte);
|
createCall(m_storeByte, {getRuntimeManager().getRuntimePtr(), _addr, byte});
|
||||||
}
|
}
|
||||||
|
|
||||||
llvm::Value* Memory::getData()
|
llvm::Value* Memory::getData()
|
||||||
|
|
@ -181,7 +181,7 @@ llvm::Value* Memory::getBytePtr(llvm::Value* _index)
|
||||||
|
|
||||||
void Memory::require(llvm::Value* _offset, llvm::Value* _size)
|
void Memory::require(llvm::Value* _offset, llvm::Value* _size)
|
||||||
{
|
{
|
||||||
createCall(m_require, getRuntimeManager().getRuntimePtr(), _offset, _size);
|
createCall(m_require, {getRuntimeManager().getRuntimePtr(), _offset, _size});
|
||||||
}
|
}
|
||||||
|
|
||||||
void Memory::copyBytes(llvm::Value* _srcPtr, llvm::Value* _srcSize, llvm::Value* _srcIdx,
|
void Memory::copyBytes(llvm::Value* _srcPtr, llvm::Value* _srcSize, llvm::Value* _srcIdx,
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue