Browse Source

- implemented LT, GT

- new tests for jumps and comparisons
cl-refactor
artur-zawlocki 10 years ago
parent
commit
8df1050fcb
  1. 20
      evmcc/Compiler.cpp
  2. 1
      evmcc/bytecode/for1.evm
  3. 1
      evmcc/bytecode/for2.evm
  4. 3
      evmcc/lll/for1.lll
  5. 3
      evmcc/lll/for2.lll

20
evmcc/Compiler.cpp

@ -286,6 +286,26 @@ std::unique_ptr<llvm::Module> Compiler::compile(const dev::bytes& bytecode)
break;
}
case Instruction::LT:
{
auto lhs = stack.pop();
auto rhs = stack.pop();
auto res1 = builder.CreateICmpULT(lhs, rhs);
auto res256 = builder.CreateZExt(res1, Types.word256);
stack.push(res256);
break;
}
case Instruction::GT:
{
auto lhs = stack.pop();
auto rhs = stack.pop();
auto res1 = builder.CreateICmpUGT(lhs, rhs);
auto res256 = builder.CreateZExt(res1, Types.word256);
stack.push(res256);
break;
}
case Instruction::NOT:
{
auto top = stack.pop();

1
evmcc/bytecode/for1.evm

@ -0,0 +1 @@
600a60805460006080530b0f60255960a0536080530160a054600160805303608054600558

1
evmcc/bytecode/for2.evm

@ -0,0 +1 @@
6000608054600a6080530a0f60255960a0536080530160a054600160805301608054600558

3
evmcc/lll/for1.lll

@ -0,0 +1,3 @@
(for [i]:10 (> @i 0) [i](- @i 1)
[j](+ @i @j)
)

3
evmcc/lll/for2.lll

@ -0,0 +1,3 @@
(for [i]:0 (< @i 10) [i](+ @i 1)
[j](+ @i @j)
)
Loading…
Cancel
Save