mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Renamed AssemblyStack to YulStack
All files, references, variables, comments, etc. were renamed to YulStack.
This commit is contained in:
parent
15c2a33eb3
commit
e1a59397c6
@ -30,7 +30,7 @@
|
|||||||
#include <libsolidity/codegen/ABIFunctions.h>
|
#include <libsolidity/codegen/ABIFunctions.h>
|
||||||
#include <libsolidity/codegen/CompilerUtils.h>
|
#include <libsolidity/codegen/CompilerUtils.h>
|
||||||
|
|
||||||
#include <libyul/AssemblyStack.h>
|
#include <libyul/YulStack.h>
|
||||||
#include <libyul/Utilities.h>
|
#include <libyul/Utilities.h>
|
||||||
|
|
||||||
#include <libsolutil/Algorithms.h>
|
#include <libsolutil/Algorithms.h>
|
||||||
@ -95,9 +95,9 @@ pair<string, string> IRGenerator::run(
|
|||||||
{
|
{
|
||||||
string ir = yul::reindent(generate(_contract, _cborMetadata, _otherYulSources));
|
string ir = yul::reindent(generate(_contract, _cborMetadata, _otherYulSources));
|
||||||
|
|
||||||
yul::AssemblyStack asmStack(
|
yul::YulStack asmStack(
|
||||||
m_evmVersion,
|
m_evmVersion,
|
||||||
yul::AssemblyStack::Language::StrictAssembly,
|
yul::YulStack::Language::StrictAssembly,
|
||||||
m_optimiserSettings,
|
m_optimiserSettings,
|
||||||
m_context.debugInfoSelection()
|
m_context.debugInfoSelection()
|
||||||
);
|
);
|
||||||
|
@ -62,7 +62,7 @@
|
|||||||
#include <libyul/YulString.h>
|
#include <libyul/YulString.h>
|
||||||
#include <libyul/AsmPrinter.h>
|
#include <libyul/AsmPrinter.h>
|
||||||
#include <libyul/AsmJsonConverter.h>
|
#include <libyul/AsmJsonConverter.h>
|
||||||
#include <libyul/AssemblyStack.h>
|
#include <libyul/YulStack.h>
|
||||||
#include <libyul/AST.h>
|
#include <libyul/AST.h>
|
||||||
#include <libyul/AsmParser.h>
|
#include <libyul/AsmParser.h>
|
||||||
|
|
||||||
@ -1382,9 +1382,9 @@ void CompilerStack::generateEVMFromIR(ContractDefinition const& _contract)
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
// Re-parse the Yul IR in EVM dialect
|
// Re-parse the Yul IR in EVM dialect
|
||||||
yul::AssemblyStack stack(
|
yul::YulStack stack(
|
||||||
m_evmVersion,
|
m_evmVersion,
|
||||||
yul::AssemblyStack::Language::StrictAssembly,
|
yul::YulStack::Language::StrictAssembly,
|
||||||
m_optimiserSettings,
|
m_optimiserSettings,
|
||||||
m_debugInfoSelection
|
m_debugInfoSelection
|
||||||
);
|
);
|
||||||
@ -1414,22 +1414,22 @@ void CompilerStack::generateEwasm(ContractDefinition const& _contract)
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
// Re-parse the Yul IR in EVM dialect
|
// Re-parse the Yul IR in EVM dialect
|
||||||
yul::AssemblyStack stack(
|
yul::YulStack stack(
|
||||||
m_evmVersion,
|
m_evmVersion,
|
||||||
yul::AssemblyStack::Language::StrictAssembly,
|
yul::YulStack::Language::StrictAssembly,
|
||||||
m_optimiserSettings,
|
m_optimiserSettings,
|
||||||
m_debugInfoSelection
|
m_debugInfoSelection
|
||||||
);
|
);
|
||||||
stack.parseAndAnalyze("", compiledContract.yulIROptimized);
|
stack.parseAndAnalyze("", compiledContract.yulIROptimized);
|
||||||
|
|
||||||
stack.optimize();
|
stack.optimize();
|
||||||
stack.translate(yul::AssemblyStack::Language::Ewasm);
|
stack.translate(yul::YulStack::Language::Ewasm);
|
||||||
stack.optimize();
|
stack.optimize();
|
||||||
|
|
||||||
//cout << yul::AsmPrinter{}(*stack.parserResult()->code) << endl;
|
//cout << yul::AsmPrinter{}(*stack.parserResult()->code) << endl;
|
||||||
|
|
||||||
// Turn into Ewasm text representation.
|
// Turn into Ewasm text representation.
|
||||||
auto result = stack.assemble(yul::AssemblyStack::Machine::Ewasm);
|
auto result = stack.assemble(yul::YulStack::Machine::Ewasm);
|
||||||
compiledContract.ewasm = std::move(result.assembly);
|
compiledContract.ewasm = std::move(result.assembly);
|
||||||
compiledContract.ewasmObject = std::move(*result.bytecode);
|
compiledContract.ewasmObject = std::move(*result.bytecode);
|
||||||
}
|
}
|
||||||
|
@ -25,7 +25,7 @@
|
|||||||
#include <libsolidity/interface/ImportRemapper.h>
|
#include <libsolidity/interface/ImportRemapper.h>
|
||||||
|
|
||||||
#include <libsolidity/ast/ASTJsonConverter.h>
|
#include <libsolidity/ast/ASTJsonConverter.h>
|
||||||
#include <libyul/AssemblyStack.h>
|
#include <libyul/YulStack.h>
|
||||||
#include <libyul/Exceptions.h>
|
#include <libyul/Exceptions.h>
|
||||||
#include <libyul/optimiser/Suite.h>
|
#include <libyul/optimiser/Suite.h>
|
||||||
|
|
||||||
@ -1407,9 +1407,9 @@ Json::Value StandardCompiler::compileYul(InputsAndSettings _inputsAndSettings)
|
|||||||
return output;
|
return output;
|
||||||
}
|
}
|
||||||
|
|
||||||
AssemblyStack stack(
|
YulStack stack(
|
||||||
_inputsAndSettings.evmVersion,
|
_inputsAndSettings.evmVersion,
|
||||||
AssemblyStack::Language::StrictAssembly,
|
YulStack::Language::StrictAssembly,
|
||||||
_inputsAndSettings.optimiserSettings,
|
_inputsAndSettings.optimiserSettings,
|
||||||
_inputsAndSettings.debugInfoSelection.has_value() ?
|
_inputsAndSettings.debugInfoSelection.has_value() ?
|
||||||
_inputsAndSettings.debugInfoSelection.value() :
|
_inputsAndSettings.debugInfoSelection.value() :
|
||||||
|
@ -30,8 +30,8 @@ add_library(yul
|
|||||||
AsmParser.h
|
AsmParser.h
|
||||||
AsmPrinter.cpp
|
AsmPrinter.cpp
|
||||||
AsmPrinter.h
|
AsmPrinter.h
|
||||||
AssemblyStack.h
|
YulStack.h
|
||||||
AssemblyStack.cpp
|
YulStack.cpp
|
||||||
CompilabilityChecker.cpp
|
CompilabilityChecker.cpp
|
||||||
CompilabilityChecker.h
|
CompilabilityChecker.h
|
||||||
ControlFlowSideEffects.h
|
ControlFlowSideEffects.h
|
||||||
|
@ -21,7 +21,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
#include <libyul/AssemblyStack.h>
|
#include <libyul/YulStack.h>
|
||||||
|
|
||||||
#include <libyul/AsmAnalysis.h>
|
#include <libyul/AsmAnalysis.h>
|
||||||
#include <libyul/AsmAnalysisInfo.h>
|
#include <libyul/AsmAnalysisInfo.h>
|
||||||
@ -48,16 +48,16 @@ using namespace solidity::langutil;
|
|||||||
|
|
||||||
namespace
|
namespace
|
||||||
{
|
{
|
||||||
Dialect const& languageToDialect(AssemblyStack::Language _language, EVMVersion _version)
|
Dialect const& languageToDialect(YulStack::Language _language, EVMVersion _version)
|
||||||
{
|
{
|
||||||
switch (_language)
|
switch (_language)
|
||||||
{
|
{
|
||||||
case AssemblyStack::Language::Assembly:
|
case YulStack::Language::Assembly:
|
||||||
case AssemblyStack::Language::StrictAssembly:
|
case YulStack::Language::StrictAssembly:
|
||||||
return EVMDialect::strictAssemblyForEVMObjects(_version);
|
return EVMDialect::strictAssemblyForEVMObjects(_version);
|
||||||
case AssemblyStack::Language::Yul:
|
case YulStack::Language::Yul:
|
||||||
return EVMDialectTyped::instance(_version);
|
return EVMDialectTyped::instance(_version);
|
||||||
case AssemblyStack::Language::Ewasm:
|
case YulStack::Language::Ewasm:
|
||||||
return WasmDialect::instance();
|
return WasmDialect::instance();
|
||||||
}
|
}
|
||||||
yulAssert(false, "");
|
yulAssert(false, "");
|
||||||
@ -88,14 +88,14 @@ evmasm::Assembly::OptimiserSettings translateOptimiserSettings(
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
CharStream const& AssemblyStack::charStream(string const& _sourceName) const
|
CharStream const& YulStack::charStream(string const& _sourceName) const
|
||||||
{
|
{
|
||||||
yulAssert(m_charStream, "");
|
yulAssert(m_charStream, "");
|
||||||
yulAssert(m_charStream->name() == _sourceName, "");
|
yulAssert(m_charStream->name() == _sourceName, "");
|
||||||
return *m_charStream;
|
return *m_charStream;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool AssemblyStack::parseAndAnalyze(std::string const& _sourceName, std::string const& _source)
|
bool YulStack::parseAndAnalyze(std::string const& _sourceName, std::string const& _source)
|
||||||
{
|
{
|
||||||
m_errors.clear();
|
m_errors.clear();
|
||||||
m_analysisSuccessful = false;
|
m_analysisSuccessful = false;
|
||||||
@ -110,7 +110,7 @@ bool AssemblyStack::parseAndAnalyze(std::string const& _sourceName, std::string
|
|||||||
return analyzeParsed();
|
return analyzeParsed();
|
||||||
}
|
}
|
||||||
|
|
||||||
void AssemblyStack::optimize()
|
void YulStack::optimize()
|
||||||
{
|
{
|
||||||
if (!m_optimiserSettings.runYulOptimiser)
|
if (!m_optimiserSettings.runYulOptimiser)
|
||||||
return;
|
return;
|
||||||
@ -123,7 +123,7 @@ void AssemblyStack::optimize()
|
|||||||
yulAssert(analyzeParsed(), "Invalid source code after optimization.");
|
yulAssert(analyzeParsed(), "Invalid source code after optimization.");
|
||||||
}
|
}
|
||||||
|
|
||||||
void AssemblyStack::translate(AssemblyStack::Language _targetLanguage)
|
void YulStack::translate(YulStack::Language _targetLanguage)
|
||||||
{
|
{
|
||||||
if (m_language == _targetLanguage)
|
if (m_language == _targetLanguage)
|
||||||
return;
|
return;
|
||||||
@ -141,14 +141,14 @@ void AssemblyStack::translate(AssemblyStack::Language _targetLanguage)
|
|||||||
m_language = _targetLanguage;
|
m_language = _targetLanguage;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool AssemblyStack::analyzeParsed()
|
bool YulStack::analyzeParsed()
|
||||||
{
|
{
|
||||||
yulAssert(m_parserResult, "");
|
yulAssert(m_parserResult, "");
|
||||||
m_analysisSuccessful = analyzeParsed(*m_parserResult);
|
m_analysisSuccessful = analyzeParsed(*m_parserResult);
|
||||||
return m_analysisSuccessful;
|
return m_analysisSuccessful;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool AssemblyStack::analyzeParsed(Object& _object)
|
bool YulStack::analyzeParsed(Object& _object)
|
||||||
{
|
{
|
||||||
yulAssert(_object.code, "");
|
yulAssert(_object.code, "");
|
||||||
_object.analysisInfo = make_shared<AsmAnalysisInfo>();
|
_object.analysisInfo = make_shared<AsmAnalysisInfo>();
|
||||||
@ -168,7 +168,7 @@ bool AssemblyStack::analyzeParsed(Object& _object)
|
|||||||
return success;
|
return success;
|
||||||
}
|
}
|
||||||
|
|
||||||
void AssemblyStack::compileEVM(AbstractAssembly& _assembly, bool _optimize) const
|
void YulStack::compileEVM(AbstractAssembly& _assembly, bool _optimize) const
|
||||||
{
|
{
|
||||||
EVMDialect const* dialect = nullptr;
|
EVMDialect const* dialect = nullptr;
|
||||||
switch (m_language)
|
switch (m_language)
|
||||||
@ -188,7 +188,7 @@ void AssemblyStack::compileEVM(AbstractAssembly& _assembly, bool _optimize) cons
|
|||||||
EVMObjectCompiler::compile(*m_parserResult, _assembly, *dialect, _optimize);
|
EVMObjectCompiler::compile(*m_parserResult, _assembly, *dialect, _optimize);
|
||||||
}
|
}
|
||||||
|
|
||||||
void AssemblyStack::optimize(Object& _object, bool _isCreation)
|
void YulStack::optimize(Object& _object, bool _isCreation)
|
||||||
{
|
{
|
||||||
yulAssert(_object.code, "");
|
yulAssert(_object.code, "");
|
||||||
yulAssert(_object.analysisInfo, "");
|
yulAssert(_object.analysisInfo, "");
|
||||||
@ -214,7 +214,7 @@ void AssemblyStack::optimize(Object& _object, bool _isCreation)
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
MachineAssemblyObject AssemblyStack::assemble(Machine _machine) const
|
MachineAssemblyObject YulStack::assemble(Machine _machine) const
|
||||||
{
|
{
|
||||||
yulAssert(m_analysisSuccessful, "");
|
yulAssert(m_analysisSuccessful, "");
|
||||||
yulAssert(m_parserResult, "");
|
yulAssert(m_parserResult, "");
|
||||||
@ -243,7 +243,7 @@ MachineAssemblyObject AssemblyStack::assemble(Machine _machine) const
|
|||||||
}
|
}
|
||||||
|
|
||||||
std::pair<MachineAssemblyObject, MachineAssemblyObject>
|
std::pair<MachineAssemblyObject, MachineAssemblyObject>
|
||||||
AssemblyStack::assembleWithDeployed(optional<string_view> _deployName) const
|
YulStack::assembleWithDeployed(optional<string_view> _deployName) const
|
||||||
{
|
{
|
||||||
auto [creationAssembly, deployedAssembly] = assembleEVMWithDeployed(_deployName);
|
auto [creationAssembly, deployedAssembly] = assembleEVMWithDeployed(_deployName);
|
||||||
yulAssert(creationAssembly, "");
|
yulAssert(creationAssembly, "");
|
||||||
@ -277,7 +277,7 @@ AssemblyStack::assembleWithDeployed(optional<string_view> _deployName) const
|
|||||||
}
|
}
|
||||||
|
|
||||||
std::pair<std::shared_ptr<evmasm::Assembly>, std::shared_ptr<evmasm::Assembly>>
|
std::pair<std::shared_ptr<evmasm::Assembly>, std::shared_ptr<evmasm::Assembly>>
|
||||||
AssemblyStack::assembleEVMWithDeployed(optional<string_view> _deployName) const
|
YulStack::assembleEVMWithDeployed(optional<string_view> _deployName) const
|
||||||
{
|
{
|
||||||
yulAssert(m_analysisSuccessful, "");
|
yulAssert(m_analysisSuccessful, "");
|
||||||
yulAssert(m_parserResult, "");
|
yulAssert(m_parserResult, "");
|
||||||
@ -317,7 +317,7 @@ AssemblyStack::assembleEVMWithDeployed(optional<string_view> _deployName) const
|
|||||||
return {make_shared<evmasm::Assembly>(assembly), {}};
|
return {make_shared<evmasm::Assembly>(assembly), {}};
|
||||||
}
|
}
|
||||||
|
|
||||||
string AssemblyStack::print(
|
string YulStack::print(
|
||||||
CharStreamProvider const* _soliditySourceProvider
|
CharStreamProvider const* _soliditySourceProvider
|
||||||
) const
|
) const
|
||||||
{
|
{
|
||||||
@ -326,7 +326,7 @@ string AssemblyStack::print(
|
|||||||
return m_parserResult->toString(&languageToDialect(m_language, m_evmVersion), m_debugInfoSelection, _soliditySourceProvider) + "\n";
|
return m_parserResult->toString(&languageToDialect(m_language, m_evmVersion), m_debugInfoSelection, _soliditySourceProvider) + "\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
shared_ptr<Object> AssemblyStack::parserResult() const
|
shared_ptr<Object> YulStack::parserResult() const
|
||||||
{
|
{
|
||||||
yulAssert(m_analysisSuccessful, "Analysis was not successful.");
|
yulAssert(m_analysisSuccessful, "Analysis was not successful.");
|
||||||
yulAssert(m_parserResult, "");
|
yulAssert(m_parserResult, "");
|
@ -63,14 +63,14 @@ struct MachineAssemblyObject
|
|||||||
* Full assembly stack that can support EVM-assembly and Yul as input and EVM, EVM1.5 and
|
* Full assembly stack that can support EVM-assembly and Yul as input and EVM, EVM1.5 and
|
||||||
* Ewasm as output.
|
* Ewasm as output.
|
||||||
*/
|
*/
|
||||||
class AssemblyStack: public langutil::CharStreamProvider
|
class YulStack: public langutil::CharStreamProvider
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
enum class Language { Yul, Assembly, StrictAssembly, Ewasm };
|
enum class Language { Yul, Assembly, StrictAssembly, Ewasm };
|
||||||
enum class Machine { EVM, Ewasm };
|
enum class Machine { EVM, Ewasm };
|
||||||
|
|
||||||
AssemblyStack():
|
YulStack():
|
||||||
AssemblyStack(
|
YulStack(
|
||||||
langutil::EVMVersion{},
|
langutil::EVMVersion{},
|
||||||
Language::Assembly,
|
Language::Assembly,
|
||||||
solidity::frontend::OptimiserSettings::none(),
|
solidity::frontend::OptimiserSettings::none(),
|
||||||
@ -78,7 +78,7 @@ public:
|
|||||||
)
|
)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
AssemblyStack(
|
YulStack(
|
||||||
langutil::EVMVersion _evmVersion,
|
langutil::EVMVersion _evmVersion,
|
||||||
Language _language,
|
Language _language,
|
||||||
solidity::frontend::OptimiserSettings _optimiserSettings,
|
solidity::frontend::OptimiserSettings _optimiserSettings,
|
@ -41,7 +41,7 @@
|
|||||||
#include <libsolidity/lsp/LanguageServer.h>
|
#include <libsolidity/lsp/LanguageServer.h>
|
||||||
#include <libsolidity/lsp/Transport.h>
|
#include <libsolidity/lsp/Transport.h>
|
||||||
|
|
||||||
#include <libyul/AssemblyStack.h>
|
#include <libyul/YulStack.h>
|
||||||
|
|
||||||
#include <libevmasm/Instruction.h>
|
#include <libevmasm/Instruction.h>
|
||||||
#include <libevmasm/Disassemble.h>
|
#include <libevmasm/Disassemble.h>
|
||||||
@ -1014,18 +1014,18 @@ string CommandLineInterface::objectWithLinkRefsHex(evmasm::LinkerObject const& _
|
|||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CommandLineInterface::assemble(yul::AssemblyStack::Language _language, yul::AssemblyStack::Machine _targetMachine)
|
void CommandLineInterface::assemble(yul::YulStack::Language _language, yul::YulStack::Machine _targetMachine)
|
||||||
{
|
{
|
||||||
solAssert(m_options.input.mode == InputMode::Assembler, "");
|
solAssert(m_options.input.mode == InputMode::Assembler, "");
|
||||||
|
|
||||||
bool successful = true;
|
bool successful = true;
|
||||||
map<string, yul::AssemblyStack> assemblyStacks;
|
map<string, yul::YulStack> yulStacks;
|
||||||
for (auto const& src: m_fileReader.sourceUnits())
|
for (auto const& src: m_fileReader.sourceUnits())
|
||||||
{
|
{
|
||||||
// --no-optimize-yul option is not accepted in assembly mode.
|
// --no-optimize-yul option is not accepted in assembly mode.
|
||||||
solAssert(!m_options.optimizer.noOptimizeYul, "");
|
solAssert(!m_options.optimizer.noOptimizeYul, "");
|
||||||
|
|
||||||
auto& stack = assemblyStacks[src.first] = yul::AssemblyStack(
|
auto& stack = yulStacks[src.first] = yul::YulStack(
|
||||||
m_options.output.evmVersion,
|
m_options.output.evmVersion,
|
||||||
_language,
|
_language,
|
||||||
m_options.optimiserSettings(),
|
m_options.optimiserSettings(),
|
||||||
@ -1040,7 +1040,7 @@ void CommandLineInterface::assemble(yul::AssemblyStack::Language _language, yul:
|
|||||||
stack.optimize();
|
stack.optimize();
|
||||||
}
|
}
|
||||||
|
|
||||||
for (auto const& sourceAndStack: assemblyStacks)
|
for (auto const& sourceAndStack: yulStacks)
|
||||||
{
|
{
|
||||||
auto const& stack = sourceAndStack.second;
|
auto const& stack = sourceAndStack.second;
|
||||||
SourceReferenceFormatter formatter(serr(false), stack, coloredOutput(m_options), m_options.formatting.withErrorIds);
|
SourceReferenceFormatter formatter(serr(false), stack, coloredOutput(m_options), m_options.formatting.withErrorIds);
|
||||||
@ -1063,11 +1063,11 @@ void CommandLineInterface::assemble(yul::AssemblyStack::Language _language, yul:
|
|||||||
for (auto const& src: m_fileReader.sourceUnits())
|
for (auto const& src: m_fileReader.sourceUnits())
|
||||||
{
|
{
|
||||||
string machine =
|
string machine =
|
||||||
_targetMachine == yul::AssemblyStack::Machine::EVM ? "EVM" :
|
_targetMachine == yul::YulStack::Machine::EVM ? "EVM" :
|
||||||
"Ewasm";
|
"Ewasm";
|
||||||
sout() << endl << "======= " << src.first << " (" << machine << ") =======" << endl;
|
sout() << endl << "======= " << src.first << " (" << machine << ") =======" << endl;
|
||||||
|
|
||||||
yul::AssemblyStack& stack = assemblyStacks[src.first];
|
yul::YulStack& stack = yulStacks[src.first];
|
||||||
|
|
||||||
if (m_options.compiler.outputs.irOptimized)
|
if (m_options.compiler.outputs.irOptimized)
|
||||||
{
|
{
|
||||||
@ -1077,9 +1077,9 @@ void CommandLineInterface::assemble(yul::AssemblyStack::Language _language, yul:
|
|||||||
sout() << stack.print() << endl;
|
sout() << stack.print() << endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_language != yul::AssemblyStack::Language::Ewasm && _targetMachine == yul::AssemblyStack::Machine::Ewasm)
|
if (_language != yul::YulStack::Language::Ewasm && _targetMachine == yul::YulStack::Machine::Ewasm)
|
||||||
{
|
{
|
||||||
stack.translate(yul::AssemblyStack::Language::Ewasm);
|
stack.translate(yul::YulStack::Language::Ewasm);
|
||||||
stack.optimize();
|
stack.optimize();
|
||||||
|
|
||||||
if (m_options.compiler.outputs.ewasmIR)
|
if (m_options.compiler.outputs.ewasmIR)
|
||||||
@ -1103,10 +1103,10 @@ void CommandLineInterface::assemble(yul::AssemblyStack::Language _language, yul:
|
|||||||
serr() << "No binary representation found." << endl;
|
serr() << "No binary representation found." << endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
solAssert(_targetMachine == yul::AssemblyStack::Machine::Ewasm || _targetMachine == yul::AssemblyStack::Machine::EVM, "");
|
solAssert(_targetMachine == yul::YulStack::Machine::Ewasm || _targetMachine == yul::YulStack::Machine::EVM, "");
|
||||||
if (
|
if (
|
||||||
(_targetMachine == yul::AssemblyStack::Machine::EVM && m_options.compiler.outputs.asm_) ||
|
(_targetMachine == yul::YulStack::Machine::EVM && m_options.compiler.outputs.asm_) ||
|
||||||
(_targetMachine == yul::AssemblyStack::Machine::Ewasm && m_options.compiler.outputs.ewasm)
|
(_targetMachine == yul::YulStack::Machine::Ewasm && m_options.compiler.outputs.ewasm)
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
sout() << endl << "Text representation:" << endl;
|
sout() << endl << "Text representation:" << endl;
|
||||||
|
@ -27,7 +27,7 @@
|
|||||||
#include <libsolidity/interface/CompilerStack.h>
|
#include <libsolidity/interface/CompilerStack.h>
|
||||||
#include <libsolidity/interface/DebugSettings.h>
|
#include <libsolidity/interface/DebugSettings.h>
|
||||||
#include <libsolidity/interface/FileReader.h>
|
#include <libsolidity/interface/FileReader.h>
|
||||||
#include <libyul/AssemblyStack.h>
|
#include <libyul/YulStack.h>
|
||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
@ -90,7 +90,7 @@ private:
|
|||||||
/// @returns the full object with library placeholder hints in hex.
|
/// @returns the full object with library placeholder hints in hex.
|
||||||
static std::string objectWithLinkRefsHex(evmasm::LinkerObject const& _obj);
|
static std::string objectWithLinkRefsHex(evmasm::LinkerObject const& _obj);
|
||||||
|
|
||||||
void assemble(yul::AssemblyStack::Language _language, yul::AssemblyStack::Machine _targetMachine);
|
void assemble(yul::YulStack::Language _language, yul::YulStack::Machine _targetMachine);
|
||||||
|
|
||||||
void outputCompilationResults();
|
void outputCompilationResults();
|
||||||
|
|
||||||
|
@ -1132,8 +1132,8 @@ void CommandLineParser::processArgs()
|
|||||||
}
|
}
|
||||||
|
|
||||||
// switch to assembly mode
|
// switch to assembly mode
|
||||||
using Input = yul::AssemblyStack::Language;
|
using Input = yul::YulStack::Language;
|
||||||
using Machine = yul::AssemblyStack::Machine;
|
using Machine = yul::YulStack::Machine;
|
||||||
m_options.assembly.inputLanguage = m_args.count(g_strYul) ? Input::Yul : (m_args.count(g_strStrictAssembly) ? Input::StrictAssembly : Input::Assembly);
|
m_options.assembly.inputLanguage = m_args.count(g_strYul) ? Input::Yul : (m_args.count(g_strStrictAssembly) ? Input::StrictAssembly : Input::Assembly);
|
||||||
|
|
||||||
if (m_args.count(g_strMachine))
|
if (m_args.count(g_strMachine))
|
||||||
|
@ -25,7 +25,7 @@
|
|||||||
#include <libsolidity/interface/FileReader.h>
|
#include <libsolidity/interface/FileReader.h>
|
||||||
#include <libsolidity/interface/ImportRemapper.h>
|
#include <libsolidity/interface/ImportRemapper.h>
|
||||||
|
|
||||||
#include <libyul/AssemblyStack.h>
|
#include <libyul/YulStack.h>
|
||||||
|
|
||||||
#include <liblangutil/DebugInfoSelection.h>
|
#include <liblangutil/DebugInfoSelection.h>
|
||||||
#include <liblangutil/EVMVersion.h>
|
#include <liblangutil/EVMVersion.h>
|
||||||
@ -190,8 +190,8 @@ struct CommandLineOptions
|
|||||||
|
|
||||||
struct
|
struct
|
||||||
{
|
{
|
||||||
yul::AssemblyStack::Machine targetMachine = yul::AssemblyStack::Machine::EVM;
|
yul::YulStack::Machine targetMachine = yul::YulStack::Machine::EVM;
|
||||||
yul::AssemblyStack::Language inputLanguage = yul::AssemblyStack::Language::StrictAssembly;
|
yul::YulStack::Language inputLanguage = yul::YulStack::Language::StrictAssembly;
|
||||||
} assembly;
|
} assembly;
|
||||||
|
|
||||||
struct
|
struct
|
||||||
|
@ -26,7 +26,7 @@
|
|||||||
|
|
||||||
#include <libsolidity/ast/AST.h>
|
#include <libsolidity/ast/AST.h>
|
||||||
|
|
||||||
#include <libyul/AssemblyStack.h>
|
#include <libyul/YulStack.h>
|
||||||
|
|
||||||
#include <liblangutil/DebugInfoSelection.h>
|
#include <liblangutil/DebugInfoSelection.h>
|
||||||
#include <liblangutil/Exceptions.h>
|
#include <liblangutil/Exceptions.h>
|
||||||
@ -56,11 +56,11 @@ std::optional<Error> parseAndReturnFirstError(
|
|||||||
string const& _source,
|
string const& _source,
|
||||||
bool _assemble = false,
|
bool _assemble = false,
|
||||||
bool _allowWarnings = true,
|
bool _allowWarnings = true,
|
||||||
AssemblyStack::Language _language = AssemblyStack::Language::Assembly,
|
YulStack::Language _language = YulStack::Language::Assembly,
|
||||||
AssemblyStack::Machine _machine = AssemblyStack::Machine::EVM
|
YulStack::Machine _machine = YulStack::Machine::EVM
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
AssemblyStack stack(
|
YulStack stack(
|
||||||
solidity::test::CommonOptions::get().evmVersion(),
|
solidity::test::CommonOptions::get().evmVersion(),
|
||||||
_language,
|
_language,
|
||||||
solidity::frontend::OptimiserSettings::none(),
|
solidity::frontend::OptimiserSettings::none(),
|
||||||
@ -103,24 +103,24 @@ bool successParse(
|
|||||||
string const& _source,
|
string const& _source,
|
||||||
bool _assemble = false,
|
bool _assemble = false,
|
||||||
bool _allowWarnings = true,
|
bool _allowWarnings = true,
|
||||||
AssemblyStack::Language _language = AssemblyStack::Language::Assembly,
|
YulStack::Language _language = YulStack::Language::Assembly,
|
||||||
AssemblyStack::Machine _machine = AssemblyStack::Machine::EVM
|
YulStack::Machine _machine = YulStack::Machine::EVM
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
return !parseAndReturnFirstError(_source, _assemble, _allowWarnings, _language, _machine);
|
return !parseAndReturnFirstError(_source, _assemble, _allowWarnings, _language, _machine);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool successAssemble(string const& _source, bool _allowWarnings = true, AssemblyStack::Language _language = AssemblyStack::Language::Assembly)
|
bool successAssemble(string const& _source, bool _allowWarnings = true, YulStack::Language _language = YulStack::Language::Assembly)
|
||||||
{
|
{
|
||||||
return
|
return
|
||||||
successParse(_source, true, _allowWarnings, _language, AssemblyStack::Machine::EVM);
|
successParse(_source, true, _allowWarnings, _language, YulStack::Machine::EVM);
|
||||||
}
|
}
|
||||||
|
|
||||||
Error expectError(
|
Error expectError(
|
||||||
std::string const& _source,
|
std::string const& _source,
|
||||||
bool _assemble,
|
bool _assemble,
|
||||||
bool _allowWarnings = false,
|
bool _allowWarnings = false,
|
||||||
AssemblyStack::Language _language = AssemblyStack::Language::Assembly
|
YulStack::Language _language = YulStack::Language::Assembly
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
|
|
||||||
@ -131,9 +131,9 @@ Error expectError(
|
|||||||
|
|
||||||
void parsePrintCompare(string const& _source, bool _canWarn = false)
|
void parsePrintCompare(string const& _source, bool _canWarn = false)
|
||||||
{
|
{
|
||||||
AssemblyStack stack(
|
YulStack stack(
|
||||||
solidity::test::CommonOptions::get().evmVersion(),
|
solidity::test::CommonOptions::get().evmVersion(),
|
||||||
AssemblyStack::Language::Assembly,
|
YulStack::Language::Assembly,
|
||||||
OptimiserSettings::none(),
|
OptimiserSettings::none(),
|
||||||
DebugInfoSelection::None()
|
DebugInfoSelection::None()
|
||||||
);
|
);
|
||||||
@ -157,7 +157,7 @@ do \
|
|||||||
} while(0)
|
} while(0)
|
||||||
|
|
||||||
#define CHECK_ERROR(text, assemble, typ, substring, warnings) \
|
#define CHECK_ERROR(text, assemble, typ, substring, warnings) \
|
||||||
CHECK_ERROR_LANG(text, assemble, typ, substring, warnings, AssemblyStack::Language::Assembly)
|
CHECK_ERROR_LANG(text, assemble, typ, substring, warnings, YulStack::Language::Assembly)
|
||||||
|
|
||||||
#define CHECK_PARSE_ERROR(text, type, substring) \
|
#define CHECK_PARSE_ERROR(text, type, substring) \
|
||||||
CHECK_ERROR(text, false, type, substring, false)
|
CHECK_ERROR(text, false, type, substring, false)
|
||||||
@ -169,13 +169,13 @@ CHECK_ERROR(text, false, type, substring, false)
|
|||||||
CHECK_ERROR(text, true, type, substring, false)
|
CHECK_ERROR(text, true, type, substring, false)
|
||||||
|
|
||||||
#define CHECK_STRICT_ERROR(text, type, substring) \
|
#define CHECK_STRICT_ERROR(text, type, substring) \
|
||||||
CHECK_ERROR_LANG(text, false, type, substring, false, AssemblyStack::Language::StrictAssembly)
|
CHECK_ERROR_LANG(text, false, type, substring, false, YulStack::Language::StrictAssembly)
|
||||||
|
|
||||||
#define CHECK_STRICT_WARNING(text, type, substring) \
|
#define CHECK_STRICT_WARNING(text, type, substring) \
|
||||||
CHECK_ERROR(text, false, type, substring, false, AssemblyStack::Language::StrictAssembly)
|
CHECK_ERROR(text, false, type, substring, false, YulStack::Language::StrictAssembly)
|
||||||
|
|
||||||
#define SUCCESS_STRICT(text) \
|
#define SUCCESS_STRICT(text) \
|
||||||
do { successParse((text), false, false, AssemblyStack::Language::StrictAssembly); } while (false)
|
do { successParse((text), false, false, YulStack::Language::StrictAssembly); } while (false)
|
||||||
|
|
||||||
|
|
||||||
BOOST_AUTO_TEST_SUITE(SolidityInlineAssembly)
|
BOOST_AUTO_TEST_SUITE(SolidityInlineAssembly)
|
||||||
@ -221,9 +221,9 @@ BOOST_AUTO_TEST_CASE(print_string_literal_unicode)
|
|||||||
{
|
{
|
||||||
string source = "{ let x := \"\\u1bac\" }";
|
string source = "{ let x := \"\\u1bac\" }";
|
||||||
string parsed = "object \"object\" {\n code { let x := \"\\xe1\\xae\\xac\" }\n}\n";
|
string parsed = "object \"object\" {\n code { let x := \"\\xe1\\xae\\xac\" }\n}\n";
|
||||||
AssemblyStack stack(
|
YulStack stack(
|
||||||
solidity::test::CommonOptions::get().evmVersion(),
|
solidity::test::CommonOptions::get().evmVersion(),
|
||||||
AssemblyStack::Language::Assembly,
|
YulStack::Language::Assembly,
|
||||||
OptimiserSettings::none(),
|
OptimiserSettings::none(),
|
||||||
DebugInfoSelection::None()
|
DebugInfoSelection::None()
|
||||||
);
|
);
|
||||||
|
@ -97,9 +97,9 @@ bytes SolidityExecutionFramework::multiSourceCompileContract(
|
|||||||
else if (forceEnableOptimizer)
|
else if (forceEnableOptimizer)
|
||||||
optimiserSettings = OptimiserSettings::full();
|
optimiserSettings = OptimiserSettings::full();
|
||||||
|
|
||||||
yul::AssemblyStack asmStack(
|
yul::YulStack asmStack(
|
||||||
m_evmVersion,
|
m_evmVersion,
|
||||||
yul::AssemblyStack::Language::StrictAssembly,
|
yul::YulStack::Language::StrictAssembly,
|
||||||
optimiserSettings,
|
optimiserSettings,
|
||||||
DebugInfoSelection::All()
|
DebugInfoSelection::All()
|
||||||
);
|
);
|
||||||
@ -109,7 +109,7 @@ bytes SolidityExecutionFramework::multiSourceCompileContract(
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
asmStack.optimize();
|
asmStack.optimize();
|
||||||
obj = move(*asmStack.assemble(yul::AssemblyStack::Machine::EVM).bytecode);
|
obj = move(*asmStack.assemble(yul::YulStack::Machine::EVM).bytecode);
|
||||||
obj.link(_libraryAddresses);
|
obj.link(_libraryAddresses);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -30,7 +30,7 @@
|
|||||||
#include <libsolidity/interface/CompilerStack.h>
|
#include <libsolidity/interface/CompilerStack.h>
|
||||||
#include <libsolidity/interface/DebugSettings.h>
|
#include <libsolidity/interface/DebugSettings.h>
|
||||||
|
|
||||||
#include <libyul/AssemblyStack.h>
|
#include <libyul/YulStack.h>
|
||||||
|
|
||||||
namespace solidity::frontend::test
|
namespace solidity::frontend::test
|
||||||
{
|
{
|
||||||
|
@ -26,7 +26,7 @@
|
|||||||
#include <libyul/optimiser/Disambiguator.h>
|
#include <libyul/optimiser/Disambiguator.h>
|
||||||
#include <libyul/AsmAnalysis.h>
|
#include <libyul/AsmAnalysis.h>
|
||||||
#include <libyul/AsmPrinter.h>
|
#include <libyul/AsmPrinter.h>
|
||||||
#include <libyul/AssemblyStack.h>
|
#include <libyul/YulStack.h>
|
||||||
#include <libyul/AST.h>
|
#include <libyul/AST.h>
|
||||||
#include <libyul/backends/evm/EVMDialect.h>
|
#include <libyul/backends/evm/EVMDialect.h>
|
||||||
#include <libyul/backends/wasm/WasmDialect.h>
|
#include <libyul/backends/wasm/WasmDialect.h>
|
||||||
@ -55,9 +55,9 @@ Dialect const& defaultDialect(bool _yul)
|
|||||||
|
|
||||||
pair<shared_ptr<Block>, shared_ptr<yul::AsmAnalysisInfo>> yul::test::parse(string const& _source, bool _yul)
|
pair<shared_ptr<Block>, shared_ptr<yul::AsmAnalysisInfo>> yul::test::parse(string const& _source, bool _yul)
|
||||||
{
|
{
|
||||||
AssemblyStack stack(
|
YulStack stack(
|
||||||
solidity::test::CommonOptions::get().evmVersion(),
|
solidity::test::CommonOptions::get().evmVersion(),
|
||||||
_yul ? AssemblyStack::Language::Yul : AssemblyStack::Language::StrictAssembly,
|
_yul ? YulStack::Language::Yul : YulStack::Language::StrictAssembly,
|
||||||
solidity::test::CommonOptions::get().optimize ?
|
solidity::test::CommonOptions::get().optimize ?
|
||||||
solidity::frontend::OptimiserSettings::standard() :
|
solidity::frontend::OptimiserSettings::standard() :
|
||||||
solidity::frontend::OptimiserSettings::minimal(),
|
solidity::frontend::OptimiserSettings::minimal(),
|
||||||
|
@ -19,7 +19,7 @@
|
|||||||
#include <test/libyul/EVMCodeTransformTest.h>
|
#include <test/libyul/EVMCodeTransformTest.h>
|
||||||
#include <test/libyul/Common.h>
|
#include <test/libyul/Common.h>
|
||||||
|
|
||||||
#include <libyul/AssemblyStack.h>
|
#include <libyul/YulStack.h>
|
||||||
#include <libyul/backends/evm/EthAssemblyAdapter.h>
|
#include <libyul/backends/evm/EthAssemblyAdapter.h>
|
||||||
#include <libyul/backends/evm/EVMObjectCompiler.h>
|
#include <libyul/backends/evm/EVMObjectCompiler.h>
|
||||||
|
|
||||||
@ -51,9 +51,9 @@ TestCase::TestResult EVMCodeTransformTest::run(ostream& _stream, string const& _
|
|||||||
solidity::frontend::OptimiserSettings settings = solidity::frontend::OptimiserSettings::none();
|
solidity::frontend::OptimiserSettings settings = solidity::frontend::OptimiserSettings::none();
|
||||||
settings.runYulOptimiser = false;
|
settings.runYulOptimiser = false;
|
||||||
settings.optimizeStackAllocation = m_stackOpt;
|
settings.optimizeStackAllocation = m_stackOpt;
|
||||||
AssemblyStack stack(
|
YulStack stack(
|
||||||
EVMVersion{},
|
EVMVersion{},
|
||||||
AssemblyStack::Language::StrictAssembly,
|
YulStack::Language::StrictAssembly,
|
||||||
settings,
|
settings,
|
||||||
DebugInfoSelection::All()
|
DebugInfoSelection::All()
|
||||||
);
|
);
|
||||||
|
@ -25,7 +25,7 @@
|
|||||||
#include <libyul/backends/evm/EVMDialect.h>
|
#include <libyul/backends/evm/EVMDialect.h>
|
||||||
#include <libyul/backends/wasm/WasmDialect.h>
|
#include <libyul/backends/wasm/WasmDialect.h>
|
||||||
#include <libyul/backends/wasm/EVMToEwasmTranslator.h>
|
#include <libyul/backends/wasm/EVMToEwasmTranslator.h>
|
||||||
#include <libyul/AssemblyStack.h>
|
#include <libyul/YulStack.h>
|
||||||
#include <libyul/AsmAnalysisInfo.h>
|
#include <libyul/AsmAnalysisInfo.h>
|
||||||
#include <libyul/AST.h>
|
#include <libyul/AST.h>
|
||||||
#include <libyul/Object.h>
|
#include <libyul/Object.h>
|
||||||
@ -80,9 +80,9 @@ TestCase::TestResult EwasmTranslationTest::run(ostream& _stream, string const& _
|
|||||||
|
|
||||||
bool EwasmTranslationTest::parse(ostream& _stream, string const& _linePrefix, bool const _formatted)
|
bool EwasmTranslationTest::parse(ostream& _stream, string const& _linePrefix, bool const _formatted)
|
||||||
{
|
{
|
||||||
m_stack = AssemblyStack(
|
m_stack = YulStack(
|
||||||
solidity::test::CommonOptions::get().evmVersion(),
|
solidity::test::CommonOptions::get().evmVersion(),
|
||||||
AssemblyStack::Language::StrictAssembly,
|
YulStack::Language::StrictAssembly,
|
||||||
solidity::frontend::OptimiserSettings::none(),
|
solidity::frontend::OptimiserSettings::none(),
|
||||||
DebugInfoSelection::All()
|
DebugInfoSelection::All()
|
||||||
);
|
);
|
||||||
|
@ -20,12 +20,12 @@
|
|||||||
|
|
||||||
#include <test/TestCase.h>
|
#include <test/TestCase.h>
|
||||||
|
|
||||||
#include <libyul/AssemblyStack.h>
|
#include <libyul/YulStack.h>
|
||||||
|
|
||||||
namespace solidity::yul
|
namespace solidity::yul
|
||||||
{
|
{
|
||||||
struct Object;
|
struct Object;
|
||||||
class AssemblyStack;
|
class YulStack;
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace solidity::yul::test
|
namespace solidity::yul::test
|
||||||
@ -48,7 +48,7 @@ private:
|
|||||||
std::string interpret();
|
std::string interpret();
|
||||||
|
|
||||||
std::shared_ptr<Object> m_object;
|
std::shared_ptr<Object> m_object;
|
||||||
AssemblyStack m_stack;
|
YulStack m_stack;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -22,7 +22,7 @@
|
|||||||
|
|
||||||
#include <libsolutil/AnsiColorized.h>
|
#include <libsolutil/AnsiColorized.h>
|
||||||
|
|
||||||
#include <libyul/AssemblyStack.h>
|
#include <libyul/YulStack.h>
|
||||||
|
|
||||||
#include <libevmasm/Instruction.h>
|
#include <libevmasm/Instruction.h>
|
||||||
#include <libevmasm/Disassemble.h>
|
#include <libevmasm/Disassemble.h>
|
||||||
@ -63,9 +63,9 @@ ObjectCompilerTest::ObjectCompilerTest(string const& _filename):
|
|||||||
|
|
||||||
TestCase::TestResult ObjectCompilerTest::run(ostream& _stream, string const& _linePrefix, bool const _formatted)
|
TestCase::TestResult ObjectCompilerTest::run(ostream& _stream, string const& _linePrefix, bool const _formatted)
|
||||||
{
|
{
|
||||||
AssemblyStack stack(
|
YulStack stack(
|
||||||
EVMVersion(),
|
EVMVersion(),
|
||||||
m_wasm ? AssemblyStack::Language::Ewasm : AssemblyStack::Language::StrictAssembly,
|
m_wasm ? YulStack::Language::Ewasm : YulStack::Language::StrictAssembly,
|
||||||
OptimiserSettings::preset(m_optimisationPreset),
|
OptimiserSettings::preset(m_optimisationPreset),
|
||||||
DebugInfoSelection::All()
|
DebugInfoSelection::All()
|
||||||
);
|
);
|
||||||
@ -80,7 +80,7 @@ TestCase::TestResult ObjectCompilerTest::run(ostream& _stream, string const& _li
|
|||||||
|
|
||||||
if (m_wasm)
|
if (m_wasm)
|
||||||
{
|
{
|
||||||
MachineAssemblyObject obj = stack.assemble(AssemblyStack::Machine::Ewasm);
|
MachineAssemblyObject obj = stack.assemble(YulStack::Machine::Ewasm);
|
||||||
solAssert(obj.bytecode, "");
|
solAssert(obj.bytecode, "");
|
||||||
|
|
||||||
m_obtainedResult = "Text:\n" + obj.assembly + "\n";
|
m_obtainedResult = "Text:\n" + obj.assembly + "\n";
|
||||||
@ -88,7 +88,7 @@ TestCase::TestResult ObjectCompilerTest::run(ostream& _stream, string const& _li
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
MachineAssemblyObject obj = stack.assemble(AssemblyStack::Machine::EVM);
|
MachineAssemblyObject obj = stack.assemble(YulStack::Machine::EVM);
|
||||||
solAssert(obj.bytecode, "");
|
solAssert(obj.bytecode, "");
|
||||||
solAssert(obj.sourceMappings, "");
|
solAssert(obj.sourceMappings, "");
|
||||||
|
|
||||||
|
@ -26,7 +26,7 @@
|
|||||||
#include <liblangutil/DebugInfoSelection.h>
|
#include <liblangutil/DebugInfoSelection.h>
|
||||||
#include <liblangutil/Scanner.h>
|
#include <liblangutil/Scanner.h>
|
||||||
|
|
||||||
#include <libyul/AssemblyStack.h>
|
#include <libyul/YulStack.h>
|
||||||
#include <libyul/backends/evm/EVMDialect.h>
|
#include <libyul/backends/evm/EVMDialect.h>
|
||||||
|
|
||||||
#include <libsolidity/interface/OptimiserSettings.h>
|
#include <libsolidity/interface/OptimiserSettings.h>
|
||||||
@ -58,9 +58,9 @@ pair<bool, ErrorList> parse(string const& _source)
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
AssemblyStack asmStack(
|
YulStack asmStack(
|
||||||
solidity::test::CommonOptions::get().evmVersion(),
|
solidity::test::CommonOptions::get().evmVersion(),
|
||||||
AssemblyStack::Language::StrictAssembly,
|
YulStack::Language::StrictAssembly,
|
||||||
solidity::frontend::OptimiserSettings::none(),
|
solidity::frontend::OptimiserSettings::none(),
|
||||||
DebugInfoSelection::All()
|
DebugInfoSelection::All()
|
||||||
);
|
);
|
||||||
@ -180,9 +180,9 @@ BOOST_AUTO_TEST_CASE(to_string)
|
|||||||
}
|
}
|
||||||
)";
|
)";
|
||||||
expectation = boost::replace_all_copy(expectation, "\t", " ");
|
expectation = boost::replace_all_copy(expectation, "\t", " ");
|
||||||
AssemblyStack asmStack(
|
YulStack asmStack(
|
||||||
solidity::test::CommonOptions::get().evmVersion(),
|
solidity::test::CommonOptions::get().evmVersion(),
|
||||||
AssemblyStack::Language::StrictAssembly,
|
YulStack::Language::StrictAssembly,
|
||||||
solidity::frontend::OptimiserSettings::none(),
|
solidity::frontend::OptimiserSettings::none(),
|
||||||
DebugInfoSelection::All()
|
DebugInfoSelection::All()
|
||||||
);
|
);
|
||||||
|
@ -23,7 +23,7 @@
|
|||||||
#include <test/Common.h>
|
#include <test/Common.h>
|
||||||
|
|
||||||
#include <libyul/backends/evm/EVMDialect.h>
|
#include <libyul/backends/evm/EVMDialect.h>
|
||||||
#include <libyul/AssemblyStack.h>
|
#include <libyul/YulStack.h>
|
||||||
#include <libyul/AsmAnalysisInfo.h>
|
#include <libyul/AsmAnalysisInfo.h>
|
||||||
|
|
||||||
#include <liblangutil/DebugInfoSelection.h>
|
#include <liblangutil/DebugInfoSelection.h>
|
||||||
@ -65,9 +65,9 @@ TestCase::TestResult YulInterpreterTest::run(ostream& _stream, string const& _li
|
|||||||
|
|
||||||
bool YulInterpreterTest::parse(ostream& _stream, string const& _linePrefix, bool const _formatted)
|
bool YulInterpreterTest::parse(ostream& _stream, string const& _linePrefix, bool const _formatted)
|
||||||
{
|
{
|
||||||
AssemblyStack stack(
|
YulStack stack(
|
||||||
solidity::test::CommonOptions::get().evmVersion(),
|
solidity::test::CommonOptions::get().evmVersion(),
|
||||||
AssemblyStack::Language::StrictAssembly,
|
YulStack::Language::StrictAssembly,
|
||||||
solidity::frontend::OptimiserSettings::none(),
|
solidity::frontend::OptimiserSettings::none(),
|
||||||
DebugInfoSelection::All()
|
DebugInfoSelection::All()
|
||||||
);
|
);
|
||||||
|
@ -233,23 +233,23 @@ BOOST_AUTO_TEST_CASE(via_ir_options)
|
|||||||
|
|
||||||
BOOST_AUTO_TEST_CASE(assembly_mode_options)
|
BOOST_AUTO_TEST_CASE(assembly_mode_options)
|
||||||
{
|
{
|
||||||
static vector<tuple<vector<string>, AssemblyStack::Machine, AssemblyStack::Language>> const allowedCombinations = {
|
static vector<tuple<vector<string>, YulStack::Machine, YulStack::Language>> const allowedCombinations = {
|
||||||
{{"--machine=ewasm", "--yul-dialect=ewasm", "--assemble"}, AssemblyStack::Machine::Ewasm, AssemblyStack::Language::Ewasm},
|
{{"--machine=ewasm", "--yul-dialect=ewasm", "--assemble"}, YulStack::Machine::Ewasm, YulStack::Language::Ewasm},
|
||||||
{{"--machine=ewasm", "--yul-dialect=ewasm", "--yul"}, AssemblyStack::Machine::Ewasm, AssemblyStack::Language::Ewasm},
|
{{"--machine=ewasm", "--yul-dialect=ewasm", "--yul"}, YulStack::Machine::Ewasm, YulStack::Language::Ewasm},
|
||||||
{{"--machine=ewasm", "--yul-dialect=ewasm", "--strict-assembly"}, AssemblyStack::Machine::Ewasm, AssemblyStack::Language::Ewasm},
|
{{"--machine=ewasm", "--yul-dialect=ewasm", "--strict-assembly"}, YulStack::Machine::Ewasm, YulStack::Language::Ewasm},
|
||||||
{{"--machine=ewasm", "--yul-dialect=evm", "--assemble"}, AssemblyStack::Machine::Ewasm, AssemblyStack::Language::StrictAssembly},
|
{{"--machine=ewasm", "--yul-dialect=evm", "--assemble"}, YulStack::Machine::Ewasm, YulStack::Language::StrictAssembly},
|
||||||
{{"--machine=ewasm", "--yul-dialect=evm", "--yul"}, AssemblyStack::Machine::Ewasm, AssemblyStack::Language::StrictAssembly},
|
{{"--machine=ewasm", "--yul-dialect=evm", "--yul"}, YulStack::Machine::Ewasm, YulStack::Language::StrictAssembly},
|
||||||
{{"--machine=ewasm", "--yul-dialect=evm", "--strict-assembly"}, AssemblyStack::Machine::Ewasm, AssemblyStack::Language::StrictAssembly},
|
{{"--machine=ewasm", "--yul-dialect=evm", "--strict-assembly"}, YulStack::Machine::Ewasm, YulStack::Language::StrictAssembly},
|
||||||
{{"--machine=ewasm", "--strict-assembly"}, AssemblyStack::Machine::Ewasm, AssemblyStack::Language::Ewasm},
|
{{"--machine=ewasm", "--strict-assembly"}, YulStack::Machine::Ewasm, YulStack::Language::Ewasm},
|
||||||
{{"--machine=evm", "--yul-dialect=evm", "--assemble"}, AssemblyStack::Machine::EVM, AssemblyStack::Language::StrictAssembly},
|
{{"--machine=evm", "--yul-dialect=evm", "--assemble"}, YulStack::Machine::EVM, YulStack::Language::StrictAssembly},
|
||||||
{{"--machine=evm", "--yul-dialect=evm", "--yul"}, AssemblyStack::Machine::EVM, AssemblyStack::Language::StrictAssembly},
|
{{"--machine=evm", "--yul-dialect=evm", "--yul"}, YulStack::Machine::EVM, YulStack::Language::StrictAssembly},
|
||||||
{{"--machine=evm", "--yul-dialect=evm", "--strict-assembly"}, AssemblyStack::Machine::EVM, AssemblyStack::Language::StrictAssembly},
|
{{"--machine=evm", "--yul-dialect=evm", "--strict-assembly"}, YulStack::Machine::EVM, YulStack::Language::StrictAssembly},
|
||||||
{{"--machine=evm", "--assemble"}, AssemblyStack::Machine::EVM, AssemblyStack::Language::Assembly},
|
{{"--machine=evm", "--assemble"}, YulStack::Machine::EVM, YulStack::Language::Assembly},
|
||||||
{{"--machine=evm", "--yul"}, AssemblyStack::Machine::EVM, AssemblyStack::Language::Yul},
|
{{"--machine=evm", "--yul"}, YulStack::Machine::EVM, YulStack::Language::Yul},
|
||||||
{{"--machine=evm", "--strict-assembly"}, AssemblyStack::Machine::EVM, AssemblyStack::Language::StrictAssembly},
|
{{"--machine=evm", "--strict-assembly"}, YulStack::Machine::EVM, YulStack::Language::StrictAssembly},
|
||||||
{{"--assemble"}, AssemblyStack::Machine::EVM, AssemblyStack::Language::Assembly},
|
{{"--assemble"}, YulStack::Machine::EVM, YulStack::Language::Assembly},
|
||||||
{{"--yul"}, AssemblyStack::Machine::EVM, AssemblyStack::Language::Yul},
|
{{"--yul"}, YulStack::Machine::EVM, YulStack::Language::Yul},
|
||||||
{{"--strict-assembly"}, AssemblyStack::Machine::EVM, AssemblyStack::Language::StrictAssembly},
|
{{"--strict-assembly"}, YulStack::Machine::EVM, YulStack::Language::StrictAssembly},
|
||||||
};
|
};
|
||||||
|
|
||||||
for (auto const& [assemblyOptions, expectedMachine, expectedLanguage]: allowedCombinations)
|
for (auto const& [assemblyOptions, expectedMachine, expectedLanguage]: allowedCombinations)
|
||||||
@ -302,7 +302,7 @@ BOOST_AUTO_TEST_CASE(assembly_mode_options)
|
|||||||
"--ewasm-ir",
|
"--ewasm-ir",
|
||||||
};
|
};
|
||||||
commandLine += assemblyOptions;
|
commandLine += assemblyOptions;
|
||||||
if (expectedLanguage == AssemblyStack::Language::StrictAssembly || expectedLanguage == AssemblyStack::Language::Ewasm)
|
if (expectedLanguage == YulStack::Language::StrictAssembly || expectedLanguage == YulStack::Language::Ewasm)
|
||||||
commandLine += vector<string>{
|
commandLine += vector<string>{
|
||||||
"--optimize",
|
"--optimize",
|
||||||
"--optimize-runs=1000",
|
"--optimize-runs=1000",
|
||||||
@ -341,7 +341,7 @@ BOOST_AUTO_TEST_CASE(assembly_mode_options)
|
|||||||
expectedOptions.compiler.outputs.irOptimized = true;
|
expectedOptions.compiler.outputs.irOptimized = true;
|
||||||
expectedOptions.compiler.outputs.ewasm = true;
|
expectedOptions.compiler.outputs.ewasm = true;
|
||||||
expectedOptions.compiler.outputs.ewasmIR = true;
|
expectedOptions.compiler.outputs.ewasmIR = true;
|
||||||
if (expectedLanguage == AssemblyStack::Language::StrictAssembly || expectedLanguage == AssemblyStack::Language::Ewasm)
|
if (expectedLanguage == YulStack::Language::StrictAssembly || expectedLanguage == YulStack::Language::Ewasm)
|
||||||
{
|
{
|
||||||
expectedOptions.optimizer.enabled = true;
|
expectedOptions.optimizer.enabled = true;
|
||||||
expectedOptions.optimizer.yulSteps = "agf";
|
expectedOptions.optimizer.yulSteps = "agf";
|
||||||
|
@ -22,7 +22,7 @@
|
|||||||
|
|
||||||
#include <libsolidity/interface/CompilerStack.h>
|
#include <libsolidity/interface/CompilerStack.h>
|
||||||
|
|
||||||
#include <libyul/AssemblyStack.h>
|
#include <libyul/YulStack.h>
|
||||||
|
|
||||||
#include <libsolutil/Keccak256.h>
|
#include <libsolutil/Keccak256.h>
|
||||||
|
|
||||||
|
@ -35,7 +35,7 @@ bytes YulAssembler::assemble()
|
|||||||
|
|
||||||
if (m_optimiseYul)
|
if (m_optimiseYul)
|
||||||
m_stack.optimize();
|
m_stack.optimize();
|
||||||
return m_stack.assemble(AssemblyStack::Machine::EVM).bytecode->bytecode;
|
return m_stack.assemble(YulStack::Machine::EVM).bytecode->bytecode;
|
||||||
}
|
}
|
||||||
|
|
||||||
evmc::result YulEvmoneUtility::deployCode(bytes const& _input, EVMHost& _host)
|
evmc::result YulEvmoneUtility::deployCode(bytes const& _input, EVMHost& _host)
|
||||||
|
@ -19,7 +19,7 @@
|
|||||||
|
|
||||||
#include <test/EVMHost.h>
|
#include <test/EVMHost.h>
|
||||||
|
|
||||||
#include <libyul/AssemblyStack.h>
|
#include <libyul/YulStack.h>
|
||||||
|
|
||||||
#include <libsolidity/interface/OptimiserSettings.h>
|
#include <libsolidity/interface/OptimiserSettings.h>
|
||||||
|
|
||||||
@ -37,7 +37,7 @@ public:
|
|||||||
):
|
):
|
||||||
m_stack(
|
m_stack(
|
||||||
_version,
|
_version,
|
||||||
solidity::yul::AssemblyStack::Language::StrictAssembly,
|
solidity::yul::YulStack::Language::StrictAssembly,
|
||||||
_optSettings,
|
_optSettings,
|
||||||
langutil::DebugInfoSelection::All()
|
langutil::DebugInfoSelection::All()
|
||||||
),
|
),
|
||||||
@ -46,7 +46,7 @@ public:
|
|||||||
{}
|
{}
|
||||||
solidity::bytes assemble();
|
solidity::bytes assemble();
|
||||||
private:
|
private:
|
||||||
solidity::yul::AssemblyStack m_stack;
|
solidity::yul::YulStack m_stack;
|
||||||
std::string m_yulProgram;
|
std::string m_yulProgram;
|
||||||
bool m_optimiseYul;
|
bool m_optimiseYul;
|
||||||
};
|
};
|
||||||
|
@ -16,7 +16,7 @@
|
|||||||
*/
|
*/
|
||||||
// SPDX-License-Identifier: GPL-3.0
|
// SPDX-License-Identifier: GPL-3.0
|
||||||
|
|
||||||
#include <libyul/AssemblyStack.h>
|
#include <libyul/YulStack.h>
|
||||||
#include <libyul/backends/evm/EVMCodeTransform.h>
|
#include <libyul/backends/evm/EVMCodeTransform.h>
|
||||||
|
|
||||||
#include <liblangutil/DebugInfoSelection.h>
|
#include <liblangutil/DebugInfoSelection.h>
|
||||||
@ -37,9 +37,9 @@ extern "C" int LLVMFuzzerTestOneInput(uint8_t const* _data, size_t _size)
|
|||||||
YulStringRepository::reset();
|
YulStringRepository::reset();
|
||||||
|
|
||||||
string input(reinterpret_cast<char const*>(_data), _size);
|
string input(reinterpret_cast<char const*>(_data), _size);
|
||||||
AssemblyStack stack(
|
YulStack stack(
|
||||||
langutil::EVMVersion(),
|
langutil::EVMVersion(),
|
||||||
AssemblyStack::Language::StrictAssembly,
|
YulStack::Language::StrictAssembly,
|
||||||
solidity::frontend::OptimiserSettings::full(),
|
solidity::frontend::OptimiserSettings::full(),
|
||||||
langutil::DebugInfoSelection::All()
|
langutil::DebugInfoSelection::All()
|
||||||
);
|
);
|
||||||
@ -49,7 +49,7 @@ extern "C" int LLVMFuzzerTestOneInput(uint8_t const* _data, size_t _size)
|
|||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
MachineAssemblyObject obj = stack.assemble(AssemblyStack::Machine::EVM);
|
MachineAssemblyObject obj = stack.assemble(YulStack::Machine::EVM);
|
||||||
solAssert(obj.bytecode, "");
|
solAssert(obj.bytecode, "");
|
||||||
}
|
}
|
||||||
catch (StackTooDeepError const&)
|
catch (StackTooDeepError const&)
|
||||||
|
@ -20,7 +20,7 @@
|
|||||||
#include <libyul/AsmAnalysis.h>
|
#include <libyul/AsmAnalysis.h>
|
||||||
#include <libyul/Dialect.h>
|
#include <libyul/Dialect.h>
|
||||||
#include <libyul/backends/evm/EVMDialect.h>
|
#include <libyul/backends/evm/EVMDialect.h>
|
||||||
#include <libyul/AssemblyStack.h>
|
#include <libyul/YulStack.h>
|
||||||
|
|
||||||
#include <liblangutil/DebugInfoSelection.h>
|
#include <liblangutil/DebugInfoSelection.h>
|
||||||
#include <liblangutil/Exceptions.h>
|
#include <liblangutil/Exceptions.h>
|
||||||
@ -60,9 +60,9 @@ extern "C" int LLVMFuzzerTestOneInput(uint8_t const* _data, size_t _size)
|
|||||||
|
|
||||||
YulStringRepository::reset();
|
YulStringRepository::reset();
|
||||||
|
|
||||||
AssemblyStack stack(
|
YulStack stack(
|
||||||
langutil::EVMVersion(),
|
langutil::EVMVersion(),
|
||||||
AssemblyStack::Language::StrictAssembly,
|
YulStack::Language::StrictAssembly,
|
||||||
solidity::frontend::OptimiserSettings::full(),
|
solidity::frontend::OptimiserSettings::full(),
|
||||||
DebugInfoSelection::All()
|
DebugInfoSelection::All()
|
||||||
);
|
);
|
||||||
|
@ -16,7 +16,7 @@
|
|||||||
*/
|
*/
|
||||||
// SPDX-License-Identifier: GPL-3.0
|
// SPDX-License-Identifier: GPL-3.0
|
||||||
|
|
||||||
#include <libyul/AssemblyStack.h>
|
#include <libyul/YulStack.h>
|
||||||
|
|
||||||
#include <liblangutil/DebugInfoSelection.h>
|
#include <liblangutil/DebugInfoSelection.h>
|
||||||
#include <liblangutil/EVMVersion.h>
|
#include <liblangutil/EVMVersion.h>
|
||||||
@ -38,9 +38,9 @@ extern "C" int LLVMFuzzerTestOneInput(uint8_t const* _data, size_t _size)
|
|||||||
YulStringRepository::reset();
|
YulStringRepository::reset();
|
||||||
|
|
||||||
string input(reinterpret_cast<char const*>(_data), _size);
|
string input(reinterpret_cast<char const*>(_data), _size);
|
||||||
AssemblyStack stack(
|
YulStack stack(
|
||||||
langutil::EVMVersion(),
|
langutil::EVMVersion(),
|
||||||
AssemblyStack::Language::StrictAssembly,
|
YulStack::Language::StrictAssembly,
|
||||||
solidity::frontend::OptimiserSettings::full(),
|
solidity::frontend::OptimiserSettings::full(),
|
||||||
DebugInfoSelection::All()
|
DebugInfoSelection::All()
|
||||||
);
|
);
|
||||||
|
@ -25,7 +25,7 @@
|
|||||||
|
|
||||||
#include <test/libyul/YulOptimizerTestCommon.h>
|
#include <test/libyul/YulOptimizerTestCommon.h>
|
||||||
|
|
||||||
#include <libyul/AssemblyStack.h>
|
#include <libyul/YulStack.h>
|
||||||
#include <libyul/Exceptions.h>
|
#include <libyul/Exceptions.h>
|
||||||
|
|
||||||
#include <libyul/backends/evm/EVMDialect.h>
|
#include <libyul/backends/evm/EVMDialect.h>
|
||||||
@ -61,10 +61,10 @@ DEFINE_PROTO_FUZZER(Program const& _input)
|
|||||||
|
|
||||||
YulStringRepository::reset();
|
YulStringRepository::reset();
|
||||||
|
|
||||||
// AssemblyStack entry point
|
// YulStack entry point
|
||||||
AssemblyStack stack(
|
YulStack stack(
|
||||||
version,
|
version,
|
||||||
AssemblyStack::Language::StrictAssembly,
|
YulStack::Language::StrictAssembly,
|
||||||
solidity::frontend::OptimiserSettings::full(),
|
solidity::frontend::OptimiserSettings::full(),
|
||||||
DebugInfoSelection::All()
|
DebugInfoSelection::All()
|
||||||
);
|
);
|
||||||
|
@ -26,7 +26,7 @@
|
|||||||
|
|
||||||
#include <src/libfuzzer/libfuzzer_macro.h>
|
#include <src/libfuzzer/libfuzzer_macro.h>
|
||||||
|
|
||||||
#include <libyul/AssemblyStack.h>
|
#include <libyul/YulStack.h>
|
||||||
#include <libyul/backends/evm/EVMDialect.h>
|
#include <libyul/backends/evm/EVMDialect.h>
|
||||||
#include <libyul/Exceptions.h>
|
#include <libyul/Exceptions.h>
|
||||||
|
|
||||||
@ -60,10 +60,10 @@ DEFINE_PROTO_FUZZER(Program const& _input)
|
|||||||
|
|
||||||
YulStringRepository::reset();
|
YulStringRepository::reset();
|
||||||
|
|
||||||
// AssemblyStack entry point
|
// YulStack entry point
|
||||||
AssemblyStack stack(
|
YulStack stack(
|
||||||
version,
|
version,
|
||||||
AssemblyStack::Language::StrictAssembly,
|
YulStack::Language::StrictAssembly,
|
||||||
solidity::frontend::OptimiserSettings::full(),
|
solidity::frontend::OptimiserSettings::full(),
|
||||||
DebugInfoSelection::All()
|
DebugInfoSelection::All()
|
||||||
);
|
);
|
||||||
|
@ -25,7 +25,7 @@
|
|||||||
#include <libyul/AsmAnalysis.h>
|
#include <libyul/AsmAnalysis.h>
|
||||||
#include <libyul/Dialect.h>
|
#include <libyul/Dialect.h>
|
||||||
#include <libyul/backends/evm/EVMDialect.h>
|
#include <libyul/backends/evm/EVMDialect.h>
|
||||||
#include <libyul/AssemblyStack.h>
|
#include <libyul/YulStack.h>
|
||||||
|
|
||||||
#include <liblangutil/DebugInfoSelection.h>
|
#include <liblangutil/DebugInfoSelection.h>
|
||||||
#include <liblangutil/Exceptions.h>
|
#include <liblangutil/Exceptions.h>
|
||||||
@ -56,9 +56,9 @@ namespace
|
|||||||
|
|
||||||
pair<shared_ptr<Block>, shared_ptr<AsmAnalysisInfo>> parse(string const& _source)
|
pair<shared_ptr<Block>, shared_ptr<AsmAnalysisInfo>> parse(string const& _source)
|
||||||
{
|
{
|
||||||
AssemblyStack stack(
|
YulStack stack(
|
||||||
langutil::EVMVersion(),
|
langutil::EVMVersion(),
|
||||||
AssemblyStack::Language::StrictAssembly,
|
YulStack::Language::StrictAssembly,
|
||||||
solidity::frontend::OptimiserSettings::none(),
|
solidity::frontend::OptimiserSettings::none(),
|
||||||
DebugInfoSelection::Default()
|
DebugInfoSelection::Default()
|
||||||
);
|
);
|
||||||
|
Loading…
Reference in New Issue
Block a user