|
|
@ -14,6 +14,7 @@ |
|
|
|
#include "Memory.h" |
|
|
|
#include "Ext.h" |
|
|
|
#include "GasMeter.h" |
|
|
|
#include "Utils.h" |
|
|
|
|
|
|
|
namespace evmcc |
|
|
|
{ |
|
|
@ -48,38 +49,8 @@ void Compiler::createBasicBlocks(const dev::bytes& bytecode) |
|
|
|
auto inst = static_cast<Instruction>(*curr); |
|
|
|
switch (inst) |
|
|
|
{ |
|
|
|
case Instruction::PUSH1: |
|
|
|
case Instruction::PUSH2: |
|
|
|
case Instruction::PUSH3: |
|
|
|
case Instruction::PUSH4: |
|
|
|
case Instruction::PUSH5: |
|
|
|
case Instruction::PUSH6: |
|
|
|
case Instruction::PUSH7: |
|
|
|
case Instruction::PUSH8: |
|
|
|
case Instruction::PUSH9: |
|
|
|
case Instruction::PUSH10: |
|
|
|
case Instruction::PUSH11: |
|
|
|
case Instruction::PUSH12: |
|
|
|
case Instruction::PUSH13: |
|
|
|
case Instruction::PUSH14: |
|
|
|
case Instruction::PUSH15: |
|
|
|
case Instruction::PUSH16: |
|
|
|
case Instruction::PUSH17: |
|
|
|
case Instruction::PUSH18: |
|
|
|
case Instruction::PUSH19: |
|
|
|
case Instruction::PUSH20: |
|
|
|
case Instruction::PUSH21: |
|
|
|
case Instruction::PUSH22: |
|
|
|
case Instruction::PUSH23: |
|
|
|
case Instruction::PUSH24: |
|
|
|
case Instruction::PUSH25: |
|
|
|
case Instruction::PUSH26: |
|
|
|
case Instruction::PUSH27: |
|
|
|
case Instruction::PUSH28: |
|
|
|
case Instruction::PUSH29: |
|
|
|
case Instruction::PUSH30: |
|
|
|
case Instruction::PUSH31: |
|
|
|
case Instruction::PUSH32: |
|
|
|
|
|
|
|
case Instruction::ANY_PUSH: |
|
|
|
{ |
|
|
|
auto numBytes = static_cast<size_t>(inst) - static_cast<size_t>(Instruction::PUSH1) + 1; |
|
|
|
auto next = curr + numBytes + 1; |
|
|
@ -477,38 +448,7 @@ std::unique_ptr<llvm::Module> Compiler::compile(const dev::bytes& bytecode) |
|
|
|
break; |
|
|
|
} |
|
|
|
|
|
|
|
case Instruction::PUSH1: |
|
|
|
case Instruction::PUSH2: |
|
|
|
case Instruction::PUSH3: |
|
|
|
case Instruction::PUSH4: |
|
|
|
case Instruction::PUSH5: |
|
|
|
case Instruction::PUSH6: |
|
|
|
case Instruction::PUSH7: |
|
|
|
case Instruction::PUSH8: |
|
|
|
case Instruction::PUSH9: |
|
|
|
case Instruction::PUSH10: |
|
|
|
case Instruction::PUSH11: |
|
|
|
case Instruction::PUSH12: |
|
|
|
case Instruction::PUSH13: |
|
|
|
case Instruction::PUSH14: |
|
|
|
case Instruction::PUSH15: |
|
|
|
case Instruction::PUSH16: |
|
|
|
case Instruction::PUSH17: |
|
|
|
case Instruction::PUSH18: |
|
|
|
case Instruction::PUSH19: |
|
|
|
case Instruction::PUSH20: |
|
|
|
case Instruction::PUSH21: |
|
|
|
case Instruction::PUSH22: |
|
|
|
case Instruction::PUSH23: |
|
|
|
case Instruction::PUSH24: |
|
|
|
case Instruction::PUSH25: |
|
|
|
case Instruction::PUSH26: |
|
|
|
case Instruction::PUSH27: |
|
|
|
case Instruction::PUSH28: |
|
|
|
case Instruction::PUSH29: |
|
|
|
case Instruction::PUSH30: |
|
|
|
case Instruction::PUSH31: |
|
|
|
case Instruction::PUSH32: |
|
|
|
case Instruction::ANY_PUSH: |
|
|
|
{ |
|
|
|
auto numBytes = static_cast<size_t>(inst)-static_cast<size_t>(Instruction::PUSH1) + 1; |
|
|
|
auto value = llvm::APInt(256, 0); |
|
|
@ -523,44 +463,14 @@ std::unique_ptr<llvm::Module> Compiler::compile(const dev::bytes& bytecode) |
|
|
|
break; |
|
|
|
} |
|
|
|
|
|
|
|
case Instruction::DUP1: |
|
|
|
case Instruction::DUP2: |
|
|
|
case Instruction::DUP3: |
|
|
|
case Instruction::DUP4: |
|
|
|
case Instruction::DUP5: |
|
|
|
case Instruction::DUP6: |
|
|
|
case Instruction::DUP7: |
|
|
|
case Instruction::DUP8: |
|
|
|
case Instruction::DUP9: |
|
|
|
case Instruction::DUP10: |
|
|
|
case Instruction::DUP11: |
|
|
|
case Instruction::DUP12: |
|
|
|
case Instruction::DUP13: |
|
|
|
case Instruction::DUP14: |
|
|
|
case Instruction::DUP15: |
|
|
|
case Instruction::DUP16: |
|
|
|
case Instruction::ANY_DUP: |
|
|
|
{ |
|
|
|
auto index = static_cast<size_t>(inst)-static_cast<size_t>(Instruction::DUP1); |
|
|
|
stack.dup(index); |
|
|
|
break; |
|
|
|
} |
|
|
|
|
|
|
|
case Instruction::SWAP1: |
|
|
|
case Instruction::SWAP2: |
|
|
|
case Instruction::SWAP3: |
|
|
|
case Instruction::SWAP4: |
|
|
|
case Instruction::SWAP5: |
|
|
|
case Instruction::SWAP6: |
|
|
|
case Instruction::SWAP7: |
|
|
|
case Instruction::SWAP8: |
|
|
|
case Instruction::SWAP9: |
|
|
|
case Instruction::SWAP10: |
|
|
|
case Instruction::SWAP11: |
|
|
|
case Instruction::SWAP12: |
|
|
|
case Instruction::SWAP13: |
|
|
|
case Instruction::SWAP14: |
|
|
|
case Instruction::SWAP15: |
|
|
|
case Instruction::SWAP16: |
|
|
|
case Instruction::ANY_SWAP: |
|
|
|
{ |
|
|
|
auto index = static_cast<size_t>(inst)-static_cast<size_t>(Instruction::SWAP1) + 1; |
|
|
|
stack.swap(index); |
|
|
|