diff --git a/libyul/CMakeLists.txt b/libyul/CMakeLists.txt index f621b2089e9b..e403d9193881 100644 --- a/libyul/CMakeLists.txt +++ b/libyul/CMakeLists.txt @@ -197,6 +197,16 @@ add_library(yul optimiser/VarDeclInitializer.h optimiser/VarNameCleaner.cpp optimiser/VarNameCleaner.h + tools/interpreter/Results.h + tools/interpreter/PureInterpreterState.h + tools/interpreter/PureInterpreterState.cpp + tools/interpreter/Scope.h + tools/interpreter/Scope.cpp + tools/interpreter/types.h + tools/interpreter/PureInterpreter.cpp + tools/interpreter/PureInterpreter.h + tools/interpreter/PureEVMInstructionInterpreter.cpp + tools/interpreter/PureEVMInstructionInterpreter.h ) target_link_libraries(yul PUBLIC evmasm solutil langutil smtutil fmt::fmt-header-only) diff --git a/libyul/tools/interpreter/PureEVMInstructionInterpreter.cpp b/libyul/tools/interpreter/PureEVMInstructionInterpreter.cpp new file mode 100644 index 000000000000..e3947eaf39f7 --- /dev/null +++ b/libyul/tools/interpreter/PureEVMInstructionInterpreter.cpp @@ -0,0 +1,312 @@ +/* + This file is part of solidity. + + solidity is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + solidity is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with solidity. If not, see . +*/ +// SPDX-License-Identifier: GPL-3.0 +/** + * Yul interpreter module that evaluates EVM instructions. + */ + +#include + +#include + +#include +#include +#include + +#include +#include + +#include +#include +#include + +#include + +using namespace solidity; +using namespace solidity::evmasm; +using namespace solidity::yul; +using namespace solidity::yul::tools::interpreter; + +using solidity::util::h160; +using solidity::util::h256; + +using u512 = boost::multiprecision::number>; + +EvaluationResult PureEVMInstructionInterpreter::eval( + evmasm::Instruction _instruction, + std::vector const& _arguments +) +{ + using namespace solidity::evmasm; + using evmasm::Instruction; + + auto info = instructionInfo(_instruction, m_evmVersion); + yulAssert(static_cast(info.args) == _arguments.size(), ""); + + auto const& arg = _arguments; + switch (_instruction) + { + case Instruction::STOP: + return ExplicitlyTerminated(); + // --------------- arithmetic --------------- + case Instruction::ADD: + return EvaluationOk(arg[0] + arg[1]); + case Instruction::MUL: + return EvaluationOk(arg[0] * arg[1]); + case Instruction::SUB: + return EvaluationOk(arg[0] - arg[1]); + case Instruction::DIV: + return EvaluationOk(arg[1] == 0 ? 0 : arg[0] / arg[1]); + case Instruction::SDIV: + return EvaluationOk(arg[1] == 0 ? 0 : s2u(u2s(arg[0]) / u2s(arg[1]))); + case Instruction::MOD: + return EvaluationOk(arg[1] == 0 ? 0 : arg[0] % arg[1]); + case Instruction::SMOD: + return EvaluationOk(arg[1] == 0 ? 0 : s2u(u2s(arg[0]) % u2s(arg[1]))); + case Instruction::EXP: + return EvaluationOk(exp256(arg[0], arg[1])); + case Instruction::NOT: + return EvaluationOk(~arg[0]); + case Instruction::LT: + return EvaluationOk(arg[0] < arg[1] ? u256(1) : u256(0)); + case Instruction::GT: + return EvaluationOk(arg[0] > arg[1] ? u256(1) : u256(0)); + case Instruction::SLT: + return EvaluationOk(u2s(arg[0]) < u2s(arg[1]) ? u256(1) : u256(0)); + case Instruction::SGT: + return EvaluationOk(u2s(arg[0]) > u2s(arg[1]) ? u256(1) : u256(0)); + case Instruction::EQ: + return EvaluationOk(arg[0] == arg[1] ? u256(1) : u256(0)); + case Instruction::ISZERO: + return EvaluationOk(arg[0] == 0 ? u256(1) : u256(0)); + case Instruction::AND: + return EvaluationOk(arg[0] & arg[1]); + case Instruction::OR: + return EvaluationOk(arg[0] | arg[1]); + case Instruction::XOR: + return EvaluationOk(arg[0] ^ arg[1]); + case Instruction::BYTE: + return EvaluationOk(arg[0] >= 32 ? 0 : (arg[1] >> unsigned(8 * (31 - arg[0]))) & 0xff); + case Instruction::SHL: + return EvaluationOk(arg[0] > 255 ? 0 : (arg[1] << unsigned(arg[0]))); + case Instruction::SHR: + return EvaluationOk(arg[0] > 255 ? 0 : (arg[1] >> unsigned(arg[0]))); + case Instruction::SAR: + { + static u256 const hibit = u256(1) << 255; + if (arg[0] >= 256) + return EvaluationOk(arg[1] & hibit ? u256(-1) : 0); + else + { + unsigned amount = unsigned(arg[0]); + u256 v = arg[1] >> amount; + if (arg[1] & hibit) + v |= u256(-1) << (256 - amount); + return EvaluationOk(v); + } + } + case Instruction::ADDMOD: + return EvaluationOk(arg[2] == 0 ? 0 : u256((u512(arg[0]) + u512(arg[1])) % arg[2])); + case Instruction::MULMOD: + return EvaluationOk(arg[2] == 0 ? 0 : u256((u512(arg[0]) * u512(arg[1])) % arg[2])); + case Instruction::SIGNEXTEND: + if (arg[0] >= 31) + return EvaluationOk(arg[1]); + else + { + unsigned testBit = unsigned(arg[0]) * 8 + 7; + u256 ret = arg[1]; + u256 mask = ((u256(1) << testBit) - 1); + if (boost::multiprecision::bit_test(ret, testBit)) + ret |= ~mask; + else + ret &= mask; + return EvaluationOk(ret); + } + // --------------- blockchain stuff --------------- + case Instruction::KECCAK256: + case Instruction::ADDRESS: + case Instruction::BALANCE: + case Instruction::SELFBALANCE: + case Instruction::ORIGIN: + case Instruction::CALLER: + case Instruction::CALLVALUE: + case Instruction::CALLDATALOAD: + case Instruction::CALLDATASIZE: + case Instruction::CALLDATACOPY: + case Instruction::CODESIZE: + case Instruction::CODECOPY: + case Instruction::GASPRICE: + case Instruction::CHAINID: + case Instruction::BASEFEE: + case Instruction::BLOBHASH: + case Instruction::BLOBBASEFEE: + case Instruction::EXTCODESIZE: + case Instruction::EXTCODEHASH: + case Instruction::EXTCODECOPY: + case Instruction::RETURNDATASIZE: + case Instruction::RETURNDATACOPY: + case Instruction::MCOPY: + case Instruction::BLOCKHASH: + case Instruction::COINBASE: + case Instruction::TIMESTAMP: + case Instruction::NUMBER: + case Instruction::PREVRANDAO: + case Instruction::GASLIMIT: + return ImpureBuiltinEncountered(); + // --------------- memory / storage / logs --------------- + case Instruction::MLOAD: + case Instruction::MSTORE: + case Instruction::MSTORE8: + case Instruction::SLOAD: + case Instruction::SSTORE: + case Instruction::PC: + case Instruction::MSIZE: + case Instruction::GAS: + case Instruction::LOG0: + case Instruction::LOG1: + case Instruction::LOG2: + case Instruction::LOG3: + case Instruction::LOG4: + case Instruction::TLOAD: + case Instruction::TSTORE: + return ImpureBuiltinEncountered(); + // --------------- calls --------------- + case Instruction::CREATE: + case Instruction::CREATE2: + case Instruction::CALL: + case Instruction::CALLCODE: + case Instruction::DELEGATECALL: + case Instruction::STATICCALL: + case Instruction::RETURN: + case Instruction::REVERT: + case Instruction::INVALID: + case Instruction::SELFDESTRUCT: + return ImpureBuiltinEncountered(); + + case Instruction::POP: + return EvaluationOk(); + // --------------- invalid in strict assembly --------------- + case Instruction::JUMP: + case Instruction::JUMPI: + case Instruction::JUMPDEST: + case Instruction::PUSH0: + 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::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::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: + { + yulAssert(false, ""); + return EvaluationOk(0); + } + } + + yulAssert(false, "Unknown instruction with opcode " + std::to_string(static_cast(_instruction))); + return EvaluationOk(0); +} + +EvaluationResult PureEVMInstructionInterpreter::evalBuiltin( + BuiltinFunctionForEVM const& _fun, + std::vector const& /* _arguments */, // This was required to execute some builtin. + // But all of them are impure. + std::vector const& _evaluatedArguments +) +{ + if (_fun.instruction) + return eval(*_fun.instruction, _evaluatedArguments); + + std::string fun = _fun.name.str(); + bool isVerbatim = boost::starts_with(fun, "verbatim"); + if (isVerbatim) + return ImpureBuiltinEncountered(); + + static std::set const NON_INSTRUCTION_BUILTIN_NAME = { + "datasize", + "dataoffset", + "datacopy", + "memoryguard", + "loadimmutable", + "setimmutable", + "linkersymbol" + }; + if (NON_INSTRUCTION_BUILTIN_NAME.count(fun)) + return ImpureBuiltinEncountered(); + + yulAssert(false, "Unknown builtin: " + fun); + return EvaluationOk(0); +} + diff --git a/libyul/tools/interpreter/PureEVMInstructionInterpreter.h b/libyul/tools/interpreter/PureEVMInstructionInterpreter.h new file mode 100644 index 000000000000..c720ed87b317 --- /dev/null +++ b/libyul/tools/interpreter/PureEVMInstructionInterpreter.h @@ -0,0 +1,76 @@ +/* + This file is part of solidity. + + solidity is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + solidity is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with solidity. If not, see . +*/ +// SPDX-License-Identifier: GPL-3.0 +/** + * Yul interpreter module that evaluates EVM instructions. + */ + +#pragma once + +#include + +#include +#include + +#include +#include +#include + +#include + +#include + +namespace solidity::evmasm +{ +enum class Instruction: uint8_t; +} + +namespace solidity::yul +{ +class YulString; +struct BuiltinFunctionForEVM; +} + +namespace solidity::yul::tools::interpreter +{ + +/** + * Interprets EVM instructions based on the current state without side-effect. + */ +class PureEVMInstructionInterpreter +{ +public: + explicit PureEVMInstructionInterpreter(langutil::EVMVersion _evmVersion): + m_evmVersion(_evmVersion) + {} + + /// Evaluate instruction + EvaluationResult eval(evmasm::Instruction _instruction, std::vector const& _arguments); + + /// Evaluate builtin function + EvaluationResult evalBuiltin( + BuiltinFunctionForEVM const& _fun, + std::vector const& _arguments, + std::vector const& _evaluatedArguments + ); + +private: + + langutil::EVMVersion m_evmVersion; +}; + +} // solidity::yul::test diff --git a/libyul/tools/interpreter/PureInterpreter.cpp b/libyul/tools/interpreter/PureInterpreter.cpp new file mode 100644 index 000000000000..11dcf1f2d089 --- /dev/null +++ b/libyul/tools/interpreter/PureInterpreter.cpp @@ -0,0 +1,360 @@ +/* + This file is part of solidity. + + solidity is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + solidity is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with solidity. If not, see . +*/ +// SPDX-License-Identifier: GPL-3.0 +/** + * Yul interpreter. + */ + +#include + +#include + +#include +#include +#include +#include + +#include + +#include +#include + + +#include +#include + +using namespace solidity; +using namespace solidity::yul; +using namespace solidity::yul::tools::interpreter; + +using solidity::util::h256; + +ExecutionResult PureInterpreter::operator()(ExpressionStatement const& _expressionStatement) +{ + EvaluationResult res = evaluate(_expressionStatement.expression, 0); + if (auto* terminated = std::get_if(&res)) return *terminated; + return ExecutionOk{ ControlFlowState::Default }; +} + +ExecutionResult PureInterpreter::operator()(Assignment const& _assignment) +{ + solAssert(_assignment.value, ""); + EvaluationResult evalRes = evaluate(*_assignment.value, _assignment.variableNames.size()); + if (auto* terminated = std::get_if(&evalRes)) return *terminated; + + std::vector const& values = std::move(std::get(evalRes).values); + for (size_t i = 0; i < values.size(); ++i) + { + YulName varName = _assignment.variableNames.at(i).name; + auto [_, isNew] = m_variables.insert_or_assign(varName, values.at(i)); + solAssert(!isNew, ""); + } + return ExecutionOk { ControlFlowState::Default }; +} + +ExecutionResult PureInterpreter::operator()(VariableDeclaration const& _declaration) +{ + std::vector values; + if (_declaration.value) + { + EvaluationResult evalRes = evaluate(*_declaration.value, _declaration.variables.size()); + if (auto* terminated = std::get_if(&evalRes)) return *terminated; + values = std::move(std::get(evalRes).values); + } + else + { + values.assign(_declaration.variables.size(), 0); + } + + solAssert(values.size() == _declaration.variables.size(), ""); + for (size_t i = 0; i < values.size(); ++i) + { + YulName varName = _declaration.variables.at(i).name; + auto [_, isNew] = m_variables.insert_or_assign(varName, values.at(i)); + solAssert(isNew, ""); + m_scope->addDeclaredVariable(varName); + } + return ExecutionOk { ControlFlowState::Default }; +} + +ExecutionResult PureInterpreter::operator()(If const& _if) +{ + solAssert(_if.condition, ""); + EvaluationResult conditionRes = evaluate(*_if.condition, 1); + if (auto* terminated = std::get_if(&conditionRes)) return *terminated; + + if (std::get(conditionRes).values.at(0) != 0) + return (*this)(_if.body); + return ExecutionOk { ControlFlowState::Default }; +} + +ExecutionResult PureInterpreter::operator()(Switch const& _switch) +{ + solAssert(_switch.expression, ""); + solAssert(!_switch.cases.empty(), ""); + + EvaluationResult expressionRes = evaluate(*_switch.expression, 1); + if (auto* terminated = std::get_if(&expressionRes)) return *terminated; + + u256 val = std::get(expressionRes).values.at(0); + for (auto const& c: _switch.cases) + { + bool caseMatched = false; + // Default case has to be last. + if (!c.value) caseMatched = true; + else + { + EvaluationResult caseRes = evaluate(*c.value, 1); + if (auto* terminated = std::get_if(&caseRes)) return *terminated; + caseMatched = std::get(caseRes).values.at(0) == val; + } + if (caseMatched) return (*this)(c.body); + } + return ExecutionOk { ControlFlowState::Default }; +} + +ExecutionResult PureInterpreter::operator()(FunctionDefinition const&) +{ + return ExecutionOk{ ControlFlowState::Default }; +} + +ExecutionResult PureInterpreter::operator()(ForLoop const& _forLoop) +{ + solAssert(_forLoop.condition, ""); + + enterScope(_forLoop.pre); + ScopeGuard g([this]{ leaveScope(); }); + + { + ExecutionResult execRes = execute(_forLoop.pre.statements); + if (execRes == ExecutionResult(ExecutionOk { ControlFlowState::Leave })) + return execRes; + } + while (true) + { + { + EvaluationResult conditionRes = evaluate(*_forLoop.condition, 1); + if (auto* terminated = std::get_if(&conditionRes)) return *terminated; + if (std::get(conditionRes).values.at(0) == 0) + break; + } + + // Increment step for each loop iteration for loops with + // an empty body and post blocks to prevent a deadlock. + if (_forLoop.body.statements.size() == 0 && _forLoop.post.statements.size() == 0) + if (auto terminated = incrementStatementStep()) return *terminated; + + { + ExecutionResult bodyRes = (*this)(_forLoop.body); + if ( + std::holds_alternative(bodyRes) || + bodyRes == ExecutionResult(ExecutionOk{ ControlFlowState::Leave }) + ) return bodyRes; + + if (bodyRes == ExecutionResult(ExecutionOk{ ControlFlowState::Break })) + return ExecutionOk { ControlFlowState::Default }; + } + + { + ExecutionResult postRes = (*this)(_forLoop.post); + if ( + std::holds_alternative(postRes) || + postRes == ExecutionResult(ExecutionOk{ ControlFlowState::Leave }) + ) return postRes; + } + } + return ExecutionOk { ControlFlowState::Default }; +} + +ExecutionResult PureInterpreter::operator()(Break const&) +{ + return ExecutionOk{ ControlFlowState::Break }; +} + +ExecutionResult PureInterpreter::operator()(Continue const&) +{ + return ExecutionOk{ ControlFlowState::Continue }; +} + +ExecutionResult PureInterpreter::operator()(Leave const&) +{ + return ExecutionOk{ ControlFlowState::Leave }; +} + +ExecutionResult PureInterpreter::operator()(Block const& _block) +{ + enterScope(_block); + ScopeGuard guard([this] { leaveScope(); }); + + return execute(_block.statements); +} + +ExecutionResult PureInterpreter::execute(std::vector const& _statements) +{ + for (auto const& statement: _statements) + { + ExecutionResult statementRes = visit(statement); + if (statementRes != ExecutionResult(ExecutionOk {ControlFlowState::Default})) + return statementRes; + } + return ExecutionOk{ ControlFlowState::Default }; +} + +ExecutionResult PureInterpreter::visit(Statement const& _st) +{ + if (auto terminated = incrementStatementStep()) return *terminated; + return std::visit(*this, _st); +} + +EvaluationResult PureInterpreter::operator()(Literal const& _literal) +{ + return EvaluationOk(_literal.value.value()); +} + +EvaluationResult PureInterpreter::operator()(Identifier const& _identifier) +{ + auto it = m_variables.find(_identifier.name); + solAssert(it != m_variables.end(), ""); + return EvaluationOk(it->second); +} + +EvaluationResult PureInterpreter::operator()(FunctionCall const& _funCall) +{ + std::vector> const* literalArguments = nullptr; + if (BuiltinFunction const* builtin = m_dialect.builtin(_funCall.functionName.name)) + if (!builtin->literalArguments.empty()) + literalArguments = &builtin->literalArguments; + EvaluationResult argsRes = evaluateArgs(_funCall.arguments, literalArguments); + if (auto* terminated = std::get_if(&argsRes)) return *terminated; + + std::vector argsValues = std::move(std::get(argsRes).values); + + if (EVMDialect const* dialect = dynamic_cast(&m_dialect)) + { + if (BuiltinFunctionForEVM const* fun = dialect->builtin(_funCall.functionName.name)) + { + PureEVMInstructionInterpreter interpreter(dialect->evmVersion()); + return interpreter.evalBuiltin(*fun, _funCall.arguments, argsValues); + } + } + + FunctionDefinition const& fun = m_scope->getFunction(_funCall.functionName.name); + + yulAssert(argsValues.size() == fun.parameters.size(), ""); + VariableValuesMap variables; + for (size_t i = 0; i < fun.parameters.size(); ++i) + variables[fun.parameters.at(i).name] = argsValues.at(i); + for (size_t i = 0; i < fun.returnVariables.size(); ++i) + variables[fun.returnVariables.at(i).name] = 0; + + std::unique_ptr interpreter = makeInterpreterCopy(std::move(variables)); + + if (auto terminated = m_state.addTrace(fun, argsValues)) return *terminated; + + ExecutionResult funcBodyRes = (*interpreter)(fun.body); + if (auto* terminated = std::get_if(&funcBodyRes)) return *terminated; + + std::vector returnedValues; + returnedValues.reserve(fun.returnVariables.size()); + for (auto const& retVar: fun.returnVariables) + returnedValues.emplace_back(interpreter->valueOfVariable(retVar.name)); + + if (auto terminated = m_state.addTrace(fun, returnedValues)) return *terminated; + + return EvaluationOk(std::move(returnedValues)); +} + +EvaluationResult PureInterpreter::visit(Expression const& _st) +{ + if (auto terminated = incrementExpressionStep()) return *terminated; + return std::visit(*this, _st); +} + +EvaluationResult PureInterpreter::evaluate(Expression const& _expression, size_t _numReturnVars) +{ + EvaluationResult res = visit(_expression); + if (auto* resOk = std::get_if(&res)) + yulAssert(resOk->values.size() == _numReturnVars, ""); + + return res; +} + +EvaluationResult PureInterpreter::evaluateArgs( + std::vector const& _expr, + std::vector> const* _literalArguments +) +{ + std::vector values(_expr.size()); + + /// Function arguments are evaluated in reverse. + for (size_t i = _expr.size(); i-- > 0; ) + { + auto const& expr = _expr[i]; + bool isLiteral = _literalArguments && _literalArguments->at(i); + if (!isLiteral) + { + EvaluationResult exprRes = evaluate(expr, 1); + if (auto* terminated = std::get_if(&exprRes)) return *terminated; + std::vector const& exprValues = std::get(exprRes).values; + values[i] = exprValues.at(0); + } + else + { + if (std::get(expr).value.unlimited()) + return UnlimitedLiteralEncountered(); + else + values[i] = std::get(expr).value.value(); + } + } + return EvaluationOk(std::move(values)); +} + +void PureInterpreter::enterScope(Block const& _block) +{ + m_scope = m_scope->getSubscope(_block); +} + +void PureInterpreter::leaveScope() +{ + m_scope->cleanupVariables(m_variables); + m_scope = m_scope->parent(); + yulAssert(m_scope, ""); +} + +std::optional PureInterpreter::incrementStatementStep() +{ + m_state.numSteps++; + if (m_state.config.maxSteps > 0 && m_state.numSteps >= m_state.config.maxSteps) + return StepLimitReached(); + + // Checking recursion depth here because we are sure that a statement + // inside the body evaluated. + if (m_state.config.maxRecursionDepth > 0 && m_recursionDepth > m_state.config.maxRecursionDepth) + return RecursionDepthLimitReached(); + + // Reset m_expressionNestingLevel, preparing for new expression. + m_expressionNestingLevel = 0; + return std::nullopt; +} + +std::optional PureInterpreter::incrementExpressionStep() +{ + m_expressionNestingLevel++; + if (m_state.config.maxExprNesting > 0 && m_expressionNestingLevel > m_state.config.maxExprNesting) + return ExpressionNestingLimitReached(); + return std::nullopt; +} diff --git a/libyul/tools/interpreter/PureInterpreter.h b/libyul/tools/interpreter/PureInterpreter.h new file mode 100644 index 000000000000..44ed99a817e3 --- /dev/null +++ b/libyul/tools/interpreter/PureInterpreter.h @@ -0,0 +1,148 @@ +/* + This file is part of solidity. + + solidity is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + solidity is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with solidity. If not, see . +*/ +// SPDX-License-Identifier: GPL-3.0 +/** + * Yul interpreter. + */ + +#pragma once + +#include +#include +#include +#include + +#include +#include +#include + +#include + +#include +#include + +#include + +#include + +namespace solidity::yul +{ +struct Dialect; +} + +namespace solidity::yul::tools::interpreter +{ + +/** + * Yul interpreter. + */ +class PureInterpreter +{ +public: + PureInterpreter( + PureInterpreterState& _state, + Dialect const& _dialect, + Scope& _scope, + size_t _callerRecursionDepth, + VariableValuesMap _variables = {} + ): + m_dialect(_dialect), + m_state(_state), + m_variables(std::move(_variables)), + m_scope(&_scope), + + // The only place that increases recursion depth + m_recursionDepth(_callerRecursionDepth + 1) + { + } + + // Statement visit methods + + ExecutionResult operator()(ExpressionStatement const& _statement); + ExecutionResult operator()(Assignment const& _assignment); + ExecutionResult operator()(VariableDeclaration const& _varDecl); + ExecutionResult operator()(If const& _if); + ExecutionResult operator()(Switch const& _switch); + ExecutionResult operator()(FunctionDefinition const&); + ExecutionResult operator()(ForLoop const&); + ExecutionResult operator()(Break const&); + ExecutionResult operator()(Continue const&); + ExecutionResult operator()(Leave const&); + ExecutionResult operator()(Block const& _block); + + /// Only execute the statements in order. + /// Will not alter the scope. + ExecutionResult execute(std::vector const& _statements); + + ExecutionResult visit(Statement const& _st); + + // Expression visit methods + + EvaluationResult operator()(Literal const&); + EvaluationResult operator()(Identifier const&); + EvaluationResult operator()(FunctionCall const& _funCall); + + EvaluationResult visit(Expression const& _st); + + u256 valueOfVariable(YulName _name) const { return m_variables.at(_name); } + VariableValuesMap const& allVariables() const { return m_variables; } + +protected: + std::unique_ptr makeInterpreterCopy(VariableValuesMap _variables = {}) const + { + return std::make_unique( + m_state, + m_dialect, + *m_scope, + m_recursionDepth, + std::move(_variables) + ); + } + + // evaluate the expression and assert that the number of return variable is _numReturnVars + EvaluationResult evaluate(Expression const& _expression, size_t _numReturnVars); + + /// Evaluates the given expression from right to left and + /// stores it in m_value. + EvaluationResult evaluateArgs( + std::vector const& _expr, + std::vector> const* _literalArguments + ); + + void enterScope(Block const& _block); + void leaveScope(); + + /// Increment interpreter step count, returning StepLimitReached if step + /// limit is reached. + std::optional incrementStatementStep(); + + /// Increment evaluation count, returning ExpressionNestingLimitReached if + /// the nesting level is beyond the upper bound configured in the + /// interpreter state. + std::optional incrementExpressionStep(); + + Dialect const& m_dialect; + PureInterpreterState& m_state; + + VariableValuesMap m_variables; + Scope* m_scope; + + size_t const m_recursionDepth = 0; + unsigned m_expressionNestingLevel = 0; +}; + +} diff --git a/libyul/tools/interpreter/PureInterpreterState.cpp b/libyul/tools/interpreter/PureInterpreterState.cpp new file mode 100644 index 000000000000..71fe9e864819 --- /dev/null +++ b/libyul/tools/interpreter/PureInterpreterState.cpp @@ -0,0 +1,79 @@ +/* + This file is part of solidity. + + solidity is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + solidity is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with solidity. If not, see . +*/ +// SPDX-License-Identifier: GPL-3.0 + +#include + +#include + +#include + +#include + +#include +#include + +using namespace solidity::yul::tools::interpreter; + +void PureInterpreterState::dumpTraces(std::ostream& _out) const +{ + static std::string_view const INDENT = " "; + static std::string_view const BAR = "│ "; + + _out << "Call trace:\n"; + std::vector stackTrace; + + auto print_values = [&](std::vector const& vec) + { + bool isFirst = true; + for (auto x: vec) + { + if (!isFirst) + _out << ", "; + isFirst = false; + _out << x; + } + }; + + for (auto const& trace: traces) { + _out << INDENT; + for (size_t i = 0, callLevel = stackTrace.size(); i < callLevel; ++i) + _out << BAR; + + std::visit(util::GenericVisitor{ + [&](FunctionCallTrace const& callTrace) { + _out << "[CALL] " << callTrace.definition.name.str() << "("; + print_values(callTrace.params); + _out << ")"; + stackTrace.push_back(&callTrace); + }, + [&](FunctionReturnTrace const& returnTrace) { + solAssert(!stackTrace.empty()); + bool areIdentical = &stackTrace.back()->definition == &returnTrace.definition; + solAssert(areIdentical); + + _out << "[RETURN]"; + if (!returnTrace.returnedValues.empty()) + _out << " "; + print_values(returnTrace.returnedValues); + stackTrace.pop_back(); + } + }, trace); + + _out << std::endl; + } +} diff --git a/libyul/tools/interpreter/PureInterpreterState.h b/libyul/tools/interpreter/PureInterpreterState.h new file mode 100644 index 000000000000..f757a3804907 --- /dev/null +++ b/libyul/tools/interpreter/PureInterpreterState.h @@ -0,0 +1,97 @@ +/* + This file is part of solidity. + + solidity is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + solidity is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with solidity. If not, see . +*/ +// SPDX-License-Identifier: GPL-3.0 + +#pragma once + +#include + +#include + +#include + +#include +#include +#include + +namespace solidity::yul::tools::interpreter +{ + +struct FunctionCallTrace +{ + FunctionDefinition const& definition; + std::vector params; + + FunctionCallTrace( + FunctionDefinition const& _definition, + std::vector const& _params + ): + definition(_definition), + params(_params) + {} +}; + +struct FunctionReturnTrace +{ + FunctionDefinition const& definition; + std::vector returnedValues; + + FunctionReturnTrace( + FunctionDefinition const& _definition, + std::vector const& _returnedValues + ): + definition(_definition), + returnedValues(_returnedValues) + {} +}; + +using LogTraceEntry = std::variant; + +struct PureInterpreterConfig +{ + // set to 0 to disable tracing + size_t maxTraceSize = 0; + + size_t maxSteps = 0; + size_t maxExprNesting = 0; + size_t maxRecursionDepth = 0; +}; + +struct PureInterpreterState +{ + PureInterpreterConfig const config; + + size_t numSteps = 0; + std::vector traces = {}; + + /// Add a log trace. + /// Will do nothing if config.maxTraceSize == 0 + /// - the log entry will not be constructed in this case + template + std::optional addTrace(Args const&... _args) + { + if (config.maxTraceSize == 0) return std::nullopt; + if (traces.size() > config.maxTraceSize) + return TraceLimitReached(); + traces.emplace_back(std::in_place_type, _args...); + return std::nullopt; + } + + void dumpTraces(std::ostream& _out) const; +}; + +} diff --git a/libyul/tools/interpreter/Results.h b/libyul/tools/interpreter/Results.h new file mode 100644 index 000000000000..767fb4c676dc --- /dev/null +++ b/libyul/tools/interpreter/Results.h @@ -0,0 +1,124 @@ +/* + This file is part of solidity. + + solidity is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + solidity is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with solidity. If not, see . +*/ +// SPDX-License-Identifier: GPL-3.0 +// +#pragma once + +#include + +#include + +namespace solidity::yul::tools::interpreter +{ + +template +class ExecutionTerminatedCommon +{ +public: + bool operator==(T) const { return true; } + bool operator!=(T) const { return false; } +}; + +class ExplicitlyTerminated : public ExecutionTerminatedCommon +{ +}; + +class StepLimitReached : public ExecutionTerminatedCommon +{ +}; + +class RecursionDepthLimitReached : public ExecutionTerminatedCommon +{ +}; + +class ExpressionNestingLimitReached : public ExecutionTerminatedCommon +{ +}; + +class ImpureBuiltinEncountered : public ExecutionTerminatedCommon +{ +}; + +class UnlimitedLiteralEncountered : public ExecutionTerminatedCommon +{ +}; + +class TraceLimitReached: public ExecutionTerminatedCommon +{ +}; + + +using ExecutionTerminated = std::variant< + ExplicitlyTerminated, + StepLimitReached, + RecursionDepthLimitReached, + ExpressionNestingLimitReached, + ImpureBuiltinEncountered, + UnlimitedLiteralEncountered, + TraceLimitReached +>; + +enum class ControlFlowState +{ + Default, + Continue, + Break, + Leave +}; + +struct ExecutionOk +{ + ControlFlowState state; + + bool operator==(ExecutionOk other) const + { + return state == other.state; + } + + bool operator!=(ExecutionOk other) const + { + return state != other.state; + } +}; + +struct EvaluationOk +{ + std::vector values; + + explicit EvaluationOk(): + values() + { + } + + explicit EvaluationOk(u256 _x): + values{_x} + { + } + + /// Disable lvalue constructor to encourage rvalue usage. + EvaluationOk(std::vector const& _values) = delete; + + explicit EvaluationOk(std::vector&& _values): + values(std::move(_values)) + { + } +}; + +using ExecutionResult = std::variant; +using EvaluationResult = std::variant; + +} diff --git a/libyul/tools/interpreter/Scope.cpp b/libyul/tools/interpreter/Scope.cpp new file mode 100644 index 000000000000..fd2529353dae --- /dev/null +++ b/libyul/tools/interpreter/Scope.cpp @@ -0,0 +1,66 @@ +/* + This file is part of solidity. + + solidity is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + solidity is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with solidity. If not, see . +*/ +// SPDX-License-Identifier: GPL-3.0 + +#include + +#include + +#include + +using namespace solidity; +using namespace solidity::yul; +using namespace solidity::yul::tools::interpreter; + +Scope* Scope::getSubscope(Block const& _block) +{ + auto [it, isNew] = m_subScopes.try_emplace(&_block, nullptr); + if (!isNew) return it->second.get(); + + it->second = std::make_unique(this); + Scope* subscope = it->second.get(); + + for (auto const& statement: _block.statements) + if (auto const* funDef = std::get_if(&statement)) + subscope->m_definedFunctions.emplace(funDef->name, *funDef); + + return subscope; +} + +void Scope::addDeclaredVariable(YulName const& _name) +{ + m_declaredVariables.push_back(_name); +} + +void Scope::cleanupVariables(VariableValuesMap& _variables) +{ + for (YulName const& varName: m_declaredVariables) + _variables.erase(varName); + + m_declaredVariables.clear(); +} + +FunctionDefinition const& Scope::getFunction(YulName const& _functionName) const +{ + for (Scope const* scope = this; scope != nullptr; scope = scope->m_parent) + { + auto it = scope->m_definedFunctions.find(_functionName); + if (it != scope->m_definedFunctions.end()) + return it->second; + } + solAssert(false, ""); +} diff --git a/libyul/tools/interpreter/Scope.h b/libyul/tools/interpreter/Scope.h new file mode 100644 index 000000000000..b52079dc8d4e --- /dev/null +++ b/libyul/tools/interpreter/Scope.h @@ -0,0 +1,68 @@ +/* + This file is part of solidity. + + solidity is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + solidity is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with solidity. If not, see . +*/ +// SPDX-License-Identifier: GPL-3.0 +#pragma once + +#include + +#include +#include + +#include + +#include +#include + +namespace solidity::yul::tools::interpreter +{ + +/** + * Scope structure built and maintained during execution. + */ +class Scope +{ +public: + Scope(Scope* const _parent = nullptr): + m_definedFunctions(), + m_declaredVariables(), + m_subScopes(), + m_parent(_parent) + {} + + Scope* parent() const + { + return m_parent; + } + + Scope* getSubscope(Block const& _block); + + void addDeclaredVariable(YulName const& _name); + + /// Note: m_declaredVariables will be cleared after this function + void cleanupVariables(VariableValuesMap& _variables); + + /// Throw an error if function with the given name is not found. + FunctionDefinition const& getFunction(YulName const& _functionName) const; + +private: + std::map m_definedFunctions; + std::vector m_declaredVariables; + std::map> m_subScopes; + Scope* const m_parent; +}; + +} diff --git a/libyul/tools/interpreter/types.h b/libyul/tools/interpreter/types.h new file mode 100644 index 000000000000..c01da44832ea --- /dev/null +++ b/libyul/tools/interpreter/types.h @@ -0,0 +1,31 @@ +/* + This file is part of solidity. + + solidity is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + solidity is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with solidity. If not, see . +*/ +// SPDX-License-Identifier: GPL-3.0 +#pragma once + +#include + +#include + +#include + +namespace solidity::yul::tools::interpreter +{ + +using VariableValuesMap = std::map; + +} diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index da115f0d4a5b..8f5558a0211e 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -164,6 +164,8 @@ set(libyul_sources libyul/SyntaxTest.cpp libyul/YulInterpreterTest.cpp libyul/YulInterpreterTest.h + libyul/YulPureInterpreterTest.h + libyul/YulPureInterpreterTest.cpp libyul/YulOptimizerTest.cpp libyul/YulOptimizerTest.h libyul/YulOptimizerTestCommon.cpp diff --git a/test/InteractiveTests.h b/test/InteractiveTests.h index e043fcdbe676..16399ca68042 100644 --- a/test/InteractiveTests.h +++ b/test/InteractiveTests.h @@ -35,6 +35,7 @@ #include #include #include +#include #include #include #include @@ -66,6 +67,7 @@ Testsuite const g_interactiveTestsuites[] = { Title Path Subpath SMT NeedsVM Creator function */ {"Yul Optimizer", "libyul", "yulOptimizerTests", false, false, &yul::test::YulOptimizerTest::create}, {"Yul Interpreter", "libyul", "yulInterpreterTests", false, false, &yul::test::YulInterpreterTest::create}, + {"Yul Pure Interpreter", "libyul", "yulPureInterpreterTests", false, false, &yul::test::YulPureInterpreterTest::create}, {"Yul Object Compiler", "libyul", "objectCompiler", false, false, &yul::test::ObjectCompilerTest::create}, {"Yul Control Flow Graph", "libyul", "yulControlFlowGraph", false, false, &yul::test::ControlFlowGraphTest::create}, {"Yul SSA Control Flow Graph", "libyul", "yulSSAControlFlowGraph", false, false, &yul::test::SSAControlFlowGraphTest::create}, diff --git a/test/libyul/YulPureInterpreterTest.cpp b/test/libyul/YulPureInterpreterTest.cpp new file mode 100644 index 000000000000..0916b17152a9 --- /dev/null +++ b/test/libyul/YulPureInterpreterTest.cpp @@ -0,0 +1,188 @@ +/* + This file is part of solidity. + + solidity is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + solidity is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with solidity. If not, see . +*/ +// SPDX-License-Identifier: GPL-3.0 + +#include + +#include + +#include + +#include +#include +#include +#include + +#include +#include +#include + +#include +#include + +#include +#include + +using namespace solidity; +using namespace solidity::util; +using namespace solidity::langutil; +using namespace solidity::yul; +using namespace solidity::yul::test; +using namespace solidity::frontend; +using namespace solidity::frontend::test; + +using solidity::util::h256; + +using namespace solidity::yul::tools::interpreter; + +YulPureInterpreterTest::YulPureInterpreterTest(std::string const& _filename): + EVMVersionRestrictedTestCase(_filename) +{ + m_source = m_reader.source(); + m_expectation = m_reader.simpleExpectations(); + + m_config.maxTraceSize = m_reader.sizetSetting("maxTraceSize", 128); + m_config.maxExprNesting = m_reader.sizetSetting("maxExprNesting", 64); + m_config.maxSteps = m_reader.sizetSetting("maxSteps", 512); + m_config.maxRecursionDepth = m_reader.sizetSetting("maxRecursionDepth", 64); + + m_printHex = m_reader.boolSetting("printHex", false); +} + +TestCase::TestResult YulPureInterpreterTest::run(std::ostream& _stream, std::string const& _linePrefix, bool const _formatted) +{ + if (!parse(_stream, _linePrefix, _formatted)) + return TestResult::FatalError; + + m_obtainedResult = interpret(); + + return checkResult(_stream, _linePrefix, _formatted); +} + +bool YulPureInterpreterTest::parse(std::ostream& _stream, std::string const& _linePrefix, bool const _formatted) +{ + YulStack stack( + solidity::test::CommonOptions::get().evmVersion(), + solidity::test::CommonOptions::get().eofVersion(), + YulStack::Language::StrictAssembly, + solidity::frontend::OptimiserSettings::none(), + DebugInfoSelection::All() + ); + if (stack.parseAndAnalyze("", m_source)) + { + m_ast = stack.parserResult()->code(); + m_analysisInfo = stack.parserResult()->analysisInfo; + return true; + } + else + { + AnsiColorized(_stream, _formatted, {formatting::BOLD, formatting::RED}) << _linePrefix << "Error parsing source." << std::endl; + SourceReferenceFormatter{_stream, stack, true, false} + .printErrorInformation(stack.errors()); + return false; + } +} + +std::string YulPureInterpreterTest::interpret() const +{ + std::stringstream resultStream; + + Block const& block = m_ast->root(); + + PureInterpreterState state { m_config }; + Dialect const& dialect = EVMDialect::strictAssemblyForEVMObjects(solidity::test::CommonOptions::get().evmVersion()); + tools::interpreter::Scope rootScope; + tools::interpreter::Scope* subscope = rootScope.getSubscope(block); + + PureInterpreter interpreter(state, dialect, *subscope, 0); + ExecutionResult res = interpreter.execute(block.statements); + VariableValuesMap const& outerMostVariables = interpreter.allVariables(); + + dumpExecutionData( + resultStream, + res, + state, + outerMostVariables + ); + + return resultStream.str(); +} + +void YulPureInterpreterTest::dumpExecutionData( + std::ostream& _stream, + tools::interpreter::ExecutionResult _res, + tools::interpreter::PureInterpreterState const& _state, + VariableValuesMap const& _outerMostVariables +) const +{ + _stream << "Execution result: "; + dumpExecutionResult(_stream, _res); + _stream << std::endl; + + _stream << "Outer most variable values:" << std::endl; + dumpVariables(_stream, _outerMostVariables); + _stream << std::endl; + + _state.dumpTraces(_stream); +} + +void YulPureInterpreterTest::dumpExecutionResult(std::ostream& _stream, tools::interpreter::ExecutionResult _res) const +{ + _stream << std::visit(GenericVisitor { + [&](ExecutionOk) { return "ExecutionOk"; }, + [&](ExecutionTerminated terminated) { + return std::visit(GenericVisitor{ + [&](ExplicitlyTerminated) { return "ExplicitlyTerminated"; }, + [&](StepLimitReached) { return "StepLimitReached"; }, + [&](RecursionDepthLimitReached) { return "RecursionDepthLimitReached"; }, + [&](ExpressionNestingLimitReached) { return "ExpressionNestingLimitReached"; }, + [&](ImpureBuiltinEncountered) { return "ImpureBuiltinEncountered"; }, + [&](UnlimitedLiteralEncountered) { return "UnlimitedLiteralEncountered"; }, + [&](TraceLimitReached) { return "TraceLimitReached"; } + }, terminated); + } + }, _res); +} + +void YulPureInterpreterTest::dumpVariables( + std::ostream& _stream, + tools::interpreter::VariableValuesMap const& _variables +) const +{ + static std::string_view const INDENT = " "; + + // _variables are sorted by id. We should sort them by name + std::map sortedVariables; + for (auto const& [name, value]: _variables) + sortedVariables[name.str()] = value; + + for (auto const& [name, value]: sortedVariables) + { + _stream << INDENT << name << " = "; + dumpValue(_stream, value); + _stream << std::endl; + } +} + +void YulPureInterpreterTest::dumpValue( + std::ostream& _stream, + u256 _value +) const +{ + if (m_printHex) _stream << "0x" << h256(_value).hex(); + else _stream << _value; +} diff --git a/test/libyul/YulPureInterpreterTest.h b/test/libyul/YulPureInterpreterTest.h new file mode 100644 index 000000000000..4083106b40b1 --- /dev/null +++ b/test/libyul/YulPureInterpreterTest.h @@ -0,0 +1,68 @@ +/* + This file is part of solidity. + + solidity is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + solidity is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with solidity. If not, see . +*/ +// SPDX-License-Identifier: GPL-3.0 + +#pragma once + +#include + +#include +#include +#include + +namespace solidity::yul +{ +struct AsmAnalysisInfo; +class AST; +} + +namespace solidity::yul::test +{ + +class YulPureInterpreterTest: public solidity::frontend::test::EVMVersionRestrictedTestCase +{ +public: + static std::unique_ptr create(Config const& _config) + { + return std::make_unique(_config.filename); + } + + explicit YulPureInterpreterTest(std::string const& _filename); + + TestResult run(std::ostream& _stream, std::string const& _linePrefix = "", bool const _formatted = false) override; + +private: + bool parse(std::ostream& _stream, std::string const& _linePrefix, bool const _formatted); + std::string interpret() const; + void dumpExecutionData( + std::ostream& _stream, + tools::interpreter::ExecutionResult _res, + tools::interpreter::PureInterpreterState const& _state, + tools::interpreter::VariableValuesMap const& _outerMostVariables + ) const; + void dumpExecutionResult(std::ostream& _stream, tools::interpreter::ExecutionResult _res) const; + void dumpVariables(std::ostream& _stream, tools::interpreter::VariableValuesMap const& _variables) const; + void dumpValue(std::ostream& _stream, u256 _value) const; + + std::shared_ptr m_ast; + std::shared_ptr m_analysisInfo; + tools::interpreter::PureInterpreterConfig m_config; + + bool m_printHex; +}; + +} diff --git a/test/libyul/yulPureInterpreterTests/ambiguous_vars.yul b/test/libyul/yulPureInterpreterTests/ambiguous_vars.yul new file mode 100644 index 000000000000..046c89600ea3 --- /dev/null +++ b/test/libyul/yulPureInterpreterTests/ambiguous_vars.yul @@ -0,0 +1,19 @@ +{ + function fake_mstore(pos, val) { } + { + let a := 0x20 + fake_mstore(a, 2) + } + let a + fake_mstore(a, 3) +} +// ---- +// Execution result: ExecutionOk +// Outer most variable values: +// a = 0 +// +// Call trace: +// [CALL] fake_mstore(32, 2) +// │ [RETURN] +// [CALL] fake_mstore(0, 3) +// │ [RETURN] diff --git a/test/libyul/yulPureInterpreterTests/bounded_recursion.yul b/test/libyul/yulPureInterpreterTests/bounded_recursion.yul new file mode 100644 index 000000000000..a1d6bd8ab5f1 --- /dev/null +++ b/test/libyul/yulPureInterpreterTests/bounded_recursion.yul @@ -0,0 +1,21 @@ +{ + function f(x) -> y { + if lt(x, 150) { + y := f(add(x, 1)) + } + if eq(x, 150) { + y := x + } + } + let res := f(0) +} + +// ==== +// maxRecursionDepth: 160 +// maxTraceSize: 0 +// ---- +// Execution result: ExecutionOk +// Outer most variable values: +// res = 150 +// +// Call trace: diff --git a/test/libyul/yulPureInterpreterTests/exp.yul b/test/libyul/yulPureInterpreterTests/exp.yul new file mode 100644 index 000000000000..8bd3f0d20354 --- /dev/null +++ b/test/libyul/yulPureInterpreterTests/exp.yul @@ -0,0 +1,11 @@ +{ + let res := exp(3,not(1)) +} +// ==== +// printHex: true +// ---- +// Execution result: ExecutionOk +// Outer most variable values: +// res = 0x8e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38e39 +// +// Call trace: diff --git a/test/libyul/yulPureInterpreterTests/expr_nesting_depth_exceeded.yul b/test/libyul/yulPureInterpreterTests/expr_nesting_depth_exceeded.yul new file mode 100644 index 000000000000..fbce52ca4bd2 --- /dev/null +++ b/test/libyul/yulPureInterpreterTests/expr_nesting_depth_exceeded.yul @@ -0,0 +1,17 @@ +{ + function f(x) -> y + { + // 32 nested additions are computed in + // exactly 66 expression evaluation steps + y := add(0x1,add(0x1,add(0x1,add(0x1,add(0x1,add(0x1,add(0x1,add(0x1,add(0x1,add(0x1,add(0x1,add(0x1,add(0x1,add(0x1,add(0x1,add(0x1,add(0x1,add(0x1,add(0x1,add(0x1,add(0x1,add(0x1,add(0x1,add(0x1,add(0x1,add(0x1,add(0x1,add(0x1,add(0x1,add(0x1,add(0x1,add(0x1,x)))))))))))))))))))))))))))))))) + } + pop(f(0)) +} +// ==== +// maxExprNesting: 64 +// ---- +// Execution result: ExpressionNestingLimitReached +// Outer most variable values: +// +// Call trace: +// [CALL] f(0) diff --git a/test/libyul/yulPureInterpreterTests/expr_nesting_depth_not_exceeded.yul b/test/libyul/yulPureInterpreterTests/expr_nesting_depth_not_exceeded.yul new file mode 100644 index 000000000000..037780831d34 --- /dev/null +++ b/test/libyul/yulPureInterpreterTests/expr_nesting_depth_not_exceeded.yul @@ -0,0 +1,41 @@ +{ + function f(x) -> t + { + // 31 nested additions are computed in + // exactly 64 expression evaluation steps + let y := add(0x1,add(0x1,add(0x1,add(0x1,add(0x1,add(0x1,add(0x1,add(0x1,add(0x1,add(0x1,add(0x1,add(0x1,add(0x1,add(0x1,add(0x1,add(0x1,add(0x1,add(0x1,add(0x1,add(0x1,add(0x1,add(0x1,add(0x1,add(0x1,add(0x1,add(0x1,add(0x1,add(0x1,add(0x1,add(0x1,add(0x1,x))))))))))))))))))))))))))))))) + let z := add(0x1,add(0x1,add(0x1,add(0x1,add(0x1,add(0x1,add(0x1,add(0x1,add(0x1,add(0x1,add(0x1,add(0x1,add(0x1,add(0x1,add(0x1,add(0x1,add(0x1,add(0x1,add(0x1,add(0x1,add(0x1,add(0x1,add(0x1,add(0x1,add(0x1,add(0x1,add(0x1,add(0x1,add(0x1,add(0x1,add(0x1,y))))))))))))))))))))))))))))))) + t := add(0x1,add(0x1,add(0x1,add(0x1,add(0x1,add(0x1,add(0x1,add(0x1,add(0x1,add(0x1,add(0x1,add(0x1,add(0x1,add(0x1,add(0x1,add(0x1,add(0x1,add(0x1,add(0x1,add(0x1,add(0x1,add(0x1,add(0x1,add(0x1,add(0x1,add(0x1,add(0x1,add(0x1,add(0x1,add(0x1,add(0x1,z))))))))))))))))))))))))))))))) + } + for { let i := 0 } lt(i, 10) { i := add(i, 1) } + { + pop(f(i)) + } +} +// ==== +// maxExprNesting: 64 +// ---- +// Execution result: ExecutionOk +// Outer most variable values: +// +// Call trace: +// [CALL] f(0) +// │ [RETURN] 93 +// [CALL] f(1) +// │ [RETURN] 94 +// [CALL] f(2) +// │ [RETURN] 95 +// [CALL] f(3) +// │ [RETURN] 96 +// [CALL] f(4) +// │ [RETURN] 97 +// [CALL] f(5) +// │ [RETURN] 98 +// [CALL] f(6) +// │ [RETURN] 99 +// [CALL] f(7) +// │ [RETURN] 100 +// [CALL] f(8) +// │ [RETURN] 101 +// [CALL] f(9) +// │ [RETURN] 102 diff --git a/test/libyul/yulPureInterpreterTests/function_calls.yul b/test/libyul/yulPureInterpreterTests/function_calls.yul new file mode 100644 index 000000000000..1a186455bef2 --- /dev/null +++ b/test/libyul/yulPureInterpreterTests/function_calls.yul @@ -0,0 +1,16 @@ +{ + function f(a, b) -> x, y { + x := add(a, b) + y := mul(a, b) + } + let r, t := f(6, 7) +} +// ---- +// Execution result: ExecutionOk +// Outer most variable values: +// r = 13 +// t = 42 +// +// Call trace: +// [CALL] f(6, 7) +// │ [RETURN] 13, 42 diff --git a/test/libyul/yulPureInterpreterTests/function_scopes.yul b/test/libyul/yulPureInterpreterTests/function_scopes.yul new file mode 100644 index 000000000000..9dfaee5ade5d --- /dev/null +++ b/test/libyul/yulPureInterpreterTests/function_scopes.yul @@ -0,0 +1,39 @@ +{ + function fake_sstore(pos, val) {} + + f(1) + function f(i) { + if i { g(1) } + function g(j) { + if j { h() } + f(0) + function h() { + g(0) + } + } + fake_sstore(i, add(i, 7)) + } +} +// ---- +// Execution result: ExecutionOk +// Outer most variable values: +// +// Call trace: +// [CALL] f(1) +// │ [CALL] g(1) +// │ │ [CALL] h() +// │ │ │ [CALL] g(0) +// │ │ │ │ [CALL] f(0) +// │ │ │ │ │ [CALL] fake_sstore(0, 7) +// │ │ │ │ │ │ [RETURN] +// │ │ │ │ │ [RETURN] +// │ │ │ │ [RETURN] +// │ │ │ [RETURN] +// │ │ [CALL] f(0) +// │ │ │ [CALL] fake_sstore(0, 7) +// │ │ │ │ [RETURN] +// │ │ │ [RETURN] +// │ │ [RETURN] +// │ [CALL] fake_sstore(1, 8) +// │ │ [RETURN] +// │ [RETURN] diff --git a/test/libyul/yulPureInterpreterTests/hex_literals.yul b/test/libyul/yulPureInterpreterTests/hex_literals.yul new file mode 100644 index 000000000000..2710e20c4d02 --- /dev/null +++ b/test/libyul/yulPureInterpreterTests/hex_literals.yul @@ -0,0 +1,13 @@ +{ + let x := hex"112233445566778899aabbccddeeff6677889900" + let y := hex"1234_abcd" +} +// ==== +// printHex: true +// ---- +// Execution result: ExecutionOk +// Outer most variable values: +// x = 0x112233445566778899aabbccddeeff6677889900000000000000000000000000 +// y = 0x1234abcd00000000000000000000000000000000000000000000000000000000 +// +// Call trace: diff --git a/test/libyul/yulPureInterpreterTests/impure_instructions/address.yul b/test/libyul/yulPureInterpreterTests/impure_instructions/address.yul new file mode 100644 index 000000000000..2b1ddf47fb92 --- /dev/null +++ b/test/libyul/yulPureInterpreterTests/impure_instructions/address.yul @@ -0,0 +1,12 @@ +{ + let x + x := 1 + pop(address()) + x := 2 +} +// ---- +// Execution result: ImpureBuiltinEncountered +// Outer most variable values: +// x = 1 +// +// Call trace: diff --git a/test/libyul/yulPureInterpreterTests/impure_instructions/balance.yul b/test/libyul/yulPureInterpreterTests/impure_instructions/balance.yul new file mode 100644 index 000000000000..0c33e9f953e2 --- /dev/null +++ b/test/libyul/yulPureInterpreterTests/impure_instructions/balance.yul @@ -0,0 +1,13 @@ +{ + let x + x := 1 + pop(balance(0)) + x := 2 +} + +// ---- +// Execution result: ImpureBuiltinEncountered +// Outer most variable values: +// x = 1 +// +// Call trace: diff --git a/test/libyul/yulPureInterpreterTests/impure_instructions/basefee.yul b/test/libyul/yulPureInterpreterTests/impure_instructions/basefee.yul new file mode 100644 index 000000000000..4d19b863c801 --- /dev/null +++ b/test/libyul/yulPureInterpreterTests/impure_instructions/basefee.yul @@ -0,0 +1,14 @@ +{ + let x + x := 1 + pop(basefee()) + x := 2 +} +// ==== +// EVMVersion: >=london +// ---- +// Execution result: ImpureBuiltinEncountered +// Outer most variable values: +// x = 1 +// +// Call trace: diff --git a/test/libyul/yulPureInterpreterTests/impure_instructions/blobbasefee.yul b/test/libyul/yulPureInterpreterTests/impure_instructions/blobbasefee.yul new file mode 100644 index 000000000000..ebfda71d46c9 --- /dev/null +++ b/test/libyul/yulPureInterpreterTests/impure_instructions/blobbasefee.yul @@ -0,0 +1,14 @@ +{ + let x + x := 1 + pop(blobbasefee()) + x := 2 +} +// ==== +// EVMVersion: >=cancun +// ---- +// Execution result: ImpureBuiltinEncountered +// Outer most variable values: +// x = 1 +// +// Call trace: diff --git a/test/libyul/yulPureInterpreterTests/impure_instructions/blobhash.yul b/test/libyul/yulPureInterpreterTests/impure_instructions/blobhash.yul new file mode 100644 index 000000000000..e369f9ff41bc --- /dev/null +++ b/test/libyul/yulPureInterpreterTests/impure_instructions/blobhash.yul @@ -0,0 +1,14 @@ +{ + let x + x := 1 + pop(blobhash(0)) + x := 2 +} +// ==== +// EVMVersion: >=cancun +// ---- +// Execution result: ImpureBuiltinEncountered +// Outer most variable values: +// x = 1 +// +// Call trace: diff --git a/test/libyul/yulPureInterpreterTests/impure_instructions/blockhash.yul b/test/libyul/yulPureInterpreterTests/impure_instructions/blockhash.yul new file mode 100644 index 000000000000..840636457eff --- /dev/null +++ b/test/libyul/yulPureInterpreterTests/impure_instructions/blockhash.yul @@ -0,0 +1,12 @@ +{ + let x + x := 1 + pop(blockhash(0)) + x := 2 +} +// ---- +// Execution result: ImpureBuiltinEncountered +// Outer most variable values: +// x = 1 +// +// Call trace: diff --git a/test/libyul/yulPureInterpreterTests/impure_instructions/call.yul b/test/libyul/yulPureInterpreterTests/impure_instructions/call.yul new file mode 100644 index 000000000000..e10d9383cb3a --- /dev/null +++ b/test/libyul/yulPureInterpreterTests/impure_instructions/call.yul @@ -0,0 +1,12 @@ +{ + let x + x := 1 + pop(call(0, 0, 0, 0, 0, 0, 0)) + x := 2 +} +// ---- +// Execution result: ImpureBuiltinEncountered +// Outer most variable values: +// x = 1 +// +// Call trace: diff --git a/test/libyul/yulPureInterpreterTests/impure_instructions/callcode.yul b/test/libyul/yulPureInterpreterTests/impure_instructions/callcode.yul new file mode 100644 index 000000000000..d08fd104b923 --- /dev/null +++ b/test/libyul/yulPureInterpreterTests/impure_instructions/callcode.yul @@ -0,0 +1,12 @@ +{ + let x + x := 1 + pop(callcode(0, 0, 0, 0, 0, 0, 0)) + x := 2 +} +// ---- +// Execution result: ImpureBuiltinEncountered +// Outer most variable values: +// x = 1 +// +// Call trace: diff --git a/test/libyul/yulPureInterpreterTests/impure_instructions/calldatacopy.yul b/test/libyul/yulPureInterpreterTests/impure_instructions/calldatacopy.yul new file mode 100644 index 000000000000..4608344ffc66 --- /dev/null +++ b/test/libyul/yulPureInterpreterTests/impure_instructions/calldatacopy.yul @@ -0,0 +1,12 @@ +{ + let x + x := 1 + calldatacopy(0, 0, 0) + x := 2 +} +// ---- +// Execution result: ImpureBuiltinEncountered +// Outer most variable values: +// x = 1 +// +// Call trace: diff --git a/test/libyul/yulPureInterpreterTests/impure_instructions/calldataload.yul b/test/libyul/yulPureInterpreterTests/impure_instructions/calldataload.yul new file mode 100644 index 000000000000..5c13eac0866d --- /dev/null +++ b/test/libyul/yulPureInterpreterTests/impure_instructions/calldataload.yul @@ -0,0 +1,12 @@ +{ + let x + x := 1 + pop(calldataload(0)) + x := 2 +} +// ---- +// Execution result: ImpureBuiltinEncountered +// Outer most variable values: +// x = 1 +// +// Call trace: diff --git a/test/libyul/yulPureInterpreterTests/impure_instructions/calldatasize.yul b/test/libyul/yulPureInterpreterTests/impure_instructions/calldatasize.yul new file mode 100644 index 000000000000..95d11a8fef14 --- /dev/null +++ b/test/libyul/yulPureInterpreterTests/impure_instructions/calldatasize.yul @@ -0,0 +1,12 @@ +{ + let x + x := 1 + pop(calldatasize()) + x := 2 +} +// ---- +// Execution result: ImpureBuiltinEncountered +// Outer most variable values: +// x = 1 +// +// Call trace: diff --git a/test/libyul/yulPureInterpreterTests/impure_instructions/caller.yul b/test/libyul/yulPureInterpreterTests/impure_instructions/caller.yul new file mode 100644 index 000000000000..2a5b2eb2b0cb --- /dev/null +++ b/test/libyul/yulPureInterpreterTests/impure_instructions/caller.yul @@ -0,0 +1,12 @@ +{ + let x + x := 1 + pop(caller()) + x := 2 +} +// ---- +// Execution result: ImpureBuiltinEncountered +// Outer most variable values: +// x = 1 +// +// Call trace: diff --git a/test/libyul/yulPureInterpreterTests/impure_instructions/callvalue.yul b/test/libyul/yulPureInterpreterTests/impure_instructions/callvalue.yul new file mode 100644 index 000000000000..438d54dba655 --- /dev/null +++ b/test/libyul/yulPureInterpreterTests/impure_instructions/callvalue.yul @@ -0,0 +1,12 @@ +{ + let x + x := 1 + pop(callvalue()) + x := 2 +} +// ---- +// Execution result: ImpureBuiltinEncountered +// Outer most variable values: +// x = 1 +// +// Call trace: diff --git a/test/libyul/yulPureInterpreterTests/impure_instructions/chainid.yul b/test/libyul/yulPureInterpreterTests/impure_instructions/chainid.yul new file mode 100644 index 000000000000..49ac970dbbad --- /dev/null +++ b/test/libyul/yulPureInterpreterTests/impure_instructions/chainid.yul @@ -0,0 +1,14 @@ +{ + let x + x := 1 + pop(chainid()) + x := 2 +} +// ==== +// EVMVersion: >=istanbul +// ---- +// Execution result: ImpureBuiltinEncountered +// Outer most variable values: +// x = 1 +// +// Call trace: diff --git a/test/libyul/yulPureInterpreterTests/impure_instructions/codecopy.yul b/test/libyul/yulPureInterpreterTests/impure_instructions/codecopy.yul new file mode 100644 index 000000000000..bdc57e21d796 --- /dev/null +++ b/test/libyul/yulPureInterpreterTests/impure_instructions/codecopy.yul @@ -0,0 +1,12 @@ +{ + let x + x := 1 + codecopy(0, 0, 0) + x := 2 +} +// ---- +// Execution result: ImpureBuiltinEncountered +// Outer most variable values: +// x = 1 +// +// Call trace: diff --git a/test/libyul/yulPureInterpreterTests/impure_instructions/codesize.yul b/test/libyul/yulPureInterpreterTests/impure_instructions/codesize.yul new file mode 100644 index 000000000000..ab8c05b8aa68 --- /dev/null +++ b/test/libyul/yulPureInterpreterTests/impure_instructions/codesize.yul @@ -0,0 +1,12 @@ +{ + let x + x := 1 + pop(codesize()) + x := 2 +} +// ---- +// Execution result: ImpureBuiltinEncountered +// Outer most variable values: +// x = 1 +// +// Call trace: diff --git a/test/libyul/yulPureInterpreterTests/impure_instructions/coinbase.yul b/test/libyul/yulPureInterpreterTests/impure_instructions/coinbase.yul new file mode 100644 index 000000000000..374b57add637 --- /dev/null +++ b/test/libyul/yulPureInterpreterTests/impure_instructions/coinbase.yul @@ -0,0 +1,12 @@ +{ + let x + x := 1 + pop(coinbase()) + x := 2 +} +// ---- +// Execution result: ImpureBuiltinEncountered +// Outer most variable values: +// x = 1 +// +// Call trace: diff --git a/test/libyul/yulPureInterpreterTests/impure_instructions/create.yul b/test/libyul/yulPureInterpreterTests/impure_instructions/create.yul new file mode 100644 index 000000000000..304bc59125be --- /dev/null +++ b/test/libyul/yulPureInterpreterTests/impure_instructions/create.yul @@ -0,0 +1,12 @@ +{ + let x + x := 1 + pop(create(0, 0, 0)) + x := 2 +} +// ---- +// Execution result: ImpureBuiltinEncountered +// Outer most variable values: +// x = 1 +// +// Call trace: diff --git a/test/libyul/yulPureInterpreterTests/impure_instructions/create2.yul b/test/libyul/yulPureInterpreterTests/impure_instructions/create2.yul new file mode 100644 index 000000000000..7867259ab3ed --- /dev/null +++ b/test/libyul/yulPureInterpreterTests/impure_instructions/create2.yul @@ -0,0 +1,14 @@ +{ + let x + x := 1 + pop(create2(0, 0, 0, 0)) + x := 2 +} +// ==== +// EVMVersion: >=constantinople +// ---- +// Execution result: ImpureBuiltinEncountered +// Outer most variable values: +// x = 1 +// +// Call trace: diff --git a/test/libyul/yulPureInterpreterTests/impure_instructions/datacopy.yul b/test/libyul/yulPureInterpreterTests/impure_instructions/datacopy.yul new file mode 100644 index 000000000000..e3d883a7e5de --- /dev/null +++ b/test/libyul/yulPureInterpreterTests/impure_instructions/datacopy.yul @@ -0,0 +1,14 @@ +object "obj" { + code { + let x + x := 1 + datacopy(0, 0, 0) + x := 2 + } +} +// ---- +// Execution result: ImpureBuiltinEncountered +// Outer most variable values: +// x = 1 +// +// Call trace: diff --git a/test/libyul/yulPureInterpreterTests/impure_instructions/dataoffset.yul b/test/libyul/yulPureInterpreterTests/impure_instructions/dataoffset.yul new file mode 100644 index 000000000000..5b0735631a3a --- /dev/null +++ b/test/libyul/yulPureInterpreterTests/impure_instructions/dataoffset.yul @@ -0,0 +1,18 @@ +object "obj" { + code { + let x + x := 1 + pop(dataoffset("obj")) + x := 2 + } +} +// "obj" was evaluated before `dataoffset` +// Expectation for this test should be changed to `ImpureBuiltinEncountered` +// if in the future if "obj" is evaluated after + +// ---- +// Execution result: UnlimitedLiteralEncountered +// Outer most variable values: +// x = 1 +// +// Call trace: diff --git a/test/libyul/yulPureInterpreterTests/impure_instructions/datasize.yul b/test/libyul/yulPureInterpreterTests/impure_instructions/datasize.yul new file mode 100644 index 000000000000..ae0ca9d014db --- /dev/null +++ b/test/libyul/yulPureInterpreterTests/impure_instructions/datasize.yul @@ -0,0 +1,18 @@ +object "obj" { + code { + let x + x := 1 + pop(datasize("obj")) + x := 2 + } +} +// "obj" was evaluated before `datasize` +// Expectation for this test should be changed to `ImpureBuiltinEncountered` +// if in the future if "obj" is evaluated after + +// ---- +// Execution result: UnlimitedLiteralEncountered +// Outer most variable values: +// x = 1 +// +// Call trace: diff --git a/test/libyul/yulPureInterpreterTests/impure_instructions/delegatecall.yul b/test/libyul/yulPureInterpreterTests/impure_instructions/delegatecall.yul new file mode 100644 index 000000000000..8346243bdd57 --- /dev/null +++ b/test/libyul/yulPureInterpreterTests/impure_instructions/delegatecall.yul @@ -0,0 +1,12 @@ +{ + let x + x := 1 + pop(delegatecall(0, 0, 0, 0, 0, 0)) + x := 2 +} +// ---- +// Execution result: ImpureBuiltinEncountered +// Outer most variable values: +// x = 1 +// +// Call trace: diff --git a/test/libyul/yulPureInterpreterTests/impure_instructions/extcodecopy.yul b/test/libyul/yulPureInterpreterTests/impure_instructions/extcodecopy.yul new file mode 100644 index 000000000000..5e4e5479876d --- /dev/null +++ b/test/libyul/yulPureInterpreterTests/impure_instructions/extcodecopy.yul @@ -0,0 +1,12 @@ +{ + let x + x := 1 + extcodecopy(0, 0, 0, 0) + x := 2 +} +// ---- +// Execution result: ImpureBuiltinEncountered +// Outer most variable values: +// x = 1 +// +// Call trace: diff --git a/test/libyul/yulPureInterpreterTests/impure_instructions/extcodehash.yul b/test/libyul/yulPureInterpreterTests/impure_instructions/extcodehash.yul new file mode 100644 index 000000000000..8053a682cef0 --- /dev/null +++ b/test/libyul/yulPureInterpreterTests/impure_instructions/extcodehash.yul @@ -0,0 +1,14 @@ +{ + let x + x := 1 + pop(extcodehash(0)) + x := 2 +} +// ==== +// EVMVersion: >=constantinople +// ---- +// Execution result: ImpureBuiltinEncountered +// Outer most variable values: +// x = 1 +// +// Call trace: diff --git a/test/libyul/yulPureInterpreterTests/impure_instructions/extcodesize.yul b/test/libyul/yulPureInterpreterTests/impure_instructions/extcodesize.yul new file mode 100644 index 000000000000..2b4bb24921ed --- /dev/null +++ b/test/libyul/yulPureInterpreterTests/impure_instructions/extcodesize.yul @@ -0,0 +1,12 @@ +{ + let x + x := 1 + pop(extcodesize(0)) + x := 2 +} +// ---- +// Execution result: ImpureBuiltinEncountered +// Outer most variable values: +// x = 1 +// +// Call trace: diff --git a/test/libyul/yulPureInterpreterTests/impure_instructions/gas.yul b/test/libyul/yulPureInterpreterTests/impure_instructions/gas.yul new file mode 100644 index 000000000000..51cfd8452bdf --- /dev/null +++ b/test/libyul/yulPureInterpreterTests/impure_instructions/gas.yul @@ -0,0 +1,12 @@ +{ + let x + x := 1 + pop(gas()) + x := 2 +} +// ---- +// Execution result: ImpureBuiltinEncountered +// Outer most variable values: +// x = 1 +// +// Call trace: diff --git a/test/libyul/yulPureInterpreterTests/impure_instructions/gaslimit.yul b/test/libyul/yulPureInterpreterTests/impure_instructions/gaslimit.yul new file mode 100644 index 000000000000..e4baab65f772 --- /dev/null +++ b/test/libyul/yulPureInterpreterTests/impure_instructions/gaslimit.yul @@ -0,0 +1,12 @@ +{ + let x + x := 1 + pop(gaslimit()) + x := 2 +} +// ---- +// Execution result: ImpureBuiltinEncountered +// Outer most variable values: +// x = 1 +// +// Call trace: diff --git a/test/libyul/yulPureInterpreterTests/impure_instructions/gasprice.yul b/test/libyul/yulPureInterpreterTests/impure_instructions/gasprice.yul new file mode 100644 index 000000000000..9feb75d9b39b --- /dev/null +++ b/test/libyul/yulPureInterpreterTests/impure_instructions/gasprice.yul @@ -0,0 +1,12 @@ +{ + let x + x := 1 + pop(gasprice()) + x := 2 +} +// ---- +// Execution result: ImpureBuiltinEncountered +// Outer most variable values: +// x = 1 +// +// Call trace: diff --git a/test/libyul/yulPureInterpreterTests/impure_instructions/invalid.yul b/test/libyul/yulPureInterpreterTests/impure_instructions/invalid.yul new file mode 100644 index 000000000000..623675f47880 --- /dev/null +++ b/test/libyul/yulPureInterpreterTests/impure_instructions/invalid.yul @@ -0,0 +1,12 @@ +{ + let x + x := 1 + invalid() + x := 2 +} +// ---- +// Execution result: ImpureBuiltinEncountered +// Outer most variable values: +// x = 1 +// +// Call trace: diff --git a/test/libyul/yulPureInterpreterTests/impure_instructions/keccak256.yul b/test/libyul/yulPureInterpreterTests/impure_instructions/keccak256.yul new file mode 100644 index 000000000000..59f5588db8b3 --- /dev/null +++ b/test/libyul/yulPureInterpreterTests/impure_instructions/keccak256.yul @@ -0,0 +1,12 @@ +{ + let x + x := 1 + pop(keccak256(0, 0)) + x := 2 +} +// ---- +// Execution result: ImpureBuiltinEncountered +// Outer most variable values: +// x = 1 +// +// Call trace: diff --git a/test/libyul/yulPureInterpreterTests/impure_instructions/linkersymbol.yul b/test/libyul/yulPureInterpreterTests/impure_instructions/linkersymbol.yul new file mode 100644 index 000000000000..278e2dd18826 --- /dev/null +++ b/test/libyul/yulPureInterpreterTests/impure_instructions/linkersymbol.yul @@ -0,0 +1,18 @@ +object "obj" { + code { + let x + x := 1 + pop(linkersymbol("foo")) + x := 2 + } +} +// "foo" was evaluated before `linkersymbol` +// Expectation for this test should be changed to `ImpureBuiltinEncountered` +// if in the future if "foo" is evaluated after + +// ---- +// Execution result: UnlimitedLiteralEncountered +// Outer most variable values: +// x = 1 +// +// Call trace: diff --git a/test/libyul/yulPureInterpreterTests/impure_instructions/loadimmutable.yul b/test/libyul/yulPureInterpreterTests/impure_instructions/loadimmutable.yul new file mode 100644 index 000000000000..f02999d1b9b8 --- /dev/null +++ b/test/libyul/yulPureInterpreterTests/impure_instructions/loadimmutable.yul @@ -0,0 +1,18 @@ +object "obj" { + code { + let x + x := 1 + pop(loadimmutable("foo")) + x := 2 + } +} +// "foo" was evaluated before `loadimmutable` +// Expectation for this test should be changed to `ImpureBuiltinEncountered` +// if in the future if "foo" is evaluated after + +// ---- +// Execution result: UnlimitedLiteralEncountered +// Outer most variable values: +// x = 1 +// +// Call trace: diff --git a/test/libyul/yulPureInterpreterTests/impure_instructions/log0.yul b/test/libyul/yulPureInterpreterTests/impure_instructions/log0.yul new file mode 100644 index 000000000000..4cbaaffba8b0 --- /dev/null +++ b/test/libyul/yulPureInterpreterTests/impure_instructions/log0.yul @@ -0,0 +1,12 @@ +{ + let x + x := 1 + log0(0, 0) + x := 2 +} +// ---- +// Execution result: ImpureBuiltinEncountered +// Outer most variable values: +// x = 1 +// +// Call trace: diff --git a/test/libyul/yulPureInterpreterTests/impure_instructions/log1.yul b/test/libyul/yulPureInterpreterTests/impure_instructions/log1.yul new file mode 100644 index 000000000000..68349084d031 --- /dev/null +++ b/test/libyul/yulPureInterpreterTests/impure_instructions/log1.yul @@ -0,0 +1,12 @@ +{ + let x + x := 1 + log1(0, 0, 0) + x := 2 +} +// ---- +// Execution result: ImpureBuiltinEncountered +// Outer most variable values: +// x = 1 +// +// Call trace: diff --git a/test/libyul/yulPureInterpreterTests/impure_instructions/log2.yul b/test/libyul/yulPureInterpreterTests/impure_instructions/log2.yul new file mode 100644 index 000000000000..6aa5d02bad13 --- /dev/null +++ b/test/libyul/yulPureInterpreterTests/impure_instructions/log2.yul @@ -0,0 +1,12 @@ +{ + let x + x := 1 + log2(0, 0, 0, 0) + x := 2 +} +// ---- +// Execution result: ImpureBuiltinEncountered +// Outer most variable values: +// x = 1 +// +// Call trace: diff --git a/test/libyul/yulPureInterpreterTests/impure_instructions/log3.yul b/test/libyul/yulPureInterpreterTests/impure_instructions/log3.yul new file mode 100644 index 000000000000..226bd9b8e5a3 --- /dev/null +++ b/test/libyul/yulPureInterpreterTests/impure_instructions/log3.yul @@ -0,0 +1,12 @@ +{ + let x + x := 1 + log3(0, 0, 0, 0, 0) + x := 2 +} +// ---- +// Execution result: ImpureBuiltinEncountered +// Outer most variable values: +// x = 1 +// +// Call trace: diff --git a/test/libyul/yulPureInterpreterTests/impure_instructions/log4.yul b/test/libyul/yulPureInterpreterTests/impure_instructions/log4.yul new file mode 100644 index 000000000000..ff17f28e4d46 --- /dev/null +++ b/test/libyul/yulPureInterpreterTests/impure_instructions/log4.yul @@ -0,0 +1,12 @@ +{ + let x + x := 1 + log4(0, 0, 0, 0, 0, 0) + x := 2 +} +// ---- +// Execution result: ImpureBuiltinEncountered +// Outer most variable values: +// x = 1 +// +// Call trace: diff --git a/test/libyul/yulPureInterpreterTests/impure_instructions/mcopy.yul b/test/libyul/yulPureInterpreterTests/impure_instructions/mcopy.yul new file mode 100644 index 000000000000..11eed638ff96 --- /dev/null +++ b/test/libyul/yulPureInterpreterTests/impure_instructions/mcopy.yul @@ -0,0 +1,14 @@ +{ + let x + x := 1 + mcopy(0, 0, 0) + x := 2 +} +// ==== +// EVMVersion: >=cancun +// ---- +// Execution result: ImpureBuiltinEncountered +// Outer most variable values: +// x = 1 +// +// Call trace: diff --git a/test/libyul/yulPureInterpreterTests/impure_instructions/memoryguard.yul b/test/libyul/yulPureInterpreterTests/impure_instructions/memoryguard.yul new file mode 100644 index 000000000000..e3f6bc5d5d78 --- /dev/null +++ b/test/libyul/yulPureInterpreterTests/impure_instructions/memoryguard.yul @@ -0,0 +1,14 @@ +object "obj" { + code { + let x + x := 1 + pop(memoryguard(0)) + x := 2 + } +} +// ---- +// Execution result: ImpureBuiltinEncountered +// Outer most variable values: +// x = 1 +// +// Call trace: diff --git a/test/libyul/yulPureInterpreterTests/impure_instructions/mload.yul b/test/libyul/yulPureInterpreterTests/impure_instructions/mload.yul new file mode 100644 index 000000000000..f24b3085e930 --- /dev/null +++ b/test/libyul/yulPureInterpreterTests/impure_instructions/mload.yul @@ -0,0 +1,12 @@ +{ + let x + x := 1 + pop(mload(0)) + x := 2 +} +// ---- +// Execution result: ImpureBuiltinEncountered +// Outer most variable values: +// x = 1 +// +// Call trace: diff --git a/test/libyul/yulPureInterpreterTests/impure_instructions/msize.yul b/test/libyul/yulPureInterpreterTests/impure_instructions/msize.yul new file mode 100644 index 000000000000..3d61b9693890 --- /dev/null +++ b/test/libyul/yulPureInterpreterTests/impure_instructions/msize.yul @@ -0,0 +1,12 @@ +{ + let x + x := 1 + pop(msize()) + x := 2 +} +// ---- +// Execution result: ImpureBuiltinEncountered +// Outer most variable values: +// x = 1 +// +// Call trace: diff --git a/test/libyul/yulPureInterpreterTests/impure_instructions/mstore.yul b/test/libyul/yulPureInterpreterTests/impure_instructions/mstore.yul new file mode 100644 index 000000000000..f37ecd811b70 --- /dev/null +++ b/test/libyul/yulPureInterpreterTests/impure_instructions/mstore.yul @@ -0,0 +1,12 @@ +{ + let x + x := 1 + mstore(0, 0) + x := 2 +} +// ---- +// Execution result: ImpureBuiltinEncountered +// Outer most variable values: +// x = 1 +// +// Call trace: diff --git a/test/libyul/yulPureInterpreterTests/impure_instructions/mstore8.yul b/test/libyul/yulPureInterpreterTests/impure_instructions/mstore8.yul new file mode 100644 index 000000000000..adb7d77ed826 --- /dev/null +++ b/test/libyul/yulPureInterpreterTests/impure_instructions/mstore8.yul @@ -0,0 +1,12 @@ +{ + let x + x := 1 + mstore8(0, 0) + x := 2 +} +// ---- +// Execution result: ImpureBuiltinEncountered +// Outer most variable values: +// x = 1 +// +// Call trace: diff --git a/test/libyul/yulPureInterpreterTests/impure_instructions/number.yul b/test/libyul/yulPureInterpreterTests/impure_instructions/number.yul new file mode 100644 index 000000000000..4f82d9e6ba2c --- /dev/null +++ b/test/libyul/yulPureInterpreterTests/impure_instructions/number.yul @@ -0,0 +1,12 @@ +{ + let x + x := 1 + pop(number()) + x := 2 +} +// ---- +// Execution result: ImpureBuiltinEncountered +// Outer most variable values: +// x = 1 +// +// Call trace: diff --git a/test/libyul/yulPureInterpreterTests/impure_instructions/origin.yul b/test/libyul/yulPureInterpreterTests/impure_instructions/origin.yul new file mode 100644 index 000000000000..fc32d6729038 --- /dev/null +++ b/test/libyul/yulPureInterpreterTests/impure_instructions/origin.yul @@ -0,0 +1,12 @@ +{ + let x + x := 1 + pop(origin()) + x := 2 +} +// ---- +// Execution result: ImpureBuiltinEncountered +// Outer most variable values: +// x = 1 +// +// Call trace: diff --git a/test/libyul/yulPureInterpreterTests/impure_instructions/prevrandao.yul b/test/libyul/yulPureInterpreterTests/impure_instructions/prevrandao.yul new file mode 100644 index 000000000000..1d0a2a21d066 --- /dev/null +++ b/test/libyul/yulPureInterpreterTests/impure_instructions/prevrandao.yul @@ -0,0 +1,14 @@ +{ + let x + x := 1 + pop(prevrandao()) + x := 2 +} +// ==== +// EVMVersion: >=paris +// ---- +// Execution result: ImpureBuiltinEncountered +// Outer most variable values: +// x = 1 +// +// Call trace: diff --git a/test/libyul/yulPureInterpreterTests/impure_instructions/return.yul b/test/libyul/yulPureInterpreterTests/impure_instructions/return.yul new file mode 100644 index 000000000000..6857eefcac63 --- /dev/null +++ b/test/libyul/yulPureInterpreterTests/impure_instructions/return.yul @@ -0,0 +1,12 @@ +{ + let x + x := 1 + return(0, 0) + x := 2 +} +// ---- +// Execution result: ImpureBuiltinEncountered +// Outer most variable values: +// x = 1 +// +// Call trace: diff --git a/test/libyul/yulPureInterpreterTests/impure_instructions/returndatacopy.yul b/test/libyul/yulPureInterpreterTests/impure_instructions/returndatacopy.yul new file mode 100644 index 000000000000..d91a9afbce39 --- /dev/null +++ b/test/libyul/yulPureInterpreterTests/impure_instructions/returndatacopy.yul @@ -0,0 +1,14 @@ +{ + let x + x := 1 + returndatacopy(0, 0, 0) + x := 2 +} +// ==== +// EVMVersion: >=byzantium +// ---- +// Execution result: ImpureBuiltinEncountered +// Outer most variable values: +// x = 1 +// +// Call trace: diff --git a/test/libyul/yulPureInterpreterTests/impure_instructions/returndatasize.yul b/test/libyul/yulPureInterpreterTests/impure_instructions/returndatasize.yul new file mode 100644 index 000000000000..3cd311947fcd --- /dev/null +++ b/test/libyul/yulPureInterpreterTests/impure_instructions/returndatasize.yul @@ -0,0 +1,14 @@ +{ + let x + x := 1 + pop(returndatasize()) + x := 2 +} +// ==== +// EVMVersion: >=byzantium +// ---- +// Execution result: ImpureBuiltinEncountered +// Outer most variable values: +// x = 1 +// +// Call trace: diff --git a/test/libyul/yulPureInterpreterTests/impure_instructions/revert.yul b/test/libyul/yulPureInterpreterTests/impure_instructions/revert.yul new file mode 100644 index 000000000000..f41c9dde356e --- /dev/null +++ b/test/libyul/yulPureInterpreterTests/impure_instructions/revert.yul @@ -0,0 +1,12 @@ +{ + let x + x := 1 + revert(0, 0) + x := 2 +} +// ---- +// Execution result: ImpureBuiltinEncountered +// Outer most variable values: +// x = 1 +// +// Call trace: diff --git a/test/libyul/yulPureInterpreterTests/impure_instructions/selfbalance.yul b/test/libyul/yulPureInterpreterTests/impure_instructions/selfbalance.yul new file mode 100644 index 000000000000..250af8158473 --- /dev/null +++ b/test/libyul/yulPureInterpreterTests/impure_instructions/selfbalance.yul @@ -0,0 +1,14 @@ +{ + let x + x := 1 + pop(selfbalance()) + x := 2 +} +// ==== +// EVMVersion: >=istanbul +// ---- +// Execution result: ImpureBuiltinEncountered +// Outer most variable values: +// x = 1 +// +// Call trace: diff --git a/test/libyul/yulPureInterpreterTests/impure_instructions/selfdestruct.yul b/test/libyul/yulPureInterpreterTests/impure_instructions/selfdestruct.yul new file mode 100644 index 000000000000..b09b497881b6 --- /dev/null +++ b/test/libyul/yulPureInterpreterTests/impure_instructions/selfdestruct.yul @@ -0,0 +1,12 @@ +{ + let x + x := 1 + selfdestruct(0) + x := 2 +} +// ---- +// Execution result: ImpureBuiltinEncountered +// Outer most variable values: +// x = 1 +// +// Call trace: diff --git a/test/libyul/yulPureInterpreterTests/impure_instructions/setimmutable.yul b/test/libyul/yulPureInterpreterTests/impure_instructions/setimmutable.yul new file mode 100644 index 000000000000..b7a5f1482d34 --- /dev/null +++ b/test/libyul/yulPureInterpreterTests/impure_instructions/setimmutable.yul @@ -0,0 +1,18 @@ +object "obj" { + code { + let x + x := 1 + setimmutable(0, "foo", 0) + x := 2 + } +} +// "foo" was evaluated before `setimmutable` +// Expectation for this test should be changed to `ImpureBuiltinEncountered` +// if in the future if "foo" is evaluated after + +// ---- +// Execution result: UnlimitedLiteralEncountered +// Outer most variable values: +// x = 1 +// +// Call trace: diff --git a/test/libyul/yulPureInterpreterTests/impure_instructions/sload.yul b/test/libyul/yulPureInterpreterTests/impure_instructions/sload.yul new file mode 100644 index 000000000000..a8cd1ba78116 --- /dev/null +++ b/test/libyul/yulPureInterpreterTests/impure_instructions/sload.yul @@ -0,0 +1,12 @@ +{ + let x + x := 1 + pop(sload(0)) + x := 2 +} +// ---- +// Execution result: ImpureBuiltinEncountered +// Outer most variable values: +// x = 1 +// +// Call trace: diff --git a/test/libyul/yulPureInterpreterTests/impure_instructions/sstore.yul b/test/libyul/yulPureInterpreterTests/impure_instructions/sstore.yul new file mode 100644 index 000000000000..9187d6e43c1f --- /dev/null +++ b/test/libyul/yulPureInterpreterTests/impure_instructions/sstore.yul @@ -0,0 +1,12 @@ +{ + let x + x := 1 + sstore(0, 0) + x := 2 +} +// ---- +// Execution result: ImpureBuiltinEncountered +// Outer most variable values: +// x = 1 +// +// Call trace: diff --git a/test/libyul/yulPureInterpreterTests/impure_instructions/staticcall.yul b/test/libyul/yulPureInterpreterTests/impure_instructions/staticcall.yul new file mode 100644 index 000000000000..1cef1ddf9748 --- /dev/null +++ b/test/libyul/yulPureInterpreterTests/impure_instructions/staticcall.yul @@ -0,0 +1,14 @@ +{ + let x + x := 1 + pop(staticcall(0, 0, 0, 0, 0, 0)) + x := 2 +} +// ==== +// EVMVersion: >=byzantium +// ---- +// Execution result: ImpureBuiltinEncountered +// Outer most variable values: +// x = 1 +// +// Call trace: diff --git a/test/libyul/yulPureInterpreterTests/impure_instructions/timestamp.yul b/test/libyul/yulPureInterpreterTests/impure_instructions/timestamp.yul new file mode 100644 index 000000000000..c600011d7603 --- /dev/null +++ b/test/libyul/yulPureInterpreterTests/impure_instructions/timestamp.yul @@ -0,0 +1,12 @@ +{ + let x + x := 1 + pop(timestamp()) + x := 2 +} +// ---- +// Execution result: ImpureBuiltinEncountered +// Outer most variable values: +// x = 1 +// +// Call trace: diff --git a/test/libyul/yulPureInterpreterTests/impure_instructions/tload.yul b/test/libyul/yulPureInterpreterTests/impure_instructions/tload.yul new file mode 100644 index 000000000000..fd2e7af9b4c0 --- /dev/null +++ b/test/libyul/yulPureInterpreterTests/impure_instructions/tload.yul @@ -0,0 +1,14 @@ +{ + let x + x := 1 + pop(tload(0)) + x := 2 +} +// ==== +// EVMVersion: >=cancun +// ---- +// Execution result: ImpureBuiltinEncountered +// Outer most variable values: +// x = 1 +// +// Call trace: diff --git a/test/libyul/yulPureInterpreterTests/impure_instructions/tstore.yul b/test/libyul/yulPureInterpreterTests/impure_instructions/tstore.yul new file mode 100644 index 000000000000..1f514d02999d --- /dev/null +++ b/test/libyul/yulPureInterpreterTests/impure_instructions/tstore.yul @@ -0,0 +1,14 @@ +{ + let x + x := 1 + tstore(0, 0) + x := 2 +} +// ==== +// EVMVersion: >=cancun +// ---- +// Execution result: ImpureBuiltinEncountered +// Outer most variable values: +// x = 1 +// +// Call trace: diff --git a/test/libyul/yulPureInterpreterTests/infinite_recursion.yul b/test/libyul/yulPureInterpreterTests/infinite_recursion.yul new file mode 100644 index 000000000000..ce61e1d11748 --- /dev/null +++ b/test/libyul/yulPureInterpreterTests/infinite_recursion.yul @@ -0,0 +1,13 @@ +{ + function f() { + f() + } + f() +} +// ==== +// maxTraceSize: 0 +// ---- +// Execution result: RecursionDepthLimitReached +// Outer most variable values: +// +// Call trace: diff --git a/test/libyul/yulPureInterpreterTests/infinite_recursion_tracelimit.yul b/test/libyul/yulPureInterpreterTests/infinite_recursion_tracelimit.yul new file mode 100644 index 000000000000..cb0bb5da30d3 --- /dev/null +++ b/test/libyul/yulPureInterpreterTests/infinite_recursion_tracelimit.yul @@ -0,0 +1,26 @@ +{ + function f() { + f() + } + f() +} +// Setting so that trace limit hit first +// ==== +// maxRecursionDepth: 1000 +// maxTraceSize: 10 +// ---- +// Execution result: TraceLimitReached +// Outer most variable values: +// +// Call trace: +// [CALL] f() +// │ [CALL] f() +// │ │ [CALL] f() +// │ │ │ [CALL] f() +// │ │ │ │ [CALL] f() +// │ │ │ │ │ [CALL] f() +// │ │ │ │ │ │ [CALL] f() +// │ │ │ │ │ │ │ [CALL] f() +// │ │ │ │ │ │ │ │ [CALL] f() +// │ │ │ │ │ │ │ │ │ [CALL] f() +// │ │ │ │ │ │ │ │ │ │ [CALL] f() diff --git a/test/libyul/yulPureInterpreterTests/leave.yul b/test/libyul/yulPureInterpreterTests/leave.yul new file mode 100644 index 000000000000..c85ba4c67239 --- /dev/null +++ b/test/libyul/yulPureInterpreterTests/leave.yul @@ -0,0 +1,21 @@ +{ + function f() -> x, y + { + for { x := 0 } lt(x, 10) { x := add(x, 1) } { + if eq(x, 5) { y := 1 leave } + } + x := 9 + } + let a, b := f() +} +// ==== +// EVMVersion: >=constantinople +// ---- +// Execution result: ExecutionOk +// Outer most variable values: +// a = 5 +// b = 1 +// +// Call trace: +// [CALL] f() +// │ [RETURN] 5, 1 diff --git a/test/libyul/yulPureInterpreterTests/leave_for_init.yul b/test/libyul/yulPureInterpreterTests/leave_for_init.yul new file mode 100644 index 000000000000..8299f8e572d4 --- /dev/null +++ b/test/libyul/yulPureInterpreterTests/leave_for_init.yul @@ -0,0 +1,18 @@ +{ + function f() -> x + { + for { leave x := 2 } eq(x, 0) { } { + } + } + let a := f() +} +// ==== +// EVMVersion: >=constantinople +// ---- +// Execution result: ExecutionOk +// Outer most variable values: +// a = 0 +// +// Call trace: +// [CALL] f() +// │ [RETURN] 0 diff --git a/test/libyul/yulPureInterpreterTests/loop.yul b/test/libyul/yulPureInterpreterTests/loop.yul new file mode 100644 index 000000000000..69b16297a9df --- /dev/null +++ b/test/libyul/yulPureInterpreterTests/loop.yul @@ -0,0 +1,28 @@ +{ + function fake_mstore(pos, val) {} + + for { let x := 2 } lt(x, 10) { x := add(x, 1) } { + fake_mstore(mul(x, 5), mul(x, 0x1000)) + } +} +// ---- +// Execution result: ExecutionOk +// Outer most variable values: +// +// Call trace: +// [CALL] fake_mstore(10, 8192) +// │ [RETURN] +// [CALL] fake_mstore(15, 12288) +// │ [RETURN] +// [CALL] fake_mstore(20, 16384) +// │ [RETURN] +// [CALL] fake_mstore(25, 20480) +// │ [RETURN] +// [CALL] fake_mstore(30, 24576) +// │ [RETURN] +// [CALL] fake_mstore(35, 28672) +// │ [RETURN] +// [CALL] fake_mstore(40, 32768) +// │ [RETURN] +// [CALL] fake_mstore(45, 36864) +// │ [RETURN] diff --git a/test/libyul/yulPureInterpreterTests/pop_byte_shr_func.yul b/test/libyul/yulPureInterpreterTests/pop_byte_shr_func.yul new file mode 100644 index 000000000000..dff8433808ae --- /dev/null +++ b/test/libyul/yulPureInterpreterTests/pop_byte_shr_func.yul @@ -0,0 +1,13 @@ +{ + function f() -> x { x := 0x1337 } + pop(byte(0, shr(0x8, f()))) +} +// ==== +// EVMVersion: >=constantinople +// ---- +// Execution result: ExecutionOk +// Outer most variable values: +// +// Call trace: +// [CALL] f() +// │ [RETURN] 4919 diff --git a/test/libyul/yulPureInterpreterTests/pure_instructions/.generate-test.py b/test/libyul/yulPureInterpreterTests/pure_instructions/.generate-test.py new file mode 100644 index 000000000000..6d66be6c3483 --- /dev/null +++ b/test/libyul/yulPureInterpreterTests/pure_instructions/.generate-test.py @@ -0,0 +1,186 @@ +# pyright: strict + +from itertools import product +import random +import os + +from typing import Callable, Iterable, Union + +os.chdir(os.path.dirname(os.path.abspath(__file__))) + +random.seed(20240823) + +MX = 2**256 + +def u256(num: int): + return int(num) % MX + +def u2s(num: int): + return int(num) - MX if (int(num) >> 255) > 0 else int(num) + +def gen_test( + fn_name: str, + *, + param_cnt: int, + calc: Callable[[tuple[int, ...]], int], + test_numbers: Union[Iterable[int], None] = None, + evm_version: Union[str, None] = None, +): + print('Generating test for', fn_name) + + src: list[str] = [] + src.append('{') + src.append(""" + function check(a, b) + { if iszero(eq(a, b)) { revert(0, 0) } } +""") + + if test_numbers is None: + if param_cnt == 1: + test_numbers = [ + 0, 1, 2, 3, + MX - 1, MX - 2, MX - 3, + random.randrange(MX), random.randrange(MX), random.randrange(MX), random.randrange(MX) + ] + else: + test_numbers = [0, 1, 2, MX - 1, MX - 2, random.randrange(MX), random.randrange(MX), random.randrange(MX)] + + param_set = list(product(test_numbers, repeat=param_cnt)) + + for p in param_set: + res = u256(calc(p)) + # printing hex to save space + src.append(f' check({fn_name}({', '.join(hex(i) for i in p)}), {hex(res)})') + src.append('}') + + src.append('// ====') + src.append('// maxTraceSize: 0') + if evm_version is not None: + src.append(f'// EVMVersion: {evm_version}') + + with open(fn_name + '.yul', 'w', encoding='utf-8') as f: + print('\n'.join(src), file=f) + +def main(): + gen_test('add', + param_cnt = 2, + calc = lambda p: p[0] + p[1]) + gen_test('mul', + param_cnt = 2, + calc = lambda p: p[0] * p[1]) + gen_test('sub', + param_cnt = 2, + calc = lambda p: p[0] - p[1]) + gen_test('div', + param_cnt = 2, + calc = lambda p: p[0] // p[1] if p[1] != 0 else 0) + gen_test('sdiv', + param_cnt = 2, + calc = signed_div) + gen_test('mod', + param_cnt = 2, + calc = lambda p: p[0] % p[1] if p[1] != 0 else 0) + gen_test('smod', + param_cnt = 2, + calc = signed_mod) + gen_test('exp', + param_cnt = 2, + calc = lambda p: pow(p[0], p[1], MX)) + gen_test('not', + param_cnt = 1, + calc = lambda p: ~p[0]) + gen_test('lt', + param_cnt = 2, + calc = lambda p: p[0] < p[1]) + gen_test('gt', + param_cnt = 2, + calc = lambda p: p[0] > p[1]) + gen_test('slt', + param_cnt = 2, + calc = lambda p: u2s(p[0]) < u2s(p[1])) + gen_test('sgt', + param_cnt = 2, + calc = lambda p: u2s(p[0]) > u2s(p[1])) + gen_test('eq', + param_cnt = 2, + calc = lambda p: p[0] == p[1]) + gen_test('iszero', + param_cnt = 1, + calc = lambda p: p[0] == 0) + gen_test('and', + param_cnt = 2, + calc=lambda p: p[0] & p[1]) + gen_test('or', + param_cnt = 2, + calc = lambda p: p[0] | p[1]) + gen_test('xor', + param_cnt = 2, + calc = lambda p: p[0] ^ p[1]) + gen_test('byte', + param_cnt = 2, + test_numbers = [ + random.randrange(MX), random.randrange(MX), random.randrange(MX), + random.randrange(1, 32), random.randrange(1, 32), random.randrange(1, 32), + 0 + ], + calc = lambda p: 0 if p[0] >= 32 else (p[1] >> (8 * (31 - p[0]))) & 0xff) + gen_test('shl', + evm_version='>=constantinople', + param_cnt = 2, + calc = lambda p: p[1] << p[0] if p[0] < 32 else 0) + gen_test('shr', + evm_version='>=constantinople', + param_cnt = 2, + calc = lambda p: p[1] >> p[0]) + gen_test('sar', + evm_version='>=constantinople', + param_cnt = 2, + calc = sar) + gen_test('addmod', + param_cnt = 3, + test_numbers = [random.randrange(0, MX) for _ in range(3)] + [0], + calc = lambda p: (p[0] + p[1]) % p[2] if p[2] != 0 else 0) + gen_test('mulmod', + param_cnt = 3, + test_numbers = [random.randrange(0, MX) for _ in range(3)] + [0], + calc = lambda p: (p[0] * p[1]) % p[2] if p[2] != 0 else 0) + gen_test('signextend', + param_cnt = 2, + calc = signextend) + +def signed_div(p: tuple[int, ...]): + (a, b) = u2s(p[0]), u2s(p[1]) + if b == 0: + return 0 + res = abs(a) // abs(b) + if (a < 0) != (b < 0): + res = -res + return res + +def signed_mod(p: tuple[int, ...]): + (a, b) = u2s(p[0]), u2s(p[1]) + if b == 0: + return 0 + res = abs(a) % abs(b) + if a < 0: + res = -res + return res + +def sar(p: tuple[int, ...]): + (sh, val) = p + high_bit = val >> 255 + val >>= sh + val |= u256(-high_bit) << max(0, 255 - sh) + return val + +def signextend(p: tuple[int, ...]): + (byte_pos, val) = p + byte_pos = min(byte_pos, 32) + mask_shift = byte_pos * 8 + 8 + high_bit = (val >> (mask_shift - 1)) & 1 + if high_bit: + return val | (u256(-1) << mask_shift) + return val & ((1 << mask_shift) - 1) + +if __name__ == '__main__': + main() diff --git a/test/libyul/yulPureInterpreterTests/pure_instructions/add.yul b/test/libyul/yulPureInterpreterTests/pure_instructions/add.yul new file mode 100644 index 000000000000..492d8522a108 --- /dev/null +++ b/test/libyul/yulPureInterpreterTests/pure_instructions/add.yul @@ -0,0 +1,77 @@ +{ + + function check(a, b) + { if iszero(eq(a, b)) { revert(0, 0) } } + + check(add(0x0, 0x0), 0x0) + check(add(0x0, 0x1), 0x1) + check(add(0x0, 0x2), 0x2) + check(add(0x0, 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff), 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff) + check(add(0x0, 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe), 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe) + check(add(0x0, 0x31c5371c46788840d973130b5c71df25f260902974ab0a71dc9e6ec7e7b3398e), 0x31c5371c46788840d973130b5c71df25f260902974ab0a71dc9e6ec7e7b3398e) + check(add(0x0, 0x2b76fc4c8d56959bb09b2d2b9c4f58cd8be6e814f188dc450260d9dd665a1efb), 0x2b76fc4c8d56959bb09b2d2b9c4f58cd8be6e814f188dc450260d9dd665a1efb) + check(add(0x0, 0x4df2d1f99bfaaadf814063267aefd221bc97c35d399874c9ea77bfe6d7c7e574), 0x4df2d1f99bfaaadf814063267aefd221bc97c35d399874c9ea77bfe6d7c7e574) + check(add(0x1, 0x0), 0x1) + check(add(0x1, 0x1), 0x2) + check(add(0x1, 0x2), 0x3) + check(add(0x1, 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff), 0x0) + check(add(0x1, 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe), 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff) + check(add(0x1, 0x31c5371c46788840d973130b5c71df25f260902974ab0a71dc9e6ec7e7b3398e), 0x31c5371c46788840d973130b5c71df25f260902974ab0a71dc9e6ec7e7b3398f) + check(add(0x1, 0x2b76fc4c8d56959bb09b2d2b9c4f58cd8be6e814f188dc450260d9dd665a1efb), 0x2b76fc4c8d56959bb09b2d2b9c4f58cd8be6e814f188dc450260d9dd665a1efc) + check(add(0x1, 0x4df2d1f99bfaaadf814063267aefd221bc97c35d399874c9ea77bfe6d7c7e574), 0x4df2d1f99bfaaadf814063267aefd221bc97c35d399874c9ea77bfe6d7c7e575) + check(add(0x2, 0x0), 0x2) + check(add(0x2, 0x1), 0x3) + check(add(0x2, 0x2), 0x4) + check(add(0x2, 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff), 0x1) + check(add(0x2, 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe), 0x0) + check(add(0x2, 0x31c5371c46788840d973130b5c71df25f260902974ab0a71dc9e6ec7e7b3398e), 0x31c5371c46788840d973130b5c71df25f260902974ab0a71dc9e6ec7e7b33990) + check(add(0x2, 0x2b76fc4c8d56959bb09b2d2b9c4f58cd8be6e814f188dc450260d9dd665a1efb), 0x2b76fc4c8d56959bb09b2d2b9c4f58cd8be6e814f188dc450260d9dd665a1efd) + check(add(0x2, 0x4df2d1f99bfaaadf814063267aefd221bc97c35d399874c9ea77bfe6d7c7e574), 0x4df2d1f99bfaaadf814063267aefd221bc97c35d399874c9ea77bfe6d7c7e576) + check(add(0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff, 0x0), 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff) + check(add(0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff, 0x1), 0x0) + check(add(0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff, 0x2), 0x1) + check(add(0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff, 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff), 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe) + check(add(0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff, 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe), 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffd) + check(add(0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff, 0x31c5371c46788840d973130b5c71df25f260902974ab0a71dc9e6ec7e7b3398e), 0x31c5371c46788840d973130b5c71df25f260902974ab0a71dc9e6ec7e7b3398d) + check(add(0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff, 0x2b76fc4c8d56959bb09b2d2b9c4f58cd8be6e814f188dc450260d9dd665a1efb), 0x2b76fc4c8d56959bb09b2d2b9c4f58cd8be6e814f188dc450260d9dd665a1efa) + check(add(0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff, 0x4df2d1f99bfaaadf814063267aefd221bc97c35d399874c9ea77bfe6d7c7e574), 0x4df2d1f99bfaaadf814063267aefd221bc97c35d399874c9ea77bfe6d7c7e573) + check(add(0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe, 0x0), 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe) + check(add(0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe, 0x1), 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff) + check(add(0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe, 0x2), 0x0) + check(add(0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe, 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff), 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffd) + check(add(0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe, 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe), 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc) + check(add(0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe, 0x31c5371c46788840d973130b5c71df25f260902974ab0a71dc9e6ec7e7b3398e), 0x31c5371c46788840d973130b5c71df25f260902974ab0a71dc9e6ec7e7b3398c) + check(add(0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe, 0x2b76fc4c8d56959bb09b2d2b9c4f58cd8be6e814f188dc450260d9dd665a1efb), 0x2b76fc4c8d56959bb09b2d2b9c4f58cd8be6e814f188dc450260d9dd665a1ef9) + check(add(0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe, 0x4df2d1f99bfaaadf814063267aefd221bc97c35d399874c9ea77bfe6d7c7e574), 0x4df2d1f99bfaaadf814063267aefd221bc97c35d399874c9ea77bfe6d7c7e572) + check(add(0x31c5371c46788840d973130b5c71df25f260902974ab0a71dc9e6ec7e7b3398e, 0x0), 0x31c5371c46788840d973130b5c71df25f260902974ab0a71dc9e6ec7e7b3398e) + check(add(0x31c5371c46788840d973130b5c71df25f260902974ab0a71dc9e6ec7e7b3398e, 0x1), 0x31c5371c46788840d973130b5c71df25f260902974ab0a71dc9e6ec7e7b3398f) + check(add(0x31c5371c46788840d973130b5c71df25f260902974ab0a71dc9e6ec7e7b3398e, 0x2), 0x31c5371c46788840d973130b5c71df25f260902974ab0a71dc9e6ec7e7b33990) + check(add(0x31c5371c46788840d973130b5c71df25f260902974ab0a71dc9e6ec7e7b3398e, 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff), 0x31c5371c46788840d973130b5c71df25f260902974ab0a71dc9e6ec7e7b3398d) + check(add(0x31c5371c46788840d973130b5c71df25f260902974ab0a71dc9e6ec7e7b3398e, 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe), 0x31c5371c46788840d973130b5c71df25f260902974ab0a71dc9e6ec7e7b3398c) + check(add(0x31c5371c46788840d973130b5c71df25f260902974ab0a71dc9e6ec7e7b3398e, 0x31c5371c46788840d973130b5c71df25f260902974ab0a71dc9e6ec7e7b3398e), 0x638a6e388cf11081b2e62616b8e3be4be4c12052e95614e3b93cdd8fcf66731c) + check(add(0x31c5371c46788840d973130b5c71df25f260902974ab0a71dc9e6ec7e7b3398e, 0x2b76fc4c8d56959bb09b2d2b9c4f58cd8be6e814f188dc450260d9dd665a1efb), 0x5d3c3368d3cf1ddc8a0e4036f8c137f37e47783e6633e6b6deff48a54e0d5889) + check(add(0x31c5371c46788840d973130b5c71df25f260902974ab0a71dc9e6ec7e7b3398e, 0x4df2d1f99bfaaadf814063267aefd221bc97c35d399874c9ea77bfe6d7c7e574), 0x7fb80915e27333205ab37631d761b147aef85386ae437f3bc7162eaebf7b1f02) + check(add(0x2b76fc4c8d56959bb09b2d2b9c4f58cd8be6e814f188dc450260d9dd665a1efb, 0x0), 0x2b76fc4c8d56959bb09b2d2b9c4f58cd8be6e814f188dc450260d9dd665a1efb) + check(add(0x2b76fc4c8d56959bb09b2d2b9c4f58cd8be6e814f188dc450260d9dd665a1efb, 0x1), 0x2b76fc4c8d56959bb09b2d2b9c4f58cd8be6e814f188dc450260d9dd665a1efc) + check(add(0x2b76fc4c8d56959bb09b2d2b9c4f58cd8be6e814f188dc450260d9dd665a1efb, 0x2), 0x2b76fc4c8d56959bb09b2d2b9c4f58cd8be6e814f188dc450260d9dd665a1efd) + check(add(0x2b76fc4c8d56959bb09b2d2b9c4f58cd8be6e814f188dc450260d9dd665a1efb, 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff), 0x2b76fc4c8d56959bb09b2d2b9c4f58cd8be6e814f188dc450260d9dd665a1efa) + check(add(0x2b76fc4c8d56959bb09b2d2b9c4f58cd8be6e814f188dc450260d9dd665a1efb, 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe), 0x2b76fc4c8d56959bb09b2d2b9c4f58cd8be6e814f188dc450260d9dd665a1ef9) + check(add(0x2b76fc4c8d56959bb09b2d2b9c4f58cd8be6e814f188dc450260d9dd665a1efb, 0x31c5371c46788840d973130b5c71df25f260902974ab0a71dc9e6ec7e7b3398e), 0x5d3c3368d3cf1ddc8a0e4036f8c137f37e47783e6633e6b6deff48a54e0d5889) + check(add(0x2b76fc4c8d56959bb09b2d2b9c4f58cd8be6e814f188dc450260d9dd665a1efb, 0x2b76fc4c8d56959bb09b2d2b9c4f58cd8be6e814f188dc450260d9dd665a1efb), 0x56edf8991aad2b3761365a57389eb19b17cdd029e311b88a04c1b3baccb43df6) + check(add(0x2b76fc4c8d56959bb09b2d2b9c4f58cd8be6e814f188dc450260d9dd665a1efb, 0x4df2d1f99bfaaadf814063267aefd221bc97c35d399874c9ea77bfe6d7c7e574), 0x7969ce462951407b31db9052173f2aef487eab722b21510eecd899c43e22046f) + check(add(0x4df2d1f99bfaaadf814063267aefd221bc97c35d399874c9ea77bfe6d7c7e574, 0x0), 0x4df2d1f99bfaaadf814063267aefd221bc97c35d399874c9ea77bfe6d7c7e574) + check(add(0x4df2d1f99bfaaadf814063267aefd221bc97c35d399874c9ea77bfe6d7c7e574, 0x1), 0x4df2d1f99bfaaadf814063267aefd221bc97c35d399874c9ea77bfe6d7c7e575) + check(add(0x4df2d1f99bfaaadf814063267aefd221bc97c35d399874c9ea77bfe6d7c7e574, 0x2), 0x4df2d1f99bfaaadf814063267aefd221bc97c35d399874c9ea77bfe6d7c7e576) + check(add(0x4df2d1f99bfaaadf814063267aefd221bc97c35d399874c9ea77bfe6d7c7e574, 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff), 0x4df2d1f99bfaaadf814063267aefd221bc97c35d399874c9ea77bfe6d7c7e573) + check(add(0x4df2d1f99bfaaadf814063267aefd221bc97c35d399874c9ea77bfe6d7c7e574, 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe), 0x4df2d1f99bfaaadf814063267aefd221bc97c35d399874c9ea77bfe6d7c7e572) + check(add(0x4df2d1f99bfaaadf814063267aefd221bc97c35d399874c9ea77bfe6d7c7e574, 0x31c5371c46788840d973130b5c71df25f260902974ab0a71dc9e6ec7e7b3398e), 0x7fb80915e27333205ab37631d761b147aef85386ae437f3bc7162eaebf7b1f02) + check(add(0x4df2d1f99bfaaadf814063267aefd221bc97c35d399874c9ea77bfe6d7c7e574, 0x2b76fc4c8d56959bb09b2d2b9c4f58cd8be6e814f188dc450260d9dd665a1efb), 0x7969ce462951407b31db9052173f2aef487eab722b21510eecd899c43e22046f) + check(add(0x4df2d1f99bfaaadf814063267aefd221bc97c35d399874c9ea77bfe6d7c7e574, 0x4df2d1f99bfaaadf814063267aefd221bc97c35d399874c9ea77bfe6d7c7e574), 0x9be5a3f337f555bf0280c64cf5dfa443792f86ba7330e993d4ef7fcdaf8fcae8) +} +// ==== +// maxTraceSize: 0 +// ---- +// Execution result: ExecutionOk +// Outer most variable values: +// +// Call trace: diff --git a/test/libyul/yulPureInterpreterTests/pure_instructions/addmod.yul b/test/libyul/yulPureInterpreterTests/pure_instructions/addmod.yul new file mode 100644 index 000000000000..d82d8dd2503f --- /dev/null +++ b/test/libyul/yulPureInterpreterTests/pure_instructions/addmod.yul @@ -0,0 +1,77 @@ +{ + + function check(a, b) + { if iszero(eq(a, b)) { revert(0, 0) } } + + check(addmod(0x9892bc92384c69bbe6785bb21c34a5ef13e9b252a036ae47f44e8a0bc2fd82d4, 0x9892bc92384c69bbe6785bb21c34a5ef13e9b252a036ae47f44e8a0bc2fd82d4, 0x9892bc92384c69bbe6785bb21c34a5ef13e9b252a036ae47f44e8a0bc2fd82d4), 0x0) + check(addmod(0x9892bc92384c69bbe6785bb21c34a5ef13e9b252a036ae47f44e8a0bc2fd82d4, 0x9892bc92384c69bbe6785bb21c34a5ef13e9b252a036ae47f44e8a0bc2fd82d4, 0xcb53a9a203346f325210a54397b34de77456e0e67d145bd86b4a6102da11212a), 0x65d1cf826d6464457ae01220a0b5fdf6b37c83bec35900b77d52b314abe9e47e) + check(addmod(0x9892bc92384c69bbe6785bb21c34a5ef13e9b252a036ae47f44e8a0bc2fd82d4, 0x9892bc92384c69bbe6785bb21c34a5ef13e9b252a036ae47f44e8a0bc2fd82d4, 0xfa861064ecbd6f61ef8c46daf84d6062699b8abc55d7703ce38f20d236224b69), 0x369f68bf83db6415dd647089401beb7bbe37d9e8ea95ec53050df3454fd8ba3f) + check(addmod(0x9892bc92384c69bbe6785bb21c34a5ef13e9b252a036ae47f44e8a0bc2fd82d4, 0x9892bc92384c69bbe6785bb21c34a5ef13e9b252a036ae47f44e8a0bc2fd82d4, 0x0), 0x0) + check(addmod(0x9892bc92384c69bbe6785bb21c34a5ef13e9b252a036ae47f44e8a0bc2fd82d4, 0xcb53a9a203346f325210a54397b34de77456e0e67d145bd86b4a6102da11212a, 0x9892bc92384c69bbe6785bb21c34a5ef13e9b252a036ae47f44e8a0bc2fd82d4), 0x32c0ed0fcae805766b9849917b7ea7f8606d2e93dcddad9076fbd6f717139e56) + check(addmod(0x9892bc92384c69bbe6785bb21c34a5ef13e9b252a036ae47f44e8a0bc2fd82d4, 0xcb53a9a203346f325210a54397b34de77456e0e67d145bd86b4a6102da11212a, 0xcb53a9a203346f325210a54397b34de77456e0e67d145bd86b4a6102da11212a), 0x9892bc92384c69bbe6785bb21c34a5ef13e9b252a036ae47f44e8a0bc2fd82d4) + check(addmod(0x9892bc92384c69bbe6785bb21c34a5ef13e9b252a036ae47f44e8a0bc2fd82d4, 0xcb53a9a203346f325210a54397b34de77456e0e67d145bd86b4a6102da11212a, 0xfa861064ecbd6f61ef8c46daf84d6062699b8abc55d7703ce38f20d236224b69), 0x696055cf4ec3698c48fcba1abb9a93741ea5087cc77399e37c09ca3c66ec5895) + check(addmod(0x9892bc92384c69bbe6785bb21c34a5ef13e9b252a036ae47f44e8a0bc2fd82d4, 0xcb53a9a203346f325210a54397b34de77456e0e67d145bd86b4a6102da11212a, 0x0), 0x0) + check(addmod(0x9892bc92384c69bbe6785bb21c34a5ef13e9b252a036ae47f44e8a0bc2fd82d4, 0xfa861064ecbd6f61ef8c46daf84d6062699b8abc55d7703ce38f20d236224b69, 0x9892bc92384c69bbe6785bb21c34a5ef13e9b252a036ae47f44e8a0bc2fd82d4), 0x61f353d2b47105a60913eb28dc18ba7355b1d869b5a0c1f4ef4096c67324c895) + check(addmod(0x9892bc92384c69bbe6785bb21c34a5ef13e9b252a036ae47f44e8a0bc2fd82d4, 0xfa861064ecbd6f61ef8c46daf84d6062699b8abc55d7703ce38f20d236224b69, 0xcb53a9a203346f325210a54397b34de77456e0e67d145bd86b4a6102da11212a), 0xc7c5235521d569eb83f3fd497cceb86a092e5c2878f9c2ac6c9349db1f0ead13) + check(addmod(0x9892bc92384c69bbe6785bb21c34a5ef13e9b252a036ae47f44e8a0bc2fd82d4, 0xfa861064ecbd6f61ef8c46daf84d6062699b8abc55d7703ce38f20d236224b69, 0xfa861064ecbd6f61ef8c46daf84d6062699b8abc55d7703ce38f20d236224b69), 0x9892bc92384c69bbe6785bb21c34a5ef13e9b252a036ae47f44e8a0bc2fd82d4) + check(addmod(0x9892bc92384c69bbe6785bb21c34a5ef13e9b252a036ae47f44e8a0bc2fd82d4, 0xfa861064ecbd6f61ef8c46daf84d6062699b8abc55d7703ce38f20d236224b69, 0x0), 0x0) + check(addmod(0x9892bc92384c69bbe6785bb21c34a5ef13e9b252a036ae47f44e8a0bc2fd82d4, 0x0, 0x9892bc92384c69bbe6785bb21c34a5ef13e9b252a036ae47f44e8a0bc2fd82d4), 0x0) + check(addmod(0x9892bc92384c69bbe6785bb21c34a5ef13e9b252a036ae47f44e8a0bc2fd82d4, 0x0, 0xcb53a9a203346f325210a54397b34de77456e0e67d145bd86b4a6102da11212a), 0x9892bc92384c69bbe6785bb21c34a5ef13e9b252a036ae47f44e8a0bc2fd82d4) + check(addmod(0x9892bc92384c69bbe6785bb21c34a5ef13e9b252a036ae47f44e8a0bc2fd82d4, 0x0, 0xfa861064ecbd6f61ef8c46daf84d6062699b8abc55d7703ce38f20d236224b69), 0x9892bc92384c69bbe6785bb21c34a5ef13e9b252a036ae47f44e8a0bc2fd82d4) + check(addmod(0x9892bc92384c69bbe6785bb21c34a5ef13e9b252a036ae47f44e8a0bc2fd82d4, 0x0, 0x0), 0x0) + check(addmod(0xcb53a9a203346f325210a54397b34de77456e0e67d145bd86b4a6102da11212a, 0x9892bc92384c69bbe6785bb21c34a5ef13e9b252a036ae47f44e8a0bc2fd82d4, 0x9892bc92384c69bbe6785bb21c34a5ef13e9b252a036ae47f44e8a0bc2fd82d4), 0x32c0ed0fcae805766b9849917b7ea7f8606d2e93dcddad9076fbd6f717139e56) + check(addmod(0xcb53a9a203346f325210a54397b34de77456e0e67d145bd86b4a6102da11212a, 0x9892bc92384c69bbe6785bb21c34a5ef13e9b252a036ae47f44e8a0bc2fd82d4, 0xcb53a9a203346f325210a54397b34de77456e0e67d145bd86b4a6102da11212a), 0x9892bc92384c69bbe6785bb21c34a5ef13e9b252a036ae47f44e8a0bc2fd82d4) + check(addmod(0xcb53a9a203346f325210a54397b34de77456e0e67d145bd86b4a6102da11212a, 0x9892bc92384c69bbe6785bb21c34a5ef13e9b252a036ae47f44e8a0bc2fd82d4, 0xfa861064ecbd6f61ef8c46daf84d6062699b8abc55d7703ce38f20d236224b69), 0x696055cf4ec3698c48fcba1abb9a93741ea5087cc77399e37c09ca3c66ec5895) + check(addmod(0xcb53a9a203346f325210a54397b34de77456e0e67d145bd86b4a6102da11212a, 0x9892bc92384c69bbe6785bb21c34a5ef13e9b252a036ae47f44e8a0bc2fd82d4, 0x0), 0x0) + check(addmod(0xcb53a9a203346f325210a54397b34de77456e0e67d145bd86b4a6102da11212a, 0xcb53a9a203346f325210a54397b34de77456e0e67d145bd86b4a6102da11212a, 0x9892bc92384c69bbe6785bb21c34a5ef13e9b252a036ae47f44e8a0bc2fd82d4), 0x6581da1f95d00aecd7309322f6fd4ff0c0da5d27b9bb5b20edf7adee2e273cac) + check(addmod(0xcb53a9a203346f325210a54397b34de77456e0e67d145bd86b4a6102da11212a, 0xcb53a9a203346f325210a54397b34de77456e0e67d145bd86b4a6102da11212a, 0xcb53a9a203346f325210a54397b34de77456e0e67d145bd86b4a6102da11212a), 0x0) + check(addmod(0xcb53a9a203346f325210a54397b34de77456e0e67d145bd86b4a6102da11212a, 0xcb53a9a203346f325210a54397b34de77456e0e67d145bd86b4a6102da11212a, 0xfa861064ecbd6f61ef8c46daf84d6062699b8abc55d7703ce38f20d236224b69), 0x9c2142df19ab6f02b49503ac37193b6c7f123710a4514773f305a1337dfff6eb) + check(addmod(0xcb53a9a203346f325210a54397b34de77456e0e67d145bd86b4a6102da11212a, 0xcb53a9a203346f325210a54397b34de77456e0e67d145bd86b4a6102da11212a, 0x0), 0x0) + check(addmod(0xcb53a9a203346f325210a54397b34de77456e0e67d145bd86b4a6102da11212a, 0xfa861064ecbd6f61ef8c46daf84d6062699b8abc55d7703ce38f20d236224b69, 0x9892bc92384c69bbe6785bb21c34a5ef13e9b252a036ae47f44e8a0bc2fd82d4), 0x94b440e27f590b1c74ac34ba5797626bb61f06fd927e6f85663c6dbd8a3866eb) + check(addmod(0xcb53a9a203346f325210a54397b34de77456e0e67d145bd86b4a6102da11212a, 0xfa861064ecbd6f61ef8c46daf84d6062699b8abc55d7703ce38f20d236224b69, 0xcb53a9a203346f325210a54397b34de77456e0e67d145bd86b4a6102da11212a), 0x2f3266c2e989002f9d7ba197609a127af544a9d5d8c314647844bfcf5c112a3f) + check(addmod(0xcb53a9a203346f325210a54397b34de77456e0e67d145bd86b4a6102da11212a, 0xfa861064ecbd6f61ef8c46daf84d6062699b8abc55d7703ce38f20d236224b69, 0xfa861064ecbd6f61ef8c46daf84d6062699b8abc55d7703ce38f20d236224b69), 0xcb53a9a203346f325210a54397b34de77456e0e67d145bd86b4a6102da11212a) + check(addmod(0xcb53a9a203346f325210a54397b34de77456e0e67d145bd86b4a6102da11212a, 0xfa861064ecbd6f61ef8c46daf84d6062699b8abc55d7703ce38f20d236224b69, 0x0), 0x0) + check(addmod(0xcb53a9a203346f325210a54397b34de77456e0e67d145bd86b4a6102da11212a, 0x0, 0x9892bc92384c69bbe6785bb21c34a5ef13e9b252a036ae47f44e8a0bc2fd82d4), 0x32c0ed0fcae805766b9849917b7ea7f8606d2e93dcddad9076fbd6f717139e56) + check(addmod(0xcb53a9a203346f325210a54397b34de77456e0e67d145bd86b4a6102da11212a, 0x0, 0xcb53a9a203346f325210a54397b34de77456e0e67d145bd86b4a6102da11212a), 0x0) + check(addmod(0xcb53a9a203346f325210a54397b34de77456e0e67d145bd86b4a6102da11212a, 0x0, 0xfa861064ecbd6f61ef8c46daf84d6062699b8abc55d7703ce38f20d236224b69), 0xcb53a9a203346f325210a54397b34de77456e0e67d145bd86b4a6102da11212a) + check(addmod(0xcb53a9a203346f325210a54397b34de77456e0e67d145bd86b4a6102da11212a, 0x0, 0x0), 0x0) + check(addmod(0xfa861064ecbd6f61ef8c46daf84d6062699b8abc55d7703ce38f20d236224b69, 0x9892bc92384c69bbe6785bb21c34a5ef13e9b252a036ae47f44e8a0bc2fd82d4, 0x9892bc92384c69bbe6785bb21c34a5ef13e9b252a036ae47f44e8a0bc2fd82d4), 0x61f353d2b47105a60913eb28dc18ba7355b1d869b5a0c1f4ef4096c67324c895) + check(addmod(0xfa861064ecbd6f61ef8c46daf84d6062699b8abc55d7703ce38f20d236224b69, 0x9892bc92384c69bbe6785bb21c34a5ef13e9b252a036ae47f44e8a0bc2fd82d4, 0xcb53a9a203346f325210a54397b34de77456e0e67d145bd86b4a6102da11212a), 0xc7c5235521d569eb83f3fd497cceb86a092e5c2878f9c2ac6c9349db1f0ead13) + check(addmod(0xfa861064ecbd6f61ef8c46daf84d6062699b8abc55d7703ce38f20d236224b69, 0x9892bc92384c69bbe6785bb21c34a5ef13e9b252a036ae47f44e8a0bc2fd82d4, 0xfa861064ecbd6f61ef8c46daf84d6062699b8abc55d7703ce38f20d236224b69), 0x9892bc92384c69bbe6785bb21c34a5ef13e9b252a036ae47f44e8a0bc2fd82d4) + check(addmod(0xfa861064ecbd6f61ef8c46daf84d6062699b8abc55d7703ce38f20d236224b69, 0x9892bc92384c69bbe6785bb21c34a5ef13e9b252a036ae47f44e8a0bc2fd82d4, 0x0), 0x0) + check(addmod(0xfa861064ecbd6f61ef8c46daf84d6062699b8abc55d7703ce38f20d236224b69, 0xcb53a9a203346f325210a54397b34de77456e0e67d145bd86b4a6102da11212a, 0x9892bc92384c69bbe6785bb21c34a5ef13e9b252a036ae47f44e8a0bc2fd82d4), 0x94b440e27f590b1c74ac34ba5797626bb61f06fd927e6f85663c6dbd8a3866eb) + check(addmod(0xfa861064ecbd6f61ef8c46daf84d6062699b8abc55d7703ce38f20d236224b69, 0xcb53a9a203346f325210a54397b34de77456e0e67d145bd86b4a6102da11212a, 0xcb53a9a203346f325210a54397b34de77456e0e67d145bd86b4a6102da11212a), 0x2f3266c2e989002f9d7ba197609a127af544a9d5d8c314647844bfcf5c112a3f) + check(addmod(0xfa861064ecbd6f61ef8c46daf84d6062699b8abc55d7703ce38f20d236224b69, 0xcb53a9a203346f325210a54397b34de77456e0e67d145bd86b4a6102da11212a, 0xfa861064ecbd6f61ef8c46daf84d6062699b8abc55d7703ce38f20d236224b69), 0xcb53a9a203346f325210a54397b34de77456e0e67d145bd86b4a6102da11212a) + check(addmod(0xfa861064ecbd6f61ef8c46daf84d6062699b8abc55d7703ce38f20d236224b69, 0xcb53a9a203346f325210a54397b34de77456e0e67d145bd86b4a6102da11212a, 0x0), 0x0) + check(addmod(0xfa861064ecbd6f61ef8c46daf84d6062699b8abc55d7703ce38f20d236224b69, 0xfa861064ecbd6f61ef8c46daf84d6062699b8abc55d7703ce38f20d236224b69, 0x9892bc92384c69bbe6785bb21c34a5ef13e9b252a036ae47f44e8a0bc2fd82d4), 0x2b53eb133095a1902baf7a9f9bfccef79779fe80cb0ad5a1ea32a381234c0e56) + check(addmod(0xfa861064ecbd6f61ef8c46daf84d6062699b8abc55d7703ce38f20d236224b69, 0xfa861064ecbd6f61ef8c46daf84d6062699b8abc55d7703ce38f20d236224b69, 0xcb53a9a203346f325210a54397b34de77456e0e67d145bd86b4a6102da11212a), 0x5e64cd85d312005f3af7432ec13424f5ea8953abb18628c8f0897f9eb822547e) + check(addmod(0xfa861064ecbd6f61ef8c46daf84d6062699b8abc55d7703ce38f20d236224b69, 0xfa861064ecbd6f61ef8c46daf84d6062699b8abc55d7703ce38f20d236224b69, 0xfa861064ecbd6f61ef8c46daf84d6062699b8abc55d7703ce38f20d236224b69), 0x0) + check(addmod(0xfa861064ecbd6f61ef8c46daf84d6062699b8abc55d7703ce38f20d236224b69, 0xfa861064ecbd6f61ef8c46daf84d6062699b8abc55d7703ce38f20d236224b69, 0x0), 0x0) + check(addmod(0xfa861064ecbd6f61ef8c46daf84d6062699b8abc55d7703ce38f20d236224b69, 0x0, 0x9892bc92384c69bbe6785bb21c34a5ef13e9b252a036ae47f44e8a0bc2fd82d4), 0x61f353d2b47105a60913eb28dc18ba7355b1d869b5a0c1f4ef4096c67324c895) + check(addmod(0xfa861064ecbd6f61ef8c46daf84d6062699b8abc55d7703ce38f20d236224b69, 0x0, 0xcb53a9a203346f325210a54397b34de77456e0e67d145bd86b4a6102da11212a), 0x2f3266c2e989002f9d7ba197609a127af544a9d5d8c314647844bfcf5c112a3f) + check(addmod(0xfa861064ecbd6f61ef8c46daf84d6062699b8abc55d7703ce38f20d236224b69, 0x0, 0xfa861064ecbd6f61ef8c46daf84d6062699b8abc55d7703ce38f20d236224b69), 0x0) + check(addmod(0xfa861064ecbd6f61ef8c46daf84d6062699b8abc55d7703ce38f20d236224b69, 0x0, 0x0), 0x0) + check(addmod(0x0, 0x9892bc92384c69bbe6785bb21c34a5ef13e9b252a036ae47f44e8a0bc2fd82d4, 0x9892bc92384c69bbe6785bb21c34a5ef13e9b252a036ae47f44e8a0bc2fd82d4), 0x0) + check(addmod(0x0, 0x9892bc92384c69bbe6785bb21c34a5ef13e9b252a036ae47f44e8a0bc2fd82d4, 0xcb53a9a203346f325210a54397b34de77456e0e67d145bd86b4a6102da11212a), 0x9892bc92384c69bbe6785bb21c34a5ef13e9b252a036ae47f44e8a0bc2fd82d4) + check(addmod(0x0, 0x9892bc92384c69bbe6785bb21c34a5ef13e9b252a036ae47f44e8a0bc2fd82d4, 0xfa861064ecbd6f61ef8c46daf84d6062699b8abc55d7703ce38f20d236224b69), 0x9892bc92384c69bbe6785bb21c34a5ef13e9b252a036ae47f44e8a0bc2fd82d4) + check(addmod(0x0, 0x9892bc92384c69bbe6785bb21c34a5ef13e9b252a036ae47f44e8a0bc2fd82d4, 0x0), 0x0) + check(addmod(0x0, 0xcb53a9a203346f325210a54397b34de77456e0e67d145bd86b4a6102da11212a, 0x9892bc92384c69bbe6785bb21c34a5ef13e9b252a036ae47f44e8a0bc2fd82d4), 0x32c0ed0fcae805766b9849917b7ea7f8606d2e93dcddad9076fbd6f717139e56) + check(addmod(0x0, 0xcb53a9a203346f325210a54397b34de77456e0e67d145bd86b4a6102da11212a, 0xcb53a9a203346f325210a54397b34de77456e0e67d145bd86b4a6102da11212a), 0x0) + check(addmod(0x0, 0xcb53a9a203346f325210a54397b34de77456e0e67d145bd86b4a6102da11212a, 0xfa861064ecbd6f61ef8c46daf84d6062699b8abc55d7703ce38f20d236224b69), 0xcb53a9a203346f325210a54397b34de77456e0e67d145bd86b4a6102da11212a) + check(addmod(0x0, 0xcb53a9a203346f325210a54397b34de77456e0e67d145bd86b4a6102da11212a, 0x0), 0x0) + check(addmod(0x0, 0xfa861064ecbd6f61ef8c46daf84d6062699b8abc55d7703ce38f20d236224b69, 0x9892bc92384c69bbe6785bb21c34a5ef13e9b252a036ae47f44e8a0bc2fd82d4), 0x61f353d2b47105a60913eb28dc18ba7355b1d869b5a0c1f4ef4096c67324c895) + check(addmod(0x0, 0xfa861064ecbd6f61ef8c46daf84d6062699b8abc55d7703ce38f20d236224b69, 0xcb53a9a203346f325210a54397b34de77456e0e67d145bd86b4a6102da11212a), 0x2f3266c2e989002f9d7ba197609a127af544a9d5d8c314647844bfcf5c112a3f) + check(addmod(0x0, 0xfa861064ecbd6f61ef8c46daf84d6062699b8abc55d7703ce38f20d236224b69, 0xfa861064ecbd6f61ef8c46daf84d6062699b8abc55d7703ce38f20d236224b69), 0x0) + check(addmod(0x0, 0xfa861064ecbd6f61ef8c46daf84d6062699b8abc55d7703ce38f20d236224b69, 0x0), 0x0) + check(addmod(0x0, 0x0, 0x9892bc92384c69bbe6785bb21c34a5ef13e9b252a036ae47f44e8a0bc2fd82d4), 0x0) + check(addmod(0x0, 0x0, 0xcb53a9a203346f325210a54397b34de77456e0e67d145bd86b4a6102da11212a), 0x0) + check(addmod(0x0, 0x0, 0xfa861064ecbd6f61ef8c46daf84d6062699b8abc55d7703ce38f20d236224b69), 0x0) + check(addmod(0x0, 0x0, 0x0), 0x0) +} +// ==== +// maxTraceSize: 0 +// ---- +// Execution result: ExecutionOk +// Outer most variable values: +// +// Call trace: diff --git a/test/libyul/yulPureInterpreterTests/pure_instructions/and.yul b/test/libyul/yulPureInterpreterTests/pure_instructions/and.yul new file mode 100644 index 000000000000..677b8e924e1c --- /dev/null +++ b/test/libyul/yulPureInterpreterTests/pure_instructions/and.yul @@ -0,0 +1,77 @@ +{ + + function check(a, b) + { if iszero(eq(a, b)) { revert(0, 0) } } + + check(and(0x0, 0x0), 0x0) + check(and(0x0, 0x1), 0x0) + check(and(0x0, 0x2), 0x0) + check(and(0x0, 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff), 0x0) + check(and(0x0, 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe), 0x0) + check(and(0x0, 0xcb4a48869485dcdf7edb34f4e58d5f628f0766bf06640f5e49993a7dc41f9156), 0x0) + check(and(0x0, 0xe7f49d7284ca13df4662a068293794dd877973e547b3ec1c2f37f8be5ec3da71), 0x0) + check(and(0x0, 0xa8d60ea4aa8b78b611bc6eca24f10a66cefc3348fe10fd1f5af1f6ff23fc44bb), 0x0) + check(and(0x1, 0x0), 0x0) + check(and(0x1, 0x1), 0x1) + check(and(0x1, 0x2), 0x0) + check(and(0x1, 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff), 0x1) + check(and(0x1, 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe), 0x0) + check(and(0x1, 0xcb4a48869485dcdf7edb34f4e58d5f628f0766bf06640f5e49993a7dc41f9156), 0x0) + check(and(0x1, 0xe7f49d7284ca13df4662a068293794dd877973e547b3ec1c2f37f8be5ec3da71), 0x1) + check(and(0x1, 0xa8d60ea4aa8b78b611bc6eca24f10a66cefc3348fe10fd1f5af1f6ff23fc44bb), 0x1) + check(and(0x2, 0x0), 0x0) + check(and(0x2, 0x1), 0x0) + check(and(0x2, 0x2), 0x2) + check(and(0x2, 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff), 0x2) + check(and(0x2, 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe), 0x2) + check(and(0x2, 0xcb4a48869485dcdf7edb34f4e58d5f628f0766bf06640f5e49993a7dc41f9156), 0x2) + check(and(0x2, 0xe7f49d7284ca13df4662a068293794dd877973e547b3ec1c2f37f8be5ec3da71), 0x0) + check(and(0x2, 0xa8d60ea4aa8b78b611bc6eca24f10a66cefc3348fe10fd1f5af1f6ff23fc44bb), 0x2) + check(and(0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff, 0x0), 0x0) + check(and(0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff, 0x1), 0x1) + check(and(0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff, 0x2), 0x2) + check(and(0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff, 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff), 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff) + check(and(0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff, 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe), 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe) + check(and(0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff, 0xcb4a48869485dcdf7edb34f4e58d5f628f0766bf06640f5e49993a7dc41f9156), 0xcb4a48869485dcdf7edb34f4e58d5f628f0766bf06640f5e49993a7dc41f9156) + check(and(0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff, 0xe7f49d7284ca13df4662a068293794dd877973e547b3ec1c2f37f8be5ec3da71), 0xe7f49d7284ca13df4662a068293794dd877973e547b3ec1c2f37f8be5ec3da71) + check(and(0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff, 0xa8d60ea4aa8b78b611bc6eca24f10a66cefc3348fe10fd1f5af1f6ff23fc44bb), 0xa8d60ea4aa8b78b611bc6eca24f10a66cefc3348fe10fd1f5af1f6ff23fc44bb) + check(and(0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe, 0x0), 0x0) + check(and(0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe, 0x1), 0x0) + check(and(0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe, 0x2), 0x2) + check(and(0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe, 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff), 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe) + check(and(0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe, 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe), 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe) + check(and(0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe, 0xcb4a48869485dcdf7edb34f4e58d5f628f0766bf06640f5e49993a7dc41f9156), 0xcb4a48869485dcdf7edb34f4e58d5f628f0766bf06640f5e49993a7dc41f9156) + check(and(0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe, 0xe7f49d7284ca13df4662a068293794dd877973e547b3ec1c2f37f8be5ec3da71), 0xe7f49d7284ca13df4662a068293794dd877973e547b3ec1c2f37f8be5ec3da70) + check(and(0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe, 0xa8d60ea4aa8b78b611bc6eca24f10a66cefc3348fe10fd1f5af1f6ff23fc44bb), 0xa8d60ea4aa8b78b611bc6eca24f10a66cefc3348fe10fd1f5af1f6ff23fc44ba) + check(and(0xcb4a48869485dcdf7edb34f4e58d5f628f0766bf06640f5e49993a7dc41f9156, 0x0), 0x0) + check(and(0xcb4a48869485dcdf7edb34f4e58d5f628f0766bf06640f5e49993a7dc41f9156, 0x1), 0x0) + check(and(0xcb4a48869485dcdf7edb34f4e58d5f628f0766bf06640f5e49993a7dc41f9156, 0x2), 0x2) + check(and(0xcb4a48869485dcdf7edb34f4e58d5f628f0766bf06640f5e49993a7dc41f9156, 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff), 0xcb4a48869485dcdf7edb34f4e58d5f628f0766bf06640f5e49993a7dc41f9156) + check(and(0xcb4a48869485dcdf7edb34f4e58d5f628f0766bf06640f5e49993a7dc41f9156, 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe), 0xcb4a48869485dcdf7edb34f4e58d5f628f0766bf06640f5e49993a7dc41f9156) + check(and(0xcb4a48869485dcdf7edb34f4e58d5f628f0766bf06640f5e49993a7dc41f9156, 0xcb4a48869485dcdf7edb34f4e58d5f628f0766bf06640f5e49993a7dc41f9156), 0xcb4a48869485dcdf7edb34f4e58d5f628f0766bf06640f5e49993a7dc41f9156) + check(and(0xcb4a48869485dcdf7edb34f4e58d5f628f0766bf06640f5e49993a7dc41f9156, 0xe7f49d7284ca13df4662a068293794dd877973e547b3ec1c2f37f8be5ec3da71), 0xc3400802848010df4642206021051440870162a506200c1c0911383c44039050) + check(and(0xcb4a48869485dcdf7edb34f4e58d5f628f0766bf06640f5e49993a7dc41f9156, 0xa8d60ea4aa8b78b611bc6eca24f10a66cefc3348fe10fd1f5af1f6ff23fc44bb), 0x8842088480815896109824c024810a628e04220806000d1e4891327d001c0012) + check(and(0xe7f49d7284ca13df4662a068293794dd877973e547b3ec1c2f37f8be5ec3da71, 0x0), 0x0) + check(and(0xe7f49d7284ca13df4662a068293794dd877973e547b3ec1c2f37f8be5ec3da71, 0x1), 0x1) + check(and(0xe7f49d7284ca13df4662a068293794dd877973e547b3ec1c2f37f8be5ec3da71, 0x2), 0x0) + check(and(0xe7f49d7284ca13df4662a068293794dd877973e547b3ec1c2f37f8be5ec3da71, 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff), 0xe7f49d7284ca13df4662a068293794dd877973e547b3ec1c2f37f8be5ec3da71) + check(and(0xe7f49d7284ca13df4662a068293794dd877973e547b3ec1c2f37f8be5ec3da71, 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe), 0xe7f49d7284ca13df4662a068293794dd877973e547b3ec1c2f37f8be5ec3da70) + check(and(0xe7f49d7284ca13df4662a068293794dd877973e547b3ec1c2f37f8be5ec3da71, 0xcb4a48869485dcdf7edb34f4e58d5f628f0766bf06640f5e49993a7dc41f9156), 0xc3400802848010df4642206021051440870162a506200c1c0911383c44039050) + check(and(0xe7f49d7284ca13df4662a068293794dd877973e547b3ec1c2f37f8be5ec3da71, 0xe7f49d7284ca13df4662a068293794dd877973e547b3ec1c2f37f8be5ec3da71), 0xe7f49d7284ca13df4662a068293794dd877973e547b3ec1c2f37f8be5ec3da71) + check(and(0xe7f49d7284ca13df4662a068293794dd877973e547b3ec1c2f37f8be5ec3da71, 0xa8d60ea4aa8b78b611bc6eca24f10a66cefc3348fe10fd1f5af1f6ff23fc44bb), 0xa0d40c20808a10960020204820310044867833404610ec1c0a31f0be02c04031) + check(and(0xa8d60ea4aa8b78b611bc6eca24f10a66cefc3348fe10fd1f5af1f6ff23fc44bb, 0x0), 0x0) + check(and(0xa8d60ea4aa8b78b611bc6eca24f10a66cefc3348fe10fd1f5af1f6ff23fc44bb, 0x1), 0x1) + check(and(0xa8d60ea4aa8b78b611bc6eca24f10a66cefc3348fe10fd1f5af1f6ff23fc44bb, 0x2), 0x2) + check(and(0xa8d60ea4aa8b78b611bc6eca24f10a66cefc3348fe10fd1f5af1f6ff23fc44bb, 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff), 0xa8d60ea4aa8b78b611bc6eca24f10a66cefc3348fe10fd1f5af1f6ff23fc44bb) + check(and(0xa8d60ea4aa8b78b611bc6eca24f10a66cefc3348fe10fd1f5af1f6ff23fc44bb, 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe), 0xa8d60ea4aa8b78b611bc6eca24f10a66cefc3348fe10fd1f5af1f6ff23fc44ba) + check(and(0xa8d60ea4aa8b78b611bc6eca24f10a66cefc3348fe10fd1f5af1f6ff23fc44bb, 0xcb4a48869485dcdf7edb34f4e58d5f628f0766bf06640f5e49993a7dc41f9156), 0x8842088480815896109824c024810a628e04220806000d1e4891327d001c0012) + check(and(0xa8d60ea4aa8b78b611bc6eca24f10a66cefc3348fe10fd1f5af1f6ff23fc44bb, 0xe7f49d7284ca13df4662a068293794dd877973e547b3ec1c2f37f8be5ec3da71), 0xa0d40c20808a10960020204820310044867833404610ec1c0a31f0be02c04031) + check(and(0xa8d60ea4aa8b78b611bc6eca24f10a66cefc3348fe10fd1f5af1f6ff23fc44bb, 0xa8d60ea4aa8b78b611bc6eca24f10a66cefc3348fe10fd1f5af1f6ff23fc44bb), 0xa8d60ea4aa8b78b611bc6eca24f10a66cefc3348fe10fd1f5af1f6ff23fc44bb) +} +// ==== +// maxTraceSize: 0 +// ---- +// Execution result: ExecutionOk +// Outer most variable values: +// +// Call trace: diff --git a/test/libyul/yulPureInterpreterTests/pure_instructions/byte.yul b/test/libyul/yulPureInterpreterTests/pure_instructions/byte.yul new file mode 100644 index 000000000000..2c5f014fb312 --- /dev/null +++ b/test/libyul/yulPureInterpreterTests/pure_instructions/byte.yul @@ -0,0 +1,62 @@ +{ + + function check(a, b) + { if iszero(eq(a, b)) { revert(0, 0) } } + + check(byte(0x18f76fcc2c24df8c0b6177329e34167b9a0fe7f2f333f87ac1a6b66c94df748, 0x18f76fcc2c24df8c0b6177329e34167b9a0fe7f2f333f87ac1a6b66c94df748), 0x0) + check(byte(0x18f76fcc2c24df8c0b6177329e34167b9a0fe7f2f333f87ac1a6b66c94df748, 0x276fd280818d7e858e46f4e43dc70433dff8afb24f559451edaecbb103873855), 0x0) + check(byte(0x18f76fcc2c24df8c0b6177329e34167b9a0fe7f2f333f87ac1a6b66c94df748, 0xc9d108de536b39631e21aa81c0f3e02c2df5e49ec7628625147361ceba089ed2), 0x0) + check(byte(0x18f76fcc2c24df8c0b6177329e34167b9a0fe7f2f333f87ac1a6b66c94df748, 0x16), 0x0) + check(byte(0x18f76fcc2c24df8c0b6177329e34167b9a0fe7f2f333f87ac1a6b66c94df748, 0x9), 0x0) + check(byte(0x18f76fcc2c24df8c0b6177329e34167b9a0fe7f2f333f87ac1a6b66c94df748, 0x1f), 0x0) + check(byte(0x18f76fcc2c24df8c0b6177329e34167b9a0fe7f2f333f87ac1a6b66c94df748, 0x0), 0x0) + check(byte(0x276fd280818d7e858e46f4e43dc70433dff8afb24f559451edaecbb103873855, 0x18f76fcc2c24df8c0b6177329e34167b9a0fe7f2f333f87ac1a6b66c94df748), 0x0) + check(byte(0x276fd280818d7e858e46f4e43dc70433dff8afb24f559451edaecbb103873855, 0x276fd280818d7e858e46f4e43dc70433dff8afb24f559451edaecbb103873855), 0x0) + check(byte(0x276fd280818d7e858e46f4e43dc70433dff8afb24f559451edaecbb103873855, 0xc9d108de536b39631e21aa81c0f3e02c2df5e49ec7628625147361ceba089ed2), 0x0) + check(byte(0x276fd280818d7e858e46f4e43dc70433dff8afb24f559451edaecbb103873855, 0x16), 0x0) + check(byte(0x276fd280818d7e858e46f4e43dc70433dff8afb24f559451edaecbb103873855, 0x9), 0x0) + check(byte(0x276fd280818d7e858e46f4e43dc70433dff8afb24f559451edaecbb103873855, 0x1f), 0x0) + check(byte(0x276fd280818d7e858e46f4e43dc70433dff8afb24f559451edaecbb103873855, 0x0), 0x0) + check(byte(0xc9d108de536b39631e21aa81c0f3e02c2df5e49ec7628625147361ceba089ed2, 0x18f76fcc2c24df8c0b6177329e34167b9a0fe7f2f333f87ac1a6b66c94df748), 0x0) + check(byte(0xc9d108de536b39631e21aa81c0f3e02c2df5e49ec7628625147361ceba089ed2, 0x276fd280818d7e858e46f4e43dc70433dff8afb24f559451edaecbb103873855), 0x0) + check(byte(0xc9d108de536b39631e21aa81c0f3e02c2df5e49ec7628625147361ceba089ed2, 0xc9d108de536b39631e21aa81c0f3e02c2df5e49ec7628625147361ceba089ed2), 0x0) + check(byte(0xc9d108de536b39631e21aa81c0f3e02c2df5e49ec7628625147361ceba089ed2, 0x16), 0x0) + check(byte(0xc9d108de536b39631e21aa81c0f3e02c2df5e49ec7628625147361ceba089ed2, 0x9), 0x0) + check(byte(0xc9d108de536b39631e21aa81c0f3e02c2df5e49ec7628625147361ceba089ed2, 0x1f), 0x0) + check(byte(0xc9d108de536b39631e21aa81c0f3e02c2df5e49ec7628625147361ceba089ed2, 0x0), 0x0) + check(byte(0x16, 0x18f76fcc2c24df8c0b6177329e34167b9a0fe7f2f333f87ac1a6b66c94df748), 0x3f) + check(byte(0x16, 0x276fd280818d7e858e46f4e43dc70433dff8afb24f559451edaecbb103873855), 0x94) + check(byte(0x16, 0xc9d108de536b39631e21aa81c0f3e02c2df5e49ec7628625147361ceba089ed2), 0x86) + check(byte(0x16, 0x16), 0x0) + check(byte(0x16, 0x9), 0x0) + check(byte(0x16, 0x1f), 0x0) + check(byte(0x16, 0x0), 0x0) + check(byte(0x9, 0x18f76fcc2c24df8c0b6177329e34167b9a0fe7f2f333f87ac1a6b66c94df748), 0xb6) + check(byte(0x9, 0x276fd280818d7e858e46f4e43dc70433dff8afb24f559451edaecbb103873855), 0x46) + check(byte(0x9, 0xc9d108de536b39631e21aa81c0f3e02c2df5e49ec7628625147361ceba089ed2), 0x21) + check(byte(0x9, 0x16), 0x0) + check(byte(0x9, 0x9), 0x0) + check(byte(0x9, 0x1f), 0x0) + check(byte(0x9, 0x0), 0x0) + check(byte(0x1f, 0x18f76fcc2c24df8c0b6177329e34167b9a0fe7f2f333f87ac1a6b66c94df748), 0x48) + check(byte(0x1f, 0x276fd280818d7e858e46f4e43dc70433dff8afb24f559451edaecbb103873855), 0x55) + check(byte(0x1f, 0xc9d108de536b39631e21aa81c0f3e02c2df5e49ec7628625147361ceba089ed2), 0xd2) + check(byte(0x1f, 0x16), 0x16) + check(byte(0x1f, 0x9), 0x9) + check(byte(0x1f, 0x1f), 0x1f) + check(byte(0x1f, 0x0), 0x0) + check(byte(0x0, 0x18f76fcc2c24df8c0b6177329e34167b9a0fe7f2f333f87ac1a6b66c94df748), 0x1) + check(byte(0x0, 0x276fd280818d7e858e46f4e43dc70433dff8afb24f559451edaecbb103873855), 0x27) + check(byte(0x0, 0xc9d108de536b39631e21aa81c0f3e02c2df5e49ec7628625147361ceba089ed2), 0xc9) + check(byte(0x0, 0x16), 0x0) + check(byte(0x0, 0x9), 0x0) + check(byte(0x0, 0x1f), 0x0) + check(byte(0x0, 0x0), 0x0) +} +// ==== +// maxTraceSize: 0 +// ---- +// Execution result: ExecutionOk +// Outer most variable values: +// +// Call trace: diff --git a/test/libyul/yulPureInterpreterTests/pure_instructions/div.yul b/test/libyul/yulPureInterpreterTests/pure_instructions/div.yul new file mode 100644 index 000000000000..c301946a8c4f --- /dev/null +++ b/test/libyul/yulPureInterpreterTests/pure_instructions/div.yul @@ -0,0 +1,77 @@ +{ + + function check(a, b) + { if iszero(eq(a, b)) { revert(0, 0) } } + + check(div(0x0, 0x0), 0x0) + check(div(0x0, 0x1), 0x0) + check(div(0x0, 0x2), 0x0) + check(div(0x0, 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff), 0x0) + check(div(0x0, 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe), 0x0) + check(div(0x0, 0x5acb92b7f48611076bb305c9575de90992f9ce2837417f8edccbf8b23ea85629), 0x0) + check(div(0x0, 0x516a5d1b8d8abbe555b0d0dc55c0631335649d6a4aa2959e69615b12cf3b2765), 0x0) + check(div(0x0, 0xfeffde5d91235d255f8bcf4cb367ba6cc8d0135019f7b69766191bf6aaa9ace9), 0x0) + check(div(0x1, 0x0), 0x0) + check(div(0x1, 0x1), 0x1) + check(div(0x1, 0x2), 0x0) + check(div(0x1, 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff), 0x0) + check(div(0x1, 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe), 0x0) + check(div(0x1, 0x5acb92b7f48611076bb305c9575de90992f9ce2837417f8edccbf8b23ea85629), 0x0) + check(div(0x1, 0x516a5d1b8d8abbe555b0d0dc55c0631335649d6a4aa2959e69615b12cf3b2765), 0x0) + check(div(0x1, 0xfeffde5d91235d255f8bcf4cb367ba6cc8d0135019f7b69766191bf6aaa9ace9), 0x0) + check(div(0x2, 0x0), 0x0) + check(div(0x2, 0x1), 0x2) + check(div(0x2, 0x2), 0x1) + check(div(0x2, 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff), 0x0) + check(div(0x2, 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe), 0x0) + check(div(0x2, 0x5acb92b7f48611076bb305c9575de90992f9ce2837417f8edccbf8b23ea85629), 0x0) + check(div(0x2, 0x516a5d1b8d8abbe555b0d0dc55c0631335649d6a4aa2959e69615b12cf3b2765), 0x0) + check(div(0x2, 0xfeffde5d91235d255f8bcf4cb367ba6cc8d0135019f7b69766191bf6aaa9ace9), 0x0) + check(div(0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff, 0x0), 0x0) + check(div(0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff, 0x1), 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff) + check(div(0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff, 0x2), 0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff) + check(div(0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff, 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff), 0x1) + check(div(0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff, 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe), 0x1) + check(div(0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff, 0x5acb92b7f48611076bb305c9575de90992f9ce2837417f8edccbf8b23ea85629), 0x2) + check(div(0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff, 0x516a5d1b8d8abbe555b0d0dc55c0631335649d6a4aa2959e69615b12cf3b2765), 0x3) + check(div(0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff, 0xfeffde5d91235d255f8bcf4cb367ba6cc8d0135019f7b69766191bf6aaa9ace9), 0x1) + check(div(0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe, 0x0), 0x0) + check(div(0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe, 0x1), 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe) + check(div(0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe, 0x2), 0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff) + check(div(0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe, 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff), 0x0) + check(div(0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe, 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe), 0x1) + check(div(0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe, 0x5acb92b7f48611076bb305c9575de90992f9ce2837417f8edccbf8b23ea85629), 0x2) + check(div(0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe, 0x516a5d1b8d8abbe555b0d0dc55c0631335649d6a4aa2959e69615b12cf3b2765), 0x3) + check(div(0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe, 0xfeffde5d91235d255f8bcf4cb367ba6cc8d0135019f7b69766191bf6aaa9ace9), 0x1) + check(div(0x5acb92b7f48611076bb305c9575de90992f9ce2837417f8edccbf8b23ea85629, 0x0), 0x0) + check(div(0x5acb92b7f48611076bb305c9575de90992f9ce2837417f8edccbf8b23ea85629, 0x1), 0x5acb92b7f48611076bb305c9575de90992f9ce2837417f8edccbf8b23ea85629) + check(div(0x5acb92b7f48611076bb305c9575de90992f9ce2837417f8edccbf8b23ea85629, 0x2), 0x2d65c95bfa430883b5d982e4abaef484c97ce7141ba0bfc76e65fc591f542b14) + check(div(0x5acb92b7f48611076bb305c9575de90992f9ce2837417f8edccbf8b23ea85629, 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff), 0x0) + check(div(0x5acb92b7f48611076bb305c9575de90992f9ce2837417f8edccbf8b23ea85629, 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe), 0x0) + check(div(0x5acb92b7f48611076bb305c9575de90992f9ce2837417f8edccbf8b23ea85629, 0x5acb92b7f48611076bb305c9575de90992f9ce2837417f8edccbf8b23ea85629), 0x1) + check(div(0x5acb92b7f48611076bb305c9575de90992f9ce2837417f8edccbf8b23ea85629, 0x516a5d1b8d8abbe555b0d0dc55c0631335649d6a4aa2959e69615b12cf3b2765), 0x1) + check(div(0x5acb92b7f48611076bb305c9575de90992f9ce2837417f8edccbf8b23ea85629, 0xfeffde5d91235d255f8bcf4cb367ba6cc8d0135019f7b69766191bf6aaa9ace9), 0x0) + check(div(0x516a5d1b8d8abbe555b0d0dc55c0631335649d6a4aa2959e69615b12cf3b2765, 0x0), 0x0) + check(div(0x516a5d1b8d8abbe555b0d0dc55c0631335649d6a4aa2959e69615b12cf3b2765, 0x1), 0x516a5d1b8d8abbe555b0d0dc55c0631335649d6a4aa2959e69615b12cf3b2765) + check(div(0x516a5d1b8d8abbe555b0d0dc55c0631335649d6a4aa2959e69615b12cf3b2765, 0x2), 0x28b52e8dc6c55df2aad8686e2ae031899ab24eb525514acf34b0ad89679d93b2) + check(div(0x516a5d1b8d8abbe555b0d0dc55c0631335649d6a4aa2959e69615b12cf3b2765, 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff), 0x0) + check(div(0x516a5d1b8d8abbe555b0d0dc55c0631335649d6a4aa2959e69615b12cf3b2765, 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe), 0x0) + check(div(0x516a5d1b8d8abbe555b0d0dc55c0631335649d6a4aa2959e69615b12cf3b2765, 0x5acb92b7f48611076bb305c9575de90992f9ce2837417f8edccbf8b23ea85629), 0x0) + check(div(0x516a5d1b8d8abbe555b0d0dc55c0631335649d6a4aa2959e69615b12cf3b2765, 0x516a5d1b8d8abbe555b0d0dc55c0631335649d6a4aa2959e69615b12cf3b2765), 0x1) + check(div(0x516a5d1b8d8abbe555b0d0dc55c0631335649d6a4aa2959e69615b12cf3b2765, 0xfeffde5d91235d255f8bcf4cb367ba6cc8d0135019f7b69766191bf6aaa9ace9), 0x0) + check(div(0xfeffde5d91235d255f8bcf4cb367ba6cc8d0135019f7b69766191bf6aaa9ace9, 0x0), 0x0) + check(div(0xfeffde5d91235d255f8bcf4cb367ba6cc8d0135019f7b69766191bf6aaa9ace9, 0x1), 0xfeffde5d91235d255f8bcf4cb367ba6cc8d0135019f7b69766191bf6aaa9ace9) + check(div(0xfeffde5d91235d255f8bcf4cb367ba6cc8d0135019f7b69766191bf6aaa9ace9, 0x2), 0x7f7fef2ec891ae92afc5e7a659b3dd36646809a80cfbdb4bb30c8dfb5554d674) + check(div(0xfeffde5d91235d255f8bcf4cb367ba6cc8d0135019f7b69766191bf6aaa9ace9, 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff), 0x0) + check(div(0xfeffde5d91235d255f8bcf4cb367ba6cc8d0135019f7b69766191bf6aaa9ace9, 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe), 0x0) + check(div(0xfeffde5d91235d255f8bcf4cb367ba6cc8d0135019f7b69766191bf6aaa9ace9, 0x5acb92b7f48611076bb305c9575de90992f9ce2837417f8edccbf8b23ea85629), 0x2) + check(div(0xfeffde5d91235d255f8bcf4cb367ba6cc8d0135019f7b69766191bf6aaa9ace9, 0x516a5d1b8d8abbe555b0d0dc55c0631335649d6a4aa2959e69615b12cf3b2765), 0x3) + check(div(0xfeffde5d91235d255f8bcf4cb367ba6cc8d0135019f7b69766191bf6aaa9ace9, 0xfeffde5d91235d255f8bcf4cb367ba6cc8d0135019f7b69766191bf6aaa9ace9), 0x1) +} +// ==== +// maxTraceSize: 0 +// ---- +// Execution result: ExecutionOk +// Outer most variable values: +// +// Call trace: diff --git a/test/libyul/yulPureInterpreterTests/pure_instructions/eq.yul b/test/libyul/yulPureInterpreterTests/pure_instructions/eq.yul new file mode 100644 index 000000000000..dc7e7bcc5f55 --- /dev/null +++ b/test/libyul/yulPureInterpreterTests/pure_instructions/eq.yul @@ -0,0 +1,77 @@ +{ + + function check(a, b) + { if iszero(eq(a, b)) { revert(0, 0) } } + + check(eq(0x0, 0x0), 0x1) + check(eq(0x0, 0x1), 0x0) + check(eq(0x0, 0x2), 0x0) + check(eq(0x0, 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff), 0x0) + check(eq(0x0, 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe), 0x0) + check(eq(0x0, 0xa9e614c47e6777a0de9ccd00457cc20a5810dc64c0f499184a38466d61dca890), 0x0) + check(eq(0x0, 0x8c6ccdffb1381f9138dcd4556cf958ee8631c9e70503f72a353cec34455e0f40), 0x0) + check(eq(0x0, 0x3f6a583db5987fc749490dfe2d871942995e19867b15d9841aff774e5268d258), 0x0) + check(eq(0x1, 0x0), 0x0) + check(eq(0x1, 0x1), 0x1) + check(eq(0x1, 0x2), 0x0) + check(eq(0x1, 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff), 0x0) + check(eq(0x1, 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe), 0x0) + check(eq(0x1, 0xa9e614c47e6777a0de9ccd00457cc20a5810dc64c0f499184a38466d61dca890), 0x0) + check(eq(0x1, 0x8c6ccdffb1381f9138dcd4556cf958ee8631c9e70503f72a353cec34455e0f40), 0x0) + check(eq(0x1, 0x3f6a583db5987fc749490dfe2d871942995e19867b15d9841aff774e5268d258), 0x0) + check(eq(0x2, 0x0), 0x0) + check(eq(0x2, 0x1), 0x0) + check(eq(0x2, 0x2), 0x1) + check(eq(0x2, 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff), 0x0) + check(eq(0x2, 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe), 0x0) + check(eq(0x2, 0xa9e614c47e6777a0de9ccd00457cc20a5810dc64c0f499184a38466d61dca890), 0x0) + check(eq(0x2, 0x8c6ccdffb1381f9138dcd4556cf958ee8631c9e70503f72a353cec34455e0f40), 0x0) + check(eq(0x2, 0x3f6a583db5987fc749490dfe2d871942995e19867b15d9841aff774e5268d258), 0x0) + check(eq(0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff, 0x0), 0x0) + check(eq(0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff, 0x1), 0x0) + check(eq(0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff, 0x2), 0x0) + check(eq(0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff, 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff), 0x1) + check(eq(0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff, 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe), 0x0) + check(eq(0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff, 0xa9e614c47e6777a0de9ccd00457cc20a5810dc64c0f499184a38466d61dca890), 0x0) + check(eq(0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff, 0x8c6ccdffb1381f9138dcd4556cf958ee8631c9e70503f72a353cec34455e0f40), 0x0) + check(eq(0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff, 0x3f6a583db5987fc749490dfe2d871942995e19867b15d9841aff774e5268d258), 0x0) + check(eq(0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe, 0x0), 0x0) + check(eq(0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe, 0x1), 0x0) + check(eq(0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe, 0x2), 0x0) + check(eq(0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe, 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff), 0x0) + check(eq(0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe, 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe), 0x1) + check(eq(0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe, 0xa9e614c47e6777a0de9ccd00457cc20a5810dc64c0f499184a38466d61dca890), 0x0) + check(eq(0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe, 0x8c6ccdffb1381f9138dcd4556cf958ee8631c9e70503f72a353cec34455e0f40), 0x0) + check(eq(0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe, 0x3f6a583db5987fc749490dfe2d871942995e19867b15d9841aff774e5268d258), 0x0) + check(eq(0xa9e614c47e6777a0de9ccd00457cc20a5810dc64c0f499184a38466d61dca890, 0x0), 0x0) + check(eq(0xa9e614c47e6777a0de9ccd00457cc20a5810dc64c0f499184a38466d61dca890, 0x1), 0x0) + check(eq(0xa9e614c47e6777a0de9ccd00457cc20a5810dc64c0f499184a38466d61dca890, 0x2), 0x0) + check(eq(0xa9e614c47e6777a0de9ccd00457cc20a5810dc64c0f499184a38466d61dca890, 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff), 0x0) + check(eq(0xa9e614c47e6777a0de9ccd00457cc20a5810dc64c0f499184a38466d61dca890, 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe), 0x0) + check(eq(0xa9e614c47e6777a0de9ccd00457cc20a5810dc64c0f499184a38466d61dca890, 0xa9e614c47e6777a0de9ccd00457cc20a5810dc64c0f499184a38466d61dca890), 0x1) + check(eq(0xa9e614c47e6777a0de9ccd00457cc20a5810dc64c0f499184a38466d61dca890, 0x8c6ccdffb1381f9138dcd4556cf958ee8631c9e70503f72a353cec34455e0f40), 0x0) + check(eq(0xa9e614c47e6777a0de9ccd00457cc20a5810dc64c0f499184a38466d61dca890, 0x3f6a583db5987fc749490dfe2d871942995e19867b15d9841aff774e5268d258), 0x0) + check(eq(0x8c6ccdffb1381f9138dcd4556cf958ee8631c9e70503f72a353cec34455e0f40, 0x0), 0x0) + check(eq(0x8c6ccdffb1381f9138dcd4556cf958ee8631c9e70503f72a353cec34455e0f40, 0x1), 0x0) + check(eq(0x8c6ccdffb1381f9138dcd4556cf958ee8631c9e70503f72a353cec34455e0f40, 0x2), 0x0) + check(eq(0x8c6ccdffb1381f9138dcd4556cf958ee8631c9e70503f72a353cec34455e0f40, 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff), 0x0) + check(eq(0x8c6ccdffb1381f9138dcd4556cf958ee8631c9e70503f72a353cec34455e0f40, 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe), 0x0) + check(eq(0x8c6ccdffb1381f9138dcd4556cf958ee8631c9e70503f72a353cec34455e0f40, 0xa9e614c47e6777a0de9ccd00457cc20a5810dc64c0f499184a38466d61dca890), 0x0) + check(eq(0x8c6ccdffb1381f9138dcd4556cf958ee8631c9e70503f72a353cec34455e0f40, 0x8c6ccdffb1381f9138dcd4556cf958ee8631c9e70503f72a353cec34455e0f40), 0x1) + check(eq(0x8c6ccdffb1381f9138dcd4556cf958ee8631c9e70503f72a353cec34455e0f40, 0x3f6a583db5987fc749490dfe2d871942995e19867b15d9841aff774e5268d258), 0x0) + check(eq(0x3f6a583db5987fc749490dfe2d871942995e19867b15d9841aff774e5268d258, 0x0), 0x0) + check(eq(0x3f6a583db5987fc749490dfe2d871942995e19867b15d9841aff774e5268d258, 0x1), 0x0) + check(eq(0x3f6a583db5987fc749490dfe2d871942995e19867b15d9841aff774e5268d258, 0x2), 0x0) + check(eq(0x3f6a583db5987fc749490dfe2d871942995e19867b15d9841aff774e5268d258, 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff), 0x0) + check(eq(0x3f6a583db5987fc749490dfe2d871942995e19867b15d9841aff774e5268d258, 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe), 0x0) + check(eq(0x3f6a583db5987fc749490dfe2d871942995e19867b15d9841aff774e5268d258, 0xa9e614c47e6777a0de9ccd00457cc20a5810dc64c0f499184a38466d61dca890), 0x0) + check(eq(0x3f6a583db5987fc749490dfe2d871942995e19867b15d9841aff774e5268d258, 0x8c6ccdffb1381f9138dcd4556cf958ee8631c9e70503f72a353cec34455e0f40), 0x0) + check(eq(0x3f6a583db5987fc749490dfe2d871942995e19867b15d9841aff774e5268d258, 0x3f6a583db5987fc749490dfe2d871942995e19867b15d9841aff774e5268d258), 0x1) +} +// ==== +// maxTraceSize: 0 +// ---- +// Execution result: ExecutionOk +// Outer most variable values: +// +// Call trace: diff --git a/test/libyul/yulPureInterpreterTests/pure_instructions/exp.yul b/test/libyul/yulPureInterpreterTests/pure_instructions/exp.yul new file mode 100644 index 000000000000..a492c6c5c636 --- /dev/null +++ b/test/libyul/yulPureInterpreterTests/pure_instructions/exp.yul @@ -0,0 +1,77 @@ +{ + + function check(a, b) + { if iszero(eq(a, b)) { revert(0, 0) } } + + check(exp(0x0, 0x0), 0x1) + check(exp(0x0, 0x1), 0x0) + check(exp(0x0, 0x2), 0x0) + check(exp(0x0, 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff), 0x0) + check(exp(0x0, 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe), 0x0) + check(exp(0x0, 0x4e79328d056b56683d768137954334511588e1ab216fd4709f3ebca8dd65019a), 0x0) + check(exp(0x0, 0x9660c1b5529940890a08f75090686376a43a659478af54ad84036a2b1742c9bc), 0x0) + check(exp(0x0, 0x1d4fcee76bd41d8000746c1c28cb2eadcbf4dfc7f1fedb0a69cb220fbe207693), 0x0) + check(exp(0x1, 0x0), 0x1) + check(exp(0x1, 0x1), 0x1) + check(exp(0x1, 0x2), 0x1) + check(exp(0x1, 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff), 0x1) + check(exp(0x1, 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe), 0x1) + check(exp(0x1, 0x4e79328d056b56683d768137954334511588e1ab216fd4709f3ebca8dd65019a), 0x1) + check(exp(0x1, 0x9660c1b5529940890a08f75090686376a43a659478af54ad84036a2b1742c9bc), 0x1) + check(exp(0x1, 0x1d4fcee76bd41d8000746c1c28cb2eadcbf4dfc7f1fedb0a69cb220fbe207693), 0x1) + check(exp(0x2, 0x0), 0x1) + check(exp(0x2, 0x1), 0x2) + check(exp(0x2, 0x2), 0x4) + check(exp(0x2, 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff), 0x0) + check(exp(0x2, 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe), 0x0) + check(exp(0x2, 0x4e79328d056b56683d768137954334511588e1ab216fd4709f3ebca8dd65019a), 0x0) + check(exp(0x2, 0x9660c1b5529940890a08f75090686376a43a659478af54ad84036a2b1742c9bc), 0x0) + check(exp(0x2, 0x1d4fcee76bd41d8000746c1c28cb2eadcbf4dfc7f1fedb0a69cb220fbe207693), 0x0) + check(exp(0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff, 0x0), 0x1) + check(exp(0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff, 0x1), 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff) + check(exp(0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff, 0x2), 0x1) + check(exp(0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff, 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff), 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff) + check(exp(0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff, 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe), 0x1) + check(exp(0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff, 0x4e79328d056b56683d768137954334511588e1ab216fd4709f3ebca8dd65019a), 0x1) + check(exp(0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff, 0x9660c1b5529940890a08f75090686376a43a659478af54ad84036a2b1742c9bc), 0x1) + check(exp(0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff, 0x1d4fcee76bd41d8000746c1c28cb2eadcbf4dfc7f1fedb0a69cb220fbe207693), 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff) + check(exp(0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe, 0x0), 0x1) + check(exp(0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe, 0x1), 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe) + check(exp(0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe, 0x2), 0x4) + check(exp(0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe, 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff), 0x0) + check(exp(0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe, 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe), 0x0) + check(exp(0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe, 0x4e79328d056b56683d768137954334511588e1ab216fd4709f3ebca8dd65019a), 0x0) + check(exp(0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe, 0x9660c1b5529940890a08f75090686376a43a659478af54ad84036a2b1742c9bc), 0x0) + check(exp(0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe, 0x1d4fcee76bd41d8000746c1c28cb2eadcbf4dfc7f1fedb0a69cb220fbe207693), 0x0) + check(exp(0x4e79328d056b56683d768137954334511588e1ab216fd4709f3ebca8dd65019a, 0x0), 0x1) + check(exp(0x4e79328d056b56683d768137954334511588e1ab216fd4709f3ebca8dd65019a, 0x1), 0x4e79328d056b56683d768137954334511588e1ab216fd4709f3ebca8dd65019a) + check(exp(0x4e79328d056b56683d768137954334511588e1ab216fd4709f3ebca8dd65019a, 0x2), 0xb17aeaa2a9c8f5f1d46aa1515d5f3e230f509fe7ca6ba039c0fbd6be278690a4) + check(exp(0x4e79328d056b56683d768137954334511588e1ab216fd4709f3ebca8dd65019a, 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff), 0x0) + check(exp(0x4e79328d056b56683d768137954334511588e1ab216fd4709f3ebca8dd65019a, 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe), 0x0) + check(exp(0x4e79328d056b56683d768137954334511588e1ab216fd4709f3ebca8dd65019a, 0x4e79328d056b56683d768137954334511588e1ab216fd4709f3ebca8dd65019a), 0x0) + check(exp(0x4e79328d056b56683d768137954334511588e1ab216fd4709f3ebca8dd65019a, 0x9660c1b5529940890a08f75090686376a43a659478af54ad84036a2b1742c9bc), 0x0) + check(exp(0x4e79328d056b56683d768137954334511588e1ab216fd4709f3ebca8dd65019a, 0x1d4fcee76bd41d8000746c1c28cb2eadcbf4dfc7f1fedb0a69cb220fbe207693), 0x0) + check(exp(0x9660c1b5529940890a08f75090686376a43a659478af54ad84036a2b1742c9bc, 0x0), 0x1) + check(exp(0x9660c1b5529940890a08f75090686376a43a659478af54ad84036a2b1742c9bc, 0x1), 0x9660c1b5529940890a08f75090686376a43a659478af54ad84036a2b1742c9bc) + check(exp(0x9660c1b5529940890a08f75090686376a43a659478af54ad84036a2b1742c9bc, 0x2), 0xdf116dc43f6b4886976bf644b66644ab5cad4ed96cb72a36bc0486d46be8c210) + check(exp(0x9660c1b5529940890a08f75090686376a43a659478af54ad84036a2b1742c9bc, 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff), 0x0) + check(exp(0x9660c1b5529940890a08f75090686376a43a659478af54ad84036a2b1742c9bc, 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe), 0x0) + check(exp(0x9660c1b5529940890a08f75090686376a43a659478af54ad84036a2b1742c9bc, 0x4e79328d056b56683d768137954334511588e1ab216fd4709f3ebca8dd65019a), 0x0) + check(exp(0x9660c1b5529940890a08f75090686376a43a659478af54ad84036a2b1742c9bc, 0x9660c1b5529940890a08f75090686376a43a659478af54ad84036a2b1742c9bc), 0x0) + check(exp(0x9660c1b5529940890a08f75090686376a43a659478af54ad84036a2b1742c9bc, 0x1d4fcee76bd41d8000746c1c28cb2eadcbf4dfc7f1fedb0a69cb220fbe207693), 0x0) + check(exp(0x1d4fcee76bd41d8000746c1c28cb2eadcbf4dfc7f1fedb0a69cb220fbe207693, 0x0), 0x1) + check(exp(0x1d4fcee76bd41d8000746c1c28cb2eadcbf4dfc7f1fedb0a69cb220fbe207693, 0x1), 0x1d4fcee76bd41d8000746c1c28cb2eadcbf4dfc7f1fedb0a69cb220fbe207693) + check(exp(0x1d4fcee76bd41d8000746c1c28cb2eadcbf4dfc7f1fedb0a69cb220fbe207693, 0x2), 0x669ad199e78968258dc1ae2be39498fa8658b5dc6a931db517a3255a0fabd869) + check(exp(0x1d4fcee76bd41d8000746c1c28cb2eadcbf4dfc7f1fedb0a69cb220fbe207693, 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff), 0x6b794c2d72683939f9b9e84d6b481559bde3d5c30350d1411657dbe7df2b179b) + check(exp(0x1d4fcee76bd41d8000746c1c28cb2eadcbf4dfc7f1fedb0a69cb220fbe207693, 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe), 0xf0208681cb5ff5bf36ad1452abc978c11b97dfb52228b3e6ec0de61afa3f37d9) + check(exp(0x1d4fcee76bd41d8000746c1c28cb2eadcbf4dfc7f1fedb0a69cb220fbe207693, 0x4e79328d056b56683d768137954334511588e1ab216fd4709f3ebca8dd65019a), 0x8f8682f8609105950657f517a2f2c8c36a009c7e8d8d1d26f7333c24d3061ec9) + check(exp(0x1d4fcee76bd41d8000746c1c28cb2eadcbf4dfc7f1fedb0a69cb220fbe207693, 0x9660c1b5529940890a08f75090686376a43a659478af54ad84036a2b1742c9bc), 0x7f34de7e2347950ac013638f82b3943c35e8a7950b6fe59a29d5f12c839f44f1) + check(exp(0x1d4fcee76bd41d8000746c1c28cb2eadcbf4dfc7f1fedb0a69cb220fbe207693, 0x1d4fcee76bd41d8000746c1c28cb2eadcbf4dfc7f1fedb0a69cb220fbe207693), 0x78a7112f259370251244c8bc2d31c0666e71009f1fc5bb97852fd11f93eb310b) +} +// ==== +// maxTraceSize: 0 +// ---- +// Execution result: ExecutionOk +// Outer most variable values: +// +// Call trace: diff --git a/test/libyul/yulPureInterpreterTests/pure_instructions/gt.yul b/test/libyul/yulPureInterpreterTests/pure_instructions/gt.yul new file mode 100644 index 000000000000..1da16455a860 --- /dev/null +++ b/test/libyul/yulPureInterpreterTests/pure_instructions/gt.yul @@ -0,0 +1,77 @@ +{ + + function check(a, b) + { if iszero(eq(a, b)) { revert(0, 0) } } + + check(gt(0x0, 0x0), 0x0) + check(gt(0x0, 0x1), 0x0) + check(gt(0x0, 0x2), 0x0) + check(gt(0x0, 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff), 0x0) + check(gt(0x0, 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe), 0x0) + check(gt(0x0, 0x669fa82c2a1943c7444d775b04a3cb87af6eae8e06150438f3b1c5c6db8ba6a4), 0x0) + check(gt(0x0, 0x7ded92de25172b3ad3c114eb1c8d4a195a9ef32570710d93c182726e5bc76c94), 0x0) + check(gt(0x0, 0x5bd730f3009bdcfe88996a42a2540782725d483b430e9ad5eab0ecd721a3b2bb), 0x0) + check(gt(0x1, 0x0), 0x1) + check(gt(0x1, 0x1), 0x0) + check(gt(0x1, 0x2), 0x0) + check(gt(0x1, 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff), 0x0) + check(gt(0x1, 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe), 0x0) + check(gt(0x1, 0x669fa82c2a1943c7444d775b04a3cb87af6eae8e06150438f3b1c5c6db8ba6a4), 0x0) + check(gt(0x1, 0x7ded92de25172b3ad3c114eb1c8d4a195a9ef32570710d93c182726e5bc76c94), 0x0) + check(gt(0x1, 0x5bd730f3009bdcfe88996a42a2540782725d483b430e9ad5eab0ecd721a3b2bb), 0x0) + check(gt(0x2, 0x0), 0x1) + check(gt(0x2, 0x1), 0x1) + check(gt(0x2, 0x2), 0x0) + check(gt(0x2, 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff), 0x0) + check(gt(0x2, 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe), 0x0) + check(gt(0x2, 0x669fa82c2a1943c7444d775b04a3cb87af6eae8e06150438f3b1c5c6db8ba6a4), 0x0) + check(gt(0x2, 0x7ded92de25172b3ad3c114eb1c8d4a195a9ef32570710d93c182726e5bc76c94), 0x0) + check(gt(0x2, 0x5bd730f3009bdcfe88996a42a2540782725d483b430e9ad5eab0ecd721a3b2bb), 0x0) + check(gt(0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff, 0x0), 0x1) + check(gt(0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff, 0x1), 0x1) + check(gt(0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff, 0x2), 0x1) + check(gt(0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff, 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff), 0x0) + check(gt(0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff, 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe), 0x1) + check(gt(0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff, 0x669fa82c2a1943c7444d775b04a3cb87af6eae8e06150438f3b1c5c6db8ba6a4), 0x1) + check(gt(0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff, 0x7ded92de25172b3ad3c114eb1c8d4a195a9ef32570710d93c182726e5bc76c94), 0x1) + check(gt(0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff, 0x5bd730f3009bdcfe88996a42a2540782725d483b430e9ad5eab0ecd721a3b2bb), 0x1) + check(gt(0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe, 0x0), 0x1) + check(gt(0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe, 0x1), 0x1) + check(gt(0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe, 0x2), 0x1) + check(gt(0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe, 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff), 0x0) + check(gt(0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe, 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe), 0x0) + check(gt(0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe, 0x669fa82c2a1943c7444d775b04a3cb87af6eae8e06150438f3b1c5c6db8ba6a4), 0x1) + check(gt(0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe, 0x7ded92de25172b3ad3c114eb1c8d4a195a9ef32570710d93c182726e5bc76c94), 0x1) + check(gt(0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe, 0x5bd730f3009bdcfe88996a42a2540782725d483b430e9ad5eab0ecd721a3b2bb), 0x1) + check(gt(0x669fa82c2a1943c7444d775b04a3cb87af6eae8e06150438f3b1c5c6db8ba6a4, 0x0), 0x1) + check(gt(0x669fa82c2a1943c7444d775b04a3cb87af6eae8e06150438f3b1c5c6db8ba6a4, 0x1), 0x1) + check(gt(0x669fa82c2a1943c7444d775b04a3cb87af6eae8e06150438f3b1c5c6db8ba6a4, 0x2), 0x1) + check(gt(0x669fa82c2a1943c7444d775b04a3cb87af6eae8e06150438f3b1c5c6db8ba6a4, 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff), 0x0) + check(gt(0x669fa82c2a1943c7444d775b04a3cb87af6eae8e06150438f3b1c5c6db8ba6a4, 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe), 0x0) + check(gt(0x669fa82c2a1943c7444d775b04a3cb87af6eae8e06150438f3b1c5c6db8ba6a4, 0x669fa82c2a1943c7444d775b04a3cb87af6eae8e06150438f3b1c5c6db8ba6a4), 0x0) + check(gt(0x669fa82c2a1943c7444d775b04a3cb87af6eae8e06150438f3b1c5c6db8ba6a4, 0x7ded92de25172b3ad3c114eb1c8d4a195a9ef32570710d93c182726e5bc76c94), 0x0) + check(gt(0x669fa82c2a1943c7444d775b04a3cb87af6eae8e06150438f3b1c5c6db8ba6a4, 0x5bd730f3009bdcfe88996a42a2540782725d483b430e9ad5eab0ecd721a3b2bb), 0x1) + check(gt(0x7ded92de25172b3ad3c114eb1c8d4a195a9ef32570710d93c182726e5bc76c94, 0x0), 0x1) + check(gt(0x7ded92de25172b3ad3c114eb1c8d4a195a9ef32570710d93c182726e5bc76c94, 0x1), 0x1) + check(gt(0x7ded92de25172b3ad3c114eb1c8d4a195a9ef32570710d93c182726e5bc76c94, 0x2), 0x1) + check(gt(0x7ded92de25172b3ad3c114eb1c8d4a195a9ef32570710d93c182726e5bc76c94, 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff), 0x0) + check(gt(0x7ded92de25172b3ad3c114eb1c8d4a195a9ef32570710d93c182726e5bc76c94, 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe), 0x0) + check(gt(0x7ded92de25172b3ad3c114eb1c8d4a195a9ef32570710d93c182726e5bc76c94, 0x669fa82c2a1943c7444d775b04a3cb87af6eae8e06150438f3b1c5c6db8ba6a4), 0x1) + check(gt(0x7ded92de25172b3ad3c114eb1c8d4a195a9ef32570710d93c182726e5bc76c94, 0x7ded92de25172b3ad3c114eb1c8d4a195a9ef32570710d93c182726e5bc76c94), 0x0) + check(gt(0x7ded92de25172b3ad3c114eb1c8d4a195a9ef32570710d93c182726e5bc76c94, 0x5bd730f3009bdcfe88996a42a2540782725d483b430e9ad5eab0ecd721a3b2bb), 0x1) + check(gt(0x5bd730f3009bdcfe88996a42a2540782725d483b430e9ad5eab0ecd721a3b2bb, 0x0), 0x1) + check(gt(0x5bd730f3009bdcfe88996a42a2540782725d483b430e9ad5eab0ecd721a3b2bb, 0x1), 0x1) + check(gt(0x5bd730f3009bdcfe88996a42a2540782725d483b430e9ad5eab0ecd721a3b2bb, 0x2), 0x1) + check(gt(0x5bd730f3009bdcfe88996a42a2540782725d483b430e9ad5eab0ecd721a3b2bb, 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff), 0x0) + check(gt(0x5bd730f3009bdcfe88996a42a2540782725d483b430e9ad5eab0ecd721a3b2bb, 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe), 0x0) + check(gt(0x5bd730f3009bdcfe88996a42a2540782725d483b430e9ad5eab0ecd721a3b2bb, 0x669fa82c2a1943c7444d775b04a3cb87af6eae8e06150438f3b1c5c6db8ba6a4), 0x0) + check(gt(0x5bd730f3009bdcfe88996a42a2540782725d483b430e9ad5eab0ecd721a3b2bb, 0x7ded92de25172b3ad3c114eb1c8d4a195a9ef32570710d93c182726e5bc76c94), 0x0) + check(gt(0x5bd730f3009bdcfe88996a42a2540782725d483b430e9ad5eab0ecd721a3b2bb, 0x5bd730f3009bdcfe88996a42a2540782725d483b430e9ad5eab0ecd721a3b2bb), 0x0) +} +// ==== +// maxTraceSize: 0 +// ---- +// Execution result: ExecutionOk +// Outer most variable values: +// +// Call trace: diff --git a/test/libyul/yulPureInterpreterTests/pure_instructions/iszero.yul b/test/libyul/yulPureInterpreterTests/pure_instructions/iszero.yul new file mode 100644 index 000000000000..4dd535dd9003 --- /dev/null +++ b/test/libyul/yulPureInterpreterTests/pure_instructions/iszero.yul @@ -0,0 +1,24 @@ +{ + + function check(a, b) + { if iszero(eq(a, b)) { revert(0, 0) } } + + check(iszero(0x0), 0x1) + check(iszero(0x1), 0x0) + check(iszero(0x2), 0x0) + check(iszero(0x3), 0x0) + check(iszero(0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff), 0x0) + check(iszero(0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe), 0x0) + check(iszero(0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffd), 0x0) + check(iszero(0xdc91451b4d11884662ecce3baf532f24813b65c6e9ff858cb3269bf73ce701a9), 0x0) + check(iszero(0x5a1caa33a14b8f9c03f754609a5eef3932e3c82f2632fb74bb1dc3f5ea044701), 0x0) + check(iszero(0xfe8be50fa47cacbcb36d160b4116bdaef12e1b99ce9ec6d4df90d398aecb34be), 0x0) + check(iszero(0x77652457195e8499212c1a3b87ff6d112cfb377bf4b33eec9f9d7ea95c763b6d), 0x0) +} +// ==== +// maxTraceSize: 0 +// ---- +// Execution result: ExecutionOk +// Outer most variable values: +// +// Call trace: diff --git a/test/libyul/yulPureInterpreterTests/pure_instructions/lt.yul b/test/libyul/yulPureInterpreterTests/pure_instructions/lt.yul new file mode 100644 index 000000000000..3427690e5f75 --- /dev/null +++ b/test/libyul/yulPureInterpreterTests/pure_instructions/lt.yul @@ -0,0 +1,77 @@ +{ + + function check(a, b) + { if iszero(eq(a, b)) { revert(0, 0) } } + + check(lt(0x0, 0x0), 0x0) + check(lt(0x0, 0x1), 0x1) + check(lt(0x0, 0x2), 0x1) + check(lt(0x0, 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff), 0x1) + check(lt(0x0, 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe), 0x1) + check(lt(0x0, 0xae19640f021de5090eeadd850aeeae859a06c5d88963f273287de022ca85d145), 0x1) + check(lt(0x0, 0x152157ed731b1ce9eb9bc7be7ab3990a6a35c553715200196b0c17c558ed0658), 0x1) + check(lt(0x0, 0x2a8f6ec8110a734f8851187a986caa2020da16c031e270b19d0de0edbacacb3b), 0x1) + check(lt(0x1, 0x0), 0x0) + check(lt(0x1, 0x1), 0x0) + check(lt(0x1, 0x2), 0x1) + check(lt(0x1, 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff), 0x1) + check(lt(0x1, 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe), 0x1) + check(lt(0x1, 0xae19640f021de5090eeadd850aeeae859a06c5d88963f273287de022ca85d145), 0x1) + check(lt(0x1, 0x152157ed731b1ce9eb9bc7be7ab3990a6a35c553715200196b0c17c558ed0658), 0x1) + check(lt(0x1, 0x2a8f6ec8110a734f8851187a986caa2020da16c031e270b19d0de0edbacacb3b), 0x1) + check(lt(0x2, 0x0), 0x0) + check(lt(0x2, 0x1), 0x0) + check(lt(0x2, 0x2), 0x0) + check(lt(0x2, 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff), 0x1) + check(lt(0x2, 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe), 0x1) + check(lt(0x2, 0xae19640f021de5090eeadd850aeeae859a06c5d88963f273287de022ca85d145), 0x1) + check(lt(0x2, 0x152157ed731b1ce9eb9bc7be7ab3990a6a35c553715200196b0c17c558ed0658), 0x1) + check(lt(0x2, 0x2a8f6ec8110a734f8851187a986caa2020da16c031e270b19d0de0edbacacb3b), 0x1) + check(lt(0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff, 0x0), 0x0) + check(lt(0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff, 0x1), 0x0) + check(lt(0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff, 0x2), 0x0) + check(lt(0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff, 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff), 0x0) + check(lt(0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff, 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe), 0x0) + check(lt(0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff, 0xae19640f021de5090eeadd850aeeae859a06c5d88963f273287de022ca85d145), 0x0) + check(lt(0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff, 0x152157ed731b1ce9eb9bc7be7ab3990a6a35c553715200196b0c17c558ed0658), 0x0) + check(lt(0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff, 0x2a8f6ec8110a734f8851187a986caa2020da16c031e270b19d0de0edbacacb3b), 0x0) + check(lt(0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe, 0x0), 0x0) + check(lt(0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe, 0x1), 0x0) + check(lt(0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe, 0x2), 0x0) + check(lt(0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe, 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff), 0x1) + check(lt(0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe, 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe), 0x0) + check(lt(0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe, 0xae19640f021de5090eeadd850aeeae859a06c5d88963f273287de022ca85d145), 0x0) + check(lt(0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe, 0x152157ed731b1ce9eb9bc7be7ab3990a6a35c553715200196b0c17c558ed0658), 0x0) + check(lt(0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe, 0x2a8f6ec8110a734f8851187a986caa2020da16c031e270b19d0de0edbacacb3b), 0x0) + check(lt(0xae19640f021de5090eeadd850aeeae859a06c5d88963f273287de022ca85d145, 0x0), 0x0) + check(lt(0xae19640f021de5090eeadd850aeeae859a06c5d88963f273287de022ca85d145, 0x1), 0x0) + check(lt(0xae19640f021de5090eeadd850aeeae859a06c5d88963f273287de022ca85d145, 0x2), 0x0) + check(lt(0xae19640f021de5090eeadd850aeeae859a06c5d88963f273287de022ca85d145, 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff), 0x1) + check(lt(0xae19640f021de5090eeadd850aeeae859a06c5d88963f273287de022ca85d145, 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe), 0x1) + check(lt(0xae19640f021de5090eeadd850aeeae859a06c5d88963f273287de022ca85d145, 0xae19640f021de5090eeadd850aeeae859a06c5d88963f273287de022ca85d145), 0x0) + check(lt(0xae19640f021de5090eeadd850aeeae859a06c5d88963f273287de022ca85d145, 0x152157ed731b1ce9eb9bc7be7ab3990a6a35c553715200196b0c17c558ed0658), 0x0) + check(lt(0xae19640f021de5090eeadd850aeeae859a06c5d88963f273287de022ca85d145, 0x2a8f6ec8110a734f8851187a986caa2020da16c031e270b19d0de0edbacacb3b), 0x0) + check(lt(0x152157ed731b1ce9eb9bc7be7ab3990a6a35c553715200196b0c17c558ed0658, 0x0), 0x0) + check(lt(0x152157ed731b1ce9eb9bc7be7ab3990a6a35c553715200196b0c17c558ed0658, 0x1), 0x0) + check(lt(0x152157ed731b1ce9eb9bc7be7ab3990a6a35c553715200196b0c17c558ed0658, 0x2), 0x0) + check(lt(0x152157ed731b1ce9eb9bc7be7ab3990a6a35c553715200196b0c17c558ed0658, 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff), 0x1) + check(lt(0x152157ed731b1ce9eb9bc7be7ab3990a6a35c553715200196b0c17c558ed0658, 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe), 0x1) + check(lt(0x152157ed731b1ce9eb9bc7be7ab3990a6a35c553715200196b0c17c558ed0658, 0xae19640f021de5090eeadd850aeeae859a06c5d88963f273287de022ca85d145), 0x1) + check(lt(0x152157ed731b1ce9eb9bc7be7ab3990a6a35c553715200196b0c17c558ed0658, 0x152157ed731b1ce9eb9bc7be7ab3990a6a35c553715200196b0c17c558ed0658), 0x0) + check(lt(0x152157ed731b1ce9eb9bc7be7ab3990a6a35c553715200196b0c17c558ed0658, 0x2a8f6ec8110a734f8851187a986caa2020da16c031e270b19d0de0edbacacb3b), 0x1) + check(lt(0x2a8f6ec8110a734f8851187a986caa2020da16c031e270b19d0de0edbacacb3b, 0x0), 0x0) + check(lt(0x2a8f6ec8110a734f8851187a986caa2020da16c031e270b19d0de0edbacacb3b, 0x1), 0x0) + check(lt(0x2a8f6ec8110a734f8851187a986caa2020da16c031e270b19d0de0edbacacb3b, 0x2), 0x0) + check(lt(0x2a8f6ec8110a734f8851187a986caa2020da16c031e270b19d0de0edbacacb3b, 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff), 0x1) + check(lt(0x2a8f6ec8110a734f8851187a986caa2020da16c031e270b19d0de0edbacacb3b, 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe), 0x1) + check(lt(0x2a8f6ec8110a734f8851187a986caa2020da16c031e270b19d0de0edbacacb3b, 0xae19640f021de5090eeadd850aeeae859a06c5d88963f273287de022ca85d145), 0x1) + check(lt(0x2a8f6ec8110a734f8851187a986caa2020da16c031e270b19d0de0edbacacb3b, 0x152157ed731b1ce9eb9bc7be7ab3990a6a35c553715200196b0c17c558ed0658), 0x0) + check(lt(0x2a8f6ec8110a734f8851187a986caa2020da16c031e270b19d0de0edbacacb3b, 0x2a8f6ec8110a734f8851187a986caa2020da16c031e270b19d0de0edbacacb3b), 0x0) +} +// ==== +// maxTraceSize: 0 +// ---- +// Execution result: ExecutionOk +// Outer most variable values: +// +// Call trace: diff --git a/test/libyul/yulPureInterpreterTests/pure_instructions/mod.yul b/test/libyul/yulPureInterpreterTests/pure_instructions/mod.yul new file mode 100644 index 000000000000..2a912548a1a0 --- /dev/null +++ b/test/libyul/yulPureInterpreterTests/pure_instructions/mod.yul @@ -0,0 +1,77 @@ +{ + + function check(a, b) + { if iszero(eq(a, b)) { revert(0, 0) } } + + check(mod(0x0, 0x0), 0x0) + check(mod(0x0, 0x1), 0x0) + check(mod(0x0, 0x2), 0x0) + check(mod(0x0, 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff), 0x0) + check(mod(0x0, 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe), 0x0) + check(mod(0x0, 0x2a0ad2a2c526c97ba4ad007d79af6df3ef119a74c02afb216791c21bb10dafd1), 0x0) + check(mod(0x0, 0xd184776e785b0f2c2a78fe227e43554ae7a004c028571a59a3dafe33cb04426), 0x0) + check(mod(0x0, 0x52ce0c067cce722748d645e39dc8a3d653b26ca8fb6c6d5ef599eb9b3792a07d), 0x0) + check(mod(0x1, 0x0), 0x0) + check(mod(0x1, 0x1), 0x0) + check(mod(0x1, 0x2), 0x1) + check(mod(0x1, 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff), 0x1) + check(mod(0x1, 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe), 0x1) + check(mod(0x1, 0x2a0ad2a2c526c97ba4ad007d79af6df3ef119a74c02afb216791c21bb10dafd1), 0x1) + check(mod(0x1, 0xd184776e785b0f2c2a78fe227e43554ae7a004c028571a59a3dafe33cb04426), 0x1) + check(mod(0x1, 0x52ce0c067cce722748d645e39dc8a3d653b26ca8fb6c6d5ef599eb9b3792a07d), 0x1) + check(mod(0x2, 0x0), 0x0) + check(mod(0x2, 0x1), 0x0) + check(mod(0x2, 0x2), 0x0) + check(mod(0x2, 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff), 0x2) + check(mod(0x2, 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe), 0x2) + check(mod(0x2, 0x2a0ad2a2c526c97ba4ad007d79af6df3ef119a74c02afb216791c21bb10dafd1), 0x2) + check(mod(0x2, 0xd184776e785b0f2c2a78fe227e43554ae7a004c028571a59a3dafe33cb04426), 0x2) + check(mod(0x2, 0x52ce0c067cce722748d645e39dc8a3d653b26ca8fb6c6d5ef599eb9b3792a07d), 0x2) + check(mod(0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff, 0x0), 0x0) + check(mod(0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff, 0x1), 0x0) + check(mod(0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff, 0x2), 0x1) + check(mod(0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff, 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff), 0x0) + check(mod(0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff, 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe), 0x1) + check(mod(0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff, 0x2a0ad2a2c526c97ba4ad007d79af6df3ef119a74c02afb216791c21bb10dafd1), 0x3bf102f6117471a23f1fd0f25e36c48659661437efe1d3792957359d9ade119) + check(mod(0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff, 0xd184776e785b0f2c2a78fe227e43554ae7a004c028571a59a3dafe33cb04426), 0x732b22cd113ddfb8d9052370a100ab70cf1fa5bd01890b58d6bf2227eeaf12d) + check(mod(0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff, 0x52ce0c067cce722748d645e39dc8a3d653b26ca8fb6c6d5ef599eb9b3792a07d), 0x795dbec8994a98a257d2e5526a6147d04e8ba050dbab7e31f323d2e59481e88) + check(mod(0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe, 0x0), 0x0) + check(mod(0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe, 0x1), 0x0) + check(mod(0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe, 0x2), 0x0) + check(mod(0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe, 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff), 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe) + check(mod(0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe, 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe), 0x0) + check(mod(0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe, 0x2a0ad2a2c526c97ba4ad007d79af6df3ef119a74c02afb216791c21bb10dafd1), 0x3bf102f6117471a23f1fd0f25e36c48659661437efe1d3792957359d9ade118) + check(mod(0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe, 0xd184776e785b0f2c2a78fe227e43554ae7a004c028571a59a3dafe33cb04426), 0x732b22cd113ddfb8d9052370a100ab70cf1fa5bd01890b58d6bf2227eeaf12c) + check(mod(0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe, 0x52ce0c067cce722748d645e39dc8a3d653b26ca8fb6c6d5ef599eb9b3792a07d), 0x795dbec8994a98a257d2e5526a6147d04e8ba050dbab7e31f323d2e59481e87) + check(mod(0x2a0ad2a2c526c97ba4ad007d79af6df3ef119a74c02afb216791c21bb10dafd1, 0x0), 0x0) + check(mod(0x2a0ad2a2c526c97ba4ad007d79af6df3ef119a74c02afb216791c21bb10dafd1, 0x1), 0x0) + check(mod(0x2a0ad2a2c526c97ba4ad007d79af6df3ef119a74c02afb216791c21bb10dafd1, 0x2), 0x1) + check(mod(0x2a0ad2a2c526c97ba4ad007d79af6df3ef119a74c02afb216791c21bb10dafd1, 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff), 0x2a0ad2a2c526c97ba4ad007d79af6df3ef119a74c02afb216791c21bb10dafd1) + check(mod(0x2a0ad2a2c526c97ba4ad007d79af6df3ef119a74c02afb216791c21bb10dafd1, 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe), 0x2a0ad2a2c526c97ba4ad007d79af6df3ef119a74c02afb216791c21bb10dafd1) + check(mod(0x2a0ad2a2c526c97ba4ad007d79af6df3ef119a74c02afb216791c21bb10dafd1, 0x2a0ad2a2c526c97ba4ad007d79af6df3ef119a74c02afb216791c21bb10dafd1), 0x0) + check(mod(0x2a0ad2a2c526c97ba4ad007d79af6df3ef119a74c02afb216791c21bb10dafd1, 0xd184776e785b0f2c2a78fe227e43554ae7a004c028571a59a3dafe33cb04426), 0x2c1fc3e0e95b6a35cb650d70202cdf5e3a39990b89aa63098d8b271fafce35f) + check(mod(0x2a0ad2a2c526c97ba4ad007d79af6df3ef119a74c02afb216791c21bb10dafd1, 0x52ce0c067cce722748d645e39dc8a3d653b26ca8fb6c6d5ef599eb9b3792a07d), 0x2a0ad2a2c526c97ba4ad007d79af6df3ef119a74c02afb216791c21bb10dafd1) + check(mod(0xd184776e785b0f2c2a78fe227e43554ae7a004c028571a59a3dafe33cb04426, 0x0), 0x0) + check(mod(0xd184776e785b0f2c2a78fe227e43554ae7a004c028571a59a3dafe33cb04426, 0x1), 0x0) + check(mod(0xd184776e785b0f2c2a78fe227e43554ae7a004c028571a59a3dafe33cb04426, 0x2), 0x0) + check(mod(0xd184776e785b0f2c2a78fe227e43554ae7a004c028571a59a3dafe33cb04426, 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff), 0xd184776e785b0f2c2a78fe227e43554ae7a004c028571a59a3dafe33cb04426) + check(mod(0xd184776e785b0f2c2a78fe227e43554ae7a004c028571a59a3dafe33cb04426, 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe), 0xd184776e785b0f2c2a78fe227e43554ae7a004c028571a59a3dafe33cb04426) + check(mod(0xd184776e785b0f2c2a78fe227e43554ae7a004c028571a59a3dafe33cb04426, 0x2a0ad2a2c526c97ba4ad007d79af6df3ef119a74c02afb216791c21bb10dafd1), 0xd184776e785b0f2c2a78fe227e43554ae7a004c028571a59a3dafe33cb04426) + check(mod(0xd184776e785b0f2c2a78fe227e43554ae7a004c028571a59a3dafe33cb04426, 0xd184776e785b0f2c2a78fe227e43554ae7a004c028571a59a3dafe33cb04426), 0x0) + check(mod(0xd184776e785b0f2c2a78fe227e43554ae7a004c028571a59a3dafe33cb04426, 0x52ce0c067cce722748d645e39dc8a3d653b26ca8fb6c6d5ef599eb9b3792a07d), 0xd184776e785b0f2c2a78fe227e43554ae7a004c028571a59a3dafe33cb04426) + check(mod(0x52ce0c067cce722748d645e39dc8a3d653b26ca8fb6c6d5ef599eb9b3792a07d, 0x0), 0x0) + check(mod(0x52ce0c067cce722748d645e39dc8a3d653b26ca8fb6c6d5ef599eb9b3792a07d, 0x1), 0x0) + check(mod(0x52ce0c067cce722748d645e39dc8a3d653b26ca8fb6c6d5ef599eb9b3792a07d, 0x2), 0x1) + check(mod(0x52ce0c067cce722748d645e39dc8a3d653b26ca8fb6c6d5ef599eb9b3792a07d, 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff), 0x52ce0c067cce722748d645e39dc8a3d653b26ca8fb6c6d5ef599eb9b3792a07d) + check(mod(0x52ce0c067cce722748d645e39dc8a3d653b26ca8fb6c6d5ef599eb9b3792a07d, 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe), 0x52ce0c067cce722748d645e39dc8a3d653b26ca8fb6c6d5ef599eb9b3792a07d) + check(mod(0x52ce0c067cce722748d645e39dc8a3d653b26ca8fb6c6d5ef599eb9b3792a07d, 0x2a0ad2a2c526c97ba4ad007d79af6df3ef119a74c02afb216791c21bb10dafd1), 0x28c33963b7a7a8aba4294566241935e264a0d2343b41723d8e08297f8684f0ac) + check(mod(0x52ce0c067cce722748d645e39dc8a3d653b26ca8fb6c6d5ef599eb9b3792a07d, 0xd184776e785b0f2c2a78fe227e43554ae7a004c028571a59a3dafe33cb04426), 0x43c5f3d0fac4c76b8e8e696ae6f63da3cd66ae0ec4bc37d5827cc47cb710799) + check(mod(0x52ce0c067cce722748d645e39dc8a3d653b26ca8fb6c6d5ef599eb9b3792a07d, 0x52ce0c067cce722748d645e39dc8a3d653b26ca8fb6c6d5ef599eb9b3792a07d), 0x0) +} +// ==== +// maxTraceSize: 0 +// ---- +// Execution result: ExecutionOk +// Outer most variable values: +// +// Call trace: diff --git a/test/libyul/yulPureInterpreterTests/pure_instructions/mul.yul b/test/libyul/yulPureInterpreterTests/pure_instructions/mul.yul new file mode 100644 index 000000000000..2bb51c2bcdfa --- /dev/null +++ b/test/libyul/yulPureInterpreterTests/pure_instructions/mul.yul @@ -0,0 +1,77 @@ +{ + + function check(a, b) + { if iszero(eq(a, b)) { revert(0, 0) } } + + check(mul(0x0, 0x0), 0x0) + check(mul(0x0, 0x1), 0x0) + check(mul(0x0, 0x2), 0x0) + check(mul(0x0, 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff), 0x0) + check(mul(0x0, 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe), 0x0) + check(mul(0x0, 0xd9043b66e7bd96b5e3687767277cfc018556f057abc236f509711b92ea70837a), 0x0) + check(mul(0x0, 0x9946a87b7b01108459e54937008df2c73ad45fc56cf1cf5136ca54cff62bbeb4), 0x0) + check(mul(0x0, 0x35e0faf858e82700044ce3d74f8cd48e15ba3e3cf3a672ff6e9b5c592336db16), 0x0) + check(mul(0x1, 0x0), 0x0) + check(mul(0x1, 0x1), 0x1) + check(mul(0x1, 0x2), 0x2) + check(mul(0x1, 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff), 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff) + check(mul(0x1, 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe), 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe) + check(mul(0x1, 0xd9043b66e7bd96b5e3687767277cfc018556f057abc236f509711b92ea70837a), 0xd9043b66e7bd96b5e3687767277cfc018556f057abc236f509711b92ea70837a) + check(mul(0x1, 0x9946a87b7b01108459e54937008df2c73ad45fc56cf1cf5136ca54cff62bbeb4), 0x9946a87b7b01108459e54937008df2c73ad45fc56cf1cf5136ca54cff62bbeb4) + check(mul(0x1, 0x35e0faf858e82700044ce3d74f8cd48e15ba3e3cf3a672ff6e9b5c592336db16), 0x35e0faf858e82700044ce3d74f8cd48e15ba3e3cf3a672ff6e9b5c592336db16) + check(mul(0x2, 0x0), 0x0) + check(mul(0x2, 0x1), 0x2) + check(mul(0x2, 0x2), 0x4) + check(mul(0x2, 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff), 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe) + check(mul(0x2, 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe), 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc) + check(mul(0x2, 0xd9043b66e7bd96b5e3687767277cfc018556f057abc236f509711b92ea70837a), 0xb20876cdcf7b2d6bc6d0eece4ef9f8030aade0af57846dea12e23725d4e106f4) + check(mul(0x2, 0x9946a87b7b01108459e54937008df2c73ad45fc56cf1cf5136ca54cff62bbeb4), 0x328d50f6f6022108b3ca926e011be58e75a8bf8ad9e39ea26d94a99fec577d68) + check(mul(0x2, 0x35e0faf858e82700044ce3d74f8cd48e15ba3e3cf3a672ff6e9b5c592336db16), 0x6bc1f5f0b1d04e000899c7ae9f19a91c2b747c79e74ce5fedd36b8b2466db62c) + check(mul(0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff, 0x0), 0x0) + check(mul(0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff, 0x1), 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff) + check(mul(0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff, 0x2), 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe) + check(mul(0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff, 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff), 0x1) + check(mul(0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff, 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe), 0x2) + check(mul(0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff, 0xd9043b66e7bd96b5e3687767277cfc018556f057abc236f509711b92ea70837a), 0x26fbc4991842694a1c978898d88303fe7aa90fa8543dc90af68ee46d158f7c86) + check(mul(0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff, 0x9946a87b7b01108459e54937008df2c73ad45fc56cf1cf5136ca54cff62bbeb4), 0x66b9578484feef7ba61ab6c8ff720d38c52ba03a930e30aec935ab3009d4414c) + check(mul(0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff, 0x35e0faf858e82700044ce3d74f8cd48e15ba3e3cf3a672ff6e9b5c592336db16), 0xca1f0507a717d8fffbb31c28b0732b71ea45c1c30c598d009164a3a6dcc924ea) + check(mul(0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe, 0x0), 0x0) + check(mul(0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe, 0x1), 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe) + check(mul(0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe, 0x2), 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc) + check(mul(0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe, 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff), 0x2) + check(mul(0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe, 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe), 0x4) + check(mul(0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe, 0xd9043b66e7bd96b5e3687767277cfc018556f057abc236f509711b92ea70837a), 0x4df789323084d294392f1131b10607fcf5521f50a87b9215ed1dc8da2b1ef90c) + check(mul(0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe, 0x9946a87b7b01108459e54937008df2c73ad45fc56cf1cf5136ca54cff62bbeb4), 0xcd72af0909fddef74c356d91fee41a718a574075261c615d926b566013a88298) + check(mul(0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe, 0x35e0faf858e82700044ce3d74f8cd48e15ba3e3cf3a672ff6e9b5c592336db16), 0x943e0a0f4e2fb1fff766385160e656e3d48b838618b31a0122c9474db99249d4) + check(mul(0xd9043b66e7bd96b5e3687767277cfc018556f057abc236f509711b92ea70837a, 0x0), 0x0) + check(mul(0xd9043b66e7bd96b5e3687767277cfc018556f057abc236f509711b92ea70837a, 0x1), 0xd9043b66e7bd96b5e3687767277cfc018556f057abc236f509711b92ea70837a) + check(mul(0xd9043b66e7bd96b5e3687767277cfc018556f057abc236f509711b92ea70837a, 0x2), 0xb20876cdcf7b2d6bc6d0eece4ef9f8030aade0af57846dea12e23725d4e106f4) + check(mul(0xd9043b66e7bd96b5e3687767277cfc018556f057abc236f509711b92ea70837a, 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff), 0x26fbc4991842694a1c978898d88303fe7aa90fa8543dc90af68ee46d158f7c86) + check(mul(0xd9043b66e7bd96b5e3687767277cfc018556f057abc236f509711b92ea70837a, 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe), 0x4df789323084d294392f1131b10607fcf5521f50a87b9215ed1dc8da2b1ef90c) + check(mul(0xd9043b66e7bd96b5e3687767277cfc018556f057abc236f509711b92ea70837a, 0xd9043b66e7bd96b5e3687767277cfc018556f057abc236f509711b92ea70837a), 0x5e212ad86e15d56a8b8dc59640978d62434da71e22e251daa07794f656461624) + check(mul(0xd9043b66e7bd96b5e3687767277cfc018556f057abc236f509711b92ea70837a, 0x9946a87b7b01108459e54937008df2c73ad45fc56cf1cf5136ca54cff62bbeb4), 0x72b7563189e6fb81a6e0c7e6ac6ae5cf9f65d32c803940a15b56442faa2efdc8) + check(mul(0xd9043b66e7bd96b5e3687767277cfc018556f057abc236f509711b92ea70837a, 0x35e0faf858e82700044ce3d74f8cd48e15ba3e3cf3a672ff6e9b5c592336db16), 0x2c78a699a972d189ec393219bb4f65066d56fdf47055c43b7095704dcfe0aa7c) + check(mul(0x9946a87b7b01108459e54937008df2c73ad45fc56cf1cf5136ca54cff62bbeb4, 0x0), 0x0) + check(mul(0x9946a87b7b01108459e54937008df2c73ad45fc56cf1cf5136ca54cff62bbeb4, 0x1), 0x9946a87b7b01108459e54937008df2c73ad45fc56cf1cf5136ca54cff62bbeb4) + check(mul(0x9946a87b7b01108459e54937008df2c73ad45fc56cf1cf5136ca54cff62bbeb4, 0x2), 0x328d50f6f6022108b3ca926e011be58e75a8bf8ad9e39ea26d94a99fec577d68) + check(mul(0x9946a87b7b01108459e54937008df2c73ad45fc56cf1cf5136ca54cff62bbeb4, 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff), 0x66b9578484feef7ba61ab6c8ff720d38c52ba03a930e30aec935ab3009d4414c) + check(mul(0x9946a87b7b01108459e54937008df2c73ad45fc56cf1cf5136ca54cff62bbeb4, 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe), 0xcd72af0909fddef74c356d91fee41a718a574075261c615d926b566013a88298) + check(mul(0x9946a87b7b01108459e54937008df2c73ad45fc56cf1cf5136ca54cff62bbeb4, 0xd9043b66e7bd96b5e3687767277cfc018556f057abc236f509711b92ea70837a), 0x72b7563189e6fb81a6e0c7e6ac6ae5cf9f65d32c803940a15b56442faa2efdc8) + check(mul(0x9946a87b7b01108459e54937008df2c73ad45fc56cf1cf5136ca54cff62bbeb4, 0x9946a87b7b01108459e54937008df2c73ad45fc56cf1cf5136ca54cff62bbeb4), 0x55fa1bc0326d6284b14f80cb3633885cd52b77b32521d9e1a0aca1138e87ae90) + check(mul(0x9946a87b7b01108459e54937008df2c73ad45fc56cf1cf5136ca54cff62bbeb4, 0x35e0faf858e82700044ce3d74f8cd48e15ba3e3cf3a672ff6e9b5c592336db16), 0xaaaa01c250e883022bf70da9614aa53fd00e10bbbc7bb19e3b31165769de5f78) + check(mul(0x35e0faf858e82700044ce3d74f8cd48e15ba3e3cf3a672ff6e9b5c592336db16, 0x0), 0x0) + check(mul(0x35e0faf858e82700044ce3d74f8cd48e15ba3e3cf3a672ff6e9b5c592336db16, 0x1), 0x35e0faf858e82700044ce3d74f8cd48e15ba3e3cf3a672ff6e9b5c592336db16) + check(mul(0x35e0faf858e82700044ce3d74f8cd48e15ba3e3cf3a672ff6e9b5c592336db16, 0x2), 0x6bc1f5f0b1d04e000899c7ae9f19a91c2b747c79e74ce5fedd36b8b2466db62c) + check(mul(0x35e0faf858e82700044ce3d74f8cd48e15ba3e3cf3a672ff6e9b5c592336db16, 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff), 0xca1f0507a717d8fffbb31c28b0732b71ea45c1c30c598d009164a3a6dcc924ea) + check(mul(0x35e0faf858e82700044ce3d74f8cd48e15ba3e3cf3a672ff6e9b5c592336db16, 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe), 0x943e0a0f4e2fb1fff766385160e656e3d48b838618b31a0122c9474db99249d4) + check(mul(0x35e0faf858e82700044ce3d74f8cd48e15ba3e3cf3a672ff6e9b5c592336db16, 0xd9043b66e7bd96b5e3687767277cfc018556f057abc236f509711b92ea70837a), 0x2c78a699a972d189ec393219bb4f65066d56fdf47055c43b7095704dcfe0aa7c) + check(mul(0x35e0faf858e82700044ce3d74f8cd48e15ba3e3cf3a672ff6e9b5c592336db16, 0x9946a87b7b01108459e54937008df2c73ad45fc56cf1cf5136ca54cff62bbeb4), 0xaaaa01c250e883022bf70da9614aa53fd00e10bbbc7bb19e3b31165769de5f78) + check(mul(0x35e0faf858e82700044ce3d74f8cd48e15ba3e3cf3a672ff6e9b5c592336db16, 0x35e0faf858e82700044ce3d74f8cd48e15ba3e3cf3a672ff6e9b5c592336db16), 0xd9d221a1c3d2f657ff36ba234d8aff13efcc67f6767406e1231830f52cc6a5e4) +} +// ==== +// maxTraceSize: 0 +// ---- +// Execution result: ExecutionOk +// Outer most variable values: +// +// Call trace: diff --git a/test/libyul/yulPureInterpreterTests/pure_instructions/mulmod.yul b/test/libyul/yulPureInterpreterTests/pure_instructions/mulmod.yul new file mode 100644 index 000000000000..d5887ae81993 --- /dev/null +++ b/test/libyul/yulPureInterpreterTests/pure_instructions/mulmod.yul @@ -0,0 +1,77 @@ +{ + + function check(a, b) + { if iszero(eq(a, b)) { revert(0, 0) } } + + check(mulmod(0xf85d65623840a7b39dd45dac05a309059516f59b8a046e896e1a0ed8e4724cac, 0xf85d65623840a7b39dd45dac05a309059516f59b8a046e896e1a0ed8e4724cac, 0xf85d65623840a7b39dd45dac05a309059516f59b8a046e896e1a0ed8e4724cac), 0x0) + check(mulmod(0xf85d65623840a7b39dd45dac05a309059516f59b8a046e896e1a0ed8e4724cac, 0xf85d65623840a7b39dd45dac05a309059516f59b8a046e896e1a0ed8e4724cac, 0x4d0e09c4149b1d571568ae031cb636085e0b262218434cb40a6b1a0645e34118), 0x168054808d0b4226e2f7d20f66d64728fd7734583dd36b66d7966a085cbcfda0) + check(mulmod(0xf85d65623840a7b39dd45dac05a309059516f59b8a046e896e1a0ed8e4724cac, 0xf85d65623840a7b39dd45dac05a309059516f59b8a046e896e1a0ed8e4724cac, 0x58ec5eb8c27553129f2f5e3d6fda36b027315d930e590b0d3a74a7a11cd03cb9), 0x14fc3916121454e5ab8985b6c8045fd2a9c752dc8d0cd64706cfc963b8627024) + check(mulmod(0xf85d65623840a7b39dd45dac05a309059516f59b8a046e896e1a0ed8e4724cac, 0xf85d65623840a7b39dd45dac05a309059516f59b8a046e896e1a0ed8e4724cac, 0x0), 0x0) + check(mulmod(0xf85d65623840a7b39dd45dac05a309059516f59b8a046e896e1a0ed8e4724cac, 0x4d0e09c4149b1d571568ae031cb636085e0b262218434cb40a6b1a0645e34118, 0xf85d65623840a7b39dd45dac05a309059516f59b8a046e896e1a0ed8e4724cac), 0x0) + check(mulmod(0xf85d65623840a7b39dd45dac05a309059516f59b8a046e896e1a0ed8e4724cac, 0x4d0e09c4149b1d571568ae031cb636085e0b262218434cb40a6b1a0645e34118, 0x4d0e09c4149b1d571568ae031cb636085e0b262218434cb40a6b1a0645e34118), 0x0) + check(mulmod(0xf85d65623840a7b39dd45dac05a309059516f59b8a046e896e1a0ed8e4724cac, 0x4d0e09c4149b1d571568ae031cb636085e0b262218434cb40a6b1a0645e34118, 0x58ec5eb8c27553129f2f5e3d6fda36b027315d930e590b0d3a74a7a11cd03cb9), 0x53239a8c18c5fa9453f5afe8c7ecf59e5b7dbb4a7aa4c2f9edd7dd4838eeb0de) + check(mulmod(0xf85d65623840a7b39dd45dac05a309059516f59b8a046e896e1a0ed8e4724cac, 0x4d0e09c4149b1d571568ae031cb636085e0b262218434cb40a6b1a0645e34118, 0x0), 0x0) + check(mulmod(0xf85d65623840a7b39dd45dac05a309059516f59b8a046e896e1a0ed8e4724cac, 0x58ec5eb8c27553129f2f5e3d6fda36b027315d930e590b0d3a74a7a11cd03cb9, 0xf85d65623840a7b39dd45dac05a309059516f59b8a046e896e1a0ed8e4724cac), 0x0) + check(mulmod(0xf85d65623840a7b39dd45dac05a309059516f59b8a046e896e1a0ed8e4724cac, 0x58ec5eb8c27553129f2f5e3d6fda36b027315d930e590b0d3a74a7a11cd03cb9, 0x4d0e09c4149b1d571568ae031cb636085e0b262218434cb40a6b1a0645e34118), 0x424eb1213861699d29b2da1027f6aea380d49af89b36be4d470a68b72e34cc2c) + check(mulmod(0xf85d65623840a7b39dd45dac05a309059516f59b8a046e896e1a0ed8e4724cac, 0x58ec5eb8c27553129f2f5e3d6fda36b027315d930e590b0d3a74a7a11cd03cb9, 0x58ec5eb8c27553129f2f5e3d6fda36b027315d930e590b0d3a74a7a11cd03cb9), 0x0) + check(mulmod(0xf85d65623840a7b39dd45dac05a309059516f59b8a046e896e1a0ed8e4724cac, 0x58ec5eb8c27553129f2f5e3d6fda36b027315d930e590b0d3a74a7a11cd03cb9, 0x0), 0x0) + check(mulmod(0xf85d65623840a7b39dd45dac05a309059516f59b8a046e896e1a0ed8e4724cac, 0x0, 0xf85d65623840a7b39dd45dac05a309059516f59b8a046e896e1a0ed8e4724cac), 0x0) + check(mulmod(0xf85d65623840a7b39dd45dac05a309059516f59b8a046e896e1a0ed8e4724cac, 0x0, 0x4d0e09c4149b1d571568ae031cb636085e0b262218434cb40a6b1a0645e34118), 0x0) + check(mulmod(0xf85d65623840a7b39dd45dac05a309059516f59b8a046e896e1a0ed8e4724cac, 0x0, 0x58ec5eb8c27553129f2f5e3d6fda36b027315d930e590b0d3a74a7a11cd03cb9), 0x0) + check(mulmod(0xf85d65623840a7b39dd45dac05a309059516f59b8a046e896e1a0ed8e4724cac, 0x0, 0x0), 0x0) + check(mulmod(0x4d0e09c4149b1d571568ae031cb636085e0b262218434cb40a6b1a0645e34118, 0xf85d65623840a7b39dd45dac05a309059516f59b8a046e896e1a0ed8e4724cac, 0xf85d65623840a7b39dd45dac05a309059516f59b8a046e896e1a0ed8e4724cac), 0x0) + check(mulmod(0x4d0e09c4149b1d571568ae031cb636085e0b262218434cb40a6b1a0645e34118, 0xf85d65623840a7b39dd45dac05a309059516f59b8a046e896e1a0ed8e4724cac, 0x4d0e09c4149b1d571568ae031cb636085e0b262218434cb40a6b1a0645e34118), 0x0) + check(mulmod(0x4d0e09c4149b1d571568ae031cb636085e0b262218434cb40a6b1a0645e34118, 0xf85d65623840a7b39dd45dac05a309059516f59b8a046e896e1a0ed8e4724cac, 0x58ec5eb8c27553129f2f5e3d6fda36b027315d930e590b0d3a74a7a11cd03cb9), 0x53239a8c18c5fa9453f5afe8c7ecf59e5b7dbb4a7aa4c2f9edd7dd4838eeb0de) + check(mulmod(0x4d0e09c4149b1d571568ae031cb636085e0b262218434cb40a6b1a0645e34118, 0xf85d65623840a7b39dd45dac05a309059516f59b8a046e896e1a0ed8e4724cac, 0x0), 0x0) + check(mulmod(0x4d0e09c4149b1d571568ae031cb636085e0b262218434cb40a6b1a0645e34118, 0x4d0e09c4149b1d571568ae031cb636085e0b262218434cb40a6b1a0645e34118, 0xf85d65623840a7b39dd45dac05a309059516f59b8a046e896e1a0ed8e4724cac), 0x521eb72d6d9a85f5f224d67f52fd342fd66eebe8fe610d679833992645442e8) + check(mulmod(0x4d0e09c4149b1d571568ae031cb636085e0b262218434cb40a6b1a0645e34118, 0x4d0e09c4149b1d571568ae031cb636085e0b262218434cb40a6b1a0645e34118, 0x4d0e09c4149b1d571568ae031cb636085e0b262218434cb40a6b1a0645e34118), 0x0) + check(mulmod(0x4d0e09c4149b1d571568ae031cb636085e0b262218434cb40a6b1a0645e34118, 0x4d0e09c4149b1d571568ae031cb636085e0b262218434cb40a6b1a0645e34118, 0x58ec5eb8c27553129f2f5e3d6fda36b027315d930e590b0d3a74a7a11cd03cb9), 0x4cf32ce1ebb97062a7f1962bbb5a94a4509467560ad9267ba07dfd126496b44d) + check(mulmod(0x4d0e09c4149b1d571568ae031cb636085e0b262218434cb40a6b1a0645e34118, 0x4d0e09c4149b1d571568ae031cb636085e0b262218434cb40a6b1a0645e34118, 0x0), 0x0) + check(mulmod(0x4d0e09c4149b1d571568ae031cb636085e0b262218434cb40a6b1a0645e34118, 0x58ec5eb8c27553129f2f5e3d6fda36b027315d930e590b0d3a74a7a11cd03cb9, 0xf85d65623840a7b39dd45dac05a309059516f59b8a046e896e1a0ed8e4724cac), 0xedca0f5f035e9b37e93b80abedf46b7ef6c3083be21e6fd53a25f57a0e040384) + check(mulmod(0x4d0e09c4149b1d571568ae031cb636085e0b262218434cb40a6b1a0645e34118, 0x58ec5eb8c27553129f2f5e3d6fda36b027315d930e590b0d3a74a7a11cd03cb9, 0x4d0e09c4149b1d571568ae031cb636085e0b262218434cb40a6b1a0645e34118), 0x0) + check(mulmod(0x4d0e09c4149b1d571568ae031cb636085e0b262218434cb40a6b1a0645e34118, 0x58ec5eb8c27553129f2f5e3d6fda36b027315d930e590b0d3a74a7a11cd03cb9, 0x58ec5eb8c27553129f2f5e3d6fda36b027315d930e590b0d3a74a7a11cd03cb9), 0x0) + check(mulmod(0x4d0e09c4149b1d571568ae031cb636085e0b262218434cb40a6b1a0645e34118, 0x58ec5eb8c27553129f2f5e3d6fda36b027315d930e590b0d3a74a7a11cd03cb9, 0x0), 0x0) + check(mulmod(0x4d0e09c4149b1d571568ae031cb636085e0b262218434cb40a6b1a0645e34118, 0x0, 0xf85d65623840a7b39dd45dac05a309059516f59b8a046e896e1a0ed8e4724cac), 0x0) + check(mulmod(0x4d0e09c4149b1d571568ae031cb636085e0b262218434cb40a6b1a0645e34118, 0x0, 0x4d0e09c4149b1d571568ae031cb636085e0b262218434cb40a6b1a0645e34118), 0x0) + check(mulmod(0x4d0e09c4149b1d571568ae031cb636085e0b262218434cb40a6b1a0645e34118, 0x0, 0x58ec5eb8c27553129f2f5e3d6fda36b027315d930e590b0d3a74a7a11cd03cb9), 0x0) + check(mulmod(0x4d0e09c4149b1d571568ae031cb636085e0b262218434cb40a6b1a0645e34118, 0x0, 0x0), 0x0) + check(mulmod(0x58ec5eb8c27553129f2f5e3d6fda36b027315d930e590b0d3a74a7a11cd03cb9, 0xf85d65623840a7b39dd45dac05a309059516f59b8a046e896e1a0ed8e4724cac, 0xf85d65623840a7b39dd45dac05a309059516f59b8a046e896e1a0ed8e4724cac), 0x0) + check(mulmod(0x58ec5eb8c27553129f2f5e3d6fda36b027315d930e590b0d3a74a7a11cd03cb9, 0xf85d65623840a7b39dd45dac05a309059516f59b8a046e896e1a0ed8e4724cac, 0x4d0e09c4149b1d571568ae031cb636085e0b262218434cb40a6b1a0645e34118), 0x424eb1213861699d29b2da1027f6aea380d49af89b36be4d470a68b72e34cc2c) + check(mulmod(0x58ec5eb8c27553129f2f5e3d6fda36b027315d930e590b0d3a74a7a11cd03cb9, 0xf85d65623840a7b39dd45dac05a309059516f59b8a046e896e1a0ed8e4724cac, 0x58ec5eb8c27553129f2f5e3d6fda36b027315d930e590b0d3a74a7a11cd03cb9), 0x0) + check(mulmod(0x58ec5eb8c27553129f2f5e3d6fda36b027315d930e590b0d3a74a7a11cd03cb9, 0xf85d65623840a7b39dd45dac05a309059516f59b8a046e896e1a0ed8e4724cac, 0x0), 0x0) + check(mulmod(0x58ec5eb8c27553129f2f5e3d6fda36b027315d930e590b0d3a74a7a11cd03cb9, 0x4d0e09c4149b1d571568ae031cb636085e0b262218434cb40a6b1a0645e34118, 0xf85d65623840a7b39dd45dac05a309059516f59b8a046e896e1a0ed8e4724cac), 0xedca0f5f035e9b37e93b80abedf46b7ef6c3083be21e6fd53a25f57a0e040384) + check(mulmod(0x58ec5eb8c27553129f2f5e3d6fda36b027315d930e590b0d3a74a7a11cd03cb9, 0x4d0e09c4149b1d571568ae031cb636085e0b262218434cb40a6b1a0645e34118, 0x4d0e09c4149b1d571568ae031cb636085e0b262218434cb40a6b1a0645e34118), 0x0) + check(mulmod(0x58ec5eb8c27553129f2f5e3d6fda36b027315d930e590b0d3a74a7a11cd03cb9, 0x4d0e09c4149b1d571568ae031cb636085e0b262218434cb40a6b1a0645e34118, 0x58ec5eb8c27553129f2f5e3d6fda36b027315d930e590b0d3a74a7a11cd03cb9), 0x0) + check(mulmod(0x58ec5eb8c27553129f2f5e3d6fda36b027315d930e590b0d3a74a7a11cd03cb9, 0x4d0e09c4149b1d571568ae031cb636085e0b262218434cb40a6b1a0645e34118, 0x0), 0x0) + check(mulmod(0x58ec5eb8c27553129f2f5e3d6fda36b027315d930e590b0d3a74a7a11cd03cb9, 0x58ec5eb8c27553129f2f5e3d6fda36b027315d930e590b0d3a74a7a11cd03cb9, 0xf85d65623840a7b39dd45dac05a309059516f59b8a046e896e1a0ed8e4724cac), 0x434c7978cc53f57ae0e7c10a07575970cdc89ca7874438066521ef135520988d) + check(mulmod(0x58ec5eb8c27553129f2f5e3d6fda36b027315d930e590b0d3a74a7a11cd03cb9, 0x58ec5eb8c27553129f2f5e3d6fda36b027315d930e590b0d3a74a7a11cd03cb9, 0x4d0e09c4149b1d571568ae031cb636085e0b262218434cb40a6b1a0645e34118), 0x2180c8bb61f74bb31ea694c77ab5b96436c5bf60c350cb227f0f4e194e678d31) + check(mulmod(0x58ec5eb8c27553129f2f5e3d6fda36b027315d930e590b0d3a74a7a11cd03cb9, 0x58ec5eb8c27553129f2f5e3d6fda36b027315d930e590b0d3a74a7a11cd03cb9, 0x58ec5eb8c27553129f2f5e3d6fda36b027315d930e590b0d3a74a7a11cd03cb9), 0x0) + check(mulmod(0x58ec5eb8c27553129f2f5e3d6fda36b027315d930e590b0d3a74a7a11cd03cb9, 0x58ec5eb8c27553129f2f5e3d6fda36b027315d930e590b0d3a74a7a11cd03cb9, 0x0), 0x0) + check(mulmod(0x58ec5eb8c27553129f2f5e3d6fda36b027315d930e590b0d3a74a7a11cd03cb9, 0x0, 0xf85d65623840a7b39dd45dac05a309059516f59b8a046e896e1a0ed8e4724cac), 0x0) + check(mulmod(0x58ec5eb8c27553129f2f5e3d6fda36b027315d930e590b0d3a74a7a11cd03cb9, 0x0, 0x4d0e09c4149b1d571568ae031cb636085e0b262218434cb40a6b1a0645e34118), 0x0) + check(mulmod(0x58ec5eb8c27553129f2f5e3d6fda36b027315d930e590b0d3a74a7a11cd03cb9, 0x0, 0x58ec5eb8c27553129f2f5e3d6fda36b027315d930e590b0d3a74a7a11cd03cb9), 0x0) + check(mulmod(0x58ec5eb8c27553129f2f5e3d6fda36b027315d930e590b0d3a74a7a11cd03cb9, 0x0, 0x0), 0x0) + check(mulmod(0x0, 0xf85d65623840a7b39dd45dac05a309059516f59b8a046e896e1a0ed8e4724cac, 0xf85d65623840a7b39dd45dac05a309059516f59b8a046e896e1a0ed8e4724cac), 0x0) + check(mulmod(0x0, 0xf85d65623840a7b39dd45dac05a309059516f59b8a046e896e1a0ed8e4724cac, 0x4d0e09c4149b1d571568ae031cb636085e0b262218434cb40a6b1a0645e34118), 0x0) + check(mulmod(0x0, 0xf85d65623840a7b39dd45dac05a309059516f59b8a046e896e1a0ed8e4724cac, 0x58ec5eb8c27553129f2f5e3d6fda36b027315d930e590b0d3a74a7a11cd03cb9), 0x0) + check(mulmod(0x0, 0xf85d65623840a7b39dd45dac05a309059516f59b8a046e896e1a0ed8e4724cac, 0x0), 0x0) + check(mulmod(0x0, 0x4d0e09c4149b1d571568ae031cb636085e0b262218434cb40a6b1a0645e34118, 0xf85d65623840a7b39dd45dac05a309059516f59b8a046e896e1a0ed8e4724cac), 0x0) + check(mulmod(0x0, 0x4d0e09c4149b1d571568ae031cb636085e0b262218434cb40a6b1a0645e34118, 0x4d0e09c4149b1d571568ae031cb636085e0b262218434cb40a6b1a0645e34118), 0x0) + check(mulmod(0x0, 0x4d0e09c4149b1d571568ae031cb636085e0b262218434cb40a6b1a0645e34118, 0x58ec5eb8c27553129f2f5e3d6fda36b027315d930e590b0d3a74a7a11cd03cb9), 0x0) + check(mulmod(0x0, 0x4d0e09c4149b1d571568ae031cb636085e0b262218434cb40a6b1a0645e34118, 0x0), 0x0) + check(mulmod(0x0, 0x58ec5eb8c27553129f2f5e3d6fda36b027315d930e590b0d3a74a7a11cd03cb9, 0xf85d65623840a7b39dd45dac05a309059516f59b8a046e896e1a0ed8e4724cac), 0x0) + check(mulmod(0x0, 0x58ec5eb8c27553129f2f5e3d6fda36b027315d930e590b0d3a74a7a11cd03cb9, 0x4d0e09c4149b1d571568ae031cb636085e0b262218434cb40a6b1a0645e34118), 0x0) + check(mulmod(0x0, 0x58ec5eb8c27553129f2f5e3d6fda36b027315d930e590b0d3a74a7a11cd03cb9, 0x58ec5eb8c27553129f2f5e3d6fda36b027315d930e590b0d3a74a7a11cd03cb9), 0x0) + check(mulmod(0x0, 0x58ec5eb8c27553129f2f5e3d6fda36b027315d930e590b0d3a74a7a11cd03cb9, 0x0), 0x0) + check(mulmod(0x0, 0x0, 0xf85d65623840a7b39dd45dac05a309059516f59b8a046e896e1a0ed8e4724cac), 0x0) + check(mulmod(0x0, 0x0, 0x4d0e09c4149b1d571568ae031cb636085e0b262218434cb40a6b1a0645e34118), 0x0) + check(mulmod(0x0, 0x0, 0x58ec5eb8c27553129f2f5e3d6fda36b027315d930e590b0d3a74a7a11cd03cb9), 0x0) + check(mulmod(0x0, 0x0, 0x0), 0x0) +} +// ==== +// maxTraceSize: 0 +// ---- +// Execution result: ExecutionOk +// Outer most variable values: +// +// Call trace: diff --git a/test/libyul/yulPureInterpreterTests/pure_instructions/not.yul b/test/libyul/yulPureInterpreterTests/pure_instructions/not.yul new file mode 100644 index 000000000000..71caf36036cb --- /dev/null +++ b/test/libyul/yulPureInterpreterTests/pure_instructions/not.yul @@ -0,0 +1,24 @@ +{ + + function check(a, b) + { if iszero(eq(a, b)) { revert(0, 0) } } + + check(not(0x0), 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff) + check(not(0x1), 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe) + check(not(0x2), 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffd) + check(not(0x3), 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc) + check(not(0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff), 0x0) + check(not(0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe), 0x1) + check(not(0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffd), 0x2) + check(not(0xb9caa39ea86683d4e096bd6edd32ae3ead3c1b3a5c0c9ff6aaf9f46e9859aa7e), 0x46355c6157997c2b1f69429122cd51c152c3e4c5a3f3600955060b9167a65581) + check(not(0xe4fe151407cfb034d8ec5ae737b2fb264e0b4084b976fa07648d31ec1b1bedcb), 0x1b01eaebf8304fcb2713a518c84d04d9b1f4bf7b468905f89b72ce13e4e41234) + check(not(0xd6bfc8a63b534b270ddfd63ce081db9109bc4355465b6a40b200b01fac47eb4e), 0x29403759c4acb4d8f22029c31f7e246ef643bcaab9a495bf4dff4fe053b814b1) + check(not(0xe40000700672cffea275f0f1a48f6096ffb97924fa63024f6d5411b5a529a84d), 0x1bffff8ff98d30015d8a0f0e5b709f69004686db059cfdb092abee4a5ad657b2) +} +// ==== +// maxTraceSize: 0 +// ---- +// Execution result: ExecutionOk +// Outer most variable values: +// +// Call trace: diff --git a/test/libyul/yulPureInterpreterTests/pure_instructions/or.yul b/test/libyul/yulPureInterpreterTests/pure_instructions/or.yul new file mode 100644 index 000000000000..a06bdde66a2d --- /dev/null +++ b/test/libyul/yulPureInterpreterTests/pure_instructions/or.yul @@ -0,0 +1,77 @@ +{ + + function check(a, b) + { if iszero(eq(a, b)) { revert(0, 0) } } + + check(or(0x0, 0x0), 0x0) + check(or(0x0, 0x1), 0x1) + check(or(0x0, 0x2), 0x2) + check(or(0x0, 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff), 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff) + check(or(0x0, 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe), 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe) + check(or(0x0, 0x3a0cfc00500ce4615f4e646f6f46d94a91965aee97d42b11d18a08b4cd8282f1), 0x3a0cfc00500ce4615f4e646f6f46d94a91965aee97d42b11d18a08b4cd8282f1) + check(or(0x0, 0x915d411255573e314706322157fe09b10a79e3248d7294b7b086968a23791b52), 0x915d411255573e314706322157fe09b10a79e3248d7294b7b086968a23791b52) + check(or(0x0, 0x60dd3763e69e46a40c1aadc179dd63b6f333358e0f2469d4e0fe0468cf0f5cfe), 0x60dd3763e69e46a40c1aadc179dd63b6f333358e0f2469d4e0fe0468cf0f5cfe) + check(or(0x1, 0x0), 0x1) + check(or(0x1, 0x1), 0x1) + check(or(0x1, 0x2), 0x3) + check(or(0x1, 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff), 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff) + check(or(0x1, 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe), 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff) + check(or(0x1, 0x3a0cfc00500ce4615f4e646f6f46d94a91965aee97d42b11d18a08b4cd8282f1), 0x3a0cfc00500ce4615f4e646f6f46d94a91965aee97d42b11d18a08b4cd8282f1) + check(or(0x1, 0x915d411255573e314706322157fe09b10a79e3248d7294b7b086968a23791b52), 0x915d411255573e314706322157fe09b10a79e3248d7294b7b086968a23791b53) + check(or(0x1, 0x60dd3763e69e46a40c1aadc179dd63b6f333358e0f2469d4e0fe0468cf0f5cfe), 0x60dd3763e69e46a40c1aadc179dd63b6f333358e0f2469d4e0fe0468cf0f5cff) + check(or(0x2, 0x0), 0x2) + check(or(0x2, 0x1), 0x3) + check(or(0x2, 0x2), 0x2) + check(or(0x2, 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff), 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff) + check(or(0x2, 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe), 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe) + check(or(0x2, 0x3a0cfc00500ce4615f4e646f6f46d94a91965aee97d42b11d18a08b4cd8282f1), 0x3a0cfc00500ce4615f4e646f6f46d94a91965aee97d42b11d18a08b4cd8282f3) + check(or(0x2, 0x915d411255573e314706322157fe09b10a79e3248d7294b7b086968a23791b52), 0x915d411255573e314706322157fe09b10a79e3248d7294b7b086968a23791b52) + check(or(0x2, 0x60dd3763e69e46a40c1aadc179dd63b6f333358e0f2469d4e0fe0468cf0f5cfe), 0x60dd3763e69e46a40c1aadc179dd63b6f333358e0f2469d4e0fe0468cf0f5cfe) + check(or(0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff, 0x0), 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff) + check(or(0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff, 0x1), 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff) + check(or(0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff, 0x2), 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff) + check(or(0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff, 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff), 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff) + check(or(0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff, 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe), 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff) + check(or(0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff, 0x3a0cfc00500ce4615f4e646f6f46d94a91965aee97d42b11d18a08b4cd8282f1), 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff) + check(or(0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff, 0x915d411255573e314706322157fe09b10a79e3248d7294b7b086968a23791b52), 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff) + check(or(0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff, 0x60dd3763e69e46a40c1aadc179dd63b6f333358e0f2469d4e0fe0468cf0f5cfe), 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff) + check(or(0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe, 0x0), 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe) + check(or(0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe, 0x1), 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff) + check(or(0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe, 0x2), 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe) + check(or(0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe, 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff), 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff) + check(or(0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe, 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe), 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe) + check(or(0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe, 0x3a0cfc00500ce4615f4e646f6f46d94a91965aee97d42b11d18a08b4cd8282f1), 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff) + check(or(0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe, 0x915d411255573e314706322157fe09b10a79e3248d7294b7b086968a23791b52), 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe) + check(or(0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe, 0x60dd3763e69e46a40c1aadc179dd63b6f333358e0f2469d4e0fe0468cf0f5cfe), 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe) + check(or(0x3a0cfc00500ce4615f4e646f6f46d94a91965aee97d42b11d18a08b4cd8282f1, 0x0), 0x3a0cfc00500ce4615f4e646f6f46d94a91965aee97d42b11d18a08b4cd8282f1) + check(or(0x3a0cfc00500ce4615f4e646f6f46d94a91965aee97d42b11d18a08b4cd8282f1, 0x1), 0x3a0cfc00500ce4615f4e646f6f46d94a91965aee97d42b11d18a08b4cd8282f1) + check(or(0x3a0cfc00500ce4615f4e646f6f46d94a91965aee97d42b11d18a08b4cd8282f1, 0x2), 0x3a0cfc00500ce4615f4e646f6f46d94a91965aee97d42b11d18a08b4cd8282f3) + check(or(0x3a0cfc00500ce4615f4e646f6f46d94a91965aee97d42b11d18a08b4cd8282f1, 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff), 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff) + check(or(0x3a0cfc00500ce4615f4e646f6f46d94a91965aee97d42b11d18a08b4cd8282f1, 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe), 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff) + check(or(0x3a0cfc00500ce4615f4e646f6f46d94a91965aee97d42b11d18a08b4cd8282f1, 0x3a0cfc00500ce4615f4e646f6f46d94a91965aee97d42b11d18a08b4cd8282f1), 0x3a0cfc00500ce4615f4e646f6f46d94a91965aee97d42b11d18a08b4cd8282f1) + check(or(0x3a0cfc00500ce4615f4e646f6f46d94a91965aee97d42b11d18a08b4cd8282f1, 0x915d411255573e314706322157fe09b10a79e3248d7294b7b086968a23791b52), 0xbb5dfd12555ffe715f4e766f7ffed9fb9bfffbee9ff6bfb7f18e9ebeeffb9bf3) + check(or(0x3a0cfc00500ce4615f4e646f6f46d94a91965aee97d42b11d18a08b4cd8282f1, 0x60dd3763e69e46a40c1aadc179dd63b6f333358e0f2469d4e0fe0468cf0f5cfe), 0x7addff63f69ee6e55f5eedef7fdffbfef3b77fee9ff46bd5f1fe0cfccf8fdeff) + check(or(0x915d411255573e314706322157fe09b10a79e3248d7294b7b086968a23791b52, 0x0), 0x915d411255573e314706322157fe09b10a79e3248d7294b7b086968a23791b52) + check(or(0x915d411255573e314706322157fe09b10a79e3248d7294b7b086968a23791b52, 0x1), 0x915d411255573e314706322157fe09b10a79e3248d7294b7b086968a23791b53) + check(or(0x915d411255573e314706322157fe09b10a79e3248d7294b7b086968a23791b52, 0x2), 0x915d411255573e314706322157fe09b10a79e3248d7294b7b086968a23791b52) + check(or(0x915d411255573e314706322157fe09b10a79e3248d7294b7b086968a23791b52, 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff), 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff) + check(or(0x915d411255573e314706322157fe09b10a79e3248d7294b7b086968a23791b52, 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe), 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe) + check(or(0x915d411255573e314706322157fe09b10a79e3248d7294b7b086968a23791b52, 0x3a0cfc00500ce4615f4e646f6f46d94a91965aee97d42b11d18a08b4cd8282f1), 0xbb5dfd12555ffe715f4e766f7ffed9fb9bfffbee9ff6bfb7f18e9ebeeffb9bf3) + check(or(0x915d411255573e314706322157fe09b10a79e3248d7294b7b086968a23791b52, 0x915d411255573e314706322157fe09b10a79e3248d7294b7b086968a23791b52), 0x915d411255573e314706322157fe09b10a79e3248d7294b7b086968a23791b52) + check(or(0x915d411255573e314706322157fe09b10a79e3248d7294b7b086968a23791b52, 0x60dd3763e69e46a40c1aadc179dd63b6f333358e0f2469d4e0fe0468cf0f5cfe), 0xf1dd7773f7df7eb54f1ebfe17fff6bb7fb7bf7ae8f76fdf7f0fe96eaef7f5ffe) + check(or(0x60dd3763e69e46a40c1aadc179dd63b6f333358e0f2469d4e0fe0468cf0f5cfe, 0x0), 0x60dd3763e69e46a40c1aadc179dd63b6f333358e0f2469d4e0fe0468cf0f5cfe) + check(or(0x60dd3763e69e46a40c1aadc179dd63b6f333358e0f2469d4e0fe0468cf0f5cfe, 0x1), 0x60dd3763e69e46a40c1aadc179dd63b6f333358e0f2469d4e0fe0468cf0f5cff) + check(or(0x60dd3763e69e46a40c1aadc179dd63b6f333358e0f2469d4e0fe0468cf0f5cfe, 0x2), 0x60dd3763e69e46a40c1aadc179dd63b6f333358e0f2469d4e0fe0468cf0f5cfe) + check(or(0x60dd3763e69e46a40c1aadc179dd63b6f333358e0f2469d4e0fe0468cf0f5cfe, 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff), 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff) + check(or(0x60dd3763e69e46a40c1aadc179dd63b6f333358e0f2469d4e0fe0468cf0f5cfe, 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe), 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe) + check(or(0x60dd3763e69e46a40c1aadc179dd63b6f333358e0f2469d4e0fe0468cf0f5cfe, 0x3a0cfc00500ce4615f4e646f6f46d94a91965aee97d42b11d18a08b4cd8282f1), 0x7addff63f69ee6e55f5eedef7fdffbfef3b77fee9ff46bd5f1fe0cfccf8fdeff) + check(or(0x60dd3763e69e46a40c1aadc179dd63b6f333358e0f2469d4e0fe0468cf0f5cfe, 0x915d411255573e314706322157fe09b10a79e3248d7294b7b086968a23791b52), 0xf1dd7773f7df7eb54f1ebfe17fff6bb7fb7bf7ae8f76fdf7f0fe96eaef7f5ffe) + check(or(0x60dd3763e69e46a40c1aadc179dd63b6f333358e0f2469d4e0fe0468cf0f5cfe, 0x60dd3763e69e46a40c1aadc179dd63b6f333358e0f2469d4e0fe0468cf0f5cfe), 0x60dd3763e69e46a40c1aadc179dd63b6f333358e0f2469d4e0fe0468cf0f5cfe) +} +// ==== +// maxTraceSize: 0 +// ---- +// Execution result: ExecutionOk +// Outer most variable values: +// +// Call trace: diff --git a/test/libyul/yulPureInterpreterTests/pure_instructions/sar.yul b/test/libyul/yulPureInterpreterTests/pure_instructions/sar.yul new file mode 100644 index 000000000000..89821bab93dd --- /dev/null +++ b/test/libyul/yulPureInterpreterTests/pure_instructions/sar.yul @@ -0,0 +1,78 @@ +{ + + function check(a, b) + { if iszero(eq(a, b)) { revert(0, 0) } } + + check(sar(0x0, 0x0), 0x0) + check(sar(0x0, 0x1), 0x1) + check(sar(0x0, 0x2), 0x2) + check(sar(0x0, 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff), 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff) + check(sar(0x0, 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe), 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe) + check(sar(0x0, 0xc949616b57035982327e8bf47b3e083d2d5533c515e9a3538dcdd5ae859c68cb), 0xc949616b57035982327e8bf47b3e083d2d5533c515e9a3538dcdd5ae859c68cb) + check(sar(0x0, 0x5dc978dd71de1a3808d45b538e1c731fc13335f2dbc829aea75b92ad10bc7979), 0x5dc978dd71de1a3808d45b538e1c731fc13335f2dbc829aea75b92ad10bc7979) + check(sar(0x0, 0x7c11c62cefc0b18b2b8c23e44046a0f7f48e2be32bcbc14959b9a929f0d88d9c), 0x7c11c62cefc0b18b2b8c23e44046a0f7f48e2be32bcbc14959b9a929f0d88d9c) + check(sar(0x1, 0x0), 0x0) + check(sar(0x1, 0x1), 0x0) + check(sar(0x1, 0x2), 0x1) + check(sar(0x1, 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff), 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff) + check(sar(0x1, 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe), 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff) + check(sar(0x1, 0xc949616b57035982327e8bf47b3e083d2d5533c515e9a3538dcdd5ae859c68cb), 0xe4a4b0b5ab81acc1193f45fa3d9f041e96aa99e28af4d1a9c6e6ead742ce3465) + check(sar(0x1, 0x5dc978dd71de1a3808d45b538e1c731fc13335f2dbc829aea75b92ad10bc7979), 0x2ee4bc6eb8ef0d1c046a2da9c70e398fe0999af96de414d753adc956885e3cbc) + check(sar(0x1, 0x7c11c62cefc0b18b2b8c23e44046a0f7f48e2be32bcbc14959b9a929f0d88d9c), 0x3e08e31677e058c595c611f22023507bfa4715f195e5e0a4acdcd494f86c46ce) + check(sar(0x2, 0x0), 0x0) + check(sar(0x2, 0x1), 0x0) + check(sar(0x2, 0x2), 0x0) + check(sar(0x2, 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff), 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff) + check(sar(0x2, 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe), 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff) + check(sar(0x2, 0xc949616b57035982327e8bf47b3e083d2d5533c515e9a3538dcdd5ae859c68cb), 0xf252585ad5c0d6608c9fa2fd1ecf820f4b554cf1457a68d4e373756ba1671a32) + check(sar(0x2, 0x5dc978dd71de1a3808d45b538e1c731fc13335f2dbc829aea75b92ad10bc7979), 0x17725e375c77868e023516d4e3871cc7f04ccd7cb6f20a6ba9d6e4ab442f1e5e) + check(sar(0x2, 0x7c11c62cefc0b18b2b8c23e44046a0f7f48e2be32bcbc14959b9a929f0d88d9c), 0x1f04718b3bf02c62cae308f91011a83dfd238af8caf2f052566e6a4a7c362367) + check(sar(0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff, 0x0), 0x0) + check(sar(0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff, 0x1), 0x0) + check(sar(0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff, 0x2), 0x0) + check(sar(0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff, 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff), 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff) + check(sar(0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff, 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe), 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff) + check(sar(0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff, 0xc949616b57035982327e8bf47b3e083d2d5533c515e9a3538dcdd5ae859c68cb), 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff) + check(sar(0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff, 0x5dc978dd71de1a3808d45b538e1c731fc13335f2dbc829aea75b92ad10bc7979), 0x0) + check(sar(0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff, 0x7c11c62cefc0b18b2b8c23e44046a0f7f48e2be32bcbc14959b9a929f0d88d9c), 0x0) + check(sar(0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe, 0x0), 0x0) + check(sar(0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe, 0x1), 0x0) + check(sar(0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe, 0x2), 0x0) + check(sar(0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe, 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff), 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff) + check(sar(0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe, 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe), 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff) + check(sar(0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe, 0xc949616b57035982327e8bf47b3e083d2d5533c515e9a3538dcdd5ae859c68cb), 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff) + check(sar(0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe, 0x5dc978dd71de1a3808d45b538e1c731fc13335f2dbc829aea75b92ad10bc7979), 0x0) + check(sar(0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe, 0x7c11c62cefc0b18b2b8c23e44046a0f7f48e2be32bcbc14959b9a929f0d88d9c), 0x0) + check(sar(0xc949616b57035982327e8bf47b3e083d2d5533c515e9a3538dcdd5ae859c68cb, 0x0), 0x0) + check(sar(0xc949616b57035982327e8bf47b3e083d2d5533c515e9a3538dcdd5ae859c68cb, 0x1), 0x0) + check(sar(0xc949616b57035982327e8bf47b3e083d2d5533c515e9a3538dcdd5ae859c68cb, 0x2), 0x0) + check(sar(0xc949616b57035982327e8bf47b3e083d2d5533c515e9a3538dcdd5ae859c68cb, 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff), 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff) + check(sar(0xc949616b57035982327e8bf47b3e083d2d5533c515e9a3538dcdd5ae859c68cb, 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe), 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff) + check(sar(0xc949616b57035982327e8bf47b3e083d2d5533c515e9a3538dcdd5ae859c68cb, 0xc949616b57035982327e8bf47b3e083d2d5533c515e9a3538dcdd5ae859c68cb), 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff) + check(sar(0xc949616b57035982327e8bf47b3e083d2d5533c515e9a3538dcdd5ae859c68cb, 0x5dc978dd71de1a3808d45b538e1c731fc13335f2dbc829aea75b92ad10bc7979), 0x0) + check(sar(0xc949616b57035982327e8bf47b3e083d2d5533c515e9a3538dcdd5ae859c68cb, 0x7c11c62cefc0b18b2b8c23e44046a0f7f48e2be32bcbc14959b9a929f0d88d9c), 0x0) + check(sar(0x5dc978dd71de1a3808d45b538e1c731fc13335f2dbc829aea75b92ad10bc7979, 0x0), 0x0) + check(sar(0x5dc978dd71de1a3808d45b538e1c731fc13335f2dbc829aea75b92ad10bc7979, 0x1), 0x0) + check(sar(0x5dc978dd71de1a3808d45b538e1c731fc13335f2dbc829aea75b92ad10bc7979, 0x2), 0x0) + check(sar(0x5dc978dd71de1a3808d45b538e1c731fc13335f2dbc829aea75b92ad10bc7979, 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff), 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff) + check(sar(0x5dc978dd71de1a3808d45b538e1c731fc13335f2dbc829aea75b92ad10bc7979, 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe), 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff) + check(sar(0x5dc978dd71de1a3808d45b538e1c731fc13335f2dbc829aea75b92ad10bc7979, 0xc949616b57035982327e8bf47b3e083d2d5533c515e9a3538dcdd5ae859c68cb), 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff) + check(sar(0x5dc978dd71de1a3808d45b538e1c731fc13335f2dbc829aea75b92ad10bc7979, 0x5dc978dd71de1a3808d45b538e1c731fc13335f2dbc829aea75b92ad10bc7979), 0x0) + check(sar(0x5dc978dd71de1a3808d45b538e1c731fc13335f2dbc829aea75b92ad10bc7979, 0x7c11c62cefc0b18b2b8c23e44046a0f7f48e2be32bcbc14959b9a929f0d88d9c), 0x0) + check(sar(0x7c11c62cefc0b18b2b8c23e44046a0f7f48e2be32bcbc14959b9a929f0d88d9c, 0x0), 0x0) + check(sar(0x7c11c62cefc0b18b2b8c23e44046a0f7f48e2be32bcbc14959b9a929f0d88d9c, 0x1), 0x0) + check(sar(0x7c11c62cefc0b18b2b8c23e44046a0f7f48e2be32bcbc14959b9a929f0d88d9c, 0x2), 0x0) + check(sar(0x7c11c62cefc0b18b2b8c23e44046a0f7f48e2be32bcbc14959b9a929f0d88d9c, 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff), 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff) + check(sar(0x7c11c62cefc0b18b2b8c23e44046a0f7f48e2be32bcbc14959b9a929f0d88d9c, 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe), 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff) + check(sar(0x7c11c62cefc0b18b2b8c23e44046a0f7f48e2be32bcbc14959b9a929f0d88d9c, 0xc949616b57035982327e8bf47b3e083d2d5533c515e9a3538dcdd5ae859c68cb), 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff) + check(sar(0x7c11c62cefc0b18b2b8c23e44046a0f7f48e2be32bcbc14959b9a929f0d88d9c, 0x5dc978dd71de1a3808d45b538e1c731fc13335f2dbc829aea75b92ad10bc7979), 0x0) + check(sar(0x7c11c62cefc0b18b2b8c23e44046a0f7f48e2be32bcbc14959b9a929f0d88d9c, 0x7c11c62cefc0b18b2b8c23e44046a0f7f48e2be32bcbc14959b9a929f0d88d9c), 0x0) +} +// ==== +// EVMVersion: >=constantinople +// maxTraceSize: 0 +// ---- +// Execution result: ExecutionOk +// Outer most variable values: +// +// Call trace: diff --git a/test/libyul/yulPureInterpreterTests/pure_instructions/sdiv.yul b/test/libyul/yulPureInterpreterTests/pure_instructions/sdiv.yul new file mode 100644 index 000000000000..241fe9a19099 --- /dev/null +++ b/test/libyul/yulPureInterpreterTests/pure_instructions/sdiv.yul @@ -0,0 +1,77 @@ +{ + + function check(a, b) + { if iszero(eq(a, b)) { revert(0, 0) } } + + check(sdiv(0x0, 0x0), 0x0) + check(sdiv(0x0, 0x1), 0x0) + check(sdiv(0x0, 0x2), 0x0) + check(sdiv(0x0, 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff), 0x0) + check(sdiv(0x0, 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe), 0x0) + check(sdiv(0x0, 0x8dffeaaf28824d5c2e15afc8058c9069a2eab7830f750651303e66b408c8f6c8), 0x0) + check(sdiv(0x0, 0x18d488b3325e2e8d2878459607279736d67c71aa2c7cdab1180636982517d8f6), 0x0) + check(sdiv(0x0, 0xff973021f85311e0ebac0cc346c81d4d2bfa7a56a2534899569b0372ef82b3e5), 0x0) + check(sdiv(0x1, 0x0), 0x0) + check(sdiv(0x1, 0x1), 0x1) + check(sdiv(0x1, 0x2), 0x0) + check(sdiv(0x1, 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff), 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff) + check(sdiv(0x1, 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe), 0x0) + check(sdiv(0x1, 0x8dffeaaf28824d5c2e15afc8058c9069a2eab7830f750651303e66b408c8f6c8), 0x0) + check(sdiv(0x1, 0x18d488b3325e2e8d2878459607279736d67c71aa2c7cdab1180636982517d8f6), 0x0) + check(sdiv(0x1, 0xff973021f85311e0ebac0cc346c81d4d2bfa7a56a2534899569b0372ef82b3e5), 0x0) + check(sdiv(0x2, 0x0), 0x0) + check(sdiv(0x2, 0x1), 0x2) + check(sdiv(0x2, 0x2), 0x1) + check(sdiv(0x2, 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff), 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe) + check(sdiv(0x2, 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe), 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff) + check(sdiv(0x2, 0x8dffeaaf28824d5c2e15afc8058c9069a2eab7830f750651303e66b408c8f6c8), 0x0) + check(sdiv(0x2, 0x18d488b3325e2e8d2878459607279736d67c71aa2c7cdab1180636982517d8f6), 0x0) + check(sdiv(0x2, 0xff973021f85311e0ebac0cc346c81d4d2bfa7a56a2534899569b0372ef82b3e5), 0x0) + check(sdiv(0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff, 0x0), 0x0) + check(sdiv(0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff, 0x1), 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff) + check(sdiv(0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff, 0x2), 0x0) + check(sdiv(0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff, 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff), 0x1) + check(sdiv(0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff, 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe), 0x0) + check(sdiv(0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff, 0x8dffeaaf28824d5c2e15afc8058c9069a2eab7830f750651303e66b408c8f6c8), 0x0) + check(sdiv(0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff, 0x18d488b3325e2e8d2878459607279736d67c71aa2c7cdab1180636982517d8f6), 0x0) + check(sdiv(0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff, 0xff973021f85311e0ebac0cc346c81d4d2bfa7a56a2534899569b0372ef82b3e5), 0x0) + check(sdiv(0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe, 0x0), 0x0) + check(sdiv(0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe, 0x1), 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe) + check(sdiv(0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe, 0x2), 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff) + check(sdiv(0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe, 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff), 0x2) + check(sdiv(0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe, 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe), 0x1) + check(sdiv(0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe, 0x8dffeaaf28824d5c2e15afc8058c9069a2eab7830f750651303e66b408c8f6c8), 0x0) + check(sdiv(0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe, 0x18d488b3325e2e8d2878459607279736d67c71aa2c7cdab1180636982517d8f6), 0x0) + check(sdiv(0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe, 0xff973021f85311e0ebac0cc346c81d4d2bfa7a56a2534899569b0372ef82b3e5), 0x0) + check(sdiv(0x8dffeaaf28824d5c2e15afc8058c9069a2eab7830f750651303e66b408c8f6c8, 0x0), 0x0) + check(sdiv(0x8dffeaaf28824d5c2e15afc8058c9069a2eab7830f750651303e66b408c8f6c8, 0x1), 0x8dffeaaf28824d5c2e15afc8058c9069a2eab7830f750651303e66b408c8f6c8) + check(sdiv(0x8dffeaaf28824d5c2e15afc8058c9069a2eab7830f750651303e66b408c8f6c8, 0x2), 0xc6fff557944126ae170ad7e402c64834d1755bc187ba8328981f335a04647b64) + check(sdiv(0x8dffeaaf28824d5c2e15afc8058c9069a2eab7830f750651303e66b408c8f6c8, 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff), 0x72001550d77db2a3d1ea5037fa736f965d15487cf08af9aecfc1994bf7370938) + check(sdiv(0x8dffeaaf28824d5c2e15afc8058c9069a2eab7830f750651303e66b408c8f6c8, 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe), 0x39000aa86bbed951e8f5281bfd39b7cb2e8aa43e78457cd767e0cca5fb9b849c) + check(sdiv(0x8dffeaaf28824d5c2e15afc8058c9069a2eab7830f750651303e66b408c8f6c8, 0x8dffeaaf28824d5c2e15afc8058c9069a2eab7830f750651303e66b408c8f6c8), 0x1) + check(sdiv(0x8dffeaaf28824d5c2e15afc8058c9069a2eab7830f750651303e66b408c8f6c8, 0x18d488b3325e2e8d2878459607279736d67c71aa2c7cdab1180636982517d8f6), 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc) + check(sdiv(0x8dffeaaf28824d5c2e15afc8058c9069a2eab7830f750651303e66b408c8f6c8, 0xff973021f85311e0ebac0cc346c81d4d2bfa7a56a2534899569b0372ef82b3e5), 0x116) + check(sdiv(0x18d488b3325e2e8d2878459607279736d67c71aa2c7cdab1180636982517d8f6, 0x0), 0x0) + check(sdiv(0x18d488b3325e2e8d2878459607279736d67c71aa2c7cdab1180636982517d8f6, 0x1), 0x18d488b3325e2e8d2878459607279736d67c71aa2c7cdab1180636982517d8f6) + check(sdiv(0x18d488b3325e2e8d2878459607279736d67c71aa2c7cdab1180636982517d8f6, 0x2), 0xc6a4459992f1746943c22cb0393cb9b6b3e38d5163e6d588c031b4c128bec7b) + check(sdiv(0x18d488b3325e2e8d2878459607279736d67c71aa2c7cdab1180636982517d8f6, 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff), 0xe72b774ccda1d172d787ba69f8d868c929838e55d383254ee7f9c967dae8270a) + check(sdiv(0x18d488b3325e2e8d2878459607279736d67c71aa2c7cdab1180636982517d8f6, 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe), 0xf395bba666d0e8b96bc3dd34fc6c346494c1c72ae9c192a773fce4b3ed741385) + check(sdiv(0x18d488b3325e2e8d2878459607279736d67c71aa2c7cdab1180636982517d8f6, 0x8dffeaaf28824d5c2e15afc8058c9069a2eab7830f750651303e66b408c8f6c8), 0x0) + check(sdiv(0x18d488b3325e2e8d2878459607279736d67c71aa2c7cdab1180636982517d8f6, 0x18d488b3325e2e8d2878459607279736d67c71aa2c7cdab1180636982517d8f6), 0x1) + check(sdiv(0x18d488b3325e2e8d2878459607279736d67c71aa2c7cdab1180636982517d8f6, 0xff973021f85311e0ebac0cc346c81d4d2bfa7a56a2534899569b0372ef82b3e5), 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc4) + check(sdiv(0xff973021f85311e0ebac0cc346c81d4d2bfa7a56a2534899569b0372ef82b3e5, 0x0), 0x0) + check(sdiv(0xff973021f85311e0ebac0cc346c81d4d2bfa7a56a2534899569b0372ef82b3e5, 0x1), 0xff973021f85311e0ebac0cc346c81d4d2bfa7a56a2534899569b0372ef82b3e5) + check(sdiv(0xff973021f85311e0ebac0cc346c81d4d2bfa7a56a2534899569b0372ef82b3e5, 0x2), 0xffcb9810fc2988f075d60661a3640ea695fd3d2b5129a44cab4d81b977c159f3) + check(sdiv(0xff973021f85311e0ebac0cc346c81d4d2bfa7a56a2534899569b0372ef82b3e5, 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff), 0x68cfde07acee1f1453f33cb937e2b2d40585a95dacb766a964fc8d107d4c1b) + check(sdiv(0xff973021f85311e0ebac0cc346c81d4d2bfa7a56a2534899569b0372ef82b3e5, 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe), 0x3467ef03d6770f8a29f99e5c9bf1596a02c2d4aed65bb354b27e46883ea60d) + check(sdiv(0xff973021f85311e0ebac0cc346c81d4d2bfa7a56a2534899569b0372ef82b3e5, 0x8dffeaaf28824d5c2e15afc8058c9069a2eab7830f750651303e66b408c8f6c8), 0x0) + check(sdiv(0xff973021f85311e0ebac0cc346c81d4d2bfa7a56a2534899569b0372ef82b3e5, 0x18d488b3325e2e8d2878459607279736d67c71aa2c7cdab1180636982517d8f6), 0x0) + check(sdiv(0xff973021f85311e0ebac0cc346c81d4d2bfa7a56a2534899569b0372ef82b3e5, 0xff973021f85311e0ebac0cc346c81d4d2bfa7a56a2534899569b0372ef82b3e5), 0x1) +} +// ==== +// maxTraceSize: 0 +// ---- +// Execution result: ExecutionOk +// Outer most variable values: +// +// Call trace: diff --git a/test/libyul/yulPureInterpreterTests/pure_instructions/sgt.yul b/test/libyul/yulPureInterpreterTests/pure_instructions/sgt.yul new file mode 100644 index 000000000000..56b422946402 --- /dev/null +++ b/test/libyul/yulPureInterpreterTests/pure_instructions/sgt.yul @@ -0,0 +1,77 @@ +{ + + function check(a, b) + { if iszero(eq(a, b)) { revert(0, 0) } } + + check(sgt(0x0, 0x0), 0x0) + check(sgt(0x0, 0x1), 0x0) + check(sgt(0x0, 0x2), 0x0) + check(sgt(0x0, 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff), 0x1) + check(sgt(0x0, 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe), 0x1) + check(sgt(0x0, 0xc1a8f6ade2306920f87bbaa51747608772d5c66c1d9944c8326ae9262279fcb4), 0x1) + check(sgt(0x0, 0x79a6410ddb1ec06466e380d4d2e2ae4a66c4c6ba06c270868274d037ac6cf53), 0x0) + check(sgt(0x0, 0x7c4c8a3d9eb0f7dc6a89d59dfd710f4ef6fd7a9eea21020eebd16cb1baa50445), 0x0) + check(sgt(0x1, 0x0), 0x1) + check(sgt(0x1, 0x1), 0x0) + check(sgt(0x1, 0x2), 0x0) + check(sgt(0x1, 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff), 0x1) + check(sgt(0x1, 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe), 0x1) + check(sgt(0x1, 0xc1a8f6ade2306920f87bbaa51747608772d5c66c1d9944c8326ae9262279fcb4), 0x1) + check(sgt(0x1, 0x79a6410ddb1ec06466e380d4d2e2ae4a66c4c6ba06c270868274d037ac6cf53), 0x0) + check(sgt(0x1, 0x7c4c8a3d9eb0f7dc6a89d59dfd710f4ef6fd7a9eea21020eebd16cb1baa50445), 0x0) + check(sgt(0x2, 0x0), 0x1) + check(sgt(0x2, 0x1), 0x1) + check(sgt(0x2, 0x2), 0x0) + check(sgt(0x2, 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff), 0x1) + check(sgt(0x2, 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe), 0x1) + check(sgt(0x2, 0xc1a8f6ade2306920f87bbaa51747608772d5c66c1d9944c8326ae9262279fcb4), 0x1) + check(sgt(0x2, 0x79a6410ddb1ec06466e380d4d2e2ae4a66c4c6ba06c270868274d037ac6cf53), 0x0) + check(sgt(0x2, 0x7c4c8a3d9eb0f7dc6a89d59dfd710f4ef6fd7a9eea21020eebd16cb1baa50445), 0x0) + check(sgt(0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff, 0x0), 0x0) + check(sgt(0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff, 0x1), 0x0) + check(sgt(0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff, 0x2), 0x0) + check(sgt(0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff, 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff), 0x0) + check(sgt(0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff, 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe), 0x1) + check(sgt(0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff, 0xc1a8f6ade2306920f87bbaa51747608772d5c66c1d9944c8326ae9262279fcb4), 0x1) + check(sgt(0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff, 0x79a6410ddb1ec06466e380d4d2e2ae4a66c4c6ba06c270868274d037ac6cf53), 0x0) + check(sgt(0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff, 0x7c4c8a3d9eb0f7dc6a89d59dfd710f4ef6fd7a9eea21020eebd16cb1baa50445), 0x0) + check(sgt(0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe, 0x0), 0x0) + check(sgt(0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe, 0x1), 0x0) + check(sgt(0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe, 0x2), 0x0) + check(sgt(0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe, 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff), 0x0) + check(sgt(0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe, 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe), 0x0) + check(sgt(0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe, 0xc1a8f6ade2306920f87bbaa51747608772d5c66c1d9944c8326ae9262279fcb4), 0x1) + check(sgt(0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe, 0x79a6410ddb1ec06466e380d4d2e2ae4a66c4c6ba06c270868274d037ac6cf53), 0x0) + check(sgt(0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe, 0x7c4c8a3d9eb0f7dc6a89d59dfd710f4ef6fd7a9eea21020eebd16cb1baa50445), 0x0) + check(sgt(0xc1a8f6ade2306920f87bbaa51747608772d5c66c1d9944c8326ae9262279fcb4, 0x0), 0x0) + check(sgt(0xc1a8f6ade2306920f87bbaa51747608772d5c66c1d9944c8326ae9262279fcb4, 0x1), 0x0) + check(sgt(0xc1a8f6ade2306920f87bbaa51747608772d5c66c1d9944c8326ae9262279fcb4, 0x2), 0x0) + check(sgt(0xc1a8f6ade2306920f87bbaa51747608772d5c66c1d9944c8326ae9262279fcb4, 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff), 0x0) + check(sgt(0xc1a8f6ade2306920f87bbaa51747608772d5c66c1d9944c8326ae9262279fcb4, 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe), 0x0) + check(sgt(0xc1a8f6ade2306920f87bbaa51747608772d5c66c1d9944c8326ae9262279fcb4, 0xc1a8f6ade2306920f87bbaa51747608772d5c66c1d9944c8326ae9262279fcb4), 0x0) + check(sgt(0xc1a8f6ade2306920f87bbaa51747608772d5c66c1d9944c8326ae9262279fcb4, 0x79a6410ddb1ec06466e380d4d2e2ae4a66c4c6ba06c270868274d037ac6cf53), 0x0) + check(sgt(0xc1a8f6ade2306920f87bbaa51747608772d5c66c1d9944c8326ae9262279fcb4, 0x7c4c8a3d9eb0f7dc6a89d59dfd710f4ef6fd7a9eea21020eebd16cb1baa50445), 0x0) + check(sgt(0x79a6410ddb1ec06466e380d4d2e2ae4a66c4c6ba06c270868274d037ac6cf53, 0x0), 0x1) + check(sgt(0x79a6410ddb1ec06466e380d4d2e2ae4a66c4c6ba06c270868274d037ac6cf53, 0x1), 0x1) + check(sgt(0x79a6410ddb1ec06466e380d4d2e2ae4a66c4c6ba06c270868274d037ac6cf53, 0x2), 0x1) + check(sgt(0x79a6410ddb1ec06466e380d4d2e2ae4a66c4c6ba06c270868274d037ac6cf53, 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff), 0x1) + check(sgt(0x79a6410ddb1ec06466e380d4d2e2ae4a66c4c6ba06c270868274d037ac6cf53, 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe), 0x1) + check(sgt(0x79a6410ddb1ec06466e380d4d2e2ae4a66c4c6ba06c270868274d037ac6cf53, 0xc1a8f6ade2306920f87bbaa51747608772d5c66c1d9944c8326ae9262279fcb4), 0x1) + check(sgt(0x79a6410ddb1ec06466e380d4d2e2ae4a66c4c6ba06c270868274d037ac6cf53, 0x79a6410ddb1ec06466e380d4d2e2ae4a66c4c6ba06c270868274d037ac6cf53), 0x0) + check(sgt(0x79a6410ddb1ec06466e380d4d2e2ae4a66c4c6ba06c270868274d037ac6cf53, 0x7c4c8a3d9eb0f7dc6a89d59dfd710f4ef6fd7a9eea21020eebd16cb1baa50445), 0x0) + check(sgt(0x7c4c8a3d9eb0f7dc6a89d59dfd710f4ef6fd7a9eea21020eebd16cb1baa50445, 0x0), 0x1) + check(sgt(0x7c4c8a3d9eb0f7dc6a89d59dfd710f4ef6fd7a9eea21020eebd16cb1baa50445, 0x1), 0x1) + check(sgt(0x7c4c8a3d9eb0f7dc6a89d59dfd710f4ef6fd7a9eea21020eebd16cb1baa50445, 0x2), 0x1) + check(sgt(0x7c4c8a3d9eb0f7dc6a89d59dfd710f4ef6fd7a9eea21020eebd16cb1baa50445, 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff), 0x1) + check(sgt(0x7c4c8a3d9eb0f7dc6a89d59dfd710f4ef6fd7a9eea21020eebd16cb1baa50445, 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe), 0x1) + check(sgt(0x7c4c8a3d9eb0f7dc6a89d59dfd710f4ef6fd7a9eea21020eebd16cb1baa50445, 0xc1a8f6ade2306920f87bbaa51747608772d5c66c1d9944c8326ae9262279fcb4), 0x1) + check(sgt(0x7c4c8a3d9eb0f7dc6a89d59dfd710f4ef6fd7a9eea21020eebd16cb1baa50445, 0x79a6410ddb1ec06466e380d4d2e2ae4a66c4c6ba06c270868274d037ac6cf53), 0x1) + check(sgt(0x7c4c8a3d9eb0f7dc6a89d59dfd710f4ef6fd7a9eea21020eebd16cb1baa50445, 0x7c4c8a3d9eb0f7dc6a89d59dfd710f4ef6fd7a9eea21020eebd16cb1baa50445), 0x0) +} +// ==== +// maxTraceSize: 0 +// ---- +// Execution result: ExecutionOk +// Outer most variable values: +// +// Call trace: diff --git a/test/libyul/yulPureInterpreterTests/pure_instructions/shl.yul b/test/libyul/yulPureInterpreterTests/pure_instructions/shl.yul new file mode 100644 index 000000000000..d1c4c1a99ad2 --- /dev/null +++ b/test/libyul/yulPureInterpreterTests/pure_instructions/shl.yul @@ -0,0 +1,78 @@ +{ + + function check(a, b) + { if iszero(eq(a, b)) { revert(0, 0) } } + + check(shl(0x0, 0x0), 0x0) + check(shl(0x0, 0x1), 0x1) + check(shl(0x0, 0x2), 0x2) + check(shl(0x0, 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff), 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff) + check(shl(0x0, 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe), 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe) + check(shl(0x0, 0x62f8c068caab79cb893521cb2fee0232d78e96bd1961e9ea7e971c3697cb7e9), 0x62f8c068caab79cb893521cb2fee0232d78e96bd1961e9ea7e971c3697cb7e9) + check(shl(0x0, 0x6325b71ac4b5fed3f416ce9f9c98d56dd79110dc6b6878eeef67f912e44aab6a), 0x6325b71ac4b5fed3f416ce9f9c98d56dd79110dc6b6878eeef67f912e44aab6a) + check(shl(0x0, 0xb0f759ae4a259c828ccb7bf5b6c878c6fe6fc5ad76ee960dac2205f393fbd951), 0xb0f759ae4a259c828ccb7bf5b6c878c6fe6fc5ad76ee960dac2205f393fbd951) + check(shl(0x1, 0x0), 0x0) + check(shl(0x1, 0x1), 0x2) + check(shl(0x1, 0x2), 0x4) + check(shl(0x1, 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff), 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe) + check(shl(0x1, 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe), 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc) + check(shl(0x1, 0x62f8c068caab79cb893521cb2fee0232d78e96bd1961e9ea7e971c3697cb7e9), 0xc5f180d19556f397126a43965fdc0465af1d2d7a32c3d3d4fd2e386d2f96fd2) + check(shl(0x1, 0x6325b71ac4b5fed3f416ce9f9c98d56dd79110dc6b6878eeef67f912e44aab6a), 0xc64b6e35896bfda7e82d9d3f3931aadbaf2221b8d6d0f1dddecff225c89556d4) + check(shl(0x1, 0xb0f759ae4a259c828ccb7bf5b6c878c6fe6fc5ad76ee960dac2205f393fbd951), 0x61eeb35c944b39051996f7eb6d90f18dfcdf8b5aeddd2c1b58440be727f7b2a2) + check(shl(0x2, 0x0), 0x0) + check(shl(0x2, 0x1), 0x4) + check(shl(0x2, 0x2), 0x8) + check(shl(0x2, 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff), 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc) + check(shl(0x2, 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe), 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8) + check(shl(0x2, 0x62f8c068caab79cb893521cb2fee0232d78e96bd1961e9ea7e971c3697cb7e9), 0x18be301a32aade72e24d4872cbfb808cb5e3a5af46587a7a9fa5c70da5f2dfa4) + check(shl(0x2, 0x6325b71ac4b5fed3f416ce9f9c98d56dd79110dc6b6878eeef67f912e44aab6a), 0x8c96dc6b12d7fb4fd05b3a7e726355b75e444371ada1e3bbbd9fe44b912aada8) + check(shl(0x2, 0xb0f759ae4a259c828ccb7bf5b6c878c6fe6fc5ad76ee960dac2205f393fbd951), 0xc3dd66b92896720a332defd6db21e31bf9bf16b5dbba5836b08817ce4fef6544) + check(shl(0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff, 0x0), 0x0) + check(shl(0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff, 0x1), 0x0) + check(shl(0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff, 0x2), 0x0) + check(shl(0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff, 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff), 0x0) + check(shl(0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff, 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe), 0x0) + check(shl(0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff, 0x62f8c068caab79cb893521cb2fee0232d78e96bd1961e9ea7e971c3697cb7e9), 0x0) + check(shl(0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff, 0x6325b71ac4b5fed3f416ce9f9c98d56dd79110dc6b6878eeef67f912e44aab6a), 0x0) + check(shl(0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff, 0xb0f759ae4a259c828ccb7bf5b6c878c6fe6fc5ad76ee960dac2205f393fbd951), 0x0) + check(shl(0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe, 0x0), 0x0) + check(shl(0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe, 0x1), 0x0) + check(shl(0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe, 0x2), 0x0) + check(shl(0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe, 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff), 0x0) + check(shl(0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe, 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe), 0x0) + check(shl(0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe, 0x62f8c068caab79cb893521cb2fee0232d78e96bd1961e9ea7e971c3697cb7e9), 0x0) + check(shl(0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe, 0x6325b71ac4b5fed3f416ce9f9c98d56dd79110dc6b6878eeef67f912e44aab6a), 0x0) + check(shl(0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe, 0xb0f759ae4a259c828ccb7bf5b6c878c6fe6fc5ad76ee960dac2205f393fbd951), 0x0) + check(shl(0x62f8c068caab79cb893521cb2fee0232d78e96bd1961e9ea7e971c3697cb7e9, 0x0), 0x0) + check(shl(0x62f8c068caab79cb893521cb2fee0232d78e96bd1961e9ea7e971c3697cb7e9, 0x1), 0x0) + check(shl(0x62f8c068caab79cb893521cb2fee0232d78e96bd1961e9ea7e971c3697cb7e9, 0x2), 0x0) + check(shl(0x62f8c068caab79cb893521cb2fee0232d78e96bd1961e9ea7e971c3697cb7e9, 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff), 0x0) + check(shl(0x62f8c068caab79cb893521cb2fee0232d78e96bd1961e9ea7e971c3697cb7e9, 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe), 0x0) + check(shl(0x62f8c068caab79cb893521cb2fee0232d78e96bd1961e9ea7e971c3697cb7e9, 0x62f8c068caab79cb893521cb2fee0232d78e96bd1961e9ea7e971c3697cb7e9), 0x0) + check(shl(0x62f8c068caab79cb893521cb2fee0232d78e96bd1961e9ea7e971c3697cb7e9, 0x6325b71ac4b5fed3f416ce9f9c98d56dd79110dc6b6878eeef67f912e44aab6a), 0x0) + check(shl(0x62f8c068caab79cb893521cb2fee0232d78e96bd1961e9ea7e971c3697cb7e9, 0xb0f759ae4a259c828ccb7bf5b6c878c6fe6fc5ad76ee960dac2205f393fbd951), 0x0) + check(shl(0x6325b71ac4b5fed3f416ce9f9c98d56dd79110dc6b6878eeef67f912e44aab6a, 0x0), 0x0) + check(shl(0x6325b71ac4b5fed3f416ce9f9c98d56dd79110dc6b6878eeef67f912e44aab6a, 0x1), 0x0) + check(shl(0x6325b71ac4b5fed3f416ce9f9c98d56dd79110dc6b6878eeef67f912e44aab6a, 0x2), 0x0) + check(shl(0x6325b71ac4b5fed3f416ce9f9c98d56dd79110dc6b6878eeef67f912e44aab6a, 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff), 0x0) + check(shl(0x6325b71ac4b5fed3f416ce9f9c98d56dd79110dc6b6878eeef67f912e44aab6a, 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe), 0x0) + check(shl(0x6325b71ac4b5fed3f416ce9f9c98d56dd79110dc6b6878eeef67f912e44aab6a, 0x62f8c068caab79cb893521cb2fee0232d78e96bd1961e9ea7e971c3697cb7e9), 0x0) + check(shl(0x6325b71ac4b5fed3f416ce9f9c98d56dd79110dc6b6878eeef67f912e44aab6a, 0x6325b71ac4b5fed3f416ce9f9c98d56dd79110dc6b6878eeef67f912e44aab6a), 0x0) + check(shl(0x6325b71ac4b5fed3f416ce9f9c98d56dd79110dc6b6878eeef67f912e44aab6a, 0xb0f759ae4a259c828ccb7bf5b6c878c6fe6fc5ad76ee960dac2205f393fbd951), 0x0) + check(shl(0xb0f759ae4a259c828ccb7bf5b6c878c6fe6fc5ad76ee960dac2205f393fbd951, 0x0), 0x0) + check(shl(0xb0f759ae4a259c828ccb7bf5b6c878c6fe6fc5ad76ee960dac2205f393fbd951, 0x1), 0x0) + check(shl(0xb0f759ae4a259c828ccb7bf5b6c878c6fe6fc5ad76ee960dac2205f393fbd951, 0x2), 0x0) + check(shl(0xb0f759ae4a259c828ccb7bf5b6c878c6fe6fc5ad76ee960dac2205f393fbd951, 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff), 0x0) + check(shl(0xb0f759ae4a259c828ccb7bf5b6c878c6fe6fc5ad76ee960dac2205f393fbd951, 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe), 0x0) + check(shl(0xb0f759ae4a259c828ccb7bf5b6c878c6fe6fc5ad76ee960dac2205f393fbd951, 0x62f8c068caab79cb893521cb2fee0232d78e96bd1961e9ea7e971c3697cb7e9), 0x0) + check(shl(0xb0f759ae4a259c828ccb7bf5b6c878c6fe6fc5ad76ee960dac2205f393fbd951, 0x6325b71ac4b5fed3f416ce9f9c98d56dd79110dc6b6878eeef67f912e44aab6a), 0x0) + check(shl(0xb0f759ae4a259c828ccb7bf5b6c878c6fe6fc5ad76ee960dac2205f393fbd951, 0xb0f759ae4a259c828ccb7bf5b6c878c6fe6fc5ad76ee960dac2205f393fbd951), 0x0) +} +// ==== +// EVMVersion: >=constantinople +// maxTraceSize: 0 +// ---- +// Execution result: ExecutionOk +// Outer most variable values: +// +// Call trace: diff --git a/test/libyul/yulPureInterpreterTests/pure_instructions/shr.yul b/test/libyul/yulPureInterpreterTests/pure_instructions/shr.yul new file mode 100644 index 000000000000..db36f407876b --- /dev/null +++ b/test/libyul/yulPureInterpreterTests/pure_instructions/shr.yul @@ -0,0 +1,78 @@ +{ + + function check(a, b) + { if iszero(eq(a, b)) { revert(0, 0) } } + + check(shr(0x0, 0x0), 0x0) + check(shr(0x0, 0x1), 0x1) + check(shr(0x0, 0x2), 0x2) + check(shr(0x0, 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff), 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff) + check(shr(0x0, 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe), 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe) + check(shr(0x0, 0xb48f5efe223aef7634f4cb07a28ed8567e798fbd568dc42df03c4f8fc7e459d0), 0xb48f5efe223aef7634f4cb07a28ed8567e798fbd568dc42df03c4f8fc7e459d0) + check(shr(0x0, 0xe27e6b3a389771a7ee605306e85d9f786bd2dc482837d0ce1c3c8d1b50d3ebeb), 0xe27e6b3a389771a7ee605306e85d9f786bd2dc482837d0ce1c3c8d1b50d3ebeb) + check(shr(0x0, 0x5170a66a217950da02ef080a4daedc2848e682f3291f982e3e9d1e3fd002b0de), 0x5170a66a217950da02ef080a4daedc2848e682f3291f982e3e9d1e3fd002b0de) + check(shr(0x1, 0x0), 0x0) + check(shr(0x1, 0x1), 0x0) + check(shr(0x1, 0x2), 0x1) + check(shr(0x1, 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff), 0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff) + check(shr(0x1, 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe), 0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff) + check(shr(0x1, 0xb48f5efe223aef7634f4cb07a28ed8567e798fbd568dc42df03c4f8fc7e459d0), 0x5a47af7f111d77bb1a7a6583d1476c2b3f3cc7deab46e216f81e27c7e3f22ce8) + check(shr(0x1, 0xe27e6b3a389771a7ee605306e85d9f786bd2dc482837d0ce1c3c8d1b50d3ebeb), 0x713f359d1c4bb8d3f7302983742ecfbc35e96e24141be8670e1e468da869f5f5) + check(shr(0x1, 0x5170a66a217950da02ef080a4daedc2848e682f3291f982e3e9d1e3fd002b0de), 0x28b8533510bca86d0177840526d76e1424734179948fcc171f4e8f1fe801586f) + check(shr(0x2, 0x0), 0x0) + check(shr(0x2, 0x1), 0x0) + check(shr(0x2, 0x2), 0x0) + check(shr(0x2, 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff), 0x3fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff) + check(shr(0x2, 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe), 0x3fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff) + check(shr(0x2, 0xb48f5efe223aef7634f4cb07a28ed8567e798fbd568dc42df03c4f8fc7e459d0), 0x2d23d7bf888ebbdd8d3d32c1e8a3b6159f9e63ef55a3710b7c0f13e3f1f91674) + check(shr(0x2, 0xe27e6b3a389771a7ee605306e85d9f786bd2dc482837d0ce1c3c8d1b50d3ebeb), 0x389f9ace8e25dc69fb9814c1ba1767de1af4b7120a0df433870f2346d434fafa) + check(shr(0x2, 0x5170a66a217950da02ef080a4daedc2848e682f3291f982e3e9d1e3fd002b0de), 0x145c299a885e543680bbc202936bb70a1239a0bcca47e60b8fa7478ff400ac37) + check(shr(0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff, 0x0), 0x0) + check(shr(0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff, 0x1), 0x0) + check(shr(0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff, 0x2), 0x0) + check(shr(0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff, 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff), 0x0) + check(shr(0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff, 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe), 0x0) + check(shr(0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff, 0xb48f5efe223aef7634f4cb07a28ed8567e798fbd568dc42df03c4f8fc7e459d0), 0x0) + check(shr(0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff, 0xe27e6b3a389771a7ee605306e85d9f786bd2dc482837d0ce1c3c8d1b50d3ebeb), 0x0) + check(shr(0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff, 0x5170a66a217950da02ef080a4daedc2848e682f3291f982e3e9d1e3fd002b0de), 0x0) + check(shr(0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe, 0x0), 0x0) + check(shr(0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe, 0x1), 0x0) + check(shr(0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe, 0x2), 0x0) + check(shr(0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe, 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff), 0x0) + check(shr(0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe, 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe), 0x0) + check(shr(0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe, 0xb48f5efe223aef7634f4cb07a28ed8567e798fbd568dc42df03c4f8fc7e459d0), 0x0) + check(shr(0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe, 0xe27e6b3a389771a7ee605306e85d9f786bd2dc482837d0ce1c3c8d1b50d3ebeb), 0x0) + check(shr(0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe, 0x5170a66a217950da02ef080a4daedc2848e682f3291f982e3e9d1e3fd002b0de), 0x0) + check(shr(0xb48f5efe223aef7634f4cb07a28ed8567e798fbd568dc42df03c4f8fc7e459d0, 0x0), 0x0) + check(shr(0xb48f5efe223aef7634f4cb07a28ed8567e798fbd568dc42df03c4f8fc7e459d0, 0x1), 0x0) + check(shr(0xb48f5efe223aef7634f4cb07a28ed8567e798fbd568dc42df03c4f8fc7e459d0, 0x2), 0x0) + check(shr(0xb48f5efe223aef7634f4cb07a28ed8567e798fbd568dc42df03c4f8fc7e459d0, 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff), 0x0) + check(shr(0xb48f5efe223aef7634f4cb07a28ed8567e798fbd568dc42df03c4f8fc7e459d0, 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe), 0x0) + check(shr(0xb48f5efe223aef7634f4cb07a28ed8567e798fbd568dc42df03c4f8fc7e459d0, 0xb48f5efe223aef7634f4cb07a28ed8567e798fbd568dc42df03c4f8fc7e459d0), 0x0) + check(shr(0xb48f5efe223aef7634f4cb07a28ed8567e798fbd568dc42df03c4f8fc7e459d0, 0xe27e6b3a389771a7ee605306e85d9f786bd2dc482837d0ce1c3c8d1b50d3ebeb), 0x0) + check(shr(0xb48f5efe223aef7634f4cb07a28ed8567e798fbd568dc42df03c4f8fc7e459d0, 0x5170a66a217950da02ef080a4daedc2848e682f3291f982e3e9d1e3fd002b0de), 0x0) + check(shr(0xe27e6b3a389771a7ee605306e85d9f786bd2dc482837d0ce1c3c8d1b50d3ebeb, 0x0), 0x0) + check(shr(0xe27e6b3a389771a7ee605306e85d9f786bd2dc482837d0ce1c3c8d1b50d3ebeb, 0x1), 0x0) + check(shr(0xe27e6b3a389771a7ee605306e85d9f786bd2dc482837d0ce1c3c8d1b50d3ebeb, 0x2), 0x0) + check(shr(0xe27e6b3a389771a7ee605306e85d9f786bd2dc482837d0ce1c3c8d1b50d3ebeb, 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff), 0x0) + check(shr(0xe27e6b3a389771a7ee605306e85d9f786bd2dc482837d0ce1c3c8d1b50d3ebeb, 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe), 0x0) + check(shr(0xe27e6b3a389771a7ee605306e85d9f786bd2dc482837d0ce1c3c8d1b50d3ebeb, 0xb48f5efe223aef7634f4cb07a28ed8567e798fbd568dc42df03c4f8fc7e459d0), 0x0) + check(shr(0xe27e6b3a389771a7ee605306e85d9f786bd2dc482837d0ce1c3c8d1b50d3ebeb, 0xe27e6b3a389771a7ee605306e85d9f786bd2dc482837d0ce1c3c8d1b50d3ebeb), 0x0) + check(shr(0xe27e6b3a389771a7ee605306e85d9f786bd2dc482837d0ce1c3c8d1b50d3ebeb, 0x5170a66a217950da02ef080a4daedc2848e682f3291f982e3e9d1e3fd002b0de), 0x0) + check(shr(0x5170a66a217950da02ef080a4daedc2848e682f3291f982e3e9d1e3fd002b0de, 0x0), 0x0) + check(shr(0x5170a66a217950da02ef080a4daedc2848e682f3291f982e3e9d1e3fd002b0de, 0x1), 0x0) + check(shr(0x5170a66a217950da02ef080a4daedc2848e682f3291f982e3e9d1e3fd002b0de, 0x2), 0x0) + check(shr(0x5170a66a217950da02ef080a4daedc2848e682f3291f982e3e9d1e3fd002b0de, 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff), 0x0) + check(shr(0x5170a66a217950da02ef080a4daedc2848e682f3291f982e3e9d1e3fd002b0de, 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe), 0x0) + check(shr(0x5170a66a217950da02ef080a4daedc2848e682f3291f982e3e9d1e3fd002b0de, 0xb48f5efe223aef7634f4cb07a28ed8567e798fbd568dc42df03c4f8fc7e459d0), 0x0) + check(shr(0x5170a66a217950da02ef080a4daedc2848e682f3291f982e3e9d1e3fd002b0de, 0xe27e6b3a389771a7ee605306e85d9f786bd2dc482837d0ce1c3c8d1b50d3ebeb), 0x0) + check(shr(0x5170a66a217950da02ef080a4daedc2848e682f3291f982e3e9d1e3fd002b0de, 0x5170a66a217950da02ef080a4daedc2848e682f3291f982e3e9d1e3fd002b0de), 0x0) +} +// ==== +// EVMVersion: >=constantinople +// maxTraceSize: 0 +// ---- +// Execution result: ExecutionOk +// Outer most variable values: +// +// Call trace: diff --git a/test/libyul/yulPureInterpreterTests/pure_instructions/signextend.yul b/test/libyul/yulPureInterpreterTests/pure_instructions/signextend.yul new file mode 100644 index 000000000000..e295a0c6ae97 --- /dev/null +++ b/test/libyul/yulPureInterpreterTests/pure_instructions/signextend.yul @@ -0,0 +1,77 @@ +{ + + function check(a, b) + { if iszero(eq(a, b)) { revert(0, 0) } } + + check(signextend(0x0, 0x0), 0x0) + check(signextend(0x0, 0x1), 0x1) + check(signextend(0x0, 0x2), 0x2) + check(signextend(0x0, 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff), 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff) + check(signextend(0x0, 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe), 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe) + check(signextend(0x0, 0x6855c4590e561bd51e79061b0952b669a42287b819f7736eb72de8dc03f347b4), 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffb4) + check(signextend(0x0, 0x61138948e40817554fc48fd1ffd4c0d2a6faff424e33da38076f97530ec2308a), 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8a) + check(signextend(0x0, 0x36b4781b870310da5481b23fe98b33115c6e598ebc74621803b9bc766b06bdb5), 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffb5) + check(signextend(0x1, 0x0), 0x0) + check(signextend(0x1, 0x1), 0x1) + check(signextend(0x1, 0x2), 0x2) + check(signextend(0x1, 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff), 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff) + check(signextend(0x1, 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe), 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe) + check(signextend(0x1, 0x6855c4590e561bd51e79061b0952b669a42287b819f7736eb72de8dc03f347b4), 0x47b4) + check(signextend(0x1, 0x61138948e40817554fc48fd1ffd4c0d2a6faff424e33da38076f97530ec2308a), 0x308a) + check(signextend(0x1, 0x36b4781b870310da5481b23fe98b33115c6e598ebc74621803b9bc766b06bdb5), 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffbdb5) + check(signextend(0x2, 0x0), 0x0) + check(signextend(0x2, 0x1), 0x1) + check(signextend(0x2, 0x2), 0x2) + check(signextend(0x2, 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff), 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff) + check(signextend(0x2, 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe), 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe) + check(signextend(0x2, 0x6855c4590e561bd51e79061b0952b669a42287b819f7736eb72de8dc03f347b4), 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffff347b4) + check(signextend(0x2, 0x61138948e40817554fc48fd1ffd4c0d2a6faff424e33da38076f97530ec2308a), 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc2308a) + check(signextend(0x2, 0x36b4781b870310da5481b23fe98b33115c6e598ebc74621803b9bc766b06bdb5), 0x6bdb5) + check(signextend(0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff, 0x0), 0x0) + check(signextend(0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff, 0x1), 0x1) + check(signextend(0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff, 0x2), 0x2) + check(signextend(0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff, 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff), 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff) + check(signextend(0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff, 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe), 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe) + check(signextend(0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff, 0x6855c4590e561bd51e79061b0952b669a42287b819f7736eb72de8dc03f347b4), 0x6855c4590e561bd51e79061b0952b669a42287b819f7736eb72de8dc03f347b4) + check(signextend(0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff, 0x61138948e40817554fc48fd1ffd4c0d2a6faff424e33da38076f97530ec2308a), 0x61138948e40817554fc48fd1ffd4c0d2a6faff424e33da38076f97530ec2308a) + check(signextend(0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff, 0x36b4781b870310da5481b23fe98b33115c6e598ebc74621803b9bc766b06bdb5), 0x36b4781b870310da5481b23fe98b33115c6e598ebc74621803b9bc766b06bdb5) + check(signextend(0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe, 0x0), 0x0) + check(signextend(0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe, 0x1), 0x1) + check(signextend(0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe, 0x2), 0x2) + check(signextend(0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe, 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff), 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff) + check(signextend(0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe, 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe), 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe) + check(signextend(0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe, 0x6855c4590e561bd51e79061b0952b669a42287b819f7736eb72de8dc03f347b4), 0x6855c4590e561bd51e79061b0952b669a42287b819f7736eb72de8dc03f347b4) + check(signextend(0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe, 0x61138948e40817554fc48fd1ffd4c0d2a6faff424e33da38076f97530ec2308a), 0x61138948e40817554fc48fd1ffd4c0d2a6faff424e33da38076f97530ec2308a) + check(signextend(0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe, 0x36b4781b870310da5481b23fe98b33115c6e598ebc74621803b9bc766b06bdb5), 0x36b4781b870310da5481b23fe98b33115c6e598ebc74621803b9bc766b06bdb5) + check(signextend(0x6855c4590e561bd51e79061b0952b669a42287b819f7736eb72de8dc03f347b4, 0x0), 0x0) + check(signextend(0x6855c4590e561bd51e79061b0952b669a42287b819f7736eb72de8dc03f347b4, 0x1), 0x1) + check(signextend(0x6855c4590e561bd51e79061b0952b669a42287b819f7736eb72de8dc03f347b4, 0x2), 0x2) + check(signextend(0x6855c4590e561bd51e79061b0952b669a42287b819f7736eb72de8dc03f347b4, 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff), 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff) + check(signextend(0x6855c4590e561bd51e79061b0952b669a42287b819f7736eb72de8dc03f347b4, 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe), 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe) + check(signextend(0x6855c4590e561bd51e79061b0952b669a42287b819f7736eb72de8dc03f347b4, 0x6855c4590e561bd51e79061b0952b669a42287b819f7736eb72de8dc03f347b4), 0x6855c4590e561bd51e79061b0952b669a42287b819f7736eb72de8dc03f347b4) + check(signextend(0x6855c4590e561bd51e79061b0952b669a42287b819f7736eb72de8dc03f347b4, 0x61138948e40817554fc48fd1ffd4c0d2a6faff424e33da38076f97530ec2308a), 0x61138948e40817554fc48fd1ffd4c0d2a6faff424e33da38076f97530ec2308a) + check(signextend(0x6855c4590e561bd51e79061b0952b669a42287b819f7736eb72de8dc03f347b4, 0x36b4781b870310da5481b23fe98b33115c6e598ebc74621803b9bc766b06bdb5), 0x36b4781b870310da5481b23fe98b33115c6e598ebc74621803b9bc766b06bdb5) + check(signextend(0x61138948e40817554fc48fd1ffd4c0d2a6faff424e33da38076f97530ec2308a, 0x0), 0x0) + check(signextend(0x61138948e40817554fc48fd1ffd4c0d2a6faff424e33da38076f97530ec2308a, 0x1), 0x1) + check(signextend(0x61138948e40817554fc48fd1ffd4c0d2a6faff424e33da38076f97530ec2308a, 0x2), 0x2) + check(signextend(0x61138948e40817554fc48fd1ffd4c0d2a6faff424e33da38076f97530ec2308a, 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff), 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff) + check(signextend(0x61138948e40817554fc48fd1ffd4c0d2a6faff424e33da38076f97530ec2308a, 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe), 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe) + check(signextend(0x61138948e40817554fc48fd1ffd4c0d2a6faff424e33da38076f97530ec2308a, 0x6855c4590e561bd51e79061b0952b669a42287b819f7736eb72de8dc03f347b4), 0x6855c4590e561bd51e79061b0952b669a42287b819f7736eb72de8dc03f347b4) + check(signextend(0x61138948e40817554fc48fd1ffd4c0d2a6faff424e33da38076f97530ec2308a, 0x61138948e40817554fc48fd1ffd4c0d2a6faff424e33da38076f97530ec2308a), 0x61138948e40817554fc48fd1ffd4c0d2a6faff424e33da38076f97530ec2308a) + check(signextend(0x61138948e40817554fc48fd1ffd4c0d2a6faff424e33da38076f97530ec2308a, 0x36b4781b870310da5481b23fe98b33115c6e598ebc74621803b9bc766b06bdb5), 0x36b4781b870310da5481b23fe98b33115c6e598ebc74621803b9bc766b06bdb5) + check(signextend(0x36b4781b870310da5481b23fe98b33115c6e598ebc74621803b9bc766b06bdb5, 0x0), 0x0) + check(signextend(0x36b4781b870310da5481b23fe98b33115c6e598ebc74621803b9bc766b06bdb5, 0x1), 0x1) + check(signextend(0x36b4781b870310da5481b23fe98b33115c6e598ebc74621803b9bc766b06bdb5, 0x2), 0x2) + check(signextend(0x36b4781b870310da5481b23fe98b33115c6e598ebc74621803b9bc766b06bdb5, 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff), 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff) + check(signextend(0x36b4781b870310da5481b23fe98b33115c6e598ebc74621803b9bc766b06bdb5, 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe), 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe) + check(signextend(0x36b4781b870310da5481b23fe98b33115c6e598ebc74621803b9bc766b06bdb5, 0x6855c4590e561bd51e79061b0952b669a42287b819f7736eb72de8dc03f347b4), 0x6855c4590e561bd51e79061b0952b669a42287b819f7736eb72de8dc03f347b4) + check(signextend(0x36b4781b870310da5481b23fe98b33115c6e598ebc74621803b9bc766b06bdb5, 0x61138948e40817554fc48fd1ffd4c0d2a6faff424e33da38076f97530ec2308a), 0x61138948e40817554fc48fd1ffd4c0d2a6faff424e33da38076f97530ec2308a) + check(signextend(0x36b4781b870310da5481b23fe98b33115c6e598ebc74621803b9bc766b06bdb5, 0x36b4781b870310da5481b23fe98b33115c6e598ebc74621803b9bc766b06bdb5), 0x36b4781b870310da5481b23fe98b33115c6e598ebc74621803b9bc766b06bdb5) +} +// ==== +// maxTraceSize: 0 +// ---- +// Execution result: ExecutionOk +// Outer most variable values: +// +// Call trace: diff --git a/test/libyul/yulPureInterpreterTests/pure_instructions/slt.yul b/test/libyul/yulPureInterpreterTests/pure_instructions/slt.yul new file mode 100644 index 000000000000..499a7ffbb861 --- /dev/null +++ b/test/libyul/yulPureInterpreterTests/pure_instructions/slt.yul @@ -0,0 +1,77 @@ +{ + + function check(a, b) + { if iszero(eq(a, b)) { revert(0, 0) } } + + check(slt(0x0, 0x0), 0x0) + check(slt(0x0, 0x1), 0x1) + check(slt(0x0, 0x2), 0x1) + check(slt(0x0, 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff), 0x0) + check(slt(0x0, 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe), 0x0) + check(slt(0x0, 0xcf8e0b6a32221ec616462752880c68a4b3b33f6a6af80fb7234a28d6cc36d2ec), 0x0) + check(slt(0x0, 0x1f7753c55d4e1c43cb26e2a041a5a57387662f1b81f96e44760b719db8cb6f36), 0x1) + check(slt(0x0, 0x981bfaba9a12b4198e7e38eb9588204d3e7d9ab8be73735dc4bf52431847d324), 0x0) + check(slt(0x1, 0x0), 0x0) + check(slt(0x1, 0x1), 0x0) + check(slt(0x1, 0x2), 0x1) + check(slt(0x1, 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff), 0x0) + check(slt(0x1, 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe), 0x0) + check(slt(0x1, 0xcf8e0b6a32221ec616462752880c68a4b3b33f6a6af80fb7234a28d6cc36d2ec), 0x0) + check(slt(0x1, 0x1f7753c55d4e1c43cb26e2a041a5a57387662f1b81f96e44760b719db8cb6f36), 0x1) + check(slt(0x1, 0x981bfaba9a12b4198e7e38eb9588204d3e7d9ab8be73735dc4bf52431847d324), 0x0) + check(slt(0x2, 0x0), 0x0) + check(slt(0x2, 0x1), 0x0) + check(slt(0x2, 0x2), 0x0) + check(slt(0x2, 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff), 0x0) + check(slt(0x2, 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe), 0x0) + check(slt(0x2, 0xcf8e0b6a32221ec616462752880c68a4b3b33f6a6af80fb7234a28d6cc36d2ec), 0x0) + check(slt(0x2, 0x1f7753c55d4e1c43cb26e2a041a5a57387662f1b81f96e44760b719db8cb6f36), 0x1) + check(slt(0x2, 0x981bfaba9a12b4198e7e38eb9588204d3e7d9ab8be73735dc4bf52431847d324), 0x0) + check(slt(0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff, 0x0), 0x1) + check(slt(0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff, 0x1), 0x1) + check(slt(0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff, 0x2), 0x1) + check(slt(0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff, 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff), 0x0) + check(slt(0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff, 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe), 0x0) + check(slt(0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff, 0xcf8e0b6a32221ec616462752880c68a4b3b33f6a6af80fb7234a28d6cc36d2ec), 0x0) + check(slt(0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff, 0x1f7753c55d4e1c43cb26e2a041a5a57387662f1b81f96e44760b719db8cb6f36), 0x1) + check(slt(0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff, 0x981bfaba9a12b4198e7e38eb9588204d3e7d9ab8be73735dc4bf52431847d324), 0x0) + check(slt(0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe, 0x0), 0x1) + check(slt(0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe, 0x1), 0x1) + check(slt(0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe, 0x2), 0x1) + check(slt(0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe, 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff), 0x1) + check(slt(0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe, 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe), 0x0) + check(slt(0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe, 0xcf8e0b6a32221ec616462752880c68a4b3b33f6a6af80fb7234a28d6cc36d2ec), 0x0) + check(slt(0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe, 0x1f7753c55d4e1c43cb26e2a041a5a57387662f1b81f96e44760b719db8cb6f36), 0x1) + check(slt(0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe, 0x981bfaba9a12b4198e7e38eb9588204d3e7d9ab8be73735dc4bf52431847d324), 0x0) + check(slt(0xcf8e0b6a32221ec616462752880c68a4b3b33f6a6af80fb7234a28d6cc36d2ec, 0x0), 0x1) + check(slt(0xcf8e0b6a32221ec616462752880c68a4b3b33f6a6af80fb7234a28d6cc36d2ec, 0x1), 0x1) + check(slt(0xcf8e0b6a32221ec616462752880c68a4b3b33f6a6af80fb7234a28d6cc36d2ec, 0x2), 0x1) + check(slt(0xcf8e0b6a32221ec616462752880c68a4b3b33f6a6af80fb7234a28d6cc36d2ec, 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff), 0x1) + check(slt(0xcf8e0b6a32221ec616462752880c68a4b3b33f6a6af80fb7234a28d6cc36d2ec, 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe), 0x1) + check(slt(0xcf8e0b6a32221ec616462752880c68a4b3b33f6a6af80fb7234a28d6cc36d2ec, 0xcf8e0b6a32221ec616462752880c68a4b3b33f6a6af80fb7234a28d6cc36d2ec), 0x0) + check(slt(0xcf8e0b6a32221ec616462752880c68a4b3b33f6a6af80fb7234a28d6cc36d2ec, 0x1f7753c55d4e1c43cb26e2a041a5a57387662f1b81f96e44760b719db8cb6f36), 0x1) + check(slt(0xcf8e0b6a32221ec616462752880c68a4b3b33f6a6af80fb7234a28d6cc36d2ec, 0x981bfaba9a12b4198e7e38eb9588204d3e7d9ab8be73735dc4bf52431847d324), 0x0) + check(slt(0x1f7753c55d4e1c43cb26e2a041a5a57387662f1b81f96e44760b719db8cb6f36, 0x0), 0x0) + check(slt(0x1f7753c55d4e1c43cb26e2a041a5a57387662f1b81f96e44760b719db8cb6f36, 0x1), 0x0) + check(slt(0x1f7753c55d4e1c43cb26e2a041a5a57387662f1b81f96e44760b719db8cb6f36, 0x2), 0x0) + check(slt(0x1f7753c55d4e1c43cb26e2a041a5a57387662f1b81f96e44760b719db8cb6f36, 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff), 0x0) + check(slt(0x1f7753c55d4e1c43cb26e2a041a5a57387662f1b81f96e44760b719db8cb6f36, 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe), 0x0) + check(slt(0x1f7753c55d4e1c43cb26e2a041a5a57387662f1b81f96e44760b719db8cb6f36, 0xcf8e0b6a32221ec616462752880c68a4b3b33f6a6af80fb7234a28d6cc36d2ec), 0x0) + check(slt(0x1f7753c55d4e1c43cb26e2a041a5a57387662f1b81f96e44760b719db8cb6f36, 0x1f7753c55d4e1c43cb26e2a041a5a57387662f1b81f96e44760b719db8cb6f36), 0x0) + check(slt(0x1f7753c55d4e1c43cb26e2a041a5a57387662f1b81f96e44760b719db8cb6f36, 0x981bfaba9a12b4198e7e38eb9588204d3e7d9ab8be73735dc4bf52431847d324), 0x0) + check(slt(0x981bfaba9a12b4198e7e38eb9588204d3e7d9ab8be73735dc4bf52431847d324, 0x0), 0x1) + check(slt(0x981bfaba9a12b4198e7e38eb9588204d3e7d9ab8be73735dc4bf52431847d324, 0x1), 0x1) + check(slt(0x981bfaba9a12b4198e7e38eb9588204d3e7d9ab8be73735dc4bf52431847d324, 0x2), 0x1) + check(slt(0x981bfaba9a12b4198e7e38eb9588204d3e7d9ab8be73735dc4bf52431847d324, 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff), 0x1) + check(slt(0x981bfaba9a12b4198e7e38eb9588204d3e7d9ab8be73735dc4bf52431847d324, 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe), 0x1) + check(slt(0x981bfaba9a12b4198e7e38eb9588204d3e7d9ab8be73735dc4bf52431847d324, 0xcf8e0b6a32221ec616462752880c68a4b3b33f6a6af80fb7234a28d6cc36d2ec), 0x1) + check(slt(0x981bfaba9a12b4198e7e38eb9588204d3e7d9ab8be73735dc4bf52431847d324, 0x1f7753c55d4e1c43cb26e2a041a5a57387662f1b81f96e44760b719db8cb6f36), 0x1) + check(slt(0x981bfaba9a12b4198e7e38eb9588204d3e7d9ab8be73735dc4bf52431847d324, 0x981bfaba9a12b4198e7e38eb9588204d3e7d9ab8be73735dc4bf52431847d324), 0x0) +} +// ==== +// maxTraceSize: 0 +// ---- +// Execution result: ExecutionOk +// Outer most variable values: +// +// Call trace: diff --git a/test/libyul/yulPureInterpreterTests/pure_instructions/smod.yul b/test/libyul/yulPureInterpreterTests/pure_instructions/smod.yul new file mode 100644 index 000000000000..fa2afc4e679a --- /dev/null +++ b/test/libyul/yulPureInterpreterTests/pure_instructions/smod.yul @@ -0,0 +1,77 @@ +{ + + function check(a, b) + { if iszero(eq(a, b)) { revert(0, 0) } } + + check(smod(0x0, 0x0), 0x0) + check(smod(0x0, 0x1), 0x0) + check(smod(0x0, 0x2), 0x0) + check(smod(0x0, 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff), 0x0) + check(smod(0x0, 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe), 0x0) + check(smod(0x0, 0xf36a4794a14e2cd68371e3b89319f21ceee3ff1d3504113508f36b07d3eab25e), 0x0) + check(smod(0x0, 0xf73c6967ffaa827783f272e2f1420e52984bb03f04b60f06b1db40c43ec2b2c), 0x0) + check(smod(0x0, 0xa0d935e612201f42a0bbb4abe8ff4920108904164a2cbcc59d2ac262fd59cac9), 0x0) + check(smod(0x1, 0x0), 0x0) + check(smod(0x1, 0x1), 0x0) + check(smod(0x1, 0x2), 0x1) + check(smod(0x1, 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff), 0x0) + check(smod(0x1, 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe), 0x1) + check(smod(0x1, 0xf36a4794a14e2cd68371e3b89319f21ceee3ff1d3504113508f36b07d3eab25e), 0x1) + check(smod(0x1, 0xf73c6967ffaa827783f272e2f1420e52984bb03f04b60f06b1db40c43ec2b2c), 0x1) + check(smod(0x1, 0xa0d935e612201f42a0bbb4abe8ff4920108904164a2cbcc59d2ac262fd59cac9), 0x1) + check(smod(0x2, 0x0), 0x0) + check(smod(0x2, 0x1), 0x0) + check(smod(0x2, 0x2), 0x0) + check(smod(0x2, 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff), 0x0) + check(smod(0x2, 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe), 0x0) + check(smod(0x2, 0xf36a4794a14e2cd68371e3b89319f21ceee3ff1d3504113508f36b07d3eab25e), 0x2) + check(smod(0x2, 0xf73c6967ffaa827783f272e2f1420e52984bb03f04b60f06b1db40c43ec2b2c), 0x2) + check(smod(0x2, 0xa0d935e612201f42a0bbb4abe8ff4920108904164a2cbcc59d2ac262fd59cac9), 0x2) + check(smod(0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff, 0x0), 0x0) + check(smod(0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff, 0x1), 0x0) + check(smod(0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff, 0x2), 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff) + check(smod(0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff, 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff), 0x0) + check(smod(0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff, 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe), 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff) + check(smod(0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff, 0xf36a4794a14e2cd68371e3b89319f21ceee3ff1d3504113508f36b07d3eab25e), 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff) + check(smod(0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff, 0xf73c6967ffaa827783f272e2f1420e52984bb03f04b60f06b1db40c43ec2b2c), 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff) + check(smod(0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff, 0xa0d935e612201f42a0bbb4abe8ff4920108904164a2cbcc59d2ac262fd59cac9), 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff) + check(smod(0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe, 0x0), 0x0) + check(smod(0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe, 0x1), 0x0) + check(smod(0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe, 0x2), 0x0) + check(smod(0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe, 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff), 0x0) + check(smod(0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe, 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe), 0x0) + check(smod(0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe, 0xf36a4794a14e2cd68371e3b89319f21ceee3ff1d3504113508f36b07d3eab25e), 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe) + check(smod(0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe, 0xf73c6967ffaa827783f272e2f1420e52984bb03f04b60f06b1db40c43ec2b2c), 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe) + check(smod(0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe, 0xa0d935e612201f42a0bbb4abe8ff4920108904164a2cbcc59d2ac262fd59cac9), 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe) + check(smod(0xf36a4794a14e2cd68371e3b89319f21ceee3ff1d3504113508f36b07d3eab25e, 0x0), 0x0) + check(smod(0xf36a4794a14e2cd68371e3b89319f21ceee3ff1d3504113508f36b07d3eab25e, 0x1), 0x0) + check(smod(0xf36a4794a14e2cd68371e3b89319f21ceee3ff1d3504113508f36b07d3eab25e, 0x2), 0x0) + check(smod(0xf36a4794a14e2cd68371e3b89319f21ceee3ff1d3504113508f36b07d3eab25e, 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff), 0x0) + check(smod(0xf36a4794a14e2cd68371e3b89319f21ceee3ff1d3504113508f36b07d3eab25e, 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe), 0x0) + check(smod(0xf36a4794a14e2cd68371e3b89319f21ceee3ff1d3504113508f36b07d3eab25e, 0xf36a4794a14e2cd68371e3b89319f21ceee3ff1d3504113508f36b07d3eab25e), 0x0) + check(smod(0xf36a4794a14e2cd68371e3b89319f21ceee3ff1d3504113508f36b07d3eab25e, 0xf73c6967ffaa827783f272e2f1420e52984bb03f04b60f06b1db40c43ec2b2c), 0xf36a4794a14e2cd68371e3b89319f21ceee3ff1d3504113508f36b07d3eab25e) + check(smod(0xf36a4794a14e2cd68371e3b89319f21ceee3ff1d3504113508f36b07d3eab25e, 0xa0d935e612201f42a0bbb4abe8ff4920108904164a2cbcc59d2ac262fd59cac9), 0xf36a4794a14e2cd68371e3b89319f21ceee3ff1d3504113508f36b07d3eab25e) + check(smod(0xf73c6967ffaa827783f272e2f1420e52984bb03f04b60f06b1db40c43ec2b2c, 0x0), 0x0) + check(smod(0xf73c6967ffaa827783f272e2f1420e52984bb03f04b60f06b1db40c43ec2b2c, 0x1), 0x0) + check(smod(0xf73c6967ffaa827783f272e2f1420e52984bb03f04b60f06b1db40c43ec2b2c, 0x2), 0x0) + check(smod(0xf73c6967ffaa827783f272e2f1420e52984bb03f04b60f06b1db40c43ec2b2c, 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff), 0x0) + check(smod(0xf73c6967ffaa827783f272e2f1420e52984bb03f04b60f06b1db40c43ec2b2c, 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe), 0x0) + check(smod(0xf73c6967ffaa827783f272e2f1420e52984bb03f04b60f06b1db40c43ec2b2c, 0xf36a4794a14e2cd68371e3b89319f21ceee3ff1d3504113508f36b07d3eab25e), 0x2de0e2b2148d4fdfbb10ae6c22e13021868ba21254f722574111f1417d6dd8a) + check(smod(0xf73c6967ffaa827783f272e2f1420e52984bb03f04b60f06b1db40c43ec2b2c, 0xf73c6967ffaa827783f272e2f1420e52984bb03f04b60f06b1db40c43ec2b2c), 0x0) + check(smod(0xf73c6967ffaa827783f272e2f1420e52984bb03f04b60f06b1db40c43ec2b2c, 0xa0d935e612201f42a0bbb4abe8ff4920108904164a2cbcc59d2ac262fd59cac9), 0xf73c6967ffaa827783f272e2f1420e52984bb03f04b60f06b1db40c43ec2b2c) + check(smod(0xa0d935e612201f42a0bbb4abe8ff4920108904164a2cbcc59d2ac262fd59cac9, 0x0), 0x0) + check(smod(0xa0d935e612201f42a0bbb4abe8ff4920108904164a2cbcc59d2ac262fd59cac9, 0x1), 0x0) + check(smod(0xa0d935e612201f42a0bbb4abe8ff4920108904164a2cbcc59d2ac262fd59cac9, 0x2), 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff) + check(smod(0xa0d935e612201f42a0bbb4abe8ff4920108904164a2cbcc59d2ac262fd59cac9, 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff), 0x0) + check(smod(0xa0d935e612201f42a0bbb4abe8ff4920108904164a2cbcc59d2ac262fd59cac9, 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe), 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff) + check(smod(0xa0d935e612201f42a0bbb4abe8ff4920108904164a2cbcc59d2ac262fd59cac9, 0xf36a4794a14e2cd68371e3b89319f21ceee3ff1d3504113508f36b07d3eab25e), 0xf8f140d5a8fce565089e7a9fe349aa55884d0a49d71044525e82d52c31eeea37) + check(smod(0xa0d935e612201f42a0bbb4abe8ff4920108904164a2cbcc59d2ac262fd59cac9, 0xf73c6967ffaa827783f272e2f1420e52984bb03f04b60f06b1db40c43ec2b2c), 0xfd8fdd6d1200102f72369fc103780e7f09a5662debf102681fdcfaac94e2cdd1) + check(smod(0xa0d935e612201f42a0bbb4abe8ff4920108904164a2cbcc59d2ac262fd59cac9, 0xa0d935e612201f42a0bbb4abe8ff4920108904164a2cbcc59d2ac262fd59cac9), 0x0) +} +// ==== +// maxTraceSize: 0 +// ---- +// Execution result: ExecutionOk +// Outer most variable values: +// +// Call trace: diff --git a/test/libyul/yulPureInterpreterTests/pure_instructions/sub.yul b/test/libyul/yulPureInterpreterTests/pure_instructions/sub.yul new file mode 100644 index 000000000000..91eabfd6d22d --- /dev/null +++ b/test/libyul/yulPureInterpreterTests/pure_instructions/sub.yul @@ -0,0 +1,77 @@ +{ + + function check(a, b) + { if iszero(eq(a, b)) { revert(0, 0) } } + + check(sub(0x0, 0x0), 0x0) + check(sub(0x0, 0x1), 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff) + check(sub(0x0, 0x2), 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe) + check(sub(0x0, 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff), 0x1) + check(sub(0x0, 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe), 0x2) + check(sub(0x0, 0x2f97ec9cfb61e89ccc0051a12a5a4d0f881cfacee0508619634b0c3b1350f17c), 0xd0681363049e176333ffae5ed5a5b2f077e305311faf79e69cb4f3c4ecaf0e84) + check(sub(0x0, 0xd0fe645ebc9875f1d7f909fad67d030a593e66629c0f33283463bbe5cd4022a), 0xf2f019ba143678a0e2806f6052982fcf5a6c1999d63f0ccd7cb9c441a32bfdd6) + check(sub(0x0, 0x9a311a5a90ce4d44fc546f265a76ff49a2c97ddbfcb7415bb2f197124b471622), 0x65cee5a56f31b2bb03ab90d9a58900b65d3682240348bea44d0e68edb4b8e9de) + check(sub(0x1, 0x0), 0x1) + check(sub(0x1, 0x1), 0x0) + check(sub(0x1, 0x2), 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff) + check(sub(0x1, 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff), 0x2) + check(sub(0x1, 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe), 0x3) + check(sub(0x1, 0x2f97ec9cfb61e89ccc0051a12a5a4d0f881cfacee0508619634b0c3b1350f17c), 0xd0681363049e176333ffae5ed5a5b2f077e305311faf79e69cb4f3c4ecaf0e85) + check(sub(0x1, 0xd0fe645ebc9875f1d7f909fad67d030a593e66629c0f33283463bbe5cd4022a), 0xf2f019ba143678a0e2806f6052982fcf5a6c1999d63f0ccd7cb9c441a32bfdd7) + check(sub(0x1, 0x9a311a5a90ce4d44fc546f265a76ff49a2c97ddbfcb7415bb2f197124b471622), 0x65cee5a56f31b2bb03ab90d9a58900b65d3682240348bea44d0e68edb4b8e9df) + check(sub(0x2, 0x0), 0x2) + check(sub(0x2, 0x1), 0x1) + check(sub(0x2, 0x2), 0x0) + check(sub(0x2, 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff), 0x3) + check(sub(0x2, 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe), 0x4) + check(sub(0x2, 0x2f97ec9cfb61e89ccc0051a12a5a4d0f881cfacee0508619634b0c3b1350f17c), 0xd0681363049e176333ffae5ed5a5b2f077e305311faf79e69cb4f3c4ecaf0e86) + check(sub(0x2, 0xd0fe645ebc9875f1d7f909fad67d030a593e66629c0f33283463bbe5cd4022a), 0xf2f019ba143678a0e2806f6052982fcf5a6c1999d63f0ccd7cb9c441a32bfdd8) + check(sub(0x2, 0x9a311a5a90ce4d44fc546f265a76ff49a2c97ddbfcb7415bb2f197124b471622), 0x65cee5a56f31b2bb03ab90d9a58900b65d3682240348bea44d0e68edb4b8e9e0) + check(sub(0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff, 0x0), 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff) + check(sub(0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff, 0x1), 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe) + check(sub(0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff, 0x2), 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffd) + check(sub(0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff, 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff), 0x0) + check(sub(0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff, 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe), 0x1) + check(sub(0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff, 0x2f97ec9cfb61e89ccc0051a12a5a4d0f881cfacee0508619634b0c3b1350f17c), 0xd0681363049e176333ffae5ed5a5b2f077e305311faf79e69cb4f3c4ecaf0e83) + check(sub(0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff, 0xd0fe645ebc9875f1d7f909fad67d030a593e66629c0f33283463bbe5cd4022a), 0xf2f019ba143678a0e2806f6052982fcf5a6c1999d63f0ccd7cb9c441a32bfdd5) + check(sub(0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff, 0x9a311a5a90ce4d44fc546f265a76ff49a2c97ddbfcb7415bb2f197124b471622), 0x65cee5a56f31b2bb03ab90d9a58900b65d3682240348bea44d0e68edb4b8e9dd) + check(sub(0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe, 0x0), 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe) + check(sub(0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe, 0x1), 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffd) + check(sub(0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe, 0x2), 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc) + check(sub(0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe, 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff), 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff) + check(sub(0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe, 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe), 0x0) + check(sub(0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe, 0x2f97ec9cfb61e89ccc0051a12a5a4d0f881cfacee0508619634b0c3b1350f17c), 0xd0681363049e176333ffae5ed5a5b2f077e305311faf79e69cb4f3c4ecaf0e82) + check(sub(0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe, 0xd0fe645ebc9875f1d7f909fad67d030a593e66629c0f33283463bbe5cd4022a), 0xf2f019ba143678a0e2806f6052982fcf5a6c1999d63f0ccd7cb9c441a32bfdd4) + check(sub(0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe, 0x9a311a5a90ce4d44fc546f265a76ff49a2c97ddbfcb7415bb2f197124b471622), 0x65cee5a56f31b2bb03ab90d9a58900b65d3682240348bea44d0e68edb4b8e9dc) + check(sub(0x2f97ec9cfb61e89ccc0051a12a5a4d0f881cfacee0508619634b0c3b1350f17c, 0x0), 0x2f97ec9cfb61e89ccc0051a12a5a4d0f881cfacee0508619634b0c3b1350f17c) + check(sub(0x2f97ec9cfb61e89ccc0051a12a5a4d0f881cfacee0508619634b0c3b1350f17c, 0x1), 0x2f97ec9cfb61e89ccc0051a12a5a4d0f881cfacee0508619634b0c3b1350f17b) + check(sub(0x2f97ec9cfb61e89ccc0051a12a5a4d0f881cfacee0508619634b0c3b1350f17c, 0x2), 0x2f97ec9cfb61e89ccc0051a12a5a4d0f881cfacee0508619634b0c3b1350f17a) + check(sub(0x2f97ec9cfb61e89ccc0051a12a5a4d0f881cfacee0508619634b0c3b1350f17c, 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff), 0x2f97ec9cfb61e89ccc0051a12a5a4d0f881cfacee0508619634b0c3b1350f17d) + check(sub(0x2f97ec9cfb61e89ccc0051a12a5a4d0f881cfacee0508619634b0c3b1350f17c, 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe), 0x2f97ec9cfb61e89ccc0051a12a5a4d0f881cfacee0508619634b0c3b1350f17e) + check(sub(0x2f97ec9cfb61e89ccc0051a12a5a4d0f881cfacee0508619634b0c3b1350f17c, 0x2f97ec9cfb61e89ccc0051a12a5a4d0f881cfacee0508619634b0c3b1350f17c), 0x0) + check(sub(0x2f97ec9cfb61e89ccc0051a12a5a4d0f881cfacee0508619634b0c3b1350f17c, 0xd0fe645ebc9875f1d7f909fad67d030a593e66629c0f33283463bbe5cd4022a), 0x228806570f98613dae80c1017cf27cdee2891468b68f92e6e004d07cb67cef52) + check(sub(0x2f97ec9cfb61e89ccc0051a12a5a4d0f881cfacee0508619634b0c3b1350f17c, 0x9a311a5a90ce4d44fc546f265a76ff49a2c97ddbfcb7415bb2f197124b471622), 0x9566d2426a939b57cfabe27acfe34dc5e5537cf2e39944bdb0597528c809db5a) + check(sub(0xd0fe645ebc9875f1d7f909fad67d030a593e66629c0f33283463bbe5cd4022a, 0x0), 0xd0fe645ebc9875f1d7f909fad67d030a593e66629c0f33283463bbe5cd4022a) + check(sub(0xd0fe645ebc9875f1d7f909fad67d030a593e66629c0f33283463bbe5cd4022a, 0x1), 0xd0fe645ebc9875f1d7f909fad67d030a593e66629c0f33283463bbe5cd40229) + check(sub(0xd0fe645ebc9875f1d7f909fad67d030a593e66629c0f33283463bbe5cd4022a, 0x2), 0xd0fe645ebc9875f1d7f909fad67d030a593e66629c0f33283463bbe5cd40228) + check(sub(0xd0fe645ebc9875f1d7f909fad67d030a593e66629c0f33283463bbe5cd4022a, 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff), 0xd0fe645ebc9875f1d7f909fad67d030a593e66629c0f33283463bbe5cd4022b) + check(sub(0xd0fe645ebc9875f1d7f909fad67d030a593e66629c0f33283463bbe5cd4022a, 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe), 0xd0fe645ebc9875f1d7f909fad67d030a593e66629c0f33283463bbe5cd4022c) + check(sub(0xd0fe645ebc9875f1d7f909fad67d030a593e66629c0f33283463bbe5cd4022a, 0x2f97ec9cfb61e89ccc0051a12a5a4d0f881cfacee0508619634b0c3b1350f17c), 0xdd77f9a8f0679ec2517f3efe830d83211d76eb9749706d191ffb2f83498310ae) + check(sub(0xd0fe645ebc9875f1d7f909fad67d030a593e66629c0f33283463bbe5cd4022a, 0xd0fe645ebc9875f1d7f909fad67d030a593e66629c0f33283463bbe5cd4022a), 0x0) + check(sub(0xd0fe645ebc9875f1d7f909fad67d030a593e66629c0f33283463bbe5cd4022a, 0x9a311a5a90ce4d44fc546f265a76ff49a2c97ddbfcb7415bb2f197124b471622), 0x72decbeb5afb3a1a212b217952f0d0e702ca688a2d09b1d6d054a4ac118cec08) + check(sub(0x9a311a5a90ce4d44fc546f265a76ff49a2c97ddbfcb7415bb2f197124b471622, 0x0), 0x9a311a5a90ce4d44fc546f265a76ff49a2c97ddbfcb7415bb2f197124b471622) + check(sub(0x9a311a5a90ce4d44fc546f265a76ff49a2c97ddbfcb7415bb2f197124b471622, 0x1), 0x9a311a5a90ce4d44fc546f265a76ff49a2c97ddbfcb7415bb2f197124b471621) + check(sub(0x9a311a5a90ce4d44fc546f265a76ff49a2c97ddbfcb7415bb2f197124b471622, 0x2), 0x9a311a5a90ce4d44fc546f265a76ff49a2c97ddbfcb7415bb2f197124b471620) + check(sub(0x9a311a5a90ce4d44fc546f265a76ff49a2c97ddbfcb7415bb2f197124b471622, 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff), 0x9a311a5a90ce4d44fc546f265a76ff49a2c97ddbfcb7415bb2f197124b471623) + check(sub(0x9a311a5a90ce4d44fc546f265a76ff49a2c97ddbfcb7415bb2f197124b471622, 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe), 0x9a311a5a90ce4d44fc546f265a76ff49a2c97ddbfcb7415bb2f197124b471624) + check(sub(0x9a311a5a90ce4d44fc546f265a76ff49a2c97ddbfcb7415bb2f197124b471622, 0x2f97ec9cfb61e89ccc0051a12a5a4d0f881cfacee0508619634b0c3b1350f17c), 0x6a992dbd956c64a830541d85301cb23a1aac830d1c66bb424fa68ad737f624a6) + check(sub(0x9a311a5a90ce4d44fc546f265a76ff49a2c97ddbfcb7415bb2f197124b471622, 0xd0fe645ebc9875f1d7f909fad67d030a593e66629c0f33283463bbe5cd4022a), 0x8d213414a504c5e5ded4de86ad0f2f18fd359775d2f64e292fab5b53ee7313f8) + check(sub(0x9a311a5a90ce4d44fc546f265a76ff49a2c97ddbfcb7415bb2f197124b471622, 0x9a311a5a90ce4d44fc546f265a76ff49a2c97ddbfcb7415bb2f197124b471622), 0x0) +} +// ==== +// maxTraceSize: 0 +// ---- +// Execution result: ExecutionOk +// Outer most variable values: +// +// Call trace: diff --git a/test/libyul/yulPureInterpreterTests/pure_instructions/xor.yul b/test/libyul/yulPureInterpreterTests/pure_instructions/xor.yul new file mode 100644 index 000000000000..de9872b308a4 --- /dev/null +++ b/test/libyul/yulPureInterpreterTests/pure_instructions/xor.yul @@ -0,0 +1,77 @@ +{ + + function check(a, b) + { if iszero(eq(a, b)) { revert(0, 0) } } + + check(xor(0x0, 0x0), 0x0) + check(xor(0x0, 0x1), 0x1) + check(xor(0x0, 0x2), 0x2) + check(xor(0x0, 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff), 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff) + check(xor(0x0, 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe), 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe) + check(xor(0x0, 0x8215e179db76e139f8b27a0e53f57f4e2b22265a9066ca0321f7ef7f63fd63ea), 0x8215e179db76e139f8b27a0e53f57f4e2b22265a9066ca0321f7ef7f63fd63ea) + check(xor(0x0, 0x2f566d8f3326fdd93e983248989ab2745edcde0a5b136a89b4e0d202cfb2f43f), 0x2f566d8f3326fdd93e983248989ab2745edcde0a5b136a89b4e0d202cfb2f43f) + check(xor(0x0, 0xdbc0c908da84d9ccb28efa9375bc20168dfdce43ebcd94b3d6a7e87f91ebf82a), 0xdbc0c908da84d9ccb28efa9375bc20168dfdce43ebcd94b3d6a7e87f91ebf82a) + check(xor(0x1, 0x0), 0x1) + check(xor(0x1, 0x1), 0x0) + check(xor(0x1, 0x2), 0x3) + check(xor(0x1, 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff), 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe) + check(xor(0x1, 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe), 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff) + check(xor(0x1, 0x8215e179db76e139f8b27a0e53f57f4e2b22265a9066ca0321f7ef7f63fd63ea), 0x8215e179db76e139f8b27a0e53f57f4e2b22265a9066ca0321f7ef7f63fd63eb) + check(xor(0x1, 0x2f566d8f3326fdd93e983248989ab2745edcde0a5b136a89b4e0d202cfb2f43f), 0x2f566d8f3326fdd93e983248989ab2745edcde0a5b136a89b4e0d202cfb2f43e) + check(xor(0x1, 0xdbc0c908da84d9ccb28efa9375bc20168dfdce43ebcd94b3d6a7e87f91ebf82a), 0xdbc0c908da84d9ccb28efa9375bc20168dfdce43ebcd94b3d6a7e87f91ebf82b) + check(xor(0x2, 0x0), 0x2) + check(xor(0x2, 0x1), 0x3) + check(xor(0x2, 0x2), 0x0) + check(xor(0x2, 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff), 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffd) + check(xor(0x2, 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe), 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc) + check(xor(0x2, 0x8215e179db76e139f8b27a0e53f57f4e2b22265a9066ca0321f7ef7f63fd63ea), 0x8215e179db76e139f8b27a0e53f57f4e2b22265a9066ca0321f7ef7f63fd63e8) + check(xor(0x2, 0x2f566d8f3326fdd93e983248989ab2745edcde0a5b136a89b4e0d202cfb2f43f), 0x2f566d8f3326fdd93e983248989ab2745edcde0a5b136a89b4e0d202cfb2f43d) + check(xor(0x2, 0xdbc0c908da84d9ccb28efa9375bc20168dfdce43ebcd94b3d6a7e87f91ebf82a), 0xdbc0c908da84d9ccb28efa9375bc20168dfdce43ebcd94b3d6a7e87f91ebf828) + check(xor(0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff, 0x0), 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff) + check(xor(0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff, 0x1), 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe) + check(xor(0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff, 0x2), 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffd) + check(xor(0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff, 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff), 0x0) + check(xor(0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff, 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe), 0x1) + check(xor(0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff, 0x8215e179db76e139f8b27a0e53f57f4e2b22265a9066ca0321f7ef7f63fd63ea), 0x7dea1e8624891ec6074d85f1ac0a80b1d4ddd9a56f9935fcde0810809c029c15) + check(xor(0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff, 0x2f566d8f3326fdd93e983248989ab2745edcde0a5b136a89b4e0d202cfb2f43f), 0xd0a99270ccd90226c167cdb767654d8ba12321f5a4ec95764b1f2dfd304d0bc0) + check(xor(0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff, 0xdbc0c908da84d9ccb28efa9375bc20168dfdce43ebcd94b3d6a7e87f91ebf82a), 0x243f36f7257b26334d71056c8a43dfe9720231bc14326b4c295817806e1407d5) + check(xor(0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe, 0x0), 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe) + check(xor(0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe, 0x1), 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff) + check(xor(0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe, 0x2), 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc) + check(xor(0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe, 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff), 0x1) + check(xor(0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe, 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe), 0x0) + check(xor(0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe, 0x8215e179db76e139f8b27a0e53f57f4e2b22265a9066ca0321f7ef7f63fd63ea), 0x7dea1e8624891ec6074d85f1ac0a80b1d4ddd9a56f9935fcde0810809c029c14) + check(xor(0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe, 0x2f566d8f3326fdd93e983248989ab2745edcde0a5b136a89b4e0d202cfb2f43f), 0xd0a99270ccd90226c167cdb767654d8ba12321f5a4ec95764b1f2dfd304d0bc1) + check(xor(0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe, 0xdbc0c908da84d9ccb28efa9375bc20168dfdce43ebcd94b3d6a7e87f91ebf82a), 0x243f36f7257b26334d71056c8a43dfe9720231bc14326b4c295817806e1407d4) + check(xor(0x8215e179db76e139f8b27a0e53f57f4e2b22265a9066ca0321f7ef7f63fd63ea, 0x0), 0x8215e179db76e139f8b27a0e53f57f4e2b22265a9066ca0321f7ef7f63fd63ea) + check(xor(0x8215e179db76e139f8b27a0e53f57f4e2b22265a9066ca0321f7ef7f63fd63ea, 0x1), 0x8215e179db76e139f8b27a0e53f57f4e2b22265a9066ca0321f7ef7f63fd63eb) + check(xor(0x8215e179db76e139f8b27a0e53f57f4e2b22265a9066ca0321f7ef7f63fd63ea, 0x2), 0x8215e179db76e139f8b27a0e53f57f4e2b22265a9066ca0321f7ef7f63fd63e8) + check(xor(0x8215e179db76e139f8b27a0e53f57f4e2b22265a9066ca0321f7ef7f63fd63ea, 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff), 0x7dea1e8624891ec6074d85f1ac0a80b1d4ddd9a56f9935fcde0810809c029c15) + check(xor(0x8215e179db76e139f8b27a0e53f57f4e2b22265a9066ca0321f7ef7f63fd63ea, 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe), 0x7dea1e8624891ec6074d85f1ac0a80b1d4ddd9a56f9935fcde0810809c029c14) + check(xor(0x8215e179db76e139f8b27a0e53f57f4e2b22265a9066ca0321f7ef7f63fd63ea, 0x8215e179db76e139f8b27a0e53f57f4e2b22265a9066ca0321f7ef7f63fd63ea), 0x0) + check(xor(0x8215e179db76e139f8b27a0e53f57f4e2b22265a9066ca0321f7ef7f63fd63ea, 0x2f566d8f3326fdd93e983248989ab2745edcde0a5b136a89b4e0d202cfb2f43f), 0xad438cf6e8501ce0c62a4846cb6fcd3a75fef850cb75a08a95173d7dac4f97d5) + check(xor(0x8215e179db76e139f8b27a0e53f57f4e2b22265a9066ca0321f7ef7f63fd63ea, 0xdbc0c908da84d9ccb28efa9375bc20168dfdce43ebcd94b3d6a7e87f91ebf82a), 0x59d5287101f238f54a3c809d26495f58a6dfe8197bab5eb0f7500700f2169bc0) + check(xor(0x2f566d8f3326fdd93e983248989ab2745edcde0a5b136a89b4e0d202cfb2f43f, 0x0), 0x2f566d8f3326fdd93e983248989ab2745edcde0a5b136a89b4e0d202cfb2f43f) + check(xor(0x2f566d8f3326fdd93e983248989ab2745edcde0a5b136a89b4e0d202cfb2f43f, 0x1), 0x2f566d8f3326fdd93e983248989ab2745edcde0a5b136a89b4e0d202cfb2f43e) + check(xor(0x2f566d8f3326fdd93e983248989ab2745edcde0a5b136a89b4e0d202cfb2f43f, 0x2), 0x2f566d8f3326fdd93e983248989ab2745edcde0a5b136a89b4e0d202cfb2f43d) + check(xor(0x2f566d8f3326fdd93e983248989ab2745edcde0a5b136a89b4e0d202cfb2f43f, 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff), 0xd0a99270ccd90226c167cdb767654d8ba12321f5a4ec95764b1f2dfd304d0bc0) + check(xor(0x2f566d8f3326fdd93e983248989ab2745edcde0a5b136a89b4e0d202cfb2f43f, 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe), 0xd0a99270ccd90226c167cdb767654d8ba12321f5a4ec95764b1f2dfd304d0bc1) + check(xor(0x2f566d8f3326fdd93e983248989ab2745edcde0a5b136a89b4e0d202cfb2f43f, 0x8215e179db76e139f8b27a0e53f57f4e2b22265a9066ca0321f7ef7f63fd63ea), 0xad438cf6e8501ce0c62a4846cb6fcd3a75fef850cb75a08a95173d7dac4f97d5) + check(xor(0x2f566d8f3326fdd93e983248989ab2745edcde0a5b136a89b4e0d202cfb2f43f, 0x2f566d8f3326fdd93e983248989ab2745edcde0a5b136a89b4e0d202cfb2f43f), 0x0) + check(xor(0x2f566d8f3326fdd93e983248989ab2745edcde0a5b136a89b4e0d202cfb2f43f, 0xdbc0c908da84d9ccb28efa9375bc20168dfdce43ebcd94b3d6a7e87f91ebf82a), 0xf496a487e9a224158c16c8dbed269262d3211049b0defe3a62473a7d5e590c15) + check(xor(0xdbc0c908da84d9ccb28efa9375bc20168dfdce43ebcd94b3d6a7e87f91ebf82a, 0x0), 0xdbc0c908da84d9ccb28efa9375bc20168dfdce43ebcd94b3d6a7e87f91ebf82a) + check(xor(0xdbc0c908da84d9ccb28efa9375bc20168dfdce43ebcd94b3d6a7e87f91ebf82a, 0x1), 0xdbc0c908da84d9ccb28efa9375bc20168dfdce43ebcd94b3d6a7e87f91ebf82b) + check(xor(0xdbc0c908da84d9ccb28efa9375bc20168dfdce43ebcd94b3d6a7e87f91ebf82a, 0x2), 0xdbc0c908da84d9ccb28efa9375bc20168dfdce43ebcd94b3d6a7e87f91ebf828) + check(xor(0xdbc0c908da84d9ccb28efa9375bc20168dfdce43ebcd94b3d6a7e87f91ebf82a, 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff), 0x243f36f7257b26334d71056c8a43dfe9720231bc14326b4c295817806e1407d5) + check(xor(0xdbc0c908da84d9ccb28efa9375bc20168dfdce43ebcd94b3d6a7e87f91ebf82a, 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe), 0x243f36f7257b26334d71056c8a43dfe9720231bc14326b4c295817806e1407d4) + check(xor(0xdbc0c908da84d9ccb28efa9375bc20168dfdce43ebcd94b3d6a7e87f91ebf82a, 0x8215e179db76e139f8b27a0e53f57f4e2b22265a9066ca0321f7ef7f63fd63ea), 0x59d5287101f238f54a3c809d26495f58a6dfe8197bab5eb0f7500700f2169bc0) + check(xor(0xdbc0c908da84d9ccb28efa9375bc20168dfdce43ebcd94b3d6a7e87f91ebf82a, 0x2f566d8f3326fdd93e983248989ab2745edcde0a5b136a89b4e0d202cfb2f43f), 0xf496a487e9a224158c16c8dbed269262d3211049b0defe3a62473a7d5e590c15) + check(xor(0xdbc0c908da84d9ccb28efa9375bc20168dfdce43ebcd94b3d6a7e87f91ebf82a, 0xdbc0c908da84d9ccb28efa9375bc20168dfdce43ebcd94b3d6a7e87f91ebf82a), 0x0) +} +// ==== +// maxTraceSize: 0 +// ---- +// Execution result: ExecutionOk +// Outer most variable values: +// +// Call trace: diff --git a/test/libyul/yulPureInterpreterTests/recursion.yul b/test/libyul/yulPureInterpreterTests/recursion.yul new file mode 100644 index 000000000000..3114c69c1159 --- /dev/null +++ b/test/libyul/yulPureInterpreterTests/recursion.yul @@ -0,0 +1,97 @@ +{ + function fib(i) -> y { + y := 1 + if gt(i, 2) { + y := add(fib(sub(i, 1)), fib(sub(i, 2))) + } + } + let res := fib(8) +} +// ---- +// Execution result: ExecutionOk +// Outer most variable values: +// res = 21 +// +// Call trace: +// [CALL] fib(8) +// │ [CALL] fib(6) +// │ │ [CALL] fib(4) +// │ │ │ [CALL] fib(2) +// │ │ │ │ [RETURN] 1 +// │ │ │ [CALL] fib(3) +// │ │ │ │ [CALL] fib(1) +// │ │ │ │ │ [RETURN] 1 +// │ │ │ │ [CALL] fib(2) +// │ │ │ │ │ [RETURN] 1 +// │ │ │ │ [RETURN] 2 +// │ │ │ [RETURN] 3 +// │ │ [CALL] fib(5) +// │ │ │ [CALL] fib(3) +// │ │ │ │ [CALL] fib(1) +// │ │ │ │ │ [RETURN] 1 +// │ │ │ │ [CALL] fib(2) +// │ │ │ │ │ [RETURN] 1 +// │ │ │ │ [RETURN] 2 +// │ │ │ [CALL] fib(4) +// │ │ │ │ [CALL] fib(2) +// │ │ │ │ │ [RETURN] 1 +// │ │ │ │ [CALL] fib(3) +// │ │ │ │ │ [CALL] fib(1) +// │ │ │ │ │ │ [RETURN] 1 +// │ │ │ │ │ [CALL] fib(2) +// │ │ │ │ │ │ [RETURN] 1 +// │ │ │ │ │ [RETURN] 2 +// │ │ │ │ [RETURN] 3 +// │ │ │ [RETURN] 5 +// │ │ [RETURN] 8 +// │ [CALL] fib(7) +// │ │ [CALL] fib(5) +// │ │ │ [CALL] fib(3) +// │ │ │ │ [CALL] fib(1) +// │ │ │ │ │ [RETURN] 1 +// │ │ │ │ [CALL] fib(2) +// │ │ │ │ │ [RETURN] 1 +// │ │ │ │ [RETURN] 2 +// │ │ │ [CALL] fib(4) +// │ │ │ │ [CALL] fib(2) +// │ │ │ │ │ [RETURN] 1 +// │ │ │ │ [CALL] fib(3) +// │ │ │ │ │ [CALL] fib(1) +// │ │ │ │ │ │ [RETURN] 1 +// │ │ │ │ │ [CALL] fib(2) +// │ │ │ │ │ │ [RETURN] 1 +// │ │ │ │ │ [RETURN] 2 +// │ │ │ │ [RETURN] 3 +// │ │ │ [RETURN] 5 +// │ │ [CALL] fib(6) +// │ │ │ [CALL] fib(4) +// │ │ │ │ [CALL] fib(2) +// │ │ │ │ │ [RETURN] 1 +// │ │ │ │ [CALL] fib(3) +// │ │ │ │ │ [CALL] fib(1) +// │ │ │ │ │ │ [RETURN] 1 +// │ │ │ │ │ [CALL] fib(2) +// │ │ │ │ │ │ [RETURN] 1 +// │ │ │ │ │ [RETURN] 2 +// │ │ │ │ [RETURN] 3 +// │ │ │ [CALL] fib(5) +// │ │ │ │ [CALL] fib(3) +// │ │ │ │ │ [CALL] fib(1) +// │ │ │ │ │ │ [RETURN] 1 +// │ │ │ │ │ [CALL] fib(2) +// │ │ │ │ │ │ [RETURN] 1 +// │ │ │ │ │ [RETURN] 2 +// │ │ │ │ [CALL] fib(4) +// │ │ │ │ │ [CALL] fib(2) +// │ │ │ │ │ │ [RETURN] 1 +// │ │ │ │ │ [CALL] fib(3) +// │ │ │ │ │ │ [CALL] fib(1) +// │ │ │ │ │ │ │ [RETURN] 1 +// │ │ │ │ │ │ [CALL] fib(2) +// │ │ │ │ │ │ │ [RETURN] 1 +// │ │ │ │ │ │ [RETURN] 2 +// │ │ │ │ │ [RETURN] 3 +// │ │ │ │ [RETURN] 5 +// │ │ │ [RETURN] 8 +// │ │ [RETURN] 13 +// │ [RETURN] 21 diff --git a/test/libyul/yulPureInterpreterTests/shadowed_symbol.yul b/test/libyul/yulPureInterpreterTests/shadowed_symbol.yul new file mode 100644 index 000000000000..ac5f5b3ca308 --- /dev/null +++ b/test/libyul/yulPureInterpreterTests/shadowed_symbol.yul @@ -0,0 +1,22 @@ +{ + function f() + { + // Variable declaration does not shadow namesake function declaration + // because latter not visible here. + let shadow_id + } + { + // Function named `shadow_id` is in scope now. + f() + function shadow_id() {} + } +} +// ==== +// EVMVersion: >=constantinople +// ---- +// Execution result: ExecutionOk +// Outer most variable values: +// +// Call trace: +// [CALL] f() +// │ [RETURN] diff --git a/test/libyul/yulPureInterpreterTests/smoke.yul b/test/libyul/yulPureInterpreterTests/smoke.yul new file mode 100644 index 000000000000..6e42acabe472 --- /dev/null +++ b/test/libyul/yulPureInterpreterTests/smoke.yul @@ -0,0 +1,6 @@ +{} +// ---- +// Execution result: ExecutionOk +// Outer most variable values: +// +// Call trace: diff --git a/test/libyul/yulPureInterpreterTests/step_limit_not_reached.yul b/test/libyul/yulPureInterpreterTests/step_limit_not_reached.yul new file mode 100644 index 000000000000..6da456ef36ac --- /dev/null +++ b/test/libyul/yulPureInterpreterTests/step_limit_not_reached.yul @@ -0,0 +1,14 @@ +{ + let i + for { i := 0 } lt(i, 100) { i := add(i, 1) } + { + } +} +// ==== +// maxSteps: 200 +// ---- +// Execution result: ExecutionOk +// Outer most variable values: +// i = 100 +// +// Call trace: diff --git a/test/libyul/yulPureInterpreterTests/step_limit_reached.yul b/test/libyul/yulPureInterpreterTests/step_limit_reached.yul new file mode 100644 index 000000000000..c8f2d9e380a8 --- /dev/null +++ b/test/libyul/yulPureInterpreterTests/step_limit_reached.yul @@ -0,0 +1,14 @@ +{ + let i + for { i := 0 } lt(i, 100) { i := add(i, 1) } + { + } +} +// ==== +// maxSteps: 100 +// ---- +// Execution result: StepLimitReached +// Outer most variable values: +// i = 96 +// +// Call trace: diff --git a/test/libyul/yulPureInterpreterTests/stop.yul b/test/libyul/yulPureInterpreterTests/stop.yul new file mode 100644 index 000000000000..9949bdf05d03 --- /dev/null +++ b/test/libyul/yulPureInterpreterTests/stop.yul @@ -0,0 +1,11 @@ +{ + let x := 1 + stop() + x := 2 +} +// ---- +// Execution result: ExplicitlyTerminated +// Outer most variable values: +// x = 1 +// +// Call trace: diff --git a/test/libyul/yulPureInterpreterTests/switch_statement.yul b/test/libyul/yulPureInterpreterTests/switch_statement.yul new file mode 100644 index 000000000000..fa69ce75113e --- /dev/null +++ b/test/libyul/yulPureInterpreterTests/switch_statement.yul @@ -0,0 +1,13 @@ +{ + let x + switch 7 + case 7 { x := 1 } + case 3 { x := 2 } + default { x := 3 } +} +// ---- +// Execution result: ExecutionOk +// Outer most variable values: +// x = 1 +// +// Call trace: diff --git a/test/libyul/yulPureInterpreterTests/verbatim.yul b/test/libyul/yulPureInterpreterTests/verbatim.yul new file mode 100644 index 000000000000..b1b2026aa743 --- /dev/null +++ b/test/libyul/yulPureInterpreterTests/verbatim.yul @@ -0,0 +1,12 @@ +{ + let double := verbatim_1i_1o(hex"600202", 1) +} +// The hext sequence was evaluated before verbatim +// Expectation for this test should be changed to `ImpureBuiltinEncountered` +// if in the future if the hex sequence is evaluated after. + +// ---- +// Execution result: UnlimitedLiteralEncountered +// Outer most variable values: +// +// Call trace: diff --git a/test/tools/CMakeLists.txt b/test/tools/CMakeLists.txt index 5c1d41b7f595..ad1f838d25d9 100644 --- a/test/tools/CMakeLists.txt +++ b/test/tools/CMakeLists.txt @@ -51,6 +51,7 @@ add_executable(isoltest ../libyul/YulOptimizerTest.cpp ../libyul/YulOptimizerTestCommon.cpp ../libyul/YulInterpreterTest.cpp + ../libyul/YulPureInterpreterTest.cpp ) target_compile_definitions(isoltest PRIVATE ISOLTEST) target_link_libraries(isoltest PRIVATE evmc libsolc solidity yulInterpreter evmasm Boost::boost Boost::program_options Boost::unit_test_framework Threads::Threads)