mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Yul: Adds optimizer pass to make variable names suffix-canonical.
This commit is contained in:
parent
c3e4c42bbd
commit
609855546e
@ -110,5 +110,7 @@ add_library(yul
|
||||
optimiser/UnusedPruner.h
|
||||
optimiser/VarDeclInitializer.cpp
|
||||
optimiser/VarDeclInitializer.h
|
||||
optimiser/VarNameCleaner.cpp
|
||||
optimiser/VarNameCleaner.h
|
||||
)
|
||||
target_link_libraries(yul PUBLIC evmasm devcore langutil)
|
||||
|
@ -40,10 +40,14 @@
|
||||
#include <libyul/optimiser/StackCompressor.h>
|
||||
#include <libyul/optimiser/StructuralSimplifier.h>
|
||||
#include <libyul/optimiser/RedundantAssignEliminator.h>
|
||||
#include <libyul/optimiser/VarNameCleaner.h>
|
||||
#include <libyul/AsmAnalysis.h>
|
||||
#include <libyul/AsmAnalysisInfo.h>
|
||||
#include <libyul/AsmData.h>
|
||||
#include <libyul/AsmPrinter.h>
|
||||
|
||||
#include <libyul/backends/evm/NoOutputAssembly.h>
|
||||
|
||||
#include <libdevcore/CommonData.h>
|
||||
|
||||
using namespace std;
|
||||
@ -61,16 +65,16 @@ void OptimiserSuite::run(
|
||||
|
||||
Block ast = boost::get<Block>(Disambiguator(*_dialect, _analysisInfo, reservedIdentifiers)(_ast));
|
||||
|
||||
(VarDeclInitializer{})(ast);
|
||||
(FunctionHoister{})(ast);
|
||||
(BlockFlattener{})(ast);
|
||||
(FunctionGrouper{})(ast);
|
||||
VarDeclInitializer{}(ast);
|
||||
FunctionHoister{}(ast);
|
||||
BlockFlattener{}(ast);
|
||||
FunctionGrouper{}(ast);
|
||||
EquivalentFunctionCombiner::run(ast);
|
||||
UnusedPruner::runUntilStabilised(*_dialect, ast, reservedIdentifiers);
|
||||
(ForLoopInitRewriter{})(ast);
|
||||
(BlockFlattener{})(ast);
|
||||
ForLoopInitRewriter{}(ast);
|
||||
BlockFlattener{}(ast);
|
||||
StructuralSimplifier{*_dialect}(ast);
|
||||
(BlockFlattener{})(ast);
|
||||
BlockFlattener{}(ast);
|
||||
|
||||
// None of the above can make stack problems worse.
|
||||
|
||||
@ -92,7 +96,7 @@ void OptimiserSuite::run(
|
||||
{
|
||||
// still in SSA, perform structural simplification
|
||||
StructuralSimplifier{*_dialect}(ast);
|
||||
(BlockFlattener{})(ast);
|
||||
BlockFlattener{}(ast);
|
||||
UnusedPruner::runUntilStabilised(*_dialect, ast, reservedIdentifiers);
|
||||
}
|
||||
{
|
||||
@ -130,10 +134,10 @@ void OptimiserSuite::run(
|
||||
|
||||
{
|
||||
// run full inliner
|
||||
(FunctionGrouper{})(ast);
|
||||
FunctionGrouper{}(ast);
|
||||
EquivalentFunctionCombiner::run(ast);
|
||||
FullInliner{ast, dispenser}.run();
|
||||
(BlockFlattener{})(ast);
|
||||
BlockFlattener{}(ast);
|
||||
}
|
||||
|
||||
{
|
||||
@ -143,7 +147,7 @@ void OptimiserSuite::run(
|
||||
RedundantAssignEliminator::run(*_dialect, ast);
|
||||
ExpressionSimplifier::run(*_dialect, ast);
|
||||
StructuralSimplifier{*_dialect}(ast);
|
||||
(BlockFlattener{})(ast);
|
||||
BlockFlattener{}(ast);
|
||||
CommonSubexpressionEliminator{*_dialect}(ast);
|
||||
SSATransform::run(ast, dispenser);
|
||||
RedundantAssignEliminator::run(*_dialect, ast);
|
||||
@ -171,9 +175,12 @@ void OptimiserSuite::run(
|
||||
Rematerialiser::run(*_dialect, ast);
|
||||
UnusedPruner::runUntilStabilised(*_dialect, ast, reservedIdentifiers);
|
||||
|
||||
(FunctionGrouper{})(ast);
|
||||
FunctionGrouper{}(ast);
|
||||
StackCompressor::run(_dialect, ast);
|
||||
(BlockFlattener{})(ast);
|
||||
BlockFlattener{}(ast);
|
||||
|
||||
VarNameCleaner{ast, *_dialect, reservedIdentifiers}(ast);
|
||||
yul::AsmAnalyzer::analyzeStrictAssertCorrect(_dialect, ast);
|
||||
|
||||
_ast = std::move(ast);
|
||||
}
|
||||
|
122
libyul/optimiser/VarNameCleaner.cpp
Normal file
122
libyul/optimiser/VarNameCleaner.cpp
Normal file
@ -0,0 +1,122 @@
|
||||
/*
|
||||
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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <libyul/optimiser/VarNameCleaner.h>
|
||||
#include <libyul/AsmData.h>
|
||||
#include <libyul/Dialect.h>
|
||||
#include <algorithm>
|
||||
#include <cctype>
|
||||
#include <climits>
|
||||
#include <iterator>
|
||||
#include <string>
|
||||
#include <regex>
|
||||
|
||||
using namespace yul;
|
||||
using namespace std;
|
||||
|
||||
VarNameCleaner::VarNameCleaner(
|
||||
Block const& _ast,
|
||||
Dialect const& _dialect,
|
||||
set<YulString> _blacklist
|
||||
):
|
||||
m_dialect{_dialect},
|
||||
m_blacklist{std::move(_blacklist)},
|
||||
m_translatedNames{}
|
||||
{
|
||||
for (auto const& statement: _ast.statements)
|
||||
if (statement.type() == typeid(FunctionDefinition))
|
||||
m_blacklist.insert(boost::get<FunctionDefinition>(statement).name);
|
||||
m_usedNames = m_blacklist;
|
||||
}
|
||||
|
||||
void VarNameCleaner::operator()(FunctionDefinition& _funDef)
|
||||
{
|
||||
yulAssert(!m_insideFunction, "");
|
||||
m_insideFunction = true;
|
||||
|
||||
set<YulString> globalUsedNames = std::move(m_usedNames);
|
||||
m_usedNames = m_blacklist;
|
||||
map<YulString, YulString> globalTranslatedNames;
|
||||
swap(globalTranslatedNames, m_translatedNames);
|
||||
|
||||
renameVariables(_funDef.parameters);
|
||||
renameVariables(_funDef.returnVariables);
|
||||
ASTModifier::operator()(_funDef);
|
||||
|
||||
swap(globalUsedNames, m_usedNames);
|
||||
swap(globalTranslatedNames, m_translatedNames);
|
||||
|
||||
m_insideFunction = false;
|
||||
}
|
||||
|
||||
void VarNameCleaner::operator()(VariableDeclaration& _varDecl)
|
||||
{
|
||||
renameVariables(_varDecl.variables);
|
||||
ASTModifier::operator()(_varDecl);
|
||||
}
|
||||
|
||||
void VarNameCleaner::renameVariables(vector<TypedName>& _variables)
|
||||
{
|
||||
for (TypedName& typedName: _variables)
|
||||
{
|
||||
auto newName = findCleanName(typedName.name);
|
||||
if (newName != typedName.name)
|
||||
{
|
||||
m_translatedNames[typedName.name] = newName;
|
||||
typedName.name = newName;
|
||||
}
|
||||
m_usedNames.insert(typedName.name);
|
||||
}
|
||||
}
|
||||
|
||||
void VarNameCleaner::operator()(Identifier& _identifier)
|
||||
{
|
||||
auto name = m_translatedNames.find(_identifier.name);
|
||||
if (name != m_translatedNames.end())
|
||||
_identifier.name = name->second;
|
||||
}
|
||||
|
||||
YulString VarNameCleaner::findCleanName(YulString const& _name) const
|
||||
{
|
||||
auto newName = stripSuffix(_name);
|
||||
if (newName != YulString{} && !isUsedName(newName))
|
||||
return newName;
|
||||
|
||||
// create new name with suffix (by finding a free identifier)
|
||||
for (size_t i = 1; i < numeric_limits<decltype(i)>::max(); ++i)
|
||||
{
|
||||
YulString newNameSuffixed = YulString{newName.str() + "_" + to_string(i)};
|
||||
if (!isUsedName(newNameSuffixed))
|
||||
return newNameSuffixed;
|
||||
}
|
||||
yulAssert(false, "Exhausted by attempting to find an available suffix.");
|
||||
}
|
||||
|
||||
bool VarNameCleaner::isUsedName(YulString const& _name) const
|
||||
{
|
||||
return m_dialect.builtin(_name) || m_usedNames.count(_name);
|
||||
}
|
||||
|
||||
YulString VarNameCleaner::stripSuffix(YulString const& _name) const
|
||||
{
|
||||
static regex const suffixRegex("(_+[0-9]+)+$");
|
||||
|
||||
smatch suffixMatch;
|
||||
if (regex_search(_name.str(), suffixMatch, suffixRegex))
|
||||
return {YulString{suffixMatch.prefix().str()}};
|
||||
return _name;
|
||||
}
|
86
libyul/optimiser/VarNameCleaner.h
Normal file
86
libyul/optimiser/VarNameCleaner.h
Normal file
@ -0,0 +1,86 @@
|
||||
/*
|
||||
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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
|
||||
#include <libyul/AsmDataForward.h>
|
||||
#include <libyul/optimiser/ASTWalker.h>
|
||||
#include <libyul/YulString.h>
|
||||
|
||||
#include <map>
|
||||
#include <set>
|
||||
#include <string>
|
||||
|
||||
namespace yul
|
||||
{
|
||||
|
||||
struct Dialect;
|
||||
|
||||
/**
|
||||
* Pass to normalize identifier suffixes.
|
||||
*
|
||||
* That is, for each function scope, nested suffixes get flattened and all suffixes
|
||||
* renumbered by their base name.
|
||||
* Function names are not modified.
|
||||
*
|
||||
* Prerequisites: Disambiguator, FunctionHoister
|
||||
*/
|
||||
class VarNameCleaner: public ASTModifier
|
||||
{
|
||||
public:
|
||||
VarNameCleaner(
|
||||
Block const& _ast,
|
||||
Dialect const& _dialect,
|
||||
std::set<YulString> _blacklist = {}
|
||||
);
|
||||
|
||||
using ASTModifier::operator();
|
||||
void operator()(VariableDeclaration& _varDecl) override;
|
||||
void operator()(Identifier& _identifier) override;
|
||||
void operator()(FunctionDefinition& _funDef) override;
|
||||
|
||||
private:
|
||||
/// Tries to rename a list of variables.
|
||||
void renameVariables(std::vector<TypedName>& _variables);
|
||||
|
||||
/// @returns suffix-stripped name, if a suffix was detected, none otherwise.
|
||||
YulString stripSuffix(YulString const& _name) const;
|
||||
|
||||
/// Looks out for a "clean name" the given @p name could be trimmed down to.
|
||||
/// @returns a trimmed down and "clean name" in case it found one, none otherwise.
|
||||
YulString findCleanName(YulString const& name) const;
|
||||
|
||||
/// Tests whether a given name was already used within this pass
|
||||
/// or is on the blacklist.
|
||||
bool isUsedName(YulString const& _name) const;
|
||||
|
||||
Dialect const& m_dialect;
|
||||
std::set<YulString> m_blacklist;
|
||||
|
||||
/// Set of names that are in use.
|
||||
std::set<YulString> m_usedNames;
|
||||
|
||||
/// Maps old to new names.
|
||||
std::map<YulString, YulString> m_translatedNames;
|
||||
|
||||
/// Whether the traverse is inside a function definition.
|
||||
/// Used to assert that a function definition cannot be inside another.
|
||||
bool m_insideFunction = false;
|
||||
};
|
||||
|
||||
}
|
@ -5,9 +5,9 @@ Pretty printed source:
|
||||
object "MyContract" {
|
||||
code {
|
||||
sstore(0, caller())
|
||||
let _3 := datasize("Runtime")
|
||||
datacopy(0, dataoffset("Runtime"), _3)
|
||||
return(0, _3)
|
||||
let _1 := datasize("Runtime")
|
||||
datacopy(0, dataoffset("Runtime"), _1)
|
||||
return(0, _1)
|
||||
}
|
||||
object "Runtime" {
|
||||
code {
|
||||
|
@ -21,6 +21,7 @@
|
||||
|
||||
#include <libyul/optimiser/BlockFlattener.h>
|
||||
#include <libyul/optimiser/VarDeclInitializer.h>
|
||||
#include <libyul/optimiser/VarNameCleaner.h>
|
||||
#include <libyul/optimiser/Disambiguator.h>
|
||||
#include <libyul/optimiser/CommonSubexpressionEliminator.h>
|
||||
#include <libyul/optimiser/NameCollector.h>
|
||||
@ -110,6 +111,8 @@ bool YulOptimizerTest::run(ostream& _stream, string const& _linePrefix, bool con
|
||||
}
|
||||
else if (m_optimizerStep == "varDeclInitializer")
|
||||
VarDeclInitializer{}(*m_ast);
|
||||
else if (m_optimizerStep == "varNameCleaner")
|
||||
VarNameCleaner{*m_ast, *m_dialect}(*m_ast);
|
||||
else if (m_optimizerStep == "forLoopInitRewriter")
|
||||
{
|
||||
disambiguate();
|
||||
|
@ -1072,73 +1072,73 @@
|
||||
// ----
|
||||
// fullSuite
|
||||
// {
|
||||
// let _2 := mload(1)
|
||||
// let _134 := mload(0)
|
||||
// if slt(sub(_2, _134), 64)
|
||||
// let _1 := mload(1)
|
||||
// let _2 := mload(0)
|
||||
// if slt(sub(_1, _2), 64)
|
||||
// {
|
||||
// revert(0, 0)
|
||||
// }
|
||||
// sstore(0, and(calldataload(_134), 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF))
|
||||
// sstore(0, and(calldataload(_2), 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF))
|
||||
// let x0, x1, x2, x3, x4 := abi_decode_tuple_t_addresst_uint256t_bytes_calldata_ptrt_enum$_Operation_$1949(mload(7), mload(8))
|
||||
// sstore(x1, x0)
|
||||
// sstore(x3, x2)
|
||||
// sstore(1, x4)
|
||||
// pop(abi_encode_tuple_t_bytes32_t_address_t_uint256_t_bytes32_t_enum$_Operation_$1949_t_uint256_t_uint256_t_uint256_t_address_t_address_t_uint256__to_t_bytes32_t_address_t_uint256_t_bytes32_t_uint8_t_uint256_t_uint256_t_uint256_t_address_t_address_t_uint256_(mload(30), mload(31), mload(32), mload(33), mload(34), mload(35), mload(36), mload(37), mload(38), mload(39), mload(40), mload(41)))
|
||||
// function abi_decode_tuple_t_addresst_uint256t_bytes_calldata_ptrt_enum$_Operation_$1949(headStart_55, dataEnd_56) -> value0_57, value1_58, value2_59, value3, value4
|
||||
// function abi_decode_tuple_t_addresst_uint256t_bytes_calldata_ptrt_enum$_Operation_$1949(headStart, dataEnd) -> value0, value1, value2, value3, value4
|
||||
// {
|
||||
// if slt(sub(dataEnd_56, headStart_55), 128)
|
||||
// if slt(sub(dataEnd, headStart), 128)
|
||||
// {
|
||||
// revert(value4, value4)
|
||||
// }
|
||||
// value0_57 := and(calldataload(headStart_55), 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF)
|
||||
// value1_58 := calldataload(add(headStart_55, 32))
|
||||
// let offset_62 := calldataload(add(headStart_55, 64))
|
||||
// let _181 := 0xffffffffffffffff
|
||||
// if gt(offset_62, _181)
|
||||
// value0 := and(calldataload(headStart), 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF)
|
||||
// value1 := calldataload(add(headStart, 32))
|
||||
// let offset := calldataload(add(headStart, 64))
|
||||
// let _1 := 0xffffffffffffffff
|
||||
// if gt(offset, _1)
|
||||
// {
|
||||
// revert(value4, value4)
|
||||
// }
|
||||
// let _183 := add(headStart_55, offset_62)
|
||||
// if iszero(slt(add(_183, 0x1f), dataEnd_56))
|
||||
// let _2 := add(headStart, offset)
|
||||
// if iszero(slt(add(_2, 0x1f), dataEnd))
|
||||
// {
|
||||
// revert(value4, value4)
|
||||
// }
|
||||
// let abi_decode_length_15_225 := calldataload(_183)
|
||||
// if gt(abi_decode_length_15_225, _181)
|
||||
// let abi_decode_length := calldataload(_2)
|
||||
// if gt(abi_decode_length, _1)
|
||||
// {
|
||||
// revert(value4, value4)
|
||||
// }
|
||||
// if gt(add(add(_183, abi_decode_length_15_225), 32), dataEnd_56)
|
||||
// if gt(add(add(_2, abi_decode_length), 32), dataEnd)
|
||||
// {
|
||||
// revert(value4, value4)
|
||||
// }
|
||||
// value2_59 := add(_183, 32)
|
||||
// value3 := abi_decode_length_15_225
|
||||
// let _186 := calldataload(add(headStart_55, 96))
|
||||
// if iszero(lt(_186, 3))
|
||||
// value2 := add(_2, 32)
|
||||
// value3 := abi_decode_length
|
||||
// let _3 := calldataload(add(headStart, 96))
|
||||
// if iszero(lt(_3, 3))
|
||||
// {
|
||||
// revert(value4, value4)
|
||||
// }
|
||||
// value4 := _186
|
||||
// value4 := _3
|
||||
// }
|
||||
// function abi_encode_tuple_t_bytes32_t_address_t_uint256_t_bytes32_t_enum$_Operation_$1949_t_uint256_t_uint256_t_uint256_t_address_t_address_t_uint256__to_t_bytes32_t_address_t_uint256_t_bytes32_t_uint8_t_uint256_t_uint256_t_uint256_t_address_t_address_t_uint256_(headStart_252, value10_253, value9_254, value8_255, value7_256, value6_257, value5_258, value4_259, value3_260, value2_261, value1_262, value0_263) -> tail_264
|
||||
// function abi_encode_tuple_t_bytes32_t_address_t_uint256_t_bytes32_t_enum$_Operation_$1949_t_uint256_t_uint256_t_uint256_t_address_t_address_t_uint256__to_t_bytes32_t_address_t_uint256_t_bytes32_t_uint8_t_uint256_t_uint256_t_uint256_t_address_t_address_t_uint256_(headStart, value10, value9, value8, value7, value6, value5, value4, value3, value2, value1, value0) -> tail
|
||||
// {
|
||||
// tail_264 := add(headStart_252, 352)
|
||||
// mstore(headStart_252, value0_263)
|
||||
// let _382 := 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
|
||||
// mstore(add(headStart_252, 32), and(value1_262, _382))
|
||||
// mstore(add(headStart_252, 64), value2_261)
|
||||
// mstore(add(headStart_252, 96), value3_260)
|
||||
// if iszero(lt(value4_259, 3))
|
||||
// tail := add(headStart, 352)
|
||||
// mstore(headStart, value0)
|
||||
// let _1 := 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
|
||||
// mstore(add(headStart, 32), and(value1, _1))
|
||||
// mstore(add(headStart, 64), value2)
|
||||
// mstore(add(headStart, 96), value3)
|
||||
// if iszero(lt(value4, 3))
|
||||
// {
|
||||
// invalid()
|
||||
// }
|
||||
// mstore(add(headStart_252, 128), value4_259)
|
||||
// mstore(add(headStart_252, 160), value5_258)
|
||||
// mstore(add(headStart_252, 192), value6_257)
|
||||
// mstore(add(headStart_252, 224), value7_256)
|
||||
// mstore(add(headStart_252, 256), and(value8_255, _382))
|
||||
// mstore(add(headStart_252, 288), and(value9_254, _382))
|
||||
// mstore(add(headStart_252, 320), value10_253)
|
||||
// mstore(add(headStart, 128), value4)
|
||||
// mstore(add(headStart, 160), value5)
|
||||
// mstore(add(headStart, 192), value6)
|
||||
// mstore(add(headStart, 224), value7)
|
||||
// mstore(add(headStart, 256), and(value8, _1))
|
||||
// mstore(add(headStart, 288), and(value9, _1))
|
||||
// mstore(add(headStart, 320), value10)
|
||||
// }
|
||||
// }
|
||||
|
@ -460,142 +460,142 @@
|
||||
// {
|
||||
// let _1 := 0x20
|
||||
// let _2 := 0
|
||||
// let _168 := mload(_2)
|
||||
// let _3 := mload(_2)
|
||||
// let abi_encode_pos := _1
|
||||
// let abi_encode_length_68 := mload(_168)
|
||||
// mstore(_1, abi_encode_length_68)
|
||||
// let abi_encode_length := mload(_3)
|
||||
// mstore(_1, abi_encode_length)
|
||||
// abi_encode_pos := 64
|
||||
// let abi_encode_srcPtr := add(_168, _1)
|
||||
// let abi_encode_i_69 := _2
|
||||
// let abi_encode_srcPtr := add(_3, _1)
|
||||
// let abi_encode_i := _2
|
||||
// for {
|
||||
// }
|
||||
// lt(abi_encode_i_69, abi_encode_length_68)
|
||||
// lt(abi_encode_i, abi_encode_length)
|
||||
// {
|
||||
// abi_encode_i_69 := add(abi_encode_i_69, 1)
|
||||
// abi_encode_i := add(abi_encode_i, 1)
|
||||
// }
|
||||
// {
|
||||
// let _491 := mload(abi_encode_srcPtr)
|
||||
// let abi_encode_pos_71_583 := abi_encode_pos
|
||||
// let abi_encode_srcPtr_73_585 := _491
|
||||
// let abi_encode_i_74_586 := _2
|
||||
// let _4 := mload(abi_encode_srcPtr)
|
||||
// let abi_encode_pos_1 := abi_encode_pos
|
||||
// let abi_encode_srcPtr_1 := _4
|
||||
// let abi_encode_i_1 := _2
|
||||
// for {
|
||||
// }
|
||||
// lt(abi_encode_i_74_586, 0x3)
|
||||
// lt(abi_encode_i_1, 0x3)
|
||||
// {
|
||||
// abi_encode_i_74_586 := add(abi_encode_i_74_586, 1)
|
||||
// abi_encode_i_1 := add(abi_encode_i_1, 1)
|
||||
// }
|
||||
// {
|
||||
// mstore(abi_encode_pos_71_583, and(mload(abi_encode_srcPtr_73_585), 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF))
|
||||
// abi_encode_srcPtr_73_585 := add(abi_encode_srcPtr_73_585, _1)
|
||||
// abi_encode_pos_71_583 := add(abi_encode_pos_71_583, _1)
|
||||
// mstore(abi_encode_pos_1, and(mload(abi_encode_srcPtr_1), 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF))
|
||||
// abi_encode_srcPtr_1 := add(abi_encode_srcPtr_1, _1)
|
||||
// abi_encode_pos_1 := add(abi_encode_pos_1, _1)
|
||||
// }
|
||||
// abi_encode_srcPtr := add(abi_encode_srcPtr, _1)
|
||||
// abi_encode_pos := add(abi_encode_pos, 0x60)
|
||||
// }
|
||||
// let _170 := mload(64)
|
||||
// let _171 := mload(_1)
|
||||
// if slt(sub(_170, _171), 128)
|
||||
// let _5 := mload(64)
|
||||
// let _6 := mload(_1)
|
||||
// if slt(sub(_5, _6), 128)
|
||||
// {
|
||||
// revert(_2, _2)
|
||||
// }
|
||||
// let abi_decode_offset_64 := calldataload(add(_171, 64))
|
||||
// let abi_decode__74 := 0xffffffffffffffff
|
||||
// if gt(abi_decode_offset_64, abi_decode__74)
|
||||
// let abi_decode_offset := calldataload(add(_6, 64))
|
||||
// let abi_decode := 0xffffffffffffffff
|
||||
// if gt(abi_decode_offset, abi_decode)
|
||||
// {
|
||||
// revert(_2, _2)
|
||||
// }
|
||||
// let abi_decode_value2_264 := abi_decode_t_array$_t_uint256_$dyn_memory_ptr(add(_171, abi_decode_offset_64), _170)
|
||||
// let abi_decode_offset_65 := calldataload(add(_171, 96))
|
||||
// if gt(abi_decode_offset_65, abi_decode__74)
|
||||
// let abi_decode_value2 := abi_decode_t_array$_t_uint256_$dyn_memory_ptr(add(_6, abi_decode_offset), _5)
|
||||
// let abi_decode_offset_1 := calldataload(add(_6, 96))
|
||||
// if gt(abi_decode_offset_1, abi_decode)
|
||||
// {
|
||||
// revert(_2, _2)
|
||||
// }
|
||||
// let abi_decode_value3_265 := abi_decode_t_array$_t_array$_t_uint256_$2_memory_$dyn_memory_ptr(add(_171, abi_decode_offset_65), _170)
|
||||
// sstore(calldataload(_171), calldataload(add(_171, _1)))
|
||||
// sstore(abi_decode_value2_264, abi_decode_value3_265)
|
||||
// let abi_decode_value3 := abi_decode_t_array$_t_array$_t_uint256_$2_memory_$dyn_memory_ptr(add(_6, abi_decode_offset_1), _5)
|
||||
// sstore(calldataload(_6), calldataload(add(_6, _1)))
|
||||
// sstore(abi_decode_value2, abi_decode_value3)
|
||||
// sstore(_2, abi_encode_pos)
|
||||
// function abi_decode_t_array$_t_array$_t_uint256_$2_memory_$dyn_memory_ptr(offset_3, end_4) -> array_5
|
||||
// function abi_decode_t_array$_t_array$_t_uint256_$2_memory_$dyn_memory_ptr(offset, end) -> array
|
||||
// {
|
||||
// if iszero(slt(add(offset_3, 0x1f), end_4))
|
||||
// if iszero(slt(add(offset, 0x1f), end))
|
||||
// {
|
||||
// revert(array_5, array_5)
|
||||
// revert(array, array)
|
||||
// }
|
||||
// let length_6 := calldataload(offset_3)
|
||||
// array_5 := allocateMemory(array_allocation_size_t_array$_t_address_$dyn_memory(length_6))
|
||||
// let dst_7 := array_5
|
||||
// mstore(array_5, length_6)
|
||||
// let _16 := 0x20
|
||||
// dst_7 := add(array_5, _16)
|
||||
// let src_8 := add(offset_3, _16)
|
||||
// if gt(add(add(offset_3, mul(length_6, 0x40)), _16), end_4)
|
||||
// let length := calldataload(offset)
|
||||
// array := allocateMemory(array_allocation_size_t_array$_t_address_$dyn_memory(length))
|
||||
// let dst := array
|
||||
// mstore(array, length)
|
||||
// let _1 := 0x20
|
||||
// dst := add(array, _1)
|
||||
// let src := add(offset, _1)
|
||||
// if gt(add(add(offset, mul(length, 0x40)), _1), end)
|
||||
// {
|
||||
// revert(0, 0)
|
||||
// }
|
||||
// let i_9 := 0
|
||||
// let i := 0
|
||||
// for {
|
||||
// }
|
||||
// lt(i_9, length_6)
|
||||
// lt(i, length)
|
||||
// {
|
||||
// i_9 := add(i_9, 1)
|
||||
// i := add(i, 1)
|
||||
// }
|
||||
// {
|
||||
// if iszero(slt(add(src_8, 0x1f), end_4))
|
||||
// if iszero(slt(add(src, 0x1f), end))
|
||||
// {
|
||||
// revert(0, 0)
|
||||
// }
|
||||
// let abi_decode_dst_15 := allocateMemory(array_allocation_size_t_array$_t_uint256_$2_memory(0x2))
|
||||
// let abi_decode_dst_15_990 := abi_decode_dst_15
|
||||
// let abi_decode_src_16 := src_8
|
||||
// let abi_decode__188 := add(src_8, 0x40)
|
||||
// if gt(abi_decode__188, end_4)
|
||||
// let abi_decode_dst := allocateMemory(array_allocation_size_t_array$_t_uint256_$2_memory(0x2))
|
||||
// let abi_decode_dst_1 := abi_decode_dst
|
||||
// let abi_decode_src := src
|
||||
// let abi_decode := add(src, 0x40)
|
||||
// if gt(abi_decode, end)
|
||||
// {
|
||||
// revert(0, 0)
|
||||
// }
|
||||
// let abi_decode_i_17 := 0
|
||||
// let abi_decode_i := 0
|
||||
// for {
|
||||
// }
|
||||
// lt(abi_decode_i_17, 0x2)
|
||||
// lt(abi_decode_i, 0x2)
|
||||
// {
|
||||
// abi_decode_i_17 := add(abi_decode_i_17, 1)
|
||||
// abi_decode_i := add(abi_decode_i, 1)
|
||||
// }
|
||||
// {
|
||||
// mstore(abi_decode_dst_15, calldataload(abi_decode_src_16))
|
||||
// abi_decode_dst_15 := add(abi_decode_dst_15, _16)
|
||||
// abi_decode_src_16 := add(abi_decode_src_16, _16)
|
||||
// mstore(abi_decode_dst, calldataload(abi_decode_src))
|
||||
// abi_decode_dst := add(abi_decode_dst, _1)
|
||||
// abi_decode_src := add(abi_decode_src, _1)
|
||||
// }
|
||||
// mstore(dst_7, abi_decode_dst_15_990)
|
||||
// dst_7 := add(dst_7, _16)
|
||||
// src_8 := abi_decode__188
|
||||
// mstore(dst, abi_decode_dst_1)
|
||||
// dst := add(dst, _1)
|
||||
// src := abi_decode
|
||||
// }
|
||||
// }
|
||||
// function abi_decode_t_array$_t_uint256_$dyn_memory_ptr(offset_27, end_28) -> array_29
|
||||
// function abi_decode_t_array$_t_uint256_$dyn_memory_ptr(offset, end) -> array
|
||||
// {
|
||||
// if iszero(slt(add(offset_27, 0x1f), end_28))
|
||||
// if iszero(slt(add(offset, 0x1f), end))
|
||||
// {
|
||||
// revert(array_29, array_29)
|
||||
// revert(array, array)
|
||||
// }
|
||||
// let length_30 := calldataload(offset_27)
|
||||
// array_29 := allocateMemory(array_allocation_size_t_array$_t_address_$dyn_memory(length_30))
|
||||
// let dst_31 := array_29
|
||||
// mstore(array_29, length_30)
|
||||
// let _52 := 0x20
|
||||
// dst_31 := add(array_29, _52)
|
||||
// let src_32 := add(offset_27, _52)
|
||||
// if gt(add(add(offset_27, mul(length_30, _52)), _52), end_28)
|
||||
// let length := calldataload(offset)
|
||||
// array := allocateMemory(array_allocation_size_t_array$_t_address_$dyn_memory(length))
|
||||
// let dst := array
|
||||
// mstore(array, length)
|
||||
// let _1 := 0x20
|
||||
// dst := add(array, _1)
|
||||
// let src := add(offset, _1)
|
||||
// if gt(add(add(offset, mul(length, _1)), _1), end)
|
||||
// {
|
||||
// revert(0, 0)
|
||||
// }
|
||||
// let i_33 := 0
|
||||
// let i := 0
|
||||
// for {
|
||||
// }
|
||||
// lt(i_33, length_30)
|
||||
// lt(i, length)
|
||||
// {
|
||||
// i_33 := add(i_33, 1)
|
||||
// i := add(i, 1)
|
||||
// }
|
||||
// {
|
||||
// mstore(dst_31, calldataload(src_32))
|
||||
// dst_31 := add(dst_31, _52)
|
||||
// src_32 := add(src_32, _52)
|
||||
// mstore(dst, calldataload(src))
|
||||
// dst := add(dst, _1)
|
||||
// src := add(src, _1)
|
||||
// }
|
||||
// }
|
||||
// function allocateMemory(size) -> memPtr
|
||||
@ -608,20 +608,20 @@
|
||||
// }
|
||||
// mstore(64, newFreePtr)
|
||||
// }
|
||||
// function array_allocation_size_t_array$_t_address_$dyn_memory(length_90) -> size_91
|
||||
// function array_allocation_size_t_array$_t_address_$dyn_memory(length) -> size
|
||||
// {
|
||||
// if gt(length_90, 0xffffffffffffffff)
|
||||
// if gt(length, 0xffffffffffffffff)
|
||||
// {
|
||||
// revert(0, 0)
|
||||
// }
|
||||
// size_91 := add(mul(length_90, 0x20), 0x20)
|
||||
// size := add(mul(length, 0x20), 0x20)
|
||||
// }
|
||||
// function array_allocation_size_t_array$_t_uint256_$2_memory(length_94) -> size_95
|
||||
// function array_allocation_size_t_array$_t_uint256_$2_memory(length) -> size
|
||||
// {
|
||||
// if gt(length_94, 0xffffffffffffffff)
|
||||
// if gt(length, 0xffffffffffffffff)
|
||||
// {
|
||||
// revert(0, 0)
|
||||
// }
|
||||
// size_95 := mul(length_94, 0x20)
|
||||
// size := mul(length, 0x20)
|
||||
// }
|
||||
// }
|
||||
|
@ -231,8 +231,8 @@
|
||||
// ----
|
||||
// fullSuite
|
||||
// {
|
||||
// let validateJo__6 := 0x80
|
||||
// mstore(validateJo__6, 7673901602397024137095011250362199966051872585513276903826533215767972925880)
|
||||
// let validateJo := 0x80
|
||||
// mstore(validateJo, 7673901602397024137095011250362199966051872585513276903826533215767972925880)
|
||||
// mstore(0xa0, 8489654445897228341090914135473290831551238522473825886865492707826370766375)
|
||||
// let validateJo_m := calldataload(0x24)
|
||||
// let validateJo_n := calldataload(add(0x04, calldataload(0x04)))
|
||||
@ -249,9 +249,9 @@
|
||||
// mstore(0x2e0, validateJo_m)
|
||||
// validateJo_kn := mulmod(sub(validateJo_gen_order, validateJo_kn), validateJo_challenge, validateJo_gen_order)
|
||||
// hashCommitments(add(0x04, calldataload(0x04)), validateJo_n)
|
||||
// let validateJo_b := add(0x300, mul(validateJo_n, validateJo__6))
|
||||
// let validateJo_b := add(0x300, mul(validateJo_n, validateJo))
|
||||
// let validateJo_i := 0
|
||||
// let validateJo_i_1218 := validateJo_i
|
||||
// let validateJo_i_1 := validateJo_i
|
||||
// for {
|
||||
// }
|
||||
// lt(validateJo_i, validateJo_n)
|
||||
@ -259,9 +259,9 @@
|
||||
// validateJo_i := add(validateJo_i, 0x01)
|
||||
// }
|
||||
// {
|
||||
// let validateJo__329 := add(calldataload(0x04), mul(validateJo_i, 0xc0))
|
||||
// let validateJo_k := validateJo_i_1218
|
||||
// let validateJo_a := calldataload(add(validateJo__329, 0x44))
|
||||
// let validateJo_1 := add(calldataload(0x04), mul(validateJo_i, 0xc0))
|
||||
// let validateJo_k := validateJo_i_1
|
||||
// let validateJo_a := calldataload(add(validateJo_1, 0x44))
|
||||
// let validateJo_c := validateJo_challenge
|
||||
// switch eq(add(validateJo_i, 0x01), validateJo_n)
|
||||
// case 1 {
|
||||
@ -272,52 +272,52 @@
|
||||
// }
|
||||
// }
|
||||
// case 0 {
|
||||
// validateJo_k := calldataload(add(validateJo__329, 0x24))
|
||||
// validateJo_k := calldataload(add(validateJo_1, 0x24))
|
||||
// }
|
||||
// validateCommitment(add(validateJo__329, 0x24), validateJo_k, validateJo_a)
|
||||
// validateCommitment(add(validateJo_1, 0x24), validateJo_k, validateJo_a)
|
||||
// switch gt(add(validateJo_i, 0x01), validateJo_m)
|
||||
// case 1 {
|
||||
// validateJo_kn := addmod(validateJo_kn, sub(validateJo_gen_order, validateJo_k), validateJo_gen_order)
|
||||
// let validateJo_x := mod(mload(validateJo_i_1218), validateJo_gen_order)
|
||||
// let validateJo_x := mod(mload(validateJo_i_1), validateJo_gen_order)
|
||||
// validateJo_k := mulmod(validateJo_k, validateJo_x, validateJo_gen_order)
|
||||
// validateJo_a := mulmod(validateJo_a, validateJo_x, validateJo_gen_order)
|
||||
// validateJo_c := mulmod(validateJo_challenge, validateJo_x, validateJo_gen_order)
|
||||
// mstore(validateJo_i_1218, keccak256(validateJo_i_1218, 0x20))
|
||||
// mstore(validateJo_i_1, keccak256(validateJo_i_1, 0x20))
|
||||
// }
|
||||
// case 0 {
|
||||
// validateJo_kn := addmod(validateJo_kn, validateJo_k, validateJo_gen_order)
|
||||
// }
|
||||
// let validateJo__52 := 0x40
|
||||
// calldatacopy(0xe0, add(validateJo__329, 164), validateJo__52)
|
||||
// calldatacopy(0x20, add(validateJo__329, 100), validateJo__52)
|
||||
// let validateJo_2 := 0x40
|
||||
// calldatacopy(0xe0, add(validateJo_1, 164), validateJo_2)
|
||||
// calldatacopy(0x20, add(validateJo_1, 100), validateJo_2)
|
||||
// mstore(0x120, sub(validateJo_gen_order, validateJo_c))
|
||||
// mstore(0x60, validateJo_k)
|
||||
// mstore(0xc0, validateJo_a)
|
||||
// let validateJo_result := call(gas(), 7, validateJo_i_1218, 0xe0, 0x60, 0x1a0, validateJo__52)
|
||||
// let validateJo_result_303 := and(validateJo_result, call(gas(), 7, validateJo_i_1218, 0x20, 0x60, 0x120, validateJo__52))
|
||||
// let validateJo_result_304 := and(validateJo_result_303, call(gas(), 7, validateJo_i_1218, validateJo__6, 0x60, 0x160, validateJo__52))
|
||||
// let validateJo_result_305 := and(validateJo_result_304, call(gas(), 6, validateJo_i_1218, 0x120, validateJo__6, 0x160, validateJo__52))
|
||||
// validateJo_result := and(validateJo_result_305, call(gas(), 6, validateJo_i_1218, 0x160, validateJo__6, validateJo_b, validateJo__52))
|
||||
// let validateJo_result := call(gas(), 7, validateJo_i_1, 0xe0, 0x60, 0x1a0, validateJo_2)
|
||||
// let validateJo_result_1 := and(validateJo_result, call(gas(), 7, validateJo_i_1, 0x20, 0x60, 0x120, validateJo_2))
|
||||
// let validateJo_result_2 := and(validateJo_result_1, call(gas(), 7, validateJo_i_1, validateJo, 0x60, 0x160, validateJo_2))
|
||||
// let validateJo_result_3 := and(validateJo_result_2, call(gas(), 6, validateJo_i_1, 0x120, validateJo, 0x160, validateJo_2))
|
||||
// validateJo_result := and(validateJo_result_3, call(gas(), 6, validateJo_i_1, 0x160, validateJo, validateJo_b, validateJo_2))
|
||||
// if eq(validateJo_i, validateJo_m)
|
||||
// {
|
||||
// mstore(0x260, mload(0x20))
|
||||
// mstore(0x280, mload(validateJo__52))
|
||||
// mstore(0x280, mload(validateJo_2))
|
||||
// mstore(0x1e0, mload(0xe0))
|
||||
// mstore(0x200, sub(0x30644e72e131a029b85045b68181585d97816a916871ca8d3c208c16d87cfd47, mload(0x100)))
|
||||
// }
|
||||
// if gt(validateJo_i, validateJo_m)
|
||||
// {
|
||||
// mstore(0x60, validateJo_c)
|
||||
// let validateJo_result_307 := and(validateJo_result, call(gas(), 7, validateJo_i_1218, 0x20, 0x60, 0x220, validateJo__52))
|
||||
// let validateJo_result_308 := and(validateJo_result_307, call(gas(), 6, validateJo_i_1218, 0x220, validateJo__6, 0x260, validateJo__52))
|
||||
// validateJo_result := and(validateJo_result_308, call(gas(), 6, validateJo_i_1218, 0x1a0, validateJo__6, 0x1e0, validateJo__52))
|
||||
// let validateJo_result_4 := and(validateJo_result, call(gas(), 7, validateJo_i_1, 0x20, 0x60, 0x220, validateJo_2))
|
||||
// let validateJo_result_5 := and(validateJo_result_4, call(gas(), 6, validateJo_i_1, 0x220, validateJo, 0x260, validateJo_2))
|
||||
// validateJo_result := and(validateJo_result_5, call(gas(), 6, validateJo_i_1, 0x1a0, validateJo, 0x1e0, validateJo_2))
|
||||
// }
|
||||
// if iszero(validateJo_result)
|
||||
// {
|
||||
// mstore(validateJo_i_1218, 400)
|
||||
// revert(validateJo_i_1218, 0x20)
|
||||
// mstore(validateJo_i_1, 400)
|
||||
// revert(validateJo_i_1, 0x20)
|
||||
// }
|
||||
// validateJo_b := add(validateJo_b, validateJo__52)
|
||||
// validateJo_b := add(validateJo_b, validateJo_2)
|
||||
// }
|
||||
// if lt(validateJo_m, validateJo_n)
|
||||
// {
|
||||
@ -325,75 +325,75 @@
|
||||
// }
|
||||
// if iszero(eq(mod(keccak256(0x2a0, add(validateJo_b, 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffd60)), validateJo_gen_order), validateJo_challenge))
|
||||
// {
|
||||
// mstore(validateJo_i_1218, 404)
|
||||
// revert(validateJo_i_1218, 0x20)
|
||||
// mstore(validateJo_i_1, 404)
|
||||
// revert(validateJo_i_1, 0x20)
|
||||
// }
|
||||
// mstore(validateJo_i_1218, 0x01)
|
||||
// return(validateJo_i_1218, 0x20)
|
||||
// mstore(validateJo_i_1218, 404)
|
||||
// revert(validateJo_i_1218, 0x20)
|
||||
// mstore(validateJo_i_1, 0x01)
|
||||
// return(validateJo_i_1, 0x20)
|
||||
// mstore(validateJo_i_1, 404)
|
||||
// revert(validateJo_i_1, 0x20)
|
||||
// function validatePairing(t2)
|
||||
// {
|
||||
// let t2_x_1 := calldataload(t2)
|
||||
// let _165 := 0x20
|
||||
// let t2_x_2 := calldataload(add(t2, _165))
|
||||
// let t2_y_1 := calldataload(add(t2, 0x40))
|
||||
// let t2_y_2 := calldataload(add(t2, 0x60))
|
||||
// let _171 := 0x90689d0585ff075ec9e99ad690c3395bc4b313370b38ef355acdadcd122975b
|
||||
// let _173 := 0x12c85ea5db8c6deb4aab71808dcb408fe3d1e7690c43d37b4ce6cc0166fa7daa
|
||||
// let _175 := 0x198e9393920d483a7260bfb731fb5d25f1aa493335a9e71297e485b7aef312c2
|
||||
// let _177 := 0x1800deef121f1e76426a00665e5c4479674322d4f75edadd46debd5cd992f6ed
|
||||
// if or(or(or(or(or(or(or(iszero(t2_x_1), iszero(t2_x_2)), iszero(t2_y_1)), iszero(t2_y_2)), eq(t2_x_1, _177)), eq(t2_x_2, _175)), eq(t2_y_1, _173)), eq(t2_y_2, _171))
|
||||
// let t2_x := calldataload(t2)
|
||||
// let _1 := 0x20
|
||||
// let t2_x_1 := calldataload(add(t2, _1))
|
||||
// let t2_y := calldataload(add(t2, 0x40))
|
||||
// let t2_y_1 := calldataload(add(t2, 0x60))
|
||||
// let _2 := 0x90689d0585ff075ec9e99ad690c3395bc4b313370b38ef355acdadcd122975b
|
||||
// let _3 := 0x12c85ea5db8c6deb4aab71808dcb408fe3d1e7690c43d37b4ce6cc0166fa7daa
|
||||
// let _4 := 0x198e9393920d483a7260bfb731fb5d25f1aa493335a9e71297e485b7aef312c2
|
||||
// let _5 := 0x1800deef121f1e76426a00665e5c4479674322d4f75edadd46debd5cd992f6ed
|
||||
// if or(or(or(or(or(or(or(iszero(t2_x), iszero(t2_x_1)), iszero(t2_y)), iszero(t2_y_1)), eq(t2_x, _5)), eq(t2_x_1, _4)), eq(t2_y, _3)), eq(t2_y_1, _2))
|
||||
// {
|
||||
// mstore(0x00, 400)
|
||||
// revert(0x00, _165)
|
||||
// revert(0x00, _1)
|
||||
// }
|
||||
// mstore(_165, mload(0x1e0))
|
||||
// mstore(_1, mload(0x1e0))
|
||||
// mstore(0x40, mload(0x200))
|
||||
// mstore(0x80, _177)
|
||||
// mstore(0x60, _175)
|
||||
// mstore(0xc0, _173)
|
||||
// mstore(0xa0, _171)
|
||||
// mstore(0x80, _5)
|
||||
// mstore(0x60, _4)
|
||||
// mstore(0xc0, _3)
|
||||
// mstore(0xa0, _2)
|
||||
// mstore(0xe0, mload(0x260))
|
||||
// mstore(0x100, mload(0x280))
|
||||
// mstore(0x140, t2_x_1)
|
||||
// mstore(0x120, t2_x_2)
|
||||
// let _216 := 0x180
|
||||
// mstore(_216, t2_y_1)
|
||||
// mstore(0x160, t2_y_2)
|
||||
// let success := call(gas(), 8, 0, _165, _216, _165, _165)
|
||||
// if or(iszero(success), iszero(mload(_165)))
|
||||
// mstore(0x140, t2_x)
|
||||
// mstore(0x120, t2_x_1)
|
||||
// let _6 := 0x180
|
||||
// mstore(_6, t2_y)
|
||||
// mstore(0x160, t2_y_1)
|
||||
// let success := call(gas(), 8, 0, _1, _6, _1, _1)
|
||||
// if or(iszero(success), iszero(mload(_1)))
|
||||
// {
|
||||
// mstore(0, 400)
|
||||
// revert(0, _165)
|
||||
// revert(0, _1)
|
||||
// }
|
||||
// }
|
||||
// function validateCommitment(note, k_1, a_2)
|
||||
// function validateCommitment(note, k, a)
|
||||
// {
|
||||
// let gen_order_3 := 0x30644e72e131a029b85045b68181585d2833e84879b9709143e1f593f0000001
|
||||
// let field_order_4 := 0x30644e72e131a029b85045b68181585d97816a916871ca8d3c208c16d87cfd47
|
||||
// let gen_order := 0x30644e72e131a029b85045b68181585d2833e84879b9709143e1f593f0000001
|
||||
// let field_order := 0x30644e72e131a029b85045b68181585d97816a916871ca8d3c208c16d87cfd47
|
||||
// let gammaX := calldataload(add(note, 0x40))
|
||||
// let gammaY := calldataload(add(note, 0x60))
|
||||
// let sigmaX := calldataload(add(note, 0x80))
|
||||
// let sigmaY := calldataload(add(note, 0xa0))
|
||||
// if iszero(and(and(and(eq(mod(a_2, gen_order_3), a_2), gt(a_2, 1)), and(eq(mod(k_1, gen_order_3), k_1), gt(k_1, 1))), and(eq(addmod(mulmod(mulmod(sigmaX, sigmaX, field_order_4), sigmaX, field_order_4), 3, field_order_4), mulmod(sigmaY, sigmaY, field_order_4)), eq(addmod(mulmod(mulmod(gammaX, gammaX, field_order_4), gammaX, field_order_4), 3, field_order_4), mulmod(gammaY, gammaY, field_order_4)))))
|
||||
// if iszero(and(and(and(eq(mod(a, gen_order), a), gt(a, 1)), and(eq(mod(k, gen_order), k), gt(k, 1))), and(eq(addmod(mulmod(mulmod(sigmaX, sigmaX, field_order), sigmaX, field_order), 3, field_order), mulmod(sigmaY, sigmaY, field_order)), eq(addmod(mulmod(mulmod(gammaX, gammaX, field_order), gammaX, field_order), 3, field_order), mulmod(gammaY, gammaY, field_order)))))
|
||||
// {
|
||||
// mstore(0x00, 400)
|
||||
// revert(0x00, 0x20)
|
||||
// }
|
||||
// }
|
||||
// function hashCommitments(notes_5, n_6)
|
||||
// function hashCommitments(notes, n)
|
||||
// {
|
||||
// let i_7 := 0
|
||||
// let i := 0
|
||||
// for {
|
||||
// }
|
||||
// lt(i_7, n_6)
|
||||
// lt(i, n)
|
||||
// {
|
||||
// i_7 := add(i_7, 0x01)
|
||||
// i := add(i, 0x01)
|
||||
// }
|
||||
// {
|
||||
// calldatacopy(add(0x300, mul(i_7, 0x80)), add(add(notes_5, mul(i_7, 0xc0)), 0x60), 0x80)
|
||||
// calldatacopy(add(0x300, mul(i, 0x80)), add(add(notes, mul(i, 0xc0)), 0x60), 0x80)
|
||||
// }
|
||||
// mstore(0, keccak256(0x300, mul(n_6, 0x80)))
|
||||
// mstore(0, keccak256(0x300, mul(n, 0x80)))
|
||||
// }
|
||||
// }
|
||||
|
@ -19,10 +19,10 @@
|
||||
// ----
|
||||
// fullSuite
|
||||
// {
|
||||
// let allocate__19 := 0x40
|
||||
// mstore(allocate__19, add(mload(allocate__19), 0x20))
|
||||
// let allocate_p_33_37 := mload(allocate__19)
|
||||
// mstore(allocate__19, add(allocate_p_33_37, allocate__19))
|
||||
// mstore(add(allocate_p_33_37, 96), 2)
|
||||
// mstore(allocate__19, 0x20)
|
||||
// let allocate := 0x40
|
||||
// mstore(allocate, add(mload(allocate), 0x20))
|
||||
// let allocate_p := mload(allocate)
|
||||
// mstore(allocate, add(allocate_p, allocate))
|
||||
// mstore(add(allocate_p, 96), 2)
|
||||
// mstore(allocate, 0x20)
|
||||
// }
|
||||
|
@ -42,19 +42,19 @@
|
||||
// a, b := abi_decode_t_bytes_calldata_ptr(a, b)
|
||||
// a, b := abi_decode_t_bytes_calldata_ptr(a, b)
|
||||
// mstore(a, b)
|
||||
// function abi_decode_t_bytes_calldata_ptr(offset_12, end_13) -> arrayPos_14, length_15
|
||||
// function abi_decode_t_bytes_calldata_ptr(offset, end) -> arrayPos, length
|
||||
// {
|
||||
// if iszero(slt(add(offset_12, 0x1f), end_13))
|
||||
// if iszero(slt(add(offset, 0x1f), end))
|
||||
// {
|
||||
// revert(0, 0)
|
||||
// }
|
||||
// length_15 := calldataload(offset_12)
|
||||
// if gt(length_15, 0xffffffffffffffff)
|
||||
// length := calldataload(offset)
|
||||
// if gt(length, 0xffffffffffffffff)
|
||||
// {
|
||||
// revert(0, 0)
|
||||
// }
|
||||
// arrayPos_14 := add(offset_12, 0x20)
|
||||
// if gt(add(add(offset_12, length_15), 0x20), end_13)
|
||||
// arrayPos := add(offset, 0x20)
|
||||
// if gt(add(add(offset, length), 0x20), end)
|
||||
// {
|
||||
// revert(0, 0)
|
||||
// }
|
||||
|
@ -0,0 +1,8 @@
|
||||
{
|
||||
let datasize_256 := 1
|
||||
}
|
||||
// ----
|
||||
// varNameCleaner
|
||||
// {
|
||||
// let datasize_1 := 1
|
||||
// }
|
@ -0,0 +1,15 @@
|
||||
{
|
||||
let f_2
|
||||
function f() { let f_1 }
|
||||
let f_10
|
||||
}
|
||||
// ----
|
||||
// varNameCleaner
|
||||
// {
|
||||
// let f_1
|
||||
// function f()
|
||||
// {
|
||||
// let f_1
|
||||
// }
|
||||
// let f_2
|
||||
// }
|
@ -0,0 +1,22 @@
|
||||
{
|
||||
let f_2
|
||||
function f(x_12) -> x, y_14
|
||||
{
|
||||
let y := x_12
|
||||
y_14 := y
|
||||
x := y_14
|
||||
}
|
||||
let f_10
|
||||
}
|
||||
// ----
|
||||
// varNameCleaner
|
||||
// {
|
||||
// let f_1
|
||||
// function f(x) -> x_1, y
|
||||
// {
|
||||
// let y_1 := x
|
||||
// y := y_1
|
||||
// x_1 := y
|
||||
// }
|
||||
// let f_2
|
||||
// }
|
@ -0,0 +1,16 @@
|
||||
{
|
||||
function f() { let x_1 := 0 }
|
||||
function g() { let x_2 := 0 }
|
||||
}
|
||||
// ----
|
||||
// varNameCleaner
|
||||
// {
|
||||
// function f()
|
||||
// {
|
||||
// let x := 0
|
||||
// }
|
||||
// function g()
|
||||
// {
|
||||
// let x := 0
|
||||
// }
|
||||
// }
|
@ -0,0 +1,14 @@
|
||||
{
|
||||
let a_1 := 1
|
||||
let a_2_1 := 2
|
||||
let a_4312 := 0xdeadbeef
|
||||
let _42 := 21718
|
||||
}
|
||||
// ----
|
||||
// varNameCleaner
|
||||
// {
|
||||
// let a := 1
|
||||
// let a_1 := 2
|
||||
// let a_2 := 0xdeadbeef
|
||||
// let _1 := 21718
|
||||
// }
|
@ -0,0 +1,14 @@
|
||||
{
|
||||
let x_4 := 1
|
||||
let x_3 := 2
|
||||
let x_2 := 3
|
||||
let x_1 := 4
|
||||
}
|
||||
// ----
|
||||
// varNameCleaner
|
||||
// {
|
||||
// let x := 1
|
||||
// let x_1 := 2
|
||||
// let x_2 := 3
|
||||
// let x_3 := 4
|
||||
// }
|
12
test/libyul/yulOptimizerTests/varNameCleaner/reshuffling.yul
Normal file
12
test/libyul/yulOptimizerTests/varNameCleaner/reshuffling.yul
Normal file
@ -0,0 +1,12 @@
|
||||
{
|
||||
let x_1 := 1
|
||||
let x_2 := 2
|
||||
let x_3 := 3
|
||||
}
|
||||
// ----
|
||||
// varNameCleaner
|
||||
// {
|
||||
// let x := 1
|
||||
// let x_1 := 2
|
||||
// let x_2 := 3
|
||||
// }
|
@ -51,6 +51,7 @@
|
||||
#include <libyul/optimiser/StackCompressor.h>
|
||||
#include <libyul/optimiser/StructuralSimplifier.h>
|
||||
#include <libyul/optimiser/VarDeclInitializer.h>
|
||||
#include <libyul/optimiser/VarNameCleaner.h>
|
||||
|
||||
#include <libyul/backends/evm/EVMDialect.h>
|
||||
|
||||
@ -128,7 +129,7 @@ public:
|
||||
disambiguated = true;
|
||||
}
|
||||
cout << "(q)quit/(f)flatten/(c)se/initialize var(d)ecls/(x)plit/(j)oin/(g)rouper/(h)oister/" << endl;
|
||||
cout << " (e)xpr inline/(i)nline/(s)implify/(u)nusedprune/ss(a) transform/" << endl;
|
||||
cout << " (e)xpr inline/(i)nline/(s)implify/varname c(l)eaner/(u)nusedprune/ss(a) transform/" << endl;
|
||||
cout << " (r)edundant assign elim./re(m)aterializer/f(o)r-loop-pre-rewriter/" << endl;
|
||||
cout << " s(t)ructural simplifier/equi(v)alent function combiner/ssa re(V)erser/? " << endl;
|
||||
cout << " stack com(p)ressor? " << endl;
|
||||
@ -151,6 +152,9 @@ public:
|
||||
case 'd':
|
||||
(VarDeclInitializer{})(*m_ast);
|
||||
break;
|
||||
case 'l':
|
||||
VarNameCleaner{*m_ast, *m_dialect}(*m_ast);
|
||||
break;
|
||||
case 'x':
|
||||
ExpressionSplitter{*m_dialect, *m_nameDispenser}(*m_ast);
|
||||
break;
|
||||
|
Loading…
Reference in New Issue
Block a user