Skip to content

Commit

Permalink
Merge pull request ethereum#11797 from ethereum/optimizedEVMCodeTrans…
Browse files Browse the repository at this point in the history
…form

Optimized EVM Code Transform. (New Code Transform Step 3)
  • Loading branch information
chriseth authored Sep 14, 2021
2 parents cb218fe + 75c3286 commit a35608a
Show file tree
Hide file tree
Showing 4 changed files with 632 additions and 9 deletions.
14 changes: 6 additions & 8 deletions libyul/AST.h
Original file line number Diff line number Diff line change
Expand Up @@ -83,18 +83,16 @@ struct Continue { std::shared_ptr<DebugData const> debugData; };
/// Leave statement (valid within function)
struct Leave { std::shared_ptr<DebugData const> debugData; };

struct LocationExtractor
/// Extracts the source location from a Yul node.
template <class T> inline langutil::SourceLocation locationOf(T const& _node)
{
template <class T> langutil::SourceLocation operator()(T const& _node) const
{
return _node.debugData ? _node.debugData->location : langutil::SourceLocation{};
}
};
return _node.debugData ? _node.debugData->location : langutil::SourceLocation{};
}

/// Extracts the source location from a Yul node.
template <class T> inline langutil::SourceLocation locationOf(T const& _node)
template <class... Args> inline langutil::SourceLocation locationOf(std::variant<Args...> const& _node)
{
return std::visit(LocationExtractor(), _node);
return std::visit([](auto const& _arg) { return locationOf(_arg); }, _node);
}

struct DebugDataExtractor
Expand Down
4 changes: 3 additions & 1 deletion libyul/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,11 @@ add_library(yul
backends/evm/EVMMetrics.h
backends/evm/NoOutputAssembly.h
backends/evm/NoOutputAssembly.cpp
backends/evm/OptimizedEVMCodeTransform.cpp
backends/evm/OptimizedEVMCodeTransform.h
backends/evm/StackHelpers.h
backends/evm/StackLayoutGenerator.h
backends/evm/StackLayoutGenerator.cpp
backends/evm/StackLayoutGenerator.h
backends/evm/VariableReferenceCounter.h
backends/evm/VariableReferenceCounter.cpp
backends/wasm/EVMToEwasmTranslator.cpp
Expand Down
Loading

0 comments on commit a35608a

Please sign in to comment.