C++ namespace cleanup (except tests).

This commit is contained in:
Christian Parpart
2020-01-07 15:51:50 +01:00
committed by Daniel Kirchner
parent 8385256bdc
commit 6b23412fae
403 changed files with 1656 additions and 1926 deletions
+18 -18
View File
@@ -38,10 +38,10 @@
#include <utility>
using namespace std;
using namespace dev;
using namespace langutil;
using namespace yul;
using namespace dev;
using namespace solidity;
using namespace solidity::yul;
using namespace solidity::util;
using namespace solidity::langutil;
namespace
{
@@ -651,7 +651,7 @@ bool AsmAnalyzer::warnOnInstructions(std::string const& _instructionIdentifier,
return false;
}
bool AsmAnalyzer::warnOnInstructions(dev::eth::Instruction _instr, SourceLocation const& _location)
bool AsmAnalyzer::warnOnInstructions(evmasm::Instruction _instr, SourceLocation const& _location)
{
// We assume that returndatacopy, returndatasize and staticcall are either all available
// or all not available.
@@ -675,44 +675,44 @@ bool AsmAnalyzer::warnOnInstructions(dev::eth::Instruction _instr, SourceLocatio
};
if ((
_instr == dev::eth::Instruction::RETURNDATACOPY ||
_instr == dev::eth::Instruction::RETURNDATASIZE
_instr == evmasm::Instruction::RETURNDATACOPY ||
_instr == evmasm::Instruction::RETURNDATASIZE
) && !m_evmVersion.supportsReturndata())
{
errorForVM("only available for Byzantium-compatible");
}
else if (_instr == dev::eth::Instruction::STATICCALL && !m_evmVersion.hasStaticCall())
else if (_instr == evmasm::Instruction::STATICCALL && !m_evmVersion.hasStaticCall())
{
errorForVM("only available for Byzantium-compatible");
}
else if ((
_instr == dev::eth::Instruction::SHL ||
_instr == dev::eth::Instruction::SHR ||
_instr == dev::eth::Instruction::SAR
_instr == evmasm::Instruction::SHL ||
_instr == evmasm::Instruction::SHR ||
_instr == evmasm::Instruction::SAR
) && !m_evmVersion.hasBitwiseShifting())
{
errorForVM("only available for Constantinople-compatible");
}
else if (_instr == dev::eth::Instruction::CREATE2 && !m_evmVersion.hasCreate2())
else if (_instr == evmasm::Instruction::CREATE2 && !m_evmVersion.hasCreate2())
{
errorForVM("only available for Constantinople-compatible");
}
else if (_instr == dev::eth::Instruction::EXTCODEHASH && !m_evmVersion.hasExtCodeHash())
else if (_instr == evmasm::Instruction::EXTCODEHASH && !m_evmVersion.hasExtCodeHash())
{
errorForVM("only available for Constantinople-compatible");
}
else if (_instr == dev::eth::Instruction::CHAINID && !m_evmVersion.hasChainID())
else if (_instr == evmasm::Instruction::CHAINID && !m_evmVersion.hasChainID())
{
errorForVM("only available for Istanbul-compatible");
}
else if (_instr == dev::eth::Instruction::SELFBALANCE && !m_evmVersion.hasSelfBalance())
else if (_instr == evmasm::Instruction::SELFBALANCE && !m_evmVersion.hasSelfBalance())
{
errorForVM("only available for Istanbul-compatible");
}
else if (
_instr == dev::eth::Instruction::JUMP ||
_instr == dev::eth::Instruction::JUMPI ||
_instr == dev::eth::Instruction::JUMPDEST
_instr == evmasm::Instruction::JUMP ||
_instr == evmasm::Instruction::JUMPI ||
_instr == evmasm::Instruction::JUMPDEST
)
{
m_errorReporter.error(
+3 -3
View File
@@ -35,13 +35,13 @@
#include <memory>
#include <optional>
namespace langutil
namespace solidity::langutil
{
class ErrorReporter;
struct SourceLocation;
}
namespace yul
namespace solidity::yul
{
struct AsmAnalysisInfo;
@@ -103,7 +103,7 @@ private:
Scope& scope(Block const* _block);
void expectValidType(std::string const& type, langutil::SourceLocation const& _location);
bool warnOnInstructions(dev::eth::Instruction _instr, langutil::SourceLocation const& _location);
bool warnOnInstructions(evmasm::Instruction _instr, langutil::SourceLocation const& _location);
bool warnOnInstructions(std::string const& _instrIdentifier, langutil::SourceLocation const& _location);
int m_stackHeight = 0;
+1 -1
View File
@@ -26,7 +26,7 @@
#include <memory>
#include <vector>
namespace yul
namespace solidity::yul
{
struct Scope;
+1 -1
View File
@@ -29,7 +29,7 @@
#include <memory>
namespace yul
namespace solidity::yul
{
using Type = YulString;
+1 -1
View File
@@ -24,7 +24,7 @@
#include <variant>
namespace yul
namespace solidity::yul
{
struct Literal;
+2 -2
View File
@@ -26,7 +26,7 @@
using namespace std;
namespace yul
namespace solidity::yul
{
Json::Value AsmJsonConverter::operator()(Block const& _node) const
@@ -52,7 +52,7 @@ Json::Value AsmJsonConverter::operator()(Literal const& _node) const
{
case LiteralKind::Number:
solAssert(
dev::isValidDecimal(_node.value.str()) || dev::isValidHex(_node.value.str()),
util::isValidDecimal(_node.value.str()) || util::isValidHex(_node.value.str()),
"Invalid number literal"
);
ret["kind"] = "number";
+1 -1
View File
@@ -26,7 +26,7 @@
#include <boost/variant.hpp>
#include <vector>
namespace yul
namespace solidity::yul
{
/**
+13 -12
View File
@@ -32,9 +32,10 @@
#include <algorithm>
using namespace std;
using namespace dev;
using namespace langutil;
using namespace yul;
using namespace solidity;
using namespace solidity::util;
using namespace solidity::langutil;
using namespace solidity::yul;
shared_ptr<Block> Parser::parse(std::shared_ptr<Scanner> const& _scanner, bool _reuseScanner)
{
@@ -59,17 +60,17 @@ shared_ptr<Block> Parser::parse(std::shared_ptr<Scanner> const& _scanner, bool _
return nullptr;
}
std::map<string, dev::eth::Instruction> const& Parser::instructions()
std::map<string, evmasm::Instruction> const& Parser::instructions()
{
// Allowed instructions, lowercase names.
static map<string, dev::eth::Instruction> s_instructions;
static map<string, evmasm::Instruction> s_instructions;
if (s_instructions.empty())
{
for (auto const& instruction: dev::eth::c_instructions)
for (auto const& instruction: evmasm::c_instructions)
{
if (
instruction.second == dev::eth::Instruction::JUMPDEST ||
dev::eth::isPushInstruction(instruction.second)
instruction.second == evmasm::Instruction::JUMPDEST ||
evmasm::isPushInstruction(instruction.second)
)
continue;
string name = instruction.first;
@@ -298,16 +299,16 @@ Expression Parser::parseExpression()
}
}
std::map<dev::eth::Instruction, string> const& Parser::instructionNames()
std::map<evmasm::Instruction, string> const& Parser::instructionNames()
{
static map<dev::eth::Instruction, string> s_instructionNames;
static map<evmasm::Instruction, string> s_instructionNames;
if (s_instructionNames.empty())
{
for (auto const& instr: instructions())
s_instructionNames[instr.second] = instr.first;
// set the ambiguous instructions to a clear default
s_instructionNames[dev::eth::Instruction::SELFDESTRUCT] = "selfdestruct";
s_instructionNames[dev::eth::Instruction::KECCAK256] = "keccak256";
s_instructionNames[evmasm::Instruction::SELFDESTRUCT] = "selfdestruct";
s_instructionNames[evmasm::Instruction::KECCAK256] = "keccak256";
}
return s_instructionNames;
}
+3 -3
View File
@@ -35,7 +35,7 @@
#include <variant>
#include <vector>
namespace yul
namespace solidity::yul
{
class Parser: public langutil::ParserBase
@@ -55,7 +55,7 @@ public:
std::shared_ptr<Block> parse(std::shared_ptr<langutil::Scanner> const& _scanner, bool _reuseScanner);
/// @returns a map of all EVM instructions available to assembly.
static std::map<std::string, dev::eth::Instruction> const& instructions();
static std::map<std::string, evmasm::Instruction> const& instructions();
protected:
using ElementaryOperation = std::variant<Literal, Identifier, FunctionCall>;
@@ -82,7 +82,7 @@ protected:
ForLoop parseForLoop();
/// Parses a functional expression that has to push exactly one stack element
Expression parseExpression();
static std::map<dev::eth::Instruction, std::string> const& instructionNames();
static std::map<evmasm::Instruction, std::string> const& instructionNames();
/// Parses an elementary operation, i.e. a literal, identifier, instruction or
/// builtin functian call (only the name).
ElementaryOperation parseElementaryOperation();
+3 -2
View File
@@ -34,8 +34,9 @@
#include <functional>
using namespace std;
using namespace dev;
using namespace yul;
using namespace solidity;
using namespace solidity::util;
using namespace solidity::yul;
//@TODO source locations
+1 -1
View File
@@ -26,7 +26,7 @@
#include <libyul/YulString.h>
namespace yul
namespace solidity::yul
{
class AsmPrinter
+3 -2
View File
@@ -21,8 +21,9 @@
#include <libyul/AsmScope.h>
using namespace std;
using namespace dev;
using namespace yul;
using namespace solidity;
using namespace solidity::yul;
using namespace solidity::util;
bool Scope::registerLabel(YulString _name)
{
+1 -1
View File
@@ -31,7 +31,7 @@
#include <optional>
#include <variant>
namespace yul
namespace solidity::yul
{
struct Scope
+4 -3
View File
@@ -35,9 +35,10 @@
#include <functional>
using namespace std;
using namespace dev;
using namespace langutil;
using namespace yul;
using namespace solidity;
using namespace solidity::yul;
using namespace solidity::util;
using namespace solidity::langutil;
ScopeFiller::ScopeFiller(AsmAnalysisInfo& _info, ErrorReporter& _errorReporter):
m_info(_info), m_errorReporter(_errorReporter)
+2 -2
View File
@@ -25,13 +25,13 @@
#include <functional>
#include <memory>
namespace langutil
namespace solidity::langutil
{
class ErrorReporter;
struct SourceLocation;
}
namespace yul
namespace solidity::yul
{
struct TypedName;
+7 -6
View File
@@ -45,8 +45,9 @@
#include <liblangutil/Scanner.h>
using namespace std;
using namespace langutil;
using namespace yul;
using namespace solidity;
using namespace solidity::yul;
using namespace solidity::langutil;
namespace
{
@@ -198,10 +199,10 @@ MachineAssemblyObject AssemblyStack::assemble(Machine _machine) const
case Machine::EVM:
{
MachineAssemblyObject object;
dev::eth::Assembly assembly;
evmasm::Assembly assembly;
EthAssemblyAdapter adapter(assembly);
compileEVM(adapter, false, m_optimiserSettings.optimizeStackAllocation);
object.bytecode = make_shared<dev::eth::LinkerObject>(assembly.assemble());
object.bytecode = make_shared<evmasm::LinkerObject>(assembly.assemble());
object.assembly = assembly.assemblyString();
return object;
}
@@ -210,7 +211,7 @@ MachineAssemblyObject AssemblyStack::assemble(Machine _machine) const
MachineAssemblyObject object;
EVMAssembly assembly(true);
compileEVM(assembly, true, m_optimiserSettings.optimizeStackAllocation);
object.bytecode = make_shared<dev::eth::LinkerObject>(assembly.finalize());
object.bytecode = make_shared<evmasm::LinkerObject>(assembly.finalize());
/// TODO: fill out text representation
return object;
}
@@ -222,7 +223,7 @@ MachineAssemblyObject AssemblyStack::assemble(Machine _machine) const
MachineAssemblyObject object;
auto result = WasmObjectCompiler::compile(*m_parserResult, dialect);
object.assembly = std::move(result.first);
object.bytecode = make_shared<dev::eth::LinkerObject>();
object.bytecode = make_shared<evmasm::LinkerObject>();
object.bytecode->bytecode = std::move(result.second);
return object;
}
+6 -6
View File
@@ -34,19 +34,19 @@
#include <memory>
#include <string>
namespace langutil
namespace solidity::langutil
{
class Scanner;
}
namespace yul
namespace solidity::yul
{
class AbstractAssembly;
struct MachineAssemblyObject
{
std::shared_ptr<dev::eth::LinkerObject> bytecode;
std::shared_ptr<evmasm::LinkerObject> bytecode;
std::string assembly;
};
@@ -61,9 +61,9 @@ public:
enum class Machine { EVM, EVM15, Ewasm };
AssemblyStack():
AssemblyStack(langutil::EVMVersion{}, Language::Assembly, dev::solidity::OptimiserSettings::none())
AssemblyStack(langutil::EVMVersion{}, Language::Assembly, solidity::frontend::OptimiserSettings::none())
{}
AssemblyStack(langutil::EVMVersion _evmVersion, Language _language, dev::solidity::OptimiserSettings _optimiserSettings):
AssemblyStack(langutil::EVMVersion _evmVersion, Language _language, solidity::frontend::OptimiserSettings _optimiserSettings):
m_language(_language),
m_evmVersion(_evmVersion),
m_optimiserSettings(std::move(_optimiserSettings)),
@@ -106,7 +106,7 @@ private:
Language m_language = Language::Assembly;
langutil::EVMVersion m_evmVersion;
dev::solidity::OptimiserSettings m_optimiserSettings;
solidity::frontend::OptimiserSettings m_optimiserSettings;
std::shared_ptr<langutil::Scanner> m_scanner;
+3 -2
View File
@@ -29,8 +29,9 @@
#include <liblangutil/EVMVersion.h>
using namespace std;
using namespace yul;
using namespace dev;
using namespace solidity;
using namespace solidity::yul;
using namespace solidity::util;
map<YulString, int> CompilabilityChecker::run(
Dialect const& _dialect,
+1 -1
View File
@@ -27,7 +27,7 @@
#include <map>
#include <memory>
namespace yul
namespace solidity::yul
{
/**
+1 -1
View File
@@ -28,7 +28,7 @@
#include <vector>
#include <set>
namespace yul
namespace solidity::yul
{
class YulString;
+3 -3
View File
@@ -23,16 +23,16 @@
#include <libdevcore/Exceptions.h>
#include <libdevcore/Assertions.h>
namespace yul
namespace solidity::yul
{
struct YulException: virtual dev::Exception {};
struct YulException: virtual util::Exception {};
struct OptimizerException: virtual YulException {};
struct CodegenException: virtual YulException {};
struct YulAssertion: virtual YulException {};
/// Assertion that throws an YulAssertion containing the given description if it is not met.
#define yulAssert(CONDITION, DESCRIPTION) \
assertThrow(CONDITION, ::yul::YulAssertion, DESCRIPTION)
assertThrow(CONDITION, ::solidity::yul::YulAssertion, DESCRIPTION)
}
+4 -3
View File
@@ -28,9 +28,10 @@
#include <boost/algorithm/string/replace.hpp>
using namespace dev;
using namespace yul;
using namespace std;
using namespace solidity;
using namespace solidity::yul;
using namespace solidity::util;
namespace
{
@@ -46,7 +47,7 @@ string indent(std::string const& _input)
string Data::toString(bool) const
{
return "data \"" + name.str() + "\" hex\"" + dev::toHex(data) + "\"";
return "data \"" + name.str() + "\" hex\"" + util::toHex(data) + "\"";
}
string Object::toString(bool _yul) const
+3 -3
View File
@@ -28,7 +28,7 @@
#include <memory>
#include <set>
namespace yul
namespace solidity::yul
{
struct AsmAnalysisInfo;
@@ -49,10 +49,10 @@ struct ObjectNode
*/
struct Data: ObjectNode
{
Data(YulString _name, dev::bytes _data): data(std::move(_data)) { name = _name; }
Data(YulString _name, bytes _data): data(std::move(_data)) { name = _name; }
std::string toString(bool _yul) const override;
dev::bytes data;
bytes data;
};
/**
+4 -4
View File
@@ -25,11 +25,11 @@
#include <liblangutil/Token.h>
using namespace dev;
using namespace langutil;
using namespace yul;
using namespace std;
using namespace solidity;
using namespace solidity::yul;
using namespace solidity::util;
using namespace solidity::langutil;
shared_ptr<Object> ObjectParser::parse(shared_ptr<Scanner> const& _scanner, bool _reuseScanner)
{
+2 -2
View File
@@ -31,12 +31,12 @@
#include <memory>
namespace langutil
namespace solidity::langutil
{
class Scanner;
}
namespace yul
namespace solidity::yul
{
/**
+1 -1
View File
@@ -19,7 +19,7 @@
#include <set>
namespace yul
namespace solidity::yul
{
/**
+7 -6
View File
@@ -34,13 +34,14 @@
#include <vector>
using namespace std;
using namespace dev;
using namespace yul;
using namespace solidity;
using namespace solidity::yul;
using namespace solidity::util;
using boost::split;
using boost::is_any_of;
string yul::reindent(string const& _code)
string solidity::yul::reindent(string const& _code)
{
int constexpr indentationWidth = 4;
@@ -82,7 +83,7 @@ string yul::reindent(string const& _code)
return out.str();
}
u256 yul::valueOfNumberLiteral(Literal const& _literal)
u256 solidity::yul::valueOfNumberLiteral(Literal const& _literal)
{
yulAssert(_literal.kind == LiteralKind::Number, "Expected number literal!");
@@ -91,7 +92,7 @@ u256 yul::valueOfNumberLiteral(Literal const& _literal)
return u256(literalString);
}
u256 yul::valueOfStringLiteral(Literal const& _literal)
u256 solidity::yul::valueOfStringLiteral(Literal const& _literal)
{
yulAssert(_literal.kind == LiteralKind::String, "Expected string literal!");
yulAssert(_literal.value.str().size() <= 32, "Literal string too long!");
@@ -111,7 +112,7 @@ u256 yul::valueOfBoolLiteral(Literal const& _literal)
yulAssert(false, "Unexpected bool literal value!");
}
u256 yul::valueOfLiteral(Literal const& _literal)
u256 solidity::yul::valueOfLiteral(Literal const& _literal)
{
switch (_literal.kind)
{
+5 -5
View File
@@ -23,15 +23,15 @@
#include <libdevcore/Common.h>
#include <libyul/AsmDataForward.h>
namespace yul
namespace solidity::yul
{
std::string reindent(std::string const& _code);
dev::u256 valueOfNumberLiteral(Literal const& _literal);
dev::u256 valueOfStringLiteral(Literal const& _literal);
dev::u256 valueOfBoolLiteral(Literal const& _literal);
dev::u256 valueOfLiteral(Literal const& _literal);
u256 valueOfNumberLiteral(Literal const& _literal);
u256 valueOfStringLiteral(Literal const& _literal);
u256 valueOfBoolLiteral(Literal const& _literal);
u256 valueOfLiteral(Literal const& _literal);
/**
* Linear order on Yul AST nodes.
+1 -1
View File
@@ -28,7 +28,7 @@
#include <string>
#include <functional>
namespace yul
namespace solidity::yul
{
/// Repository for YulStrings.
+6 -9
View File
@@ -28,20 +28,17 @@
#include <functional>
#include <memory>
namespace langutil
namespace solidity::langutil
{
struct SourceLocation;
}
namespace dev
{
namespace eth
namespace solidity::evmasm
{
enum class Instruction: uint8_t;
}
}
namespace yul
namespace solidity::yul
{
struct Identifier;
@@ -63,9 +60,9 @@ public:
virtual int stackHeight() const = 0;
virtual void setStackHeight(int height) = 0;
/// Append an EVM instruction.
virtual void appendInstruction(dev::eth::Instruction _instruction) = 0;
virtual void appendInstruction(evmasm::Instruction _instruction) = 0;
/// Append a constant.
virtual void appendConstant(dev::u256 const& _constant) = 0;
virtual void appendConstant(u256 const& _constant) = 0;
/// Append a label.
virtual void appendLabel(LabelID _labelId) = 0;
/// Append a label reference.
@@ -107,7 +104,7 @@ public:
/// Appends the size of the given sub-assembly or data.
virtual void appendDataSize(SubID _sub) = 0;
/// Appends the given data to the assembly and returns its ID.
virtual SubID appendData(dev::bytes const& _data) = 0;
virtual SubID appendData(bytes const& _data) = 0;
};
enum class IdentifierContext { LValue, RValue, VariableDeclaration };
+15 -14
View File
@@ -38,11 +38,12 @@
#include <functional>
using namespace std;
using namespace dev;
using namespace langutil;
using namespace yul;
using namespace solidity;
using namespace solidity::yul;
using namespace solidity::util;
using namespace solidity::langutil;
EthAssemblyAdapter::EthAssemblyAdapter(eth::Assembly& _assembly):
EthAssemblyAdapter::EthAssemblyAdapter(evmasm::Assembly& _assembly):
m_assembly(_assembly)
{
}
@@ -62,7 +63,7 @@ void EthAssemblyAdapter::setStackHeight(int height)
m_assembly.setDeposit(height);
}
void EthAssemblyAdapter::appendInstruction(dev::eth::Instruction _instruction)
void EthAssemblyAdapter::appendInstruction(evmasm::Instruction _instruction)
{
m_assembly.append(_instruction);
}
@@ -74,12 +75,12 @@ void EthAssemblyAdapter::appendConstant(u256 const& _constant)
void EthAssemblyAdapter::appendLabel(LabelID _labelId)
{
m_assembly.append(eth::AssemblyItem(eth::Tag, _labelId));
m_assembly.append(evmasm::AssemblyItem(evmasm::Tag, _labelId));
}
void EthAssemblyAdapter::appendLabelReference(LabelID _labelId)
{
m_assembly.append(eth::AssemblyItem(eth::PushTag, _labelId));
m_assembly.append(evmasm::AssemblyItem(evmasm::PushTag, _labelId));
}
size_t EthAssemblyAdapter::newLabelId()
@@ -99,7 +100,7 @@ void EthAssemblyAdapter::appendLinkerSymbol(std::string const& _linkerSymbol)
void EthAssemblyAdapter::appendJump(int _stackDiffAfter)
{
appendInstruction(dev::eth::Instruction::JUMP);
appendInstruction(evmasm::Instruction::JUMP);
m_assembly.adjustDeposit(_stackDiffAfter);
}
@@ -112,7 +113,7 @@ void EthAssemblyAdapter::appendJumpTo(LabelID _labelId, int _stackDiffAfter)
void EthAssemblyAdapter::appendJumpToIf(LabelID _labelId)
{
appendLabelReference(_labelId);
appendInstruction(dev::eth::Instruction::JUMPI);
appendInstruction(evmasm::Instruction::JUMPI);
}
void EthAssemblyAdapter::appendBeginsub(LabelID, int)
@@ -140,7 +141,7 @@ void EthAssemblyAdapter::appendAssemblySize()
pair<shared_ptr<AbstractAssembly>, AbstractAssembly::SubID> EthAssemblyAdapter::createSubAssembly()
{
shared_ptr<eth::Assembly> assembly{make_shared<eth::Assembly>()};
shared_ptr<evmasm::Assembly> assembly{make_shared<evmasm::Assembly>()};
auto sub = m_assembly.newSub(assembly);
return {make_shared<EthAssemblyAdapter>(*assembly), size_t(sub.data())};
}
@@ -151,7 +152,7 @@ void EthAssemblyAdapter::appendDataOffset(AbstractAssembly::SubID _sub)
if (it == m_dataHashBySubId.end())
m_assembly.pushSubroutineOffset(size_t(_sub));
else
m_assembly << eth::AssemblyItem(eth::PushData, it->second);
m_assembly << evmasm::AssemblyItem(evmasm::PushData, it->second);
}
void EthAssemblyAdapter::appendDataSize(AbstractAssembly::SubID _sub)
@@ -165,13 +166,13 @@ void EthAssemblyAdapter::appendDataSize(AbstractAssembly::SubID _sub)
AbstractAssembly::SubID EthAssemblyAdapter::appendData(bytes const& _data)
{
eth::AssemblyItem pushData = m_assembly.newData(_data);
evmasm::AssemblyItem pushData = m_assembly.newData(_data);
SubID subID = m_nextDataCounter++;
m_dataHashBySubId[subID] = pushData.data();
return subID;
}
EthAssemblyAdapter::LabelID EthAssemblyAdapter::assemblyTagToIdentifier(eth::AssemblyItem const& _tag)
EthAssemblyAdapter::LabelID EthAssemblyAdapter::assemblyTagToIdentifier(evmasm::AssemblyItem const& _tag)
{
u256 id = _tag.data();
yulAssert(id <= std::numeric_limits<LabelID>::max(), "Tag id too large.");
@@ -181,7 +182,7 @@ EthAssemblyAdapter::LabelID EthAssemblyAdapter::assemblyTagToIdentifier(eth::Ass
void CodeGenerator::assemble(
Block const& _parsedData,
AsmAnalysisInfo& _analysisInfo,
eth::Assembly& _assembly,
evmasm::Assembly& _assembly,
langutil::EVMVersion _evmVersion,
ExternalIdentifierAccess const& _identifierAccess,
bool _useNamedLabelsForFunctions,
+10 -13
View File
@@ -25,28 +25,25 @@
#include <liblangutil/SourceLocation.h>
#include <functional>
namespace dev
{
namespace eth
namespace solidity::evmasm
{
class Assembly;
class AssemblyItem;
}
}
namespace yul
namespace solidity::yul
{
struct Block;
class EthAssemblyAdapter: public AbstractAssembly
{
public:
explicit EthAssemblyAdapter(dev::eth::Assembly& _assembly);
explicit EthAssemblyAdapter(evmasm::Assembly& _assembly);
void setSourceLocation(langutil::SourceLocation const& _location) override;
int stackHeight() const override;
void setStackHeight(int height) override;
void appendInstruction(dev::eth::Instruction _instruction) override;
void appendConstant(dev::u256 const& _constant) override;
void appendInstruction(evmasm::Instruction _instruction) override;
void appendConstant(u256 const& _constant) override;
void appendLabel(LabelID _labelId) override;
void appendLabelReference(LabelID _labelId) override;
size_t newLabelId() override;
@@ -62,13 +59,13 @@ public:
std::pair<std::shared_ptr<AbstractAssembly>, SubID> createSubAssembly() override;
void appendDataOffset(SubID _sub) override;
void appendDataSize(SubID _sub) override;
SubID appendData(dev::bytes const& _data) override;
SubID appendData(bytes const& _data) override;
private:
static LabelID assemblyTagToIdentifier(dev::eth::AssemblyItem const& _tag);
static LabelID assemblyTagToIdentifier(evmasm::AssemblyItem const& _tag);
dev::eth::Assembly& m_assembly;
std::map<SubID, dev::u256> m_dataHashBySubId;
evmasm::Assembly& m_assembly;
std::map<SubID, u256> m_dataHashBySubId;
size_t m_nextDataCounter = std::numeric_limits<size_t>::max() / 2;
};
@@ -79,7 +76,7 @@ public:
static void assemble(
Block const& _parsedData,
AsmAnalysisInfo& _analysisInfo,
dev::eth::Assembly& _assembly,
evmasm::Assembly& _assembly,
langutil::EVMVersion _evmVersion,
ExternalIdentifierAccess const& _identifierAccess = ExternalIdentifierAccess(),
bool _useNamedLabelsForFunctions = false,
+14 -13
View File
@@ -30,8 +30,9 @@
#include <variant>
using namespace std;
using namespace dev;
using namespace yul;
using namespace solidity;
using namespace solidity::yul;
using namespace solidity::util;
using Representation = ConstantOptimiser::Representation;
@@ -46,24 +47,24 @@ struct MiniEVMInterpreter
return std::visit(*this, _expr);
}
u256 eval(dev::eth::Instruction _instr, vector<Expression> const& _arguments)
u256 eval(evmasm::Instruction _instr, vector<Expression> const& _arguments)
{
vector<u256> args;
for (auto const& arg: _arguments)
args.emplace_back(eval(arg));
switch (_instr)
{
case eth::Instruction::ADD:
case evmasm::Instruction::ADD:
return args.at(0) + args.at(1);
case eth::Instruction::SUB:
case evmasm::Instruction::SUB:
return args.at(0) - args.at(1);
case eth::Instruction::MUL:
case evmasm::Instruction::MUL:
return args.at(0) * args.at(1);
case eth::Instruction::EXP:
case evmasm::Instruction::EXP:
return exp256(args.at(0), args.at(1));
case eth::Instruction::SHL:
case evmasm::Instruction::SHL:
return args.at(0) > 255 ? 0 : (args.at(1) << unsigned(args.at(0)));
case eth::Instruction::NOT:
case evmasm::Instruction::NOT:
return ~args.at(0);
default:
yulAssert(false, "Invalid operation generated in constant optimizer.");
@@ -107,7 +108,7 @@ void ConstantOptimiser::visit(Expression& _e)
ASTModifier::visit(_e);
}
Expression const* RepresentationFinder::tryFindRepresentation(dev::u256 const& _value)
Expression const* RepresentationFinder::tryFindRepresentation(u256 const& _value)
{
if (_value < 0x10000)
return nullptr;
@@ -119,14 +120,14 @@ Expression const* RepresentationFinder::tryFindRepresentation(dev::u256 const& _
return repr.expression.get();
}
Representation const& RepresentationFinder::findRepresentation(dev::u256 const& _value)
Representation const& RepresentationFinder::findRepresentation(u256 const& _value)
{
if (m_cache.count(_value))
return m_cache.at(_value);
Representation routine = represent(_value);
if (dev::bytesRequired(~_value) < dev::bytesRequired(_value))
if (bytesRequired(~_value) < bytesRequired(_value))
// Negated is shorter to represent
routine = min(move(routine), represent("not"_yulstring, findRepresentation(~_value)));
@@ -175,7 +176,7 @@ Representation const& RepresentationFinder::findRepresentation(dev::u256 const&
return m_cache[_value] = move(routine);
}
Representation RepresentationFinder::represent(dev::u256 const& _value) const
Representation RepresentationFinder::represent(u256 const& _value) const
{
Representation repr;
repr.expression = make_unique<Expression>(Literal{m_location, LiteralKind::Number, YulString{formatNumber(_value)}, {}});
+7 -7
View File
@@ -34,7 +34,7 @@
#include <map>
#include <memory>
namespace yul
namespace solidity::yul
{
struct Dialect;
class GasMeter;
@@ -63,7 +63,7 @@ public:
private:
EVMDialect const& m_dialect;
GasMeter const& m_meter;
std::map<dev::u256, Representation> m_cache;
std::map<u256, Representation> m_cache;
};
class RepresentationFinder
@@ -74,7 +74,7 @@ public:
EVMDialect const& _dialect,
GasMeter const& _meter,
langutil::SourceLocation _location,
std::map<dev::u256, Representation>& _cache
std::map<u256, Representation>& _cache
):
m_dialect(_dialect),
m_meter(_meter),
@@ -84,14 +84,14 @@ public:
/// @returns a cheaper representation for the number than its representation
/// as a literal or nullptr otherwise.
Expression const* tryFindRepresentation(dev::u256 const& _value);
Expression const* tryFindRepresentation(u256 const& _value);
private:
/// Recursively try to find the cheapest representation of the given number,
/// literal if necessary.
Representation const& findRepresentation(dev::u256 const& _value);
Representation const& findRepresentation(u256 const& _value);
Representation represent(dev::u256 const& _value) const;
Representation represent(u256 const& _value) const;
Representation represent(YulString _instruction, Representation const& _arg) const;
Representation represent(YulString _instruction, Representation const& _arg1, Representation const& _arg2) const;
@@ -102,7 +102,7 @@ private:
langutil::SourceLocation m_location;
/// Counter for the complexity of optimization, will stop when it reaches zero.
size_t m_maxSteps = 10000;
std::map<dev::u256, Representation>& m_cache;
std::map<u256, Representation>& m_cache;
};
}
+18 -18
View File
@@ -24,10 +24,10 @@
#include <libevmasm/Instruction.h>
using namespace std;
using namespace dev;
using namespace dev::eth;
using namespace langutil;
using namespace yul;
using namespace solidity;
using namespace solidity::yul;
using namespace solidity::util;
using namespace solidity::langutil;
namespace
{
@@ -43,7 +43,7 @@ void EVMAssembly::setSourceLocation(SourceLocation const&)
// Ignored for now;
}
void EVMAssembly::appendInstruction(dev::eth::Instruction _instr)
void EVMAssembly::appendInstruction(evmasm::Instruction _instr)
{
m_bytecode.push_back(uint8_t(_instr));
m_stackHeight += instructionInfo(_instr).ret - instructionInfo(_instr).args;
@@ -52,14 +52,14 @@ void EVMAssembly::appendInstruction(dev::eth::Instruction _instr)
void EVMAssembly::appendConstant(u256 const& _constant)
{
bytes data = toCompactBigEndian(_constant, 1);
appendInstruction(pushInstruction(data.size()));
appendInstruction(evmasm::pushInstruction(data.size()));
m_bytecode += data;
}
void EVMAssembly::appendLabel(LabelID _labelId)
{
setLabelToCurrentPosition(_labelId);
appendInstruction(dev::eth::Instruction::JUMPDEST);
appendInstruction(evmasm::Instruction::JUMPDEST);
}
void EVMAssembly::appendLabelReference(LabelID _labelId)
@@ -67,7 +67,7 @@ void EVMAssembly::appendLabelReference(LabelID _labelId)
yulAssert(!m_evm15, "Cannot use plain label references in EMV1.5 mode.");
// @TODO we now always use labelReferenceSize for all labels, it could be shortened
// for some of them.
appendInstruction(dev::eth::pushInstruction(labelReferenceSize));
appendInstruction(evmasm::pushInstruction(labelReferenceSize));
m_labelReferences[m_bytecode.size()] = _labelId;
m_bytecode += bytes(labelReferenceSize);
}
@@ -94,7 +94,7 @@ void EVMAssembly::appendLinkerSymbol(string const&)
void EVMAssembly::appendJump(int _stackDiffAfter)
{
yulAssert(!m_evm15, "Plain JUMP used for EVM 1.5");
appendInstruction(dev::eth::Instruction::JUMP);
appendInstruction(evmasm::Instruction::JUMP);
m_stackHeight += _stackDiffAfter;
}
@@ -102,7 +102,7 @@ void EVMAssembly::appendJumpTo(LabelID _labelId, int _stackDiffAfter)
{
if (m_evm15)
{
m_bytecode.push_back(uint8_t(dev::eth::Instruction::JUMPTO));
m_bytecode.push_back(uint8_t(evmasm::Instruction::JUMPTO));
appendLabelReferenceInternal(_labelId);
m_stackHeight += _stackDiffAfter;
}
@@ -117,14 +117,14 @@ void EVMAssembly::appendJumpToIf(LabelID _labelId)
{
if (m_evm15)
{
m_bytecode.push_back(uint8_t(dev::eth::Instruction::JUMPIF));
m_bytecode.push_back(uint8_t(evmasm::Instruction::JUMPIF));
appendLabelReferenceInternal(_labelId);
m_stackHeight--;
}
else
{
appendLabelReference(_labelId);
appendInstruction(dev::eth::Instruction::JUMPI);
appendInstruction(evmasm::Instruction::JUMPI);
}
}
@@ -133,7 +133,7 @@ void EVMAssembly::appendBeginsub(LabelID _labelId, int _arguments)
yulAssert(m_evm15, "BEGINSUB used for EVM 1.0");
yulAssert(_arguments >= 0, "");
setLabelToCurrentPosition(_labelId);
m_bytecode.push_back(uint8_t(dev::eth::Instruction::BEGINSUB));
m_bytecode.push_back(uint8_t(evmasm::Instruction::BEGINSUB));
m_stackHeight += _arguments;
}
@@ -141,7 +141,7 @@ void EVMAssembly::appendJumpsub(LabelID _labelId, int _arguments, int _returns)
{
yulAssert(m_evm15, "JUMPSUB used for EVM 1.0");
yulAssert(_arguments >= 0 && _returns >= 0, "");
m_bytecode.push_back(uint8_t(dev::eth::Instruction::JUMPSUB));
m_bytecode.push_back(uint8_t(evmasm::Instruction::JUMPSUB));
appendLabelReferenceInternal(_labelId);
m_stackHeight += _returns - _arguments;
}
@@ -150,11 +150,11 @@ void EVMAssembly::appendReturnsub(int _returns, int _stackDiffAfter)
{
yulAssert(m_evm15, "RETURNSUB used for EVM 1.0");
yulAssert(_returns >= 0, "");
m_bytecode.push_back(uint8_t(dev::eth::Instruction::RETURNSUB));
m_bytecode.push_back(uint8_t(evmasm::Instruction::RETURNSUB));
m_stackHeight += _stackDiffAfter - _returns;
}
eth::LinkerObject EVMAssembly::finalize()
evmasm::LinkerObject EVMAssembly::finalize()
{
size_t bytecodeSize = m_bytecode.size();
for (auto const& ref: m_assemblySizePositions)
@@ -169,7 +169,7 @@ eth::LinkerObject EVMAssembly::finalize()
updateReference(referencePos, labelReferenceSize, u256(labelPos));
}
eth::LinkerObject obj;
evmasm::LinkerObject obj;
obj.bytecode = m_bytecode;
return obj;
}
@@ -189,7 +189,7 @@ void EVMAssembly::appendLabelReferenceInternal(LabelID _labelId)
void EVMAssembly::appendAssemblySize()
{
appendInstruction(dev::eth::pushInstruction(assemblySizeReferenceSize));
appendInstruction(evmasm::pushInstruction(assemblySizeReferenceSize));
m_assemblySizePositions.push_back(m_bytecode.size());
m_bytecode += bytes(assemblySizeReferenceSize);
}
+8 -8
View File
@@ -26,12 +26,12 @@
#include <map>
namespace langutil
namespace solidity::langutil
{
struct SourceLocation;
}
namespace yul
namespace solidity::yul
{
class EVMAssembly: public AbstractAssembly
@@ -47,9 +47,9 @@ public:
int stackHeight() const override { return m_stackHeight; }
void setStackHeight(int height) override { m_stackHeight = height; }
/// Append an EVM instruction.
void appendInstruction(dev::eth::Instruction _instruction) override;
void appendInstruction(evmasm::Instruction _instruction) override;
/// Append a constant.
void appendConstant(dev::u256 const& _constant) override;
void appendConstant(u256 const& _constant) override;
/// Append a label.
void appendLabel(LabelID _labelId) override;
/// Append a label reference.
@@ -81,20 +81,20 @@ public:
std::pair<std::shared_ptr<AbstractAssembly>, SubID> createSubAssembly() override;
void appendDataOffset(SubID _sub) override;
void appendDataSize(SubID _sub) override;
SubID appendData(dev::bytes const& _data) override;
SubID appendData(bytes const& _data) override;
/// Resolves references inside the bytecode and returns the linker object.
dev::eth::LinkerObject finalize();
evmasm::LinkerObject finalize();
private:
void setLabelToCurrentPosition(AbstractAssembly::LabelID _labelId);
void appendLabelReferenceInternal(AbstractAssembly::LabelID _labelId);
void updateReference(size_t pos, size_t size, dev::u256 value);
void updateReference(size_t pos, size_t size, u256 value);
bool m_evm15 = false; ///< if true, switch to evm1.5 mode
LabelID m_nextLabelId = 0;
int m_stackHeight = 0;
dev::bytes m_bytecode;
bytes m_bytecode;
std::map<std::string, LabelID> m_namedLabels;
std::map<LabelID, size_t> m_labelPositions;
std::map<size_t, LabelID> m_labelReferences;
+21 -20
View File
@@ -32,8 +32,9 @@
#include <variant>
using namespace std;
using namespace dev;
using namespace yul;
using namespace solidity;
using namespace solidity::yul;
using namespace solidity::util;
void VariableReferenceCounter::operator()(Identifier const& _identifier)
{
@@ -158,7 +159,7 @@ void CodeTransform::freeUnusedVariables()
while (m_unusedStackSlots.count(m_assembly.stackHeight() - 1))
{
yulAssert(m_unusedStackSlots.erase(m_assembly.stackHeight() - 1), "");
m_assembly.appendInstruction(dev::eth::Instruction::POP);
m_assembly.appendInstruction(evmasm::Instruction::POP);
--m_stackAdjustment;
}
}
@@ -206,7 +207,7 @@ void CodeTransform::operator()(VariableDeclaration const& _varDecl)
{
m_context->variableStackHeights.erase(&var);
m_assembly.setSourceLocation(_varDecl.location);
m_assembly.appendInstruction(dev::eth::Instruction::POP);
m_assembly.appendInstruction(evmasm::Instruction::POP);
--m_stackAdjustment;
}
else
@@ -221,8 +222,8 @@ void CodeTransform::operator()(VariableDeclaration const& _varDecl)
m_context->variableStackHeights[&var] = slot;
m_assembly.setSourceLocation(_varDecl.location);
if (int heightDiff = variableHeightDiff(var, varName, true))
m_assembly.appendInstruction(dev::eth::swapInstruction(heightDiff - 1));
m_assembly.appendInstruction(dev::eth::Instruction::POP);
m_assembly.appendInstruction(evmasm::swapInstruction(heightDiff - 1));
m_assembly.appendInstruction(evmasm::Instruction::POP);
--m_stackAdjustment;
}
}
@@ -231,10 +232,10 @@ void CodeTransform::operator()(VariableDeclaration const& _varDecl)
void CodeTransform::stackError(StackTooDeepError _error, int _targetStackHeight)
{
m_assembly.appendInstruction(dev::eth::Instruction::INVALID);
m_assembly.appendInstruction(evmasm::Instruction::INVALID);
// Correct the stack.
while (m_assembly.stackHeight() > _targetStackHeight)
m_assembly.appendInstruction(dev::eth::Instruction::POP);
m_assembly.appendInstruction(evmasm::Instruction::POP);
while (m_assembly.stackHeight() < _targetStackHeight)
m_assembly.appendConstant(u256(0));
// Store error.
@@ -316,7 +317,7 @@ void CodeTransform::operator()(Identifier const& _identifier)
// TODO: opportunity for optimization: Do not DUP if this is the last reference
// to the top most element of the stack
if (int heightDiff = variableHeightDiff(_var, _identifier.name, false))
m_assembly.appendInstruction(dev::eth::dupInstruction(heightDiff));
m_assembly.appendInstruction(evmasm::dupInstruction(heightDiff));
else
// Store something to balance the stack
m_assembly.appendConstant(u256(0));
@@ -354,7 +355,7 @@ void CodeTransform::operator()(If const& _if)
{
visitExpression(*_if.condition);
m_assembly.setSourceLocation(_if.location);
m_assembly.appendInstruction(dev::eth::Instruction::ISZERO);
m_assembly.appendInstruction(evmasm::Instruction::ISZERO);
AbstractAssembly::LabelID end = m_assembly.newLabelId();
m_assembly.appendJumpToIf(end);
(*this)(_if.body);
@@ -380,8 +381,8 @@ void CodeTransform::operator()(Switch const& _switch)
AbstractAssembly::LabelID bodyLabel = m_assembly.newLabelId();
caseBodies[&c] = bodyLabel;
yulAssert(m_assembly.stackHeight() == expressionHeight + 1, "");
m_assembly.appendInstruction(dev::eth::dupInstruction(2));
m_assembly.appendInstruction(dev::eth::Instruction::EQ);
m_assembly.appendInstruction(evmasm::dupInstruction(2));
m_assembly.appendInstruction(evmasm::Instruction::EQ);
m_assembly.appendJumpToIf(bodyLabel);
}
else
@@ -407,7 +408,7 @@ void CodeTransform::operator()(Switch const& _switch)
m_assembly.setSourceLocation(_switch.location);
m_assembly.appendLabel(end);
m_assembly.appendInstruction(dev::eth::Instruction::POP);
m_assembly.appendInstruction(evmasm::Instruction::POP);
checkStackHeight(&_switch);
}
@@ -516,12 +517,12 @@ void CodeTransform::operator()(FunctionDefinition const& _function)
while (!stackLayout.empty() && stackLayout.back() != int(stackLayout.size() - 1))
if (stackLayout.back() < 0)
{
m_assembly.appendInstruction(dev::eth::Instruction::POP);
m_assembly.appendInstruction(evmasm::Instruction::POP);
stackLayout.pop_back();
}
else
{
m_assembly.appendInstruction(dev::eth::swapInstruction(stackLayout.size() - stackLayout.back() - 1));
m_assembly.appendInstruction(evmasm::swapInstruction(stackLayout.size() - stackLayout.back() - 1));
swap(stackLayout[stackLayout.back()], stackLayout.back());
}
for (int i = 0; size_t(i) < stackLayout.size(); ++i)
@@ -555,7 +556,7 @@ void CodeTransform::operator()(ForLoop const& _forLoop)
visitExpression(*_forLoop.condition);
m_assembly.setSourceLocation(_forLoop.location);
m_assembly.appendInstruction(dev::eth::Instruction::ISZERO);
m_assembly.appendInstruction(evmasm::Instruction::ISZERO);
m_assembly.appendJumpToIf(loopEnd);
int const stackHeightBody = m_assembly.stackHeight();
@@ -581,7 +582,7 @@ int CodeTransform::appendPopUntil(int _targetDepth)
{
int const stackDiffAfter = m_assembly.stackHeight() - _targetDepth;
for (int i = 0; i < stackDiffAfter; ++i)
m_assembly.appendInstruction(dev::eth::Instruction::POP);
m_assembly.appendInstruction(evmasm::Instruction::POP);
return stackDiffAfter;
}
@@ -725,7 +726,7 @@ void CodeTransform::finalizeBlock(Block const& _block, int blockStartStackHeight
m_stackAdjustment++;
}
else
m_assembly.appendInstruction(dev::eth::Instruction::POP);
m_assembly.appendInstruction(evmasm::Instruction::POP);
}
int deposit = m_assembly.stackHeight() - blockStartStackHeight;
@@ -747,8 +748,8 @@ void CodeTransform::generateAssignment(Identifier const& _variableName)
{
Scope::Variable const& _var = std::get<Scope::Variable>(*var);
if (int heightDiff = variableHeightDiff(_var, _variableName.name, true))
m_assembly.appendInstruction(dev::eth::swapInstruction(heightDiff - 1));
m_assembly.appendInstruction(dev::eth::Instruction::POP);
m_assembly.appendInstruction(evmasm::swapInstruction(heightDiff - 1));
m_assembly.appendInstruction(evmasm::Instruction::POP);
decreaseReference(_variableName.name, _var);
}
else
+2 -2
View File
@@ -30,12 +30,12 @@
#include <optional>
#include <stack>
namespace langutil
namespace solidity::langutil
{
class ErrorReporter;
}
namespace yul
namespace solidity::yul
{
struct AsmAnalysisInfo;
class EVMAssembly;
+17 -16
View File
@@ -35,23 +35,24 @@
#include <boost/range/adaptor/reversed.hpp>
using namespace std;
using namespace dev;
using namespace yul;
using namespace solidity;
using namespace solidity::yul;
using namespace solidity::util;
namespace
{
pair<YulString, BuiltinFunctionForEVM> createEVMFunction(
string const& _name,
dev::eth::Instruction _instruction
evmasm::Instruction _instruction
)
{
eth::InstructionInfo info = dev::eth::instructionInfo(_instruction);
evmasm::InstructionInfo info = evmasm::instructionInfo(_instruction);
BuiltinFunctionForEVM f;
f.name = YulString{_name};
f.parameters.resize(info.args);
f.returns.resize(info.ret);
f.sideEffects = EVMDialect::sideEffectsOfInstruction(_instruction);
f.isMSize = _instruction == dev::eth::Instruction::MSIZE;
f.isMSize = _instruction == evmasm::Instruction::MSIZE;
f.literalArguments = false;
f.instruction = _instruction;
f.generateCode = [_instruction](
@@ -94,10 +95,10 @@ map<YulString, BuiltinFunctionForEVM> createBuiltins(langutil::EVMVersion _evmVe
map<YulString, BuiltinFunctionForEVM> builtins;
for (auto const& instr: Parser::instructions())
if (
!dev::eth::isDupInstruction(instr.second) &&
!dev::eth::isSwapInstruction(instr.second) &&
instr.second != eth::Instruction::JUMP &&
instr.second != eth::Instruction::JUMPI &&
!evmasm::isDupInstruction(instr.second) &&
!evmasm::isSwapInstruction(instr.second) &&
instr.second != evmasm::Instruction::JUMP &&
instr.second != evmasm::Instruction::JUMPI &&
_evmVersion.hasOpcode(instr.second)
)
builtins.emplace(createEVMFunction(instr.first, instr.second));
@@ -159,7 +160,7 @@ map<YulString, BuiltinFunctionForEVM> createBuiltins(langutil::EVMVersion _evmVe
std::function<void()> _visitArguments
) {
_visitArguments();
_assembly.appendInstruction(dev::eth::Instruction::CODECOPY);
_assembly.appendInstruction(evmasm::Instruction::CODECOPY);
}
));
}
@@ -212,13 +213,13 @@ EVMDialect const& EVMDialect::yulForEVM(langutil::EVMVersion _version)
return *dialects[_version];
}
SideEffects EVMDialect::sideEffectsOfInstruction(eth::Instruction _instruction)
SideEffects EVMDialect::sideEffectsOfInstruction(evmasm::Instruction _instruction)
{
return SideEffects{
eth::SemanticInformation::movable(_instruction),
eth::SemanticInformation::sideEffectFree(_instruction),
eth::SemanticInformation::sideEffectFreeIfNoMSize(_instruction),
eth::SemanticInformation::invalidatesStorage(_instruction),
eth::SemanticInformation::invalidatesMemory(_instruction)
evmasm::SemanticInformation::movable(_instruction),
evmasm::SemanticInformation::sideEffectFree(_instruction),
evmasm::SemanticInformation::sideEffectFreeIfNoMSize(_instruction),
evmasm::SemanticInformation::invalidatesStorage(_instruction),
evmasm::SemanticInformation::invalidatesMemory(_instruction)
};
}
+3 -3
View File
@@ -27,7 +27,7 @@
#include <map>
namespace yul
namespace solidity::yul
{
class YulString;
@@ -47,7 +47,7 @@ struct BuiltinContext
struct BuiltinFunctionForEVM: BuiltinFunction
{
std::optional<dev::eth::Instruction> instruction;
std::optional<evmasm::Instruction> instruction;
/// Function to generate code for the given function call and append it to the abstract
/// assembly. The fourth parameter is called to visit (and generate code for) the arguments
/// from right to left.
@@ -80,7 +80,7 @@ struct EVMDialect: public Dialect
bool providesObjectAccess() const { return m_objectAccess; }
static SideEffects sideEffectsOfInstruction(dev::eth::Instruction _instruction);
static SideEffects sideEffectsOfInstruction(evmasm::Instruction _instruction);
protected:
bool const m_objectAccess;
+14 -13
View File
@@ -32,15 +32,16 @@
#include <libdevcore/CommonData.h>
using namespace std;
using namespace dev;
using namespace yul;
using namespace solidity;
using namespace solidity::yul;
using namespace solidity::util;
size_t GasMeter::costs(Expression const& _expression) const
{
return combineCosts(GasMeterVisitor::costs(_expression, m_dialect, m_isCreation));
}
size_t GasMeter::instructionCosts(eth::Instruction _instruction) const
size_t GasMeter::instructionCosts(evmasm::Instruction _instruction) const
{
return combineCosts(GasMeterVisitor::instructionCosts(_instruction, m_dialect, m_isCreation));
}
@@ -63,7 +64,7 @@ pair<size_t, size_t> GasMeterVisitor::costs(
}
pair<size_t, size_t> GasMeterVisitor::instructionCosts(
dev::eth::Instruction _instruction,
evmasm::Instruction _instruction,
EVMDialect const& _dialect,
bool _isCreation
)
@@ -87,31 +88,31 @@ void GasMeterVisitor::operator()(FunctionCall const& _funCall)
void GasMeterVisitor::operator()(Literal const& _lit)
{
m_runGas += dev::eth::GasMeter::runGas(dev::eth::Instruction::PUSH1);
m_runGas += evmasm::GasMeter::runGas(evmasm::Instruction::PUSH1);
m_dataGas +=
singleByteDataGas() +
size_t(dev::eth::GasMeter::dataGas(dev::toCompactBigEndian(valueOfLiteral(_lit), 1), m_isCreation, m_dialect.evmVersion()));
size_t(evmasm::GasMeter::dataGas(toCompactBigEndian(valueOfLiteral(_lit), 1), m_isCreation, m_dialect.evmVersion()));
}
void GasMeterVisitor::operator()(Identifier const&)
{
m_runGas += dev::eth::GasMeter::runGas(dev::eth::Instruction::DUP1);
m_runGas += evmasm::GasMeter::runGas(evmasm::Instruction::DUP1);
m_dataGas += singleByteDataGas();
}
size_t GasMeterVisitor::singleByteDataGas() const
{
if (m_isCreation)
return dev::eth::GasCosts::txDataNonZeroGas(m_dialect.evmVersion());
return evmasm::GasCosts::txDataNonZeroGas(m_dialect.evmVersion());
else
return dev::eth::GasCosts::createDataGas;
return evmasm::GasCosts::createDataGas;
}
void GasMeterVisitor::instructionCostsInternal(dev::eth::Instruction _instruction)
void GasMeterVisitor::instructionCostsInternal(evmasm::Instruction _instruction)
{
if (_instruction == eth::Instruction::EXP)
m_runGas += dev::eth::GasCosts::expGas + dev::eth::GasCosts::expByteGas(m_dialect.evmVersion());
if (_instruction == evmasm::Instruction::EXP)
m_runGas += evmasm::GasCosts::expGas + evmasm::GasCosts::expByteGas(m_dialect.evmVersion());
else
m_runGas += dev::eth::GasMeter::runGas(_instruction);
m_runGas += evmasm::GasMeter::runGas(_instruction);
m_dataGas += singleByteDataGas();
}
+4 -4
View File
@@ -24,7 +24,7 @@
#include <liblangutil/EVMVersion.h>
#include <libevmasm/Instruction.h>
namespace yul
namespace solidity::yul
{
struct EVMDialect;
@@ -49,7 +49,7 @@ public:
size_t costs(Expression const& _expression) const;
/// @returns the combined costs of deploying and running the instruction, not including
/// the costs for its arguments.
size_t instructionCosts(dev::eth::Instruction _instruction) const;
size_t instructionCosts(evmasm::Instruction _instruction) const;
private:
size_t combineCosts(std::pair<size_t, size_t> _costs) const;
@@ -69,7 +69,7 @@ public:
);
static std::pair<size_t, size_t> instructionCosts(
dev::eth::Instruction _instruction,
evmasm::Instruction _instruction,
EVMDialect const& _dialect,
bool _isCreation = false
);
@@ -89,7 +89,7 @@ private:
/// Computes the cost of storing and executing the single instruction (excluding its arguments).
/// For EXP, it assumes that the exponent is at most 255.
/// Does not work particularly exact for anything apart from arithmetic.
void instructionCostsInternal(dev::eth::Instruction _instruction);
void instructionCostsInternal(evmasm::Instruction _instruction);
EVMDialect const& m_dialect;
bool m_isCreation = false;
+1 -1
View File
@@ -26,7 +26,7 @@
#include <libyul/Object.h>
#include <libyul/Exceptions.h>
using namespace yul;
using namespace solidity::yul;
using namespace std;
void EVMObjectCompiler::compile(Object& _object, AbstractAssembly& _assembly, EVMDialect const& _dialect, bool _evm15, bool _optimize)
+1 -1
View File
@@ -20,7 +20,7 @@
#pragma once
namespace yul
namespace solidity::yul
{
struct Object;
class AbstractAssembly;
+14 -13
View File
@@ -24,30 +24,31 @@
#include <libevmasm/Instruction.h>
using namespace std;
using namespace dev;
using namespace langutil;
using namespace yul;
using namespace solidity;
using namespace solidity::yul;
using namespace solidity::util;
using namespace solidity::langutil;
void NoOutputAssembly::appendInstruction(dev::eth::Instruction _instr)
void NoOutputAssembly::appendInstruction(evmasm::Instruction _instr)
{
m_stackHeight += instructionInfo(_instr).ret - instructionInfo(_instr).args;
}
void NoOutputAssembly::appendConstant(u256 const&)
{
appendInstruction(dev::eth::pushInstruction(1));
appendInstruction(evmasm::pushInstruction(1));
}
void NoOutputAssembly::appendLabel(LabelID)
{
appendInstruction(dev::eth::Instruction::JUMPDEST);
appendInstruction(evmasm::Instruction::JUMPDEST);
}
void NoOutputAssembly::appendLabelReference(LabelID)
{
yulAssert(!m_evm15, "Cannot use plain label references in EMV1.5 mode.");
appendInstruction(dev::eth::pushInstruction(1));
appendInstruction(evmasm::pushInstruction(1));
}
NoOutputAssembly::LabelID NoOutputAssembly::newLabelId()
@@ -68,7 +69,7 @@ void NoOutputAssembly::appendLinkerSymbol(string const&)
void NoOutputAssembly::appendJump(int _stackDiffAfter)
{
yulAssert(!m_evm15, "Plain JUMP used for EVM 1.5");
appendInstruction(dev::eth::Instruction::JUMP);
appendInstruction(evmasm::Instruction::JUMP);
m_stackHeight += _stackDiffAfter;
}
@@ -90,7 +91,7 @@ void NoOutputAssembly::appendJumpToIf(LabelID _labelId)
else
{
appendLabelReference(_labelId);
appendInstruction(dev::eth::Instruction::JUMPI);
appendInstruction(evmasm::Instruction::JUMPI);
}
}
@@ -117,7 +118,7 @@ void NoOutputAssembly::appendReturnsub(int _returns, int _stackDiffAfter)
void NoOutputAssembly::appendAssemblySize()
{
appendInstruction(dev::eth::Instruction::PUSH1);
appendInstruction(evmasm::Instruction::PUSH1);
}
pair<shared_ptr<AbstractAssembly>, AbstractAssembly::SubID> NoOutputAssembly::createSubAssembly()
@@ -128,12 +129,12 @@ pair<shared_ptr<AbstractAssembly>, AbstractAssembly::SubID> NoOutputAssembly::cr
void NoOutputAssembly::appendDataOffset(AbstractAssembly::SubID)
{
appendInstruction(dev::eth::Instruction::PUSH1);
appendInstruction(evmasm::Instruction::PUSH1);
}
void NoOutputAssembly::appendDataSize(AbstractAssembly::SubID)
{
appendInstruction(dev::eth::Instruction::PUSH1);
appendInstruction(evmasm::Instruction::PUSH1);
}
AbstractAssembly::SubID NoOutputAssembly::appendData(bytes const&)
@@ -152,7 +153,7 @@ NoOutputEVMDialect::NoOutputEVMDialect(EVMDialect const& _copyFrom):
{
_visitArguments();
for (size_t i = 0; i < parameters; i++)
_assembly.appendInstruction(dev::eth::Instruction::POP);
_assembly.appendInstruction(evmasm::Instruction::POP);
for (size_t i = 0; i < returns; i++)
_assembly.appendConstant(u256(0));
+5 -5
View File
@@ -28,12 +28,12 @@
#include <map>
namespace langutil
namespace solidity::langutil
{
struct SourceLocation;
}
namespace yul
namespace solidity::yul
{
@@ -50,8 +50,8 @@ public:
void setSourceLocation(langutil::SourceLocation const&) override {}
int stackHeight() const override { return m_stackHeight; }
void setStackHeight(int height) override { m_stackHeight = height; }
void appendInstruction(dev::eth::Instruction _instruction) override;
void appendConstant(dev::u256 const& _constant) override;
void appendInstruction(evmasm::Instruction _instruction) override;
void appendConstant(u256 const& _constant) override;
void appendLabel(LabelID _labelId) override;
void appendLabelReference(LabelID _labelId) override;
LabelID newLabelId() override;
@@ -69,7 +69,7 @@ public:
std::pair<std::shared_ptr<AbstractAssembly>, SubID> createSubAssembly() override;
void appendDataOffset(SubID _sub) override;
void appendDataSize(SubID _sub) override;
SubID appendData(dev::bytes const& _data) override;
SubID appendData(bytes const& _data) override;
private:
bool m_evm15 = false; ///< if true, switch to evm1.5 mode
+4 -3
View File
@@ -26,9 +26,10 @@
#include <boost/range/adaptor/reversed.hpp>
using namespace std;
using namespace yul;
using namespace dev;
using namespace yul::wasm;
using namespace solidity;
using namespace solidity::yul;
using namespace solidity::yul::wasm;
using namespace solidity::util;
namespace
{
+28 -32
View File
@@ -27,9 +27,7 @@
#include <vector>
#include <stack>
namespace yul
{
namespace wasm
namespace solidity::yul::wasm
{
/**
@@ -38,23 +36,23 @@ namespace wasm
class BinaryTransform
{
public:
static dev::bytes run(Module const& _module);
static bytes run(Module const& _module);
dev::bytes operator()(wasm::Literal const& _literal);
dev::bytes operator()(wasm::StringLiteral const& _literal);
dev::bytes operator()(wasm::LocalVariable const& _identifier);
dev::bytes operator()(wasm::GlobalVariable const& _identifier);
dev::bytes operator()(wasm::BuiltinCall const& _builinCall);
dev::bytes operator()(wasm::FunctionCall const& _functionCall);
dev::bytes operator()(wasm::LocalAssignment const& _assignment);
dev::bytes operator()(wasm::GlobalAssignment const& _assignment);
dev::bytes operator()(wasm::If const& _if);
dev::bytes operator()(wasm::Loop const& _loop);
dev::bytes operator()(wasm::Break const& _break);
dev::bytes operator()(wasm::BreakIf const& _break);
dev::bytes operator()(wasm::Return const& _return);
dev::bytes operator()(wasm::Block const& _block);
dev::bytes operator()(wasm::FunctionDefinition const& _function);
bytes operator()(wasm::Literal const& _literal);
bytes operator()(wasm::StringLiteral const& _literal);
bytes operator()(wasm::LocalVariable const& _identifier);
bytes operator()(wasm::GlobalVariable const& _identifier);
bytes operator()(wasm::BuiltinCall const& _builinCall);
bytes operator()(wasm::FunctionCall const& _functionCall);
bytes operator()(wasm::LocalAssignment const& _assignment);
bytes operator()(wasm::GlobalAssignment const& _assignment);
bytes operator()(wasm::If const& _if);
bytes operator()(wasm::Loop const& _loop);
bytes operator()(wasm::Break const& _break);
bytes operator()(wasm::BreakIf const& _break);
bytes operator()(wasm::Return const& _return);
bytes operator()(wasm::Block const& _block);
bytes operator()(wasm::FunctionDefinition const& _function);
private:
using Type = std::pair<std::vector<std::uint8_t>, std::vector<std::uint8_t>>;
@@ -63,23 +61,23 @@ private:
static uint8_t encodeType(std::string const& _typeName);
static std::vector<uint8_t> encodeTypes(std::vector<std::string> const& _typeNames);
dev::bytes typeSection(
bytes typeSection(
std::vector<wasm::FunctionImport> const& _imports,
std::vector<wasm::FunctionDefinition> const& _functions
);
dev::bytes importSection(std::vector<wasm::FunctionImport> const& _imports);
dev::bytes functionSection(std::vector<wasm::FunctionDefinition> const& _functions);
dev::bytes memorySection();
dev::bytes globalSection();
dev::bytes exportSection();
dev::bytes customSection(std::string const& _name, dev::bytes _data);
dev::bytes codeSection(std::vector<wasm::FunctionDefinition> const& _functions);
bytes importSection(std::vector<wasm::FunctionImport> const& _imports);
bytes functionSection(std::vector<wasm::FunctionDefinition> const& _functions);
bytes memorySection();
bytes globalSection();
bytes exportSection();
bytes customSection(std::string const& _name, bytes _data);
bytes codeSection(std::vector<wasm::FunctionDefinition> const& _functions);
dev::bytes visit(std::vector<wasm::Expression> const& _expressions);
dev::bytes visitReversed(std::vector<wasm::Expression> const& _expressions);
bytes visit(std::vector<wasm::Expression> const& _expressions);
bytes visitReversed(std::vector<wasm::Expression> const& _expressions);
static dev::bytes encodeName(std::string const& _name);
static bytes encodeName(std::string const& _name);
std::map<std::string, size_t> m_locals;
std::map<std::string, size_t> m_globals;
@@ -89,7 +87,5 @@ private:
std::map<std::string, std::pair<size_t, size_t>> m_subModulePosAndSize;
};
}
}
@@ -41,9 +41,10 @@
#include <liblangutil/SourceReferenceFormatter.h>
using namespace std;
using namespace dev;
using namespace yul;
using namespace langutil;
using namespace solidity;
using namespace solidity::yul;
using namespace solidity::util;
using namespace solidity::langutil;
namespace
{
+1 -1
View File
@@ -24,7 +24,7 @@
#include <libyul/optimiser/ASTWalker.h>
#include <libyul/Dialect.h>
namespace yul
namespace solidity::yul
{
struct Object;
+4 -3
View File
@@ -27,9 +27,10 @@
#include <boost/range/adaptor/transformed.hpp>
using namespace std;
using namespace yul;
using namespace dev;
using namespace yul::wasm;
using namespace solidity;
using namespace solidity::yul;
using namespace solidity::yul::wasm;
using namespace solidity::util;
string TextTransform::run(wasm::Module const& _module)
{
+3 -3
View File
@@ -24,11 +24,12 @@
#include <vector>
namespace yul
namespace solidity::yul
{
struct AsmAnalysisInfo;
}
namespace wasm
namespace solidity::yul::wasm
{
class TextTransform
@@ -65,4 +66,3 @@ private:
};
}
}
+1 -4
View File
@@ -26,9 +26,7 @@
#include <map>
#include <memory>
namespace yul
{
namespace wasm
namespace solidity::yul::wasm
{
struct Literal;
@@ -102,4 +100,3 @@ struct Module
};
}
}
+3 -2
View File
@@ -33,8 +33,9 @@
#include <boost/range/adaptor/transformed.hpp>
using namespace std;
using namespace dev;
using namespace yul;
using namespace solidity;
using namespace solidity::yul;
using namespace solidity::util;
wasm::Module WasmCodeTransform::run(Dialect const& _dialect, yul::Block const& _ast)
{
+1 -1
View File
@@ -28,7 +28,7 @@
#include <stack>
#include <map>
namespace yul
namespace solidity::yul
{
struct AsmAnalysisInfo;
+1 -1
View File
@@ -21,7 +21,7 @@
#include <libyul/backends/wasm/WasmDialect.h>
using namespace std;
using namespace yul;
using namespace solidity::yul;
WasmDialect::WasmDialect():
Dialect{AsmFlavour::Strict}
+1 -1
View File
@@ -24,7 +24,7 @@
#include <map>
namespace yul
namespace solidity::yul
{
class YulString;
+3 -2
View File
@@ -29,10 +29,11 @@
#include <libdevcore/CommonData.h>
using namespace yul;
using namespace solidity;
using namespace solidity::yul;
using namespace std;
pair<string, dev::bytes> WasmObjectCompiler::compile(Object& _object, Dialect const& _dialect)
pair<string, bytes> WasmObjectCompiler::compile(Object& _object, Dialect const& _dialect)
{
WasmObjectCompiler compiler(_dialect);
wasm::Module module = compiler.run(_object);
+3 -7
View File
@@ -23,13 +23,9 @@
#include <string>
#include <vector>
#include <tuple>
#include <libdevcore/Common.h> // solidity::bytes
namespace dev
{
using bytes = std::vector<uint8_t>;
}
namespace yul
namespace solidity::yul
{
struct Object;
struct Dialect;
@@ -42,7 +38,7 @@ class WasmObjectCompiler
{
public:
/// Compiles the given object and returns the Wasm text and binary representation.
static std::pair<std::string, dev::bytes> compile(Object& _object, Dialect const& _dialect);
static std::pair<std::string, bytes> compile(Object& _object, Dialect const& _dialect);
private:
WasmObjectCompiler(Dialect const& _dialect):
m_dialect(_dialect)
+3 -2
View File
@@ -28,8 +28,9 @@
#include <variant>
using namespace std;
using namespace dev;
using namespace yul;
using namespace solidity;
using namespace solidity::yul;
using namespace solidity::util;
void WordSizeTransform::operator()(FunctionDefinition& _fd)
{
+1 -1
View File
@@ -28,7 +28,7 @@
#include <array>
#include <vector>
namespace yul
namespace solidity::yul
{
/**
+3 -2
View File
@@ -27,8 +27,9 @@
#include <libdevcore/Common.h>
using namespace std;
using namespace dev;
using namespace yul;
using namespace solidity;
using namespace solidity::yul;
using namespace solidity::util;
Statement ASTCopier::operator()(ExpressionStatement const& _statement)
{
+1 -1
View File
@@ -29,7 +29,7 @@
#include <set>
#include <vector>
namespace yul
namespace solidity::yul
{
class ExpressionCopier
+3 -2
View File
@@ -25,8 +25,9 @@
#include <boost/range/adaptor/reversed.hpp>
using namespace std;
using namespace dev;
using namespace yul;
using namespace solidity;
using namespace solidity::yul;
using namespace solidity::util;
void ASTWalker::operator()(FunctionCall const& _funCall)
{
+1 -1
View File
@@ -30,7 +30,7 @@
#include <set>
#include <vector>
namespace yul
namespace solidity::yul
{
/**
+3 -2
View File
@@ -21,8 +21,9 @@
#include <functional>
using namespace std;
using namespace dev;
using namespace yul;
using namespace solidity;
using namespace solidity::yul;
using namespace solidity::util;
void BlockFlattener::operator()(Block& _block)
{
+1 -1
View File
@@ -19,7 +19,7 @@
#include <libyul/optimiser/ASTWalker.h>
#include <libyul/optimiser/OptimiserStep.h>
namespace yul
namespace solidity::yul
{
class BlockFlattener: public ASTModifier
+3 -2
View File
@@ -24,8 +24,9 @@
#include <libdevcore/CommonData.h>
using namespace std;
using namespace dev;
using namespace yul;
using namespace solidity;
using namespace solidity::yul;
using namespace solidity::util;
namespace
{
+1 -1
View File
@@ -24,7 +24,7 @@
#include <libyul/YulString.h>
#include <libyul/AsmData.h>
namespace yul
namespace solidity::yul
{
/**
+3 -2
View File
@@ -26,8 +26,9 @@
#include <stack>
using namespace std;
using namespace dev;
using namespace yul;
using namespace solidity;
using namespace solidity::yul;
using namespace solidity::util;
CallGraph CallGraphGenerator::callGraph(Block const& _ast)
{
+1 -1
View File
@@ -28,7 +28,7 @@
#include <optional>
#include <set>
namespace yul
namespace solidity::yul
{
struct CallGraph
@@ -31,8 +31,9 @@
#include <libyul/Dialect.h>
using namespace std;
using namespace dev;
using namespace yul;
using namespace solidity;
using namespace solidity::yul;
using namespace solidity::util;
void CommonSubexpressionEliminator::run(OptimiserStepContext& _context, Block& _ast)
{
@@ -24,7 +24,7 @@
#include <libyul/optimiser/DataFlowAnalyzer.h>
#include <libyul/optimiser/OptimiserStep.h>
namespace yul
namespace solidity::yul
{
struct Dialect;
+3 -2
View File
@@ -23,8 +23,9 @@
#include <libdevcore/Visitor.h>
using namespace std;
using namespace dev;
using namespace yul;
using namespace solidity;
using namespace solidity::yul;
using namespace solidity::util;
void ConditionalSimplifier::operator()(Switch& _switch)
{
+1 -1
View File
@@ -21,7 +21,7 @@
#include <libyul/Dialect.h>
#include <libdevcore/Common.h>
namespace yul
namespace solidity::yul
{
/**
+3 -2
View File
@@ -23,8 +23,9 @@
#include <libdevcore/Visitor.h>
using namespace std;
using namespace dev;
using namespace yul;
using namespace solidity;
using namespace solidity::yul;
using namespace solidity::util;
void ConditionalUnsimplifier::operator()(Switch& _switch)
{
+1 -1
View File
@@ -21,7 +21,7 @@
#include <libyul/Dialect.h>
#include <libdevcore/Common.h>
namespace yul
namespace solidity::yul
{
/**
+3 -2
View File
@@ -27,8 +27,9 @@
#include <boost/algorithm/cxx11/any_of.hpp>
using namespace std;
using namespace dev;
using namespace yul;
using namespace solidity;
using namespace solidity::util;
using namespace solidity::yul;
using OptionalStatements = std::optional<vector<Statement>>;
+1 -1
View File
@@ -19,7 +19,7 @@
#include <libyul/optimiser/ASTWalker.h>
#include <libyul/optimiser/OptimiserStep.h>
namespace yul
namespace solidity::yul
{
struct Dialect;
struct OptimiserStepContext;
+8 -7
View File
@@ -35,13 +35,14 @@
#include <variant>
using namespace std;
using namespace dev;
using namespace yul;
using namespace solidity;
using namespace solidity::util;
using namespace solidity::yul;
void DataFlowAnalyzer::operator()(ExpressionStatement& _statement)
{
if (auto vars = isSimpleStore(dev::eth::Instruction::SSTORE, _statement))
if (auto vars = isSimpleStore(evmasm::Instruction::SSTORE, _statement))
{
ASTModifier::operator()(_statement);
set<YulString> keysToErase;
@@ -55,7 +56,7 @@ void DataFlowAnalyzer::operator()(ExpressionStatement& _statement)
m_storage.eraseKey(key);
m_storage.set(vars->first, vars->second);
}
else if (auto vars = isSimpleStore(dev::eth::Instruction::MSTORE, _statement))
else if (auto vars = isSimpleStore(evmasm::Instruction::MSTORE, _statement))
{
ASTModifier::operator()(_statement);
set<YulString> keysToErase;
@@ -360,13 +361,13 @@ bool DataFlowAnalyzer::inScope(YulString _variableName) const
}
std::optional<pair<YulString, YulString>> DataFlowAnalyzer::isSimpleStore(
dev::eth::Instruction _store,
evmasm::Instruction _store,
ExpressionStatement const& _statement
) const
{
yulAssert(
_store == dev::eth::Instruction::MSTORE ||
_store == dev::eth::Instruction::SSTORE,
_store == evmasm::Instruction::MSTORE ||
_store == evmasm::Instruction::SSTORE,
""
);
if (holds_alternative<FunctionCall>(_statement.expression))
+2 -2
View File
@@ -36,7 +36,7 @@
#include <map>
#include <set>
namespace yul
namespace solidity::yul
{
struct Dialect;
struct SideEffects;
@@ -133,7 +133,7 @@ protected:
bool inScope(YulString _variableName) const;
std::optional<std::pair<YulString, YulString>> isSimpleStore(
dev::eth::Instruction _store,
evmasm::Instruction _store,
ExpressionStatement const& _statement
) const;
+3 -3
View File
@@ -29,9 +29,9 @@
#include <algorithm>
using namespace std;
using namespace dev;
using namespace yul;
using namespace solidity;
using namespace solidity::util;
using namespace solidity::yul;
void DeadCodeEliminator::run(OptimiserStepContext& _context, Block& _ast)
{
+1 -1
View File
@@ -26,7 +26,7 @@
#include <map>
#include <set>
namespace yul
namespace solidity::yul
{
struct Dialect;
struct OptimiserStepContext;
+3 -2
View File
@@ -26,8 +26,9 @@
#include <libyul/Dialect.h>
using namespace std;
using namespace dev;
using namespace yul;
using namespace solidity;
using namespace solidity::yul;
using namespace solidity::util;
YulString Disambiguator::translateIdentifier(YulString _originalName)
{
+1 -1
View File
@@ -28,7 +28,7 @@
#include <optional>
#include <set>
namespace yul
namespace solidity::yul
{
struct Dialect;
@@ -23,8 +23,8 @@
#include <libdevcore/CommonData.h>
using namespace std;
using namespace dev;
using namespace yul;
using namespace solidity;
using namespace solidity::yul;
void EquivalentFunctionCombiner::run(OptimiserStepContext&, Block& _ast)
{
@@ -24,7 +24,7 @@
#include <libyul/optimiser/OptimiserStep.h>
#include <libyul/AsmDataForward.h>
namespace yul
namespace solidity::yul
{
struct OptimiserStepContext;
@@ -25,8 +25,8 @@
#include <libyul/optimiser/Metrics.h>
using namespace std;
using namespace dev;
using namespace yul;
using namespace solidity;
using namespace solidity::yul;
void EquivalentFunctionDetector::operator()(FunctionDefinition const& _fun)
{
@@ -23,7 +23,7 @@
#include <libyul/optimiser/BlockHasher.h>
#include <libyul/AsmDataForward.h>
namespace yul
namespace solidity::yul
{
/**
+2 -2
View File
@@ -30,8 +30,8 @@
#include <libyul/AsmData.h>
using namespace std;
using namespace dev;
using namespace yul;
using namespace solidity;
using namespace solidity::yul;
void ExpressionInliner::run(OptimiserStepContext& _context, Block& _ast)
{
+1 -1
View File
@@ -25,7 +25,7 @@
#include <optional>
#include <set>
namespace yul
namespace solidity::yul
{
struct Dialect;
struct OptimiserStepContext;
+2 -2
View File
@@ -31,8 +31,8 @@
#include <boost/range/adaptor/reversed.hpp>
using namespace std;
using namespace dev;
using namespace yul;
using namespace solidity;
using namespace solidity::yul;
void ExpressionJoiner::run(OptimiserStepContext&, Block& _ast)
{
+1 -1
View File
@@ -25,7 +25,7 @@
#include <map>
namespace yul
namespace solidity::yul
{
class NameCollector;
+2 -2
View File
@@ -28,8 +28,8 @@
#include <libdevcore/CommonData.h>
using namespace std;
using namespace dev;
using namespace yul;
using namespace solidity;
using namespace solidity::yul;
void ExpressionSimplifier::run(OptimiserStepContext& _context, Block& _ast)
{
+1 -1
View File
@@ -24,7 +24,7 @@
#include <libyul/optimiser/DataFlowAnalyzer.h>
namespace yul
namespace solidity::yul
{
struct Dialect;
struct OptimiserStepContext;
+4 -3
View File
@@ -32,9 +32,10 @@
#include <boost/range/adaptor/reversed.hpp>
using namespace std;
using namespace dev;
using namespace langutil;
using namespace yul;
using namespace solidity;
using namespace solidity::yul;
using namespace solidity::util;
using namespace solidity::langutil;
void ExpressionSplitter::run(OptimiserStepContext& _context, Block& _ast)
{
+1 -1
View File
@@ -27,7 +27,7 @@
#include <vector>
namespace yul
namespace solidity::yul
{
class NameCollector;
@@ -21,8 +21,8 @@
#include <libdevcore/CommonData.h>
using namespace std;
using namespace dev;
using namespace yul;
using namespace solidity;
using namespace solidity::yul;
void ForLoopConditionIntoBody::run(OptimiserStepContext& _context, Block& _ast)
{
@@ -47,10 +47,10 @@ void ForLoopConditionIntoBody::operator()(ForLoop& _forLoop)
FunctionCall {
loc,
{loc, m_dialect.booleanNegationFunction()->name},
make_vector<Expression>(std::move(*_forLoop.condition))
util::make_vector<Expression>(std::move(*_forLoop.condition))
}
),
Block {loc, make_vector<Statement>(Break{{}})}
Block {loc, util::make_vector<Statement>(Break{{}})}
}
);
_forLoop.condition = make_unique<Expression>(
+1 -1
View File
@@ -19,7 +19,7 @@
#include <libyul/optimiser/ASTWalker.h>
#include <libyul/Dialect.h>
namespace yul
namespace solidity::yul
{
struct OptimiserStepContext;
@@ -22,8 +22,8 @@
#include <libdevcore/CommonData.h>
using namespace std;
using namespace dev;
using namespace yul;
using namespace solidity;
using namespace solidity::yul;
void ForLoopConditionOutOfBody::run(OptimiserStepContext& _context, Block& _ast)
{
@@ -64,7 +64,7 @@ void ForLoopConditionOutOfBody::operator()(ForLoop& _forLoop)
_forLoop.condition = make_unique<Expression>(FunctionCall{
location,
Identifier{location, iszero},
make_vector<Expression>(
util::make_vector<Expression>(
std::move(*firstStatement.condition)
)
});

Some files were not shown because too many files have changed in this diff Show More