diff --git a/Changelog.md b/Changelog.md index 54088143b..1a6e0a51a 100644 --- a/Changelog.md +++ b/Changelog.md @@ -8,6 +8,7 @@ Compiler Features: * Code Generator: Skip existence check for external contract if return data is expected. In this case, the ABI decoder will revert if the contract does not exist. * Commandline Interface: Accept nested brackets in step sequences passed to ``--yul-optimizations``. * Commandline Interface: Add ``--debug-info`` option for selecting how much extra debug information should be included in the produced EVM assembly and Yul code. + * Commandline Interface: Support ``--asm``, ``--bin``, ``--ir-optimized``, ``--ewasm`` and ``--ewasm-ir`` output selection options in assembler mode. * Commandline Interface: Use different colors when printing errors, warnings and infos. * SMTChecker: Output values for ``block.*``, ``msg.*`` and ``tx.*`` variables that are present in the called functions. * SMTChecker: Report contract invariants and reentrancy properties. This can be enabled via the CLI option ``--model-checker-invariants`` or the Standard JSON option ``settings.modelChecker.invariants``. diff --git a/solc/CommandLineInterface.cpp b/solc/CommandLineInterface.cpp index 9d2279910..1d069f925 100644 --- a/solc/CommandLineInterface.cpp +++ b/solc/CommandLineInterface.cpp @@ -1042,34 +1042,52 @@ bool CommandLineInterface::assemble(yul::AssemblyStack::Language _language, yul: yul::AssemblyStack& stack = assemblyStacks[src.first]; - sout() << endl << "Pretty printed source:" << endl; - sout() << stack.print() << endl; + if (m_options.compiler.outputs.irOptimized) + { + // NOTE: This actually outputs unoptimized code when the optimizer is disabled but + // 'ir' output in StandardCompiler works the same way. + sout() << endl << "Pretty printed source:" << endl; + sout() << stack.print() << endl; + } if (_language != yul::AssemblyStack::Language::Ewasm && _targetMachine == yul::AssemblyStack::Machine::Ewasm) { stack.translate(yul::AssemblyStack::Language::Ewasm); stack.optimize(); - sout() << endl << "==========================" << endl; - sout() << endl << "Translated source:" << endl; - sout() << stack.print() << endl; + if (m_options.compiler.outputs.ewasmIR) + { + sout() << endl << "==========================" << endl; + sout() << endl << "Translated source:" << endl; + sout() << stack.print() << endl; + } } yul::MachineAssemblyObject object; object = stack.assemble(_targetMachine); object.bytecode->link(m_options.linker.libraries); - sout() << endl << "Binary representation:" << endl; - if (object.bytecode) - sout() << object.bytecode->toHex() << endl; - else - serr() << "No binary representation found." << endl; + if (m_options.compiler.outputs.binary) + { + sout() << endl << "Binary representation:" << endl; + if (object.bytecode) + sout() << object.bytecode->toHex() << endl; + else + serr() << "No binary representation found." << endl; + } - sout() << endl << "Text representation:" << endl; - if (!object.assembly.empty()) - sout() << object.assembly << endl; - else - serr() << "No text representation found." << endl; + solAssert(_targetMachine == yul::AssemblyStack::Machine::Ewasm || _targetMachine == yul::AssemblyStack::Machine::EVM, ""); + if ( + (_targetMachine == yul::AssemblyStack::Machine::EVM && m_options.compiler.outputs.asm_) || + (_targetMachine == yul::AssemblyStack::Machine::Ewasm && m_options.compiler.outputs.ewasm) + ) + { + sout() << endl << "Text representation:" << endl; + if (!object.assembly.empty()) + sout() << object.assembly << endl; + else + serr() << "No text representation found." << endl; + } } return true; diff --git a/solc/CommandLineParser.cpp b/solc/CommandLineParser.cpp index c3448ff8f..9356c9662 100644 --- a/solc/CommandLineParser.cpp +++ b/solc/CommandLineParser.cpp @@ -446,10 +446,18 @@ bool CommandLineParser::parseOutputSelection() { static auto outputSupported = [](InputMode _mode, string_view _outputName) { - static set const compilerModeOutputs = + static set const compilerModeOutputs = ( CompilerOutputs::componentMap() | ranges::views::keys | - ranges::to(); + ranges::to() + ) - set{CompilerOutputs::componentName(&CompilerOutputs::ewasmIR)}; + static set const assemblerModeOutputs = { + CompilerOutputs::componentName(&CompilerOutputs::asm_), + CompilerOutputs::componentName(&CompilerOutputs::binary), + CompilerOutputs::componentName(&CompilerOutputs::irOptimized), + CompilerOutputs::componentName(&CompilerOutputs::ewasm), + CompilerOutputs::componentName(&CompilerOutputs::ewasmIR), + }; switch (_mode) { @@ -461,6 +469,7 @@ bool CommandLineParser::parseOutputSelection() case InputMode::CompilerWithASTImport: return contains(compilerModeOutputs, _outputName); case InputMode::Assembler: + return contains(assemblerModeOutputs, _outputName); case InputMode::StandardJson: case InputMode::Linker: return false; @@ -472,6 +481,17 @@ bool CommandLineParser::parseOutputSelection() for (auto&& [optionName, outputComponent]: CompilerOutputs::componentMap()) m_options.compiler.outputs.*outputComponent = (m_args.count(optionName) > 0); + if (m_options.input.mode == InputMode::Assembler && m_options.compiler.outputs == CompilerOutputs{}) + { + // In assembly mode keep the default outputs enabled for backwards-compatibility. + // TODO: Remove this (must be done in a breaking release). + m_options.compiler.outputs.asm_ = true; + m_options.compiler.outputs.binary = true; + m_options.compiler.outputs.irOptimized = true; + m_options.compiler.outputs.ewasm = true; + m_options.compiler.outputs.ewasmIR = true; + } + vector unsupportedOutputs; for (auto&& [optionName, outputComponent]: CompilerOutputs::componentMap()) if (m_options.compiler.outputs.*outputComponent && !outputSupported(m_options.input.mode, optionName)) @@ -692,6 +712,7 @@ General Information)").c_str(), (CompilerOutputs::componentName(&CompilerOutputs::ir).c_str(), "Intermediate Representation (IR) of all contracts (EXPERIMENTAL).") (CompilerOutputs::componentName(&CompilerOutputs::irOptimized).c_str(), "Optimized intermediate Representation (IR) of all contracts (EXPERIMENTAL).") (CompilerOutputs::componentName(&CompilerOutputs::ewasm).c_str(), "Ewasm text representation of all contracts (EXPERIMENTAL).") + (CompilerOutputs::componentName(&CompilerOutputs::ewasmIR).c_str(), "Intermediate representation (IR) converted to a form that can be translated directly into Ewasm text representation (EXPERIMENTAL).") (CompilerOutputs::componentName(&CompilerOutputs::signatureHashes).c_str(), "Function signature hashes of the contracts.") (CompilerOutputs::componentName(&CompilerOutputs::natspecUser).c_str(), "Natspec user documentation of all contracts.") (CompilerOutputs::componentName(&CompilerOutputs::natspecDev).c_str(), "Natspec developer documentation of all contracts.") @@ -906,11 +927,12 @@ bool CommandLineParser::processArgs() if (!checkMutuallyExclusive({g_strColor, g_strNoColor})) return false; - array const conflictingWithStopAfter{ + array const conflictingWithStopAfter{ CompilerOutputs::componentName(&CompilerOutputs::binary), CompilerOutputs::componentName(&CompilerOutputs::ir), CompilerOutputs::componentName(&CompilerOutputs::irOptimized), CompilerOutputs::componentName(&CompilerOutputs::ewasm), + CompilerOutputs::componentName(&CompilerOutputs::ewasmIR), g_strGas, CompilerOutputs::componentName(&CompilerOutputs::asm_), CompilerOutputs::componentName(&CompilerOutputs::asmJson), diff --git a/solc/CommandLineParser.h b/solc/CommandLineParser.h index 27a64c7b9..a1d13c690 100644 --- a/solc/CommandLineParser.h +++ b/solc/CommandLineParser.h @@ -78,6 +78,7 @@ struct CompilerOutputs {"ir", &CompilerOutputs::ir}, {"ir-optimized", &CompilerOutputs::irOptimized}, {"ewasm", &CompilerOutputs::ewasm}, + {"ewasm-ir", &CompilerOutputs::ewasmIR}, {"hashes", &CompilerOutputs::signatureHashes}, {"userdoc", &CompilerOutputs::natspecUser}, {"devdoc", &CompilerOutputs::natspecDev}, @@ -97,6 +98,7 @@ struct CompilerOutputs bool ir = false; bool irOptimized = false; bool ewasm = false; + bool ewasmIR = false; bool signatureHashes = false; bool natspecUser = false; bool natspecDev = false; diff --git a/test/cmdlineTests/evm_to_wasm_output_selection_asm_only/args b/test/cmdlineTests/evm_to_wasm_output_selection_asm_only/args new file mode 100644 index 000000000..f39038498 --- /dev/null +++ b/test/cmdlineTests/evm_to_wasm_output_selection_asm_only/args @@ -0,0 +1 @@ +--assemble --optimize --yul-dialect evm --machine ewasm --asm diff --git a/test/cmdlineTests/evm_to_wasm_output_selection_asm_only/err b/test/cmdlineTests/evm_to_wasm_output_selection_asm_only/err new file mode 100644 index 000000000..014a1178f --- /dev/null +++ b/test/cmdlineTests/evm_to_wasm_output_selection_asm_only/err @@ -0,0 +1 @@ +Warning: Yul is still experimental. Please use the output with care. diff --git a/test/cmdlineTests/evm_to_wasm_output_selection_asm_only/input.yul b/test/cmdlineTests/evm_to_wasm_output_selection_asm_only/input.yul new file mode 100644 index 000000000..4fa5ef66f --- /dev/null +++ b/test/cmdlineTests/evm_to_wasm_output_selection_asm_only/input.yul @@ -0,0 +1,4 @@ +{ + let x := 42 + sstore(0, x) +} diff --git a/test/cmdlineTests/evm_to_wasm_output_selection_asm_only/output b/test/cmdlineTests/evm_to_wasm_output_selection_asm_only/output new file mode 100644 index 000000000..d0cb60f39 --- /dev/null +++ b/test/cmdlineTests/evm_to_wasm_output_selection_asm_only/output @@ -0,0 +1,2 @@ + +======= evm_to_wasm_output_selection_asm_only/input.yul (Ewasm) ======= diff --git a/test/cmdlineTests/evm_to_wasm_output_selection_ewasm_ir_only/args b/test/cmdlineTests/evm_to_wasm_output_selection_ewasm_ir_only/args new file mode 100644 index 000000000..7c6526b56 --- /dev/null +++ b/test/cmdlineTests/evm_to_wasm_output_selection_ewasm_ir_only/args @@ -0,0 +1 @@ +--assemble --optimize --yul-dialect evm --machine ewasm --ewasm-ir diff --git a/test/cmdlineTests/evm_to_wasm_output_selection_ewasm_ir_only/err b/test/cmdlineTests/evm_to_wasm_output_selection_ewasm_ir_only/err new file mode 100644 index 000000000..014a1178f --- /dev/null +++ b/test/cmdlineTests/evm_to_wasm_output_selection_ewasm_ir_only/err @@ -0,0 +1 @@ +Warning: Yul is still experimental. Please use the output with care. diff --git a/test/cmdlineTests/evm_to_wasm_output_selection_ewasm_ir_only/input.yul b/test/cmdlineTests/evm_to_wasm_output_selection_ewasm_ir_only/input.yul new file mode 100644 index 000000000..4fa5ef66f --- /dev/null +++ b/test/cmdlineTests/evm_to_wasm_output_selection_ewasm_ir_only/input.yul @@ -0,0 +1,4 @@ +{ + let x := 42 + sstore(0, x) +} diff --git a/test/cmdlineTests/evm_to_wasm_output_selection_ewasm_ir_only/output b/test/cmdlineTests/evm_to_wasm_output_selection_ewasm_ir_only/output new file mode 100644 index 000000000..3124db17d --- /dev/null +++ b/test/cmdlineTests/evm_to_wasm_output_selection_ewasm_ir_only/output @@ -0,0 +1,34 @@ + +======= evm_to_wasm_output_selection_ewasm_ir_only/input.yul (Ewasm) ======= + +========================== + +Translated source: +object "object" { + code { + function main() + { + let hi := i64.shl(i64.extend_i32_u(bswap32(i32.wrap_i64(0))), 32) + let y := i64.or(hi, i64.extend_i32_u(bswap32(i32.wrap_i64(i64.shr_u(0, 32))))) + i64.store(0:i32, y) + i64.store(i32.add(0:i32, 8:i32), y) + i64.store(i32.add(0:i32, 16:i32), y) + i64.store(i32.add(0:i32, 24:i32), y) + i64.store(32:i32, y) + i64.store(i32.add(32:i32, 8:i32), y) + i64.store(i32.add(32:i32, 16:i32), y) + let hi_1 := i64.shl(i64.extend_i32_u(bswap32(i32.wrap_i64(42))), 32) + i64.store(i32.add(32:i32, 24:i32), i64.or(hi_1, i64.extend_i32_u(bswap32(i32.wrap_i64(i64.shr_u(42, 32)))))) + eth.storageStore(0:i32, 32:i32) + } + function bswap16(x:i32) -> y:i32 + { + y := i32.or(i32.and(i32.shl(x, 8:i32), 0xff00:i32), i32.and(i32.shr_u(x, 8:i32), 0xff:i32)) + } + function bswap32(x:i32) -> y:i32 + { + let hi:i32 := i32.shl(bswap16(x), 16:i32) + y := i32.or(hi, bswap16(i32.shr_u(x, 16:i32))) + } + } +} diff --git a/test/cmdlineTests/evm_to_wasm_output_selection_ewasm_only/args b/test/cmdlineTests/evm_to_wasm_output_selection_ewasm_only/args new file mode 100644 index 000000000..48a844213 --- /dev/null +++ b/test/cmdlineTests/evm_to_wasm_output_selection_ewasm_only/args @@ -0,0 +1 @@ +--assemble --optimize --yul-dialect evm --machine ewasm --ewasm diff --git a/test/cmdlineTests/evm_to_wasm_output_selection_ewasm_only/err b/test/cmdlineTests/evm_to_wasm_output_selection_ewasm_only/err new file mode 100644 index 000000000..014a1178f --- /dev/null +++ b/test/cmdlineTests/evm_to_wasm_output_selection_ewasm_only/err @@ -0,0 +1 @@ +Warning: Yul is still experimental. Please use the output with care. diff --git a/test/cmdlineTests/evm_to_wasm_output_selection_ewasm_only/input.yul b/test/cmdlineTests/evm_to_wasm_output_selection_ewasm_only/input.yul new file mode 100644 index 000000000..4fa5ef66f --- /dev/null +++ b/test/cmdlineTests/evm_to_wasm_output_selection_ewasm_only/input.yul @@ -0,0 +1,4 @@ +{ + let x := 42 + sstore(0, x) +} diff --git a/test/cmdlineTests/evm_to_wasm_output_selection_ewasm_only/output b/test/cmdlineTests/evm_to_wasm_output_selection_ewasm_only/output new file mode 100644 index 000000000..e8b306260 --- /dev/null +++ b/test/cmdlineTests/evm_to_wasm_output_selection_ewasm_only/output @@ -0,0 +1,54 @@ + +======= evm_to_wasm_output_selection_ewasm_only/input.yul (Ewasm) ======= + +Text representation: +(module + (import "ethereum" "storageStore" (func $eth.storageStore (param i32 i32))) + (memory $memory (export "memory") 1) + (export "main" (func $main)) + +(func $main + (local $hi i64) + (local $y i64) + (local $hi_1 i64) + (block $label_ + (local.set $hi (i64.shl (i64.extend_i32_u (call $bswap32 (i32.wrap_i64 (i64.const 0)))) (i64.const 32))) + (local.set $y (i64.or (local.get $hi) (i64.extend_i32_u (call $bswap32 (i32.wrap_i64 (i64.shr_u (i64.const 0) (i64.const 32))))))) + (i64.store (i32.const 0) (local.get $y)) + (i64.store (i32.add (i32.const 0) (i32.const 8)) (local.get $y)) + (i64.store (i32.add (i32.const 0) (i32.const 16)) (local.get $y)) + (i64.store (i32.add (i32.const 0) (i32.const 24)) (local.get $y)) + (i64.store (i32.const 32) (local.get $y)) + (i64.store (i32.add (i32.const 32) (i32.const 8)) (local.get $y)) + (i64.store (i32.add (i32.const 32) (i32.const 16)) (local.get $y)) + (local.set $hi_1 (i64.shl (i64.extend_i32_u (call $bswap32 (i32.wrap_i64 (i64.const 42)))) (i64.const 32))) + (i64.store (i32.add (i32.const 32) (i32.const 24)) (i64.or (local.get $hi_1) (i64.extend_i32_u (call $bswap32 (i32.wrap_i64 (i64.shr_u (i64.const 42) (i64.const 32))))))) + (call $eth.storageStore (i32.const 0) (i32.const 32)) + ) +) + +(func $bswap16 + (param $x i32) + (result i32) + (local $y i32) + (block $label__1 + (local.set $y (i32.or (i32.and (i32.shl (local.get $x) (i32.const 8)) (i32.const 65280)) (i32.and (i32.shr_u (local.get $x) (i32.const 8)) (i32.const 255)))) + + ) + (local.get $y) +) + +(func $bswap32 + (param $x i32) + (result i32) + (local $y i32) + (local $hi i32) + (block $label__2 + (local.set $hi (i32.shl (call $bswap16 (local.get $x)) (i32.const 16))) + (local.set $y (i32.or (local.get $hi) (call $bswap16 (i32.shr_u (local.get $x) (i32.const 16))))) + + ) + (local.get $y) +) + +) diff --git a/test/cmdlineTests/output_selection_ewasm_ir_only/args b/test/cmdlineTests/output_selection_ewasm_ir_only/args new file mode 100644 index 000000000..bccff6085 --- /dev/null +++ b/test/cmdlineTests/output_selection_ewasm_ir_only/args @@ -0,0 +1 @@ +--optimize --ewasm-ir diff --git a/test/cmdlineTests/output_selection_ewasm_ir_only/err b/test/cmdlineTests/output_selection_ewasm_ir_only/err new file mode 100644 index 000000000..52dd265b5 --- /dev/null +++ b/test/cmdlineTests/output_selection_ewasm_ir_only/err @@ -0,0 +1 @@ +The following outputs are not supported in compiler mode: --ewasm-ir. diff --git a/test/cmdlineTests/output_selection_ewasm_ir_only/exit b/test/cmdlineTests/output_selection_ewasm_ir_only/exit new file mode 100644 index 000000000..d00491fd7 --- /dev/null +++ b/test/cmdlineTests/output_selection_ewasm_ir_only/exit @@ -0,0 +1 @@ +1 diff --git a/test/cmdlineTests/output_selection_ewasm_ir_only/input.sol b/test/cmdlineTests/output_selection_ewasm_ir_only/input.sol new file mode 100644 index 000000000..9755e16e7 --- /dev/null +++ b/test/cmdlineTests/output_selection_ewasm_ir_only/input.sol @@ -0,0 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0 +pragma solidity *; + +contract C {} diff --git a/test/cmdlineTests/standard_cli_output_selection_invalid/args b/test/cmdlineTests/standard_cli_output_selection_invalid/args index f2deb3847..538c87097 100644 --- a/test/cmdlineTests/standard_cli_output_selection_invalid/args +++ b/test/cmdlineTests/standard_cli_output_selection_invalid/args @@ -1 +1 @@ ---ast-compact-json --asm --asm-json --opcodes --bin --bin-runtime --abi --ir --ir-optimized --ewasm --hashes --userdoc --devdoc --metadata --storage-layout +--ast-compact-json --asm --asm-json --opcodes --bin --bin-runtime --abi --ir --ir-optimized --ewasm --ewasm-ir --hashes --userdoc --devdoc --metadata --storage-layout diff --git a/test/cmdlineTests/standard_cli_output_selection_invalid/err b/test/cmdlineTests/standard_cli_output_selection_invalid/err index d6ed4d572..e9d24e61d 100644 --- a/test/cmdlineTests/standard_cli_output_selection_invalid/err +++ b/test/cmdlineTests/standard_cli_output_selection_invalid/err @@ -1 +1 @@ -The following outputs are not supported in standard JSON mode: --abi, --asm, --asm-json, --ast-compact-json, --bin, --bin-runtime, --devdoc, --ewasm, --hashes, --ir, --ir-optimized, --metadata, --opcodes, --storage-layout, --userdoc. +The following outputs are not supported in standard JSON mode: --abi, --asm, --asm-json, --ast-compact-json, --bin, --bin-runtime, --devdoc, --ewasm, --ewasm-ir, --hashes, --ir, --ir-optimized, --metadata, --opcodes, --storage-layout, --userdoc. diff --git a/test/cmdlineTests/strict_asm_output_selection_asm_only/args b/test/cmdlineTests/strict_asm_output_selection_asm_only/args new file mode 100644 index 000000000..eff031170 --- /dev/null +++ b/test/cmdlineTests/strict_asm_output_selection_asm_only/args @@ -0,0 +1 @@ +--strict-assembly --optimize --asm diff --git a/test/cmdlineTests/strict_asm_output_selection_asm_only/err b/test/cmdlineTests/strict_asm_output_selection_asm_only/err new file mode 100644 index 000000000..014a1178f --- /dev/null +++ b/test/cmdlineTests/strict_asm_output_selection_asm_only/err @@ -0,0 +1 @@ +Warning: Yul is still experimental. Please use the output with care. diff --git a/test/cmdlineTests/strict_asm_output_selection_asm_only/input.yul b/test/cmdlineTests/strict_asm_output_selection_asm_only/input.yul new file mode 100644 index 000000000..4fa5ef66f --- /dev/null +++ b/test/cmdlineTests/strict_asm_output_selection_asm_only/input.yul @@ -0,0 +1,4 @@ +{ + let x := 42 + sstore(0, x) +} diff --git a/test/cmdlineTests/strict_asm_output_selection_asm_only/output b/test/cmdlineTests/strict_asm_output_selection_asm_only/output new file mode 100644 index 000000000..abe2143d3 --- /dev/null +++ b/test/cmdlineTests/strict_asm_output_selection_asm_only/output @@ -0,0 +1,12 @@ + +======= strict_asm_output_selection_asm_only/input.yul (EVM) ======= + +Text representation: + /* "strict_asm_output_selection_asm_only/input.yul":15:17 */ + 0x2a + /* "strict_asm_output_selection_asm_only/input.yul":29:30 */ + 0x00 + /* "strict_asm_output_selection_asm_only/input.yul":22:34 */ + sstore + /* "strict_asm_output_selection_asm_only/input.yul":0:36 */ + stop diff --git a/test/cmdlineTests/strict_asm_output_selection_bin_only/args b/test/cmdlineTests/strict_asm_output_selection_bin_only/args new file mode 100644 index 000000000..73ca2cca2 --- /dev/null +++ b/test/cmdlineTests/strict_asm_output_selection_bin_only/args @@ -0,0 +1 @@ +--strict-assembly --optimize --bin diff --git a/test/cmdlineTests/strict_asm_output_selection_bin_only/err b/test/cmdlineTests/strict_asm_output_selection_bin_only/err new file mode 100644 index 000000000..014a1178f --- /dev/null +++ b/test/cmdlineTests/strict_asm_output_selection_bin_only/err @@ -0,0 +1 @@ +Warning: Yul is still experimental. Please use the output with care. diff --git a/test/cmdlineTests/strict_asm_output_selection_bin_only/input.yul b/test/cmdlineTests/strict_asm_output_selection_bin_only/input.yul new file mode 100644 index 000000000..4fa5ef66f --- /dev/null +++ b/test/cmdlineTests/strict_asm_output_selection_bin_only/input.yul @@ -0,0 +1,4 @@ +{ + let x := 42 + sstore(0, x) +} diff --git a/test/cmdlineTests/strict_asm_output_selection_bin_only/output b/test/cmdlineTests/strict_asm_output_selection_bin_only/output new file mode 100644 index 000000000..3ffa826b8 --- /dev/null +++ b/test/cmdlineTests/strict_asm_output_selection_bin_only/output @@ -0,0 +1,5 @@ + +======= strict_asm_output_selection_bin_only/input.yul (EVM) ======= + +Binary representation: +602a60005500 diff --git a/test/cmdlineTests/strict_asm_output_selection_ewasm_ir_only/args b/test/cmdlineTests/strict_asm_output_selection_ewasm_ir_only/args new file mode 100644 index 000000000..647c63654 --- /dev/null +++ b/test/cmdlineTests/strict_asm_output_selection_ewasm_ir_only/args @@ -0,0 +1 @@ +--strict-assembly --optimize --ewasm-ir diff --git a/test/cmdlineTests/strict_asm_output_selection_ewasm_ir_only/err b/test/cmdlineTests/strict_asm_output_selection_ewasm_ir_only/err new file mode 100644 index 000000000..014a1178f --- /dev/null +++ b/test/cmdlineTests/strict_asm_output_selection_ewasm_ir_only/err @@ -0,0 +1 @@ +Warning: Yul is still experimental. Please use the output with care. diff --git a/test/cmdlineTests/strict_asm_output_selection_ewasm_ir_only/input.yul b/test/cmdlineTests/strict_asm_output_selection_ewasm_ir_only/input.yul new file mode 100644 index 000000000..4fa5ef66f --- /dev/null +++ b/test/cmdlineTests/strict_asm_output_selection_ewasm_ir_only/input.yul @@ -0,0 +1,4 @@ +{ + let x := 42 + sstore(0, x) +} diff --git a/test/cmdlineTests/strict_asm_output_selection_ewasm_ir_only/output b/test/cmdlineTests/strict_asm_output_selection_ewasm_ir_only/output new file mode 100644 index 000000000..8026a6e83 --- /dev/null +++ b/test/cmdlineTests/strict_asm_output_selection_ewasm_ir_only/output @@ -0,0 +1,2 @@ + +======= strict_asm_output_selection_ewasm_ir_only/input.yul (EVM) ======= diff --git a/test/cmdlineTests/strict_asm_output_selection_ewasm_only/args b/test/cmdlineTests/strict_asm_output_selection_ewasm_only/args new file mode 100644 index 000000000..bb147ae33 --- /dev/null +++ b/test/cmdlineTests/strict_asm_output_selection_ewasm_only/args @@ -0,0 +1 @@ +--strict-assembly --optimize --ewasm diff --git a/test/cmdlineTests/strict_asm_output_selection_ewasm_only/err b/test/cmdlineTests/strict_asm_output_selection_ewasm_only/err new file mode 100644 index 000000000..014a1178f --- /dev/null +++ b/test/cmdlineTests/strict_asm_output_selection_ewasm_only/err @@ -0,0 +1 @@ +Warning: Yul is still experimental. Please use the output with care. diff --git a/test/cmdlineTests/strict_asm_output_selection_ewasm_only/input.yul b/test/cmdlineTests/strict_asm_output_selection_ewasm_only/input.yul new file mode 100644 index 000000000..4fa5ef66f --- /dev/null +++ b/test/cmdlineTests/strict_asm_output_selection_ewasm_only/input.yul @@ -0,0 +1,4 @@ +{ + let x := 42 + sstore(0, x) +} diff --git a/test/cmdlineTests/strict_asm_output_selection_ewasm_only/output b/test/cmdlineTests/strict_asm_output_selection_ewasm_only/output new file mode 100644 index 000000000..f90f049aa --- /dev/null +++ b/test/cmdlineTests/strict_asm_output_selection_ewasm_only/output @@ -0,0 +1,2 @@ + +======= strict_asm_output_selection_ewasm_only/input.yul (EVM) ======= diff --git a/test/cmdlineTests/strict_asm_output_selection_invalid/err b/test/cmdlineTests/strict_asm_output_selection_invalid/err index 736eb2c8a..9c9104482 100644 --- a/test/cmdlineTests/strict_asm_output_selection_invalid/err +++ b/test/cmdlineTests/strict_asm_output_selection_invalid/err @@ -1 +1 @@ -The following outputs are not supported in assembler mode: --abi, --asm, --asm-json, --bin, --bin-runtime, --devdoc, --ewasm, --hashes, --ir, --ir-optimized, --metadata, --opcodes, --storage-layout, --userdoc. +The following outputs are not supported in assembler mode: --abi, --asm-json, --bin-runtime, --devdoc, --hashes, --ir, --metadata, --opcodes, --storage-layout, --userdoc. diff --git a/test/cmdlineTests/strict_asm_output_selection_ir_optimized_only/args b/test/cmdlineTests/strict_asm_output_selection_ir_optimized_only/args new file mode 100644 index 000000000..90b16d1f0 --- /dev/null +++ b/test/cmdlineTests/strict_asm_output_selection_ir_optimized_only/args @@ -0,0 +1 @@ +--strict-assembly --optimize --ir-optimized diff --git a/test/cmdlineTests/strict_asm_output_selection_ir_optimized_only/err b/test/cmdlineTests/strict_asm_output_selection_ir_optimized_only/err new file mode 100644 index 000000000..014a1178f --- /dev/null +++ b/test/cmdlineTests/strict_asm_output_selection_ir_optimized_only/err @@ -0,0 +1 @@ +Warning: Yul is still experimental. Please use the output with care. diff --git a/test/cmdlineTests/strict_asm_output_selection_ir_optimized_only/input.yul b/test/cmdlineTests/strict_asm_output_selection_ir_optimized_only/input.yul new file mode 100644 index 000000000..4fa5ef66f --- /dev/null +++ b/test/cmdlineTests/strict_asm_output_selection_ir_optimized_only/input.yul @@ -0,0 +1,4 @@ +{ + let x := 42 + sstore(0, x) +} diff --git a/test/cmdlineTests/strict_asm_output_selection_ir_optimized_only/output b/test/cmdlineTests/strict_asm_output_selection_ir_optimized_only/output new file mode 100644 index 000000000..1fa4b72c7 --- /dev/null +++ b/test/cmdlineTests/strict_asm_output_selection_ir_optimized_only/output @@ -0,0 +1,7 @@ + +======= strict_asm_output_selection_ir_optimized_only/input.yul (EVM) ======= + +Pretty printed source: +object "object" { + code { { sstore(0, 42) } } +} diff --git a/test/solc/CommandLineParser.cpp b/test/solc/CommandLineParser.cpp index a9ba08d81..23ea1efb1 100644 --- a/test/solc/CommandLineParser.cpp +++ b/test/solc/CommandLineParser.cpp @@ -198,7 +198,9 @@ BOOST_AUTO_TEST_CASE(cli_mode_options) true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, + true, }; + expectedOptions.compiler.outputs.ewasmIR = false; expectedOptions.compiler.estimateGas = true; expectedOptions.compiler.combinedJsonRequests = { true, true, true, true, true, @@ -297,6 +299,11 @@ BOOST_AUTO_TEST_CASE(assembly_mode_options) "underflow," "divByZero", "--model-checker-timeout=5", // Ignored in assembly mode + "--asm", + "--bin", + "--ir-optimized", + "--ewasm", + "--ewasm-ir", }; commandLine += assemblyOptions; if (expectedLanguage == AssemblyStack::Language::StrictAssembly || expectedLanguage == AssemblyStack::Language::Ewasm) @@ -333,6 +340,11 @@ BOOST_AUTO_TEST_CASE(assembly_mode_options) }; expectedOptions.formatting.coloredOutput = false; expectedOptions.formatting.withErrorIds = true; + expectedOptions.compiler.outputs.asm_ = true; + expectedOptions.compiler.outputs.binary = true; + expectedOptions.compiler.outputs.irOptimized = true; + expectedOptions.compiler.outputs.ewasm = true; + expectedOptions.compiler.outputs.ewasmIR = true; if (expectedLanguage == AssemblyStack::Language::StrictAssembly || expectedLanguage == AssemblyStack::Language::Ewasm) { expectedOptions.optimizer.enabled = true;