mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-20 19:56:44 +00:00
parent
7a89751433
commit
f95999c6b3
6 changed files with 19 additions and 1 deletions
|
|
@ -102,7 +102,7 @@ int ExecutionEngine::run(std::unique_ptr<llvm::Module> _module)
|
||||||
auto returnCode = static_cast<ReturnCode>(result.IntVal.getZExtValue());
|
auto returnCode = static_cast<ReturnCode>(result.IntVal.getZExtValue());
|
||||||
if (returnCode == ReturnCode::Return)
|
if (returnCode == ReturnCode::Return)
|
||||||
{
|
{
|
||||||
auto&& returnData = Memory::getReturnData();
|
auto&& returnData = Memory::getReturnData(); // TODO: It might be better to place is in Runtime interface
|
||||||
|
|
||||||
std::cout << "RETURN [ ";
|
std::cout << "RETURN [ ";
|
||||||
for (auto it = returnData.begin(), end = returnData.end(); it != end; ++it)
|
for (auto it = returnData.begin(), end = returnData.end(); it != end; ++it)
|
||||||
|
|
|
||||||
|
|
@ -133,6 +133,9 @@ llvm::Value* Memory::getSize()
|
||||||
|
|
||||||
void Memory::registerReturnData(llvm::Value* _index, llvm::Value* _size)
|
void Memory::registerReturnData(llvm::Value* _index, llvm::Value* _size)
|
||||||
{
|
{
|
||||||
|
auto lastWord = m_builder.CreateAdd(_index, m_builder.CreateSub(_size, Constant::get(32)), "lastWord");
|
||||||
|
loadWord(lastWord); // Make sure that memory is allocated and count gas
|
||||||
|
|
||||||
m_builder.CreateStore(_index, m_returnDataOffset);
|
m_builder.CreateStore(_index, m_returnDataOffset);
|
||||||
m_builder.CreateStore(_size, m_returnDataSize);
|
m_builder.CreateStore(_size, m_returnDataSize);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -25,6 +25,11 @@ void Type::init(llvm::LLVMContext& _context)
|
||||||
MainReturn = llvm::Type::getInt32Ty(_context);
|
MainReturn = llvm::Type::getInt32Ty(_context);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
llvm::Constant* Constant::get(uint64_t _n)
|
||||||
|
{
|
||||||
|
return llvm::ConstantInt::get(Type::i256, _n);
|
||||||
|
}
|
||||||
|
|
||||||
llvm::Constant* Constant::get(ReturnCode _returnCode)
|
llvm::Constant* Constant::get(ReturnCode _returnCode)
|
||||||
{
|
{
|
||||||
return llvm::ConstantInt::get(Type::MainReturn, static_cast<uint64_t>(_returnCode));
|
return llvm::ConstantInt::get(Type::MainReturn, static_cast<uint64_t>(_returnCode));
|
||||||
|
|
|
||||||
|
|
@ -38,6 +38,9 @@ enum class ReturnCode
|
||||||
|
|
||||||
struct Constant
|
struct Constant
|
||||||
{
|
{
|
||||||
|
/// Returns word-size constant
|
||||||
|
static llvm::Constant* get(uint64_t _n);
|
||||||
|
|
||||||
static llvm::Constant* get(ReturnCode _returnCode);
|
static llvm::Constant* get(ReturnCode _returnCode);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
1
evmcc/bytecode/return2.evm
Normal file
1
evmcc/bytecode/return2.evm
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
6001620f4240f2
|
||||||
6
evmcc/lll/return2.lll
Normal file
6
evmcc/lll/return2.lll
Normal file
|
|
@ -0,0 +1,6 @@
|
||||||
|
|
||||||
|
(asm
|
||||||
|
1
|
||||||
|
1000000
|
||||||
|
RETURN ;; return 1 byte from index 1M
|
||||||
|
)
|
||||||
Loading…
Reference in a new issue