33
44
55#include < boost/test/unit_test.hpp>
6+ #include < fmt/ranges.h>
67
7- #include < libyul/backends/evm/ssa/LivenessAnalysis.h>
8- #include < libyul/backends/evm/SSACFGStack.h>
98#include < libyul/backends/evm/SSACFGStackShuffler.h>
9+ #include < libyul/backends/evm/ssa/LivenessAnalysis.h>
1010
1111#include < range/v3/view/concat.hpp>
1212
@@ -60,18 +60,7 @@ struct PrintCallback
6060 std::optional<std::function<void ()>> callback;
6161};
6262
63- struct SlotCanBeFreelyGenerated
64- {
65- using Slot = SourceSlot;
66- bool operator ()(Slot const & _slot) const
67- {
68- return canBeFreelyGenerated (_slot);
69- }
70-
71- solidity::yul::ssa::SlotCanBeFreelyGenerated<solidity::yul::ssa::StackSlot> canBeFreelyGenerated;
72- };
73-
74- using TestStack = solidity::yul::ssa::Stack<SourceSlot, PrintCallback, SlotCanBeFreelyGenerated>;
63+ using TestStack = solidity::yul::ssa::Stack<PrintCallback>;
7564
7665
7766
@@ -117,7 +106,6 @@ BOOST_AUTO_TEST_CASE(yo)
117106 if (stack)
118107 std::cout << ssa::stackToString (stack->data (), *cfg) << std::endl;
119108 });
120- SlotCanBeFreelyGenerated canBeFreelyGenerated{.canBeFreelyGenerated = {cfg.get ()}};
121109
122110 FunctionCall funDeposit {
123111 .debugData = nullptr ,
@@ -131,17 +119,17 @@ BOOST_AUTO_TEST_CASE(yo)
131119 auto const v139 = cfg->newVariable ({0 });
132120 auto const v141 = cfg->newVariable ({0 });
133121
134- std::vector<SourceSlot> slotsRef {
122+ std::vector slotsRef {
135123 // ssa::JunkSlot{}, ssa::JunkSlot{}, ssa::JunkSlot{}, ssa::JunkSlot{}, ssa::JunkSlot{},
136- v113, v115, v119, v136, /* ssa::JunkSlot{}, ssa::JunkSlot{},*/ v139, v141
124+ SourceSlot::makeValueIDSlot ( v113), SourceSlot::makeValueIDSlot ( v115), SourceSlot::makeValueIDSlot ( v119), SourceSlot::makeValueIDSlot ( v136) , /* ssa::JunkSlot{}, ssa::JunkSlot{},*/ SourceSlot::makeValueIDSlot ( v139), SourceSlot::makeValueIDSlot ( v141)
137125 };
138126 ssa::LivenessAnalysis::LivenessData liveness ({{v113, 1 }, {v115, 1 }, {v119, 1 }});
139- TestStack::Data args{thirtytwo, zero, v139, v136, two, v141};
127+ TestStack::Data args{SourceSlot::makeValueIDSlot ( thirtytwo), SourceSlot::makeValueIDSlot ( zero), SourceSlot::makeValueIDSlot ( v139), SourceSlot::makeValueIDSlot ( v136), SourceSlot::makeValueIDSlot ( two), SourceSlot::makeValueIDSlot ( v141) };
140128 std::vector<SourceSlot> final ;
141129
142130 {
143131 auto slots = slotsRef;
144- stack = std::make_shared<TestStack>(slots, callback, canBeFreelyGenerated );
132+ stack = std::make_shared<TestStack>(slots, callback, TestStack::CanBeFreelyGenerated{} );
145133
146134 // fun_deposit([JUNK x 6, v58, v59, JUNK, v67, v68, JUNK, v76, v77, v79] -> { [] } + [ReturnLabel[fun_deposit], v79, v77, v76, v68, v67, v59, v58])
147135 // mstore([JUNK x 7, v48, v49] -> { [v49] } + [v48, v49]) -> DUP1 + SWAP2 + SWAP1 + -> [JUNK x 7, v49]
@@ -165,14 +153,14 @@ BOOST_AUTO_TEST_CASE(yo)
165153 {
166154 constexpr auto SlotIsCompatible = [](TestStack::Slot const & _source, TestStack::Slot const & _target) { return std::holds_alternative<ssa::JunkSlot>(_target) || _source == _target; };
167155 auto slots = slotsRef;
168- stack = std::make_shared<TestStack>(slots, callback, canBeFreelyGenerated );
156+ stack = std::make_shared<TestStack>(slots, callback, TestStack::CanBeFreelyGenerated{} );
169157 std::cout << fmt::format (" \n\n And now with A*:\n " ) << std::flush;
170158 TestStack::Data tail (final .begin (), final .begin () + static_cast <size_t >(final .size () - args.size ()));
171159 ssa::BlockForwardAStarShuffler<TestStack, SlotIsCompatible>::shuffle (*stack, tail, args);
172160 }
173161 {
174162 auto slots = slotsRef;
175- stack = std::make_shared<TestStack>(slots, callback, canBeFreelyGenerated );
163+ stack = std::make_shared<TestStack>(slots, callback, TestStack::CanBeFreelyGenerated{} );
176164
177165 std::cout << fmt::format (" \n\n And now with Daniel shuffler:\n " ) << std::flush;
178166 DanielShuffler<TestStack>::shuffle (*stack, {}, final );
0 commit comments