From 5e8d348f6639cb04db2d80bbbc14cb3d68cca161 Mon Sep 17 00:00:00 2001 From: Christian Parpart Date: Tue, 10 Sep 2019 10:55:39 +0200 Subject: [PATCH] Assembly: Remove StackAssignment instruction. --- docs/assembly.rst | 2 -- libsolidity/analysis/ViewPureChecker.cpp | 1 - libyul/AsmAnalysis.cpp | 11 ----------- libyul/AsmAnalysis.h | 1 - libyul/AsmData.h | 2 -- libyul/AsmDataForward.h | 3 +-- libyul/AsmParser.cpp | 17 ----------------- libyul/AsmPrinter.cpp | 7 ------- libyul/AsmPrinter.h | 1 - libyul/AsmScopeFiller.h | 1 - libyul/backends/evm/EVMCodeTransform.cpp | 8 -------- libyul/backends/evm/EVMCodeTransform.h | 1 - libyul/backends/wasm/EWasmCodeTransform.cpp | 6 ------ libyul/backends/wasm/EWasmCodeTransform.h | 1 - libyul/optimiser/ASTCopier.cpp | 6 ------ libyul/optimiser/ASTCopier.h | 2 -- libyul/optimiser/ASTWalker.h | 2 -- libyul/optimiser/SyntacticalEquality.cpp | 5 ----- libyul/optimiser/SyntacticalEquality.h | 1 - 19 files changed, 1 insertion(+), 77 deletions(-) diff --git a/docs/assembly.rst b/docs/assembly.rst index d735b54cd..dc5371699 100644 --- a/docs/assembly.rst +++ b/docs/assembly.rst @@ -763,7 +763,6 @@ Grammar:: AssemblyExpression | AssemblyLocalDefinition | AssemblyAssignment | - AssemblyStackAssignment | LabelDefinition | AssemblyIf | AssemblySwitch | @@ -780,7 +779,6 @@ Grammar:: AssemblyAssignment = IdentifierOrList ':=' AssemblyExpression IdentifierOrList = Identifier | '(' IdentifierList ')' IdentifierList = Identifier ( ',' Identifier)* - AssemblyStackAssignment = '=:' Identifier LabelDefinition = Identifier ':' AssemblyIf = 'if' AssemblyExpression AssemblyBlock AssemblySwitch = 'switch' AssemblyExpression AssemblyCase* diff --git a/libsolidity/analysis/ViewPureChecker.cpp b/libsolidity/analysis/ViewPureChecker.cpp index 7ead355e1..d7efcc5e4 100644 --- a/libsolidity/analysis/ViewPureChecker.cpp +++ b/libsolidity/analysis/ViewPureChecker.cpp @@ -58,7 +58,6 @@ public: { boost::apply_visitor(*this, _expr.expression); } - void operator()(yul::StackAssignment const&) {} void operator()(yul::Assignment const& _assignment) { boost::apply_visitor(*this, *_assignment.value); diff --git a/libyul/AsmAnalysis.cpp b/libyul/AsmAnalysis.cpp index 9c62737d8..b08b884de 100644 --- a/libyul/AsmAnalysis.cpp +++ b/libyul/AsmAnalysis.cpp @@ -232,17 +232,6 @@ bool AsmAnalyzer::operator()(ExpressionStatement const& _statement) return success; } -bool AsmAnalyzer::operator()(StackAssignment const& _assignment) -{ - checkLooseFeature( - _assignment.location, - "The use of stack assignment is disallowed. Please use assignment in functional notation instead." - ); - bool success = checkAssignment(_assignment.variableName, size_t(-1)); - m_info.stackHeightInfo[&_assignment] = m_stackHeight; - return success; -} - bool AsmAnalyzer::operator()(Assignment const& _assignment) { solAssert(_assignment.value, ""); diff --git a/libyul/AsmAnalysis.h b/libyul/AsmAnalysis.h index facae9187..df30631fe 100644 --- a/libyul/AsmAnalysis.h +++ b/libyul/AsmAnalysis.h @@ -87,7 +87,6 @@ public: bool operator()(FunctionalInstruction const& _functionalInstruction); bool operator()(Label const& _label); bool operator()(ExpressionStatement const&); - bool operator()(StackAssignment const&); bool operator()(Assignment const& _assignment); bool operator()(VariableDeclaration const& _variableDeclaration); bool operator()(FunctionDefinition const& _functionDefinition); diff --git a/libyul/AsmData.h b/libyul/AsmData.h index cedff1106..adfa9331e 100644 --- a/libyul/AsmData.h +++ b/libyul/AsmData.h @@ -51,8 +51,6 @@ struct Literal { langutil::SourceLocation location; LiteralKind kind; YulString struct Identifier { langutil::SourceLocation location; YulString name; }; /// Jump label ("name:") struct Label { langutil::SourceLocation location; YulString name; }; -/// Assignment from stack (":= x", moves stack top into x, potentially multiple slots) -struct StackAssignment { langutil::SourceLocation location; Identifier variableName; }; /// Assignment ("x := mload(20:u256)", expects push-1-expression on the right hand /// side and requires x to occupy exactly one stack slot. /// diff --git a/libyul/AsmDataForward.h b/libyul/AsmDataForward.h index d01b1dffa..feb0e0724 100644 --- a/libyul/AsmDataForward.h +++ b/libyul/AsmDataForward.h @@ -30,7 +30,6 @@ namespace yul struct Instruction; struct Literal; struct Label; -struct StackAssignment; struct Identifier; struct Assignment; struct VariableDeclaration; @@ -49,6 +48,6 @@ struct Block; struct TypedName; using Expression = boost::variant; -using Statement = boost::variant; +using Statement = boost::variant; } diff --git a/libyul/AsmParser.cpp b/libyul/AsmParser.cpp index ae3056f21..c8484314a 100644 --- a/libyul/AsmParser.cpp +++ b/libyul/AsmParser.cpp @@ -144,23 +144,6 @@ Statement Parser::parseStatement() m_scanner->next(); return stmt; } - case Token::Assign: - { - if (m_dialect.flavour != AsmFlavour::Loose) - break; - StackAssignment assignment = createWithLocation(); - advance(); - expectToken(Token::Colon); - assignment.variableName.location = location(); - assignment.variableName.name = YulString(currentLiteral()); - if (m_dialect.builtin(assignment.variableName.name)) - fatalParserError("Identifier expected, got builtin symbol."); - else if (instructions().count(assignment.variableName.name.str())) - fatalParserError("Identifier expected, got instruction name."); - assignment.location.end = endPosition(); - expectToken(Token::Identifier); - return Statement{move(assignment)}; - } default: break; } diff --git a/libyul/AsmPrinter.cpp b/libyul/AsmPrinter.cpp index 71151a0cf..580e8544c 100644 --- a/libyul/AsmPrinter.cpp +++ b/libyul/AsmPrinter.cpp @@ -120,13 +120,6 @@ string AsmPrinter::operator()(Label const& _label) const return _label.name.str() + ":"; } -string AsmPrinter::operator()(StackAssignment const& _assignment) const -{ - solAssert(!m_yul, ""); - solAssert(!_assignment.variableName.name.empty(), "Invalid variable name."); - return "=: " + (*this)(_assignment.variableName); -} - string AsmPrinter::operator()(Assignment const& _assignment) const { solAssert(_assignment.variableNames.size() >= 1, ""); diff --git a/libyul/AsmPrinter.h b/libyul/AsmPrinter.h index 82fed24f2..7c6bcbc70 100644 --- a/libyul/AsmPrinter.h +++ b/libyul/AsmPrinter.h @@ -42,7 +42,6 @@ public: std::string operator()(FunctionalInstruction const& _functionalInstruction) const; std::string operator()(ExpressionStatement const& _expr) const; std::string operator()(Label const& _label) const; - std::string operator()(StackAssignment const& _assignment) const; std::string operator()(Assignment const& _assignment) const; std::string operator()(VariableDeclaration const& _variableDeclaration) const; std::string operator()(FunctionDefinition const& _functionDefinition) const; diff --git a/libyul/AsmScopeFiller.h b/libyul/AsmScopeFiller.h index 220538bb2..8b1807398 100644 --- a/libyul/AsmScopeFiller.h +++ b/libyul/AsmScopeFiller.h @@ -55,7 +55,6 @@ public: bool operator()(FunctionalInstruction const&) { return true; } bool operator()(ExpressionStatement const& _expr); bool operator()(Label const& _label); - bool operator()(StackAssignment const&) { return true; } bool operator()(Assignment const&) { return true; } bool operator()(VariableDeclaration const& _variableDeclaration); bool operator()(FunctionDefinition const& _functionDefinition); diff --git a/libyul/backends/evm/EVMCodeTransform.cpp b/libyul/backends/evm/EVMCodeTransform.cpp index 9ca079f07..64f26eb1d 100644 --- a/libyul/backends/evm/EVMCodeTransform.cpp +++ b/libyul/backends/evm/EVMCodeTransform.cpp @@ -250,14 +250,6 @@ void CodeTransform::operator()(Assignment const& _assignment) checkStackHeight(&_assignment); } -void CodeTransform::operator()(StackAssignment const& _assignment) -{ - solAssert(!m_allowStackOpt, ""); - m_assembly.setSourceLocation(_assignment.location); - generateAssignment(_assignment.variableName); - checkStackHeight(&_assignment); -} - void CodeTransform::operator()(ExpressionStatement const& _statement) { m_assembly.setSourceLocation(_statement.location); diff --git a/libyul/backends/evm/EVMCodeTransform.h b/libyul/backends/evm/EVMCodeTransform.h index 866322d2d..715aa28ee 100644 --- a/libyul/backends/evm/EVMCodeTransform.h +++ b/libyul/backends/evm/EVMCodeTransform.h @@ -178,7 +178,6 @@ public: void operator()(FunctionCall const&); void operator()(ExpressionStatement const& _statement); void operator()(Label const& _label); - void operator()(StackAssignment const& _assignment); void operator()(Assignment const& _assignment); void operator()(VariableDeclaration const& _varDecl); void operator()(If const& _if); diff --git a/libyul/backends/wasm/EWasmCodeTransform.cpp b/libyul/backends/wasm/EWasmCodeTransform.cpp index f9e28e94a..de089df36 100644 --- a/libyul/backends/wasm/EWasmCodeTransform.cpp +++ b/libyul/backends/wasm/EWasmCodeTransform.cpp @@ -108,12 +108,6 @@ wasm::Expression EWasmCodeTransform::operator()(Assignment const& _assignment) return generateMultiAssignment(move(variableNames), visit(*_assignment.value)); } -wasm::Expression EWasmCodeTransform::operator()(StackAssignment const&) -{ - yulAssert(false, ""); - return {}; -} - wasm::Expression EWasmCodeTransform::operator()(ExpressionStatement const& _statement) { return visitReturnByValue(_statement.expression); diff --git a/libyul/backends/wasm/EWasmCodeTransform.h b/libyul/backends/wasm/EWasmCodeTransform.h index bbe0e1b69..c20ef89ea 100644 --- a/libyul/backends/wasm/EWasmCodeTransform.h +++ b/libyul/backends/wasm/EWasmCodeTransform.h @@ -45,7 +45,6 @@ public: wasm::Expression operator()(yul::FunctionCall const&); wasm::Expression operator()(yul::ExpressionStatement const& _statement); wasm::Expression operator()(yul::Label const& _label); - wasm::Expression operator()(yul::StackAssignment const& _assignment); wasm::Expression operator()(yul::Assignment const& _assignment); wasm::Expression operator()(yul::VariableDeclaration const& _varDecl); wasm::Expression operator()(yul::If const& _if); diff --git a/libyul/optimiser/ASTCopier.cpp b/libyul/optimiser/ASTCopier.cpp index efe3ff854..085efe6c3 100644 --- a/libyul/optimiser/ASTCopier.cpp +++ b/libyul/optimiser/ASTCopier.cpp @@ -59,12 +59,6 @@ Statement ASTCopier::operator()(Assignment const& _assignment) }; } -Statement ASTCopier::operator()(StackAssignment const&) -{ - assertThrow(false, OptimizerException, "Invalid operation."); - return {}; -} - Statement ASTCopier::operator()(Label const&) { assertThrow(false, OptimizerException, "Invalid operation."); diff --git a/libyul/optimiser/ASTCopier.h b/libyul/optimiser/ASTCopier.h index b2e0a383a..2ba9727a5 100644 --- a/libyul/optimiser/ASTCopier.h +++ b/libyul/optimiser/ASTCopier.h @@ -51,7 +51,6 @@ public: virtual Statement operator()(ExpressionStatement const& _statement) = 0; virtual Statement operator()(Instruction const& _instruction) = 0; virtual Statement operator()(Label const& _label) = 0; - virtual Statement operator()(StackAssignment const& _assignment) = 0; virtual Statement operator()(Assignment const& _assignment) = 0; virtual Statement operator()(VariableDeclaration const& _varDecl) = 0; virtual Statement operator()(If const& _if) = 0; @@ -78,7 +77,6 @@ public: Expression operator()(FunctionCall const&) override; Statement operator()(ExpressionStatement const& _statement) override; Statement operator()(Label const& _label) override; - Statement operator()(StackAssignment const& _assignment) override; Statement operator()(Assignment const& _assignment) override; Statement operator()(VariableDeclaration const& _varDecl) override; Statement operator()(If const& _if) override; diff --git a/libyul/optimiser/ASTWalker.h b/libyul/optimiser/ASTWalker.h index a1f244795..4e4968556 100644 --- a/libyul/optimiser/ASTWalker.h +++ b/libyul/optimiser/ASTWalker.h @@ -49,7 +49,6 @@ public: virtual void operator()(FunctionCall const& _funCall); virtual void operator()(ExpressionStatement const& _statement); virtual void operator()(Label const&) { assertThrow(false, OptimizerException, ""); } - virtual void operator()(StackAssignment const&) { assertThrow(false, OptimizerException, ""); } virtual void operator()(Assignment const& _assignment); virtual void operator()(VariableDeclaration const& _varDecl); virtual void operator()(If const& _if); @@ -86,7 +85,6 @@ public: virtual void operator()(FunctionCall& _funCall); virtual void operator()(ExpressionStatement& _statement); virtual void operator()(Label&) { assertThrow(false, OptimizerException, ""); } - virtual void operator()(StackAssignment&) { assertThrow(false, OptimizerException, ""); } virtual void operator()(Assignment& _assignment); virtual void operator()(VariableDeclaration& _varDecl); virtual void operator()(If& _if); diff --git a/libyul/optimiser/SyntacticalEquality.cpp b/libyul/optimiser/SyntacticalEquality.cpp index 9e425b17e..e3bd8bf4f 100644 --- a/libyul/optimiser/SyntacticalEquality.cpp +++ b/libyul/optimiser/SyntacticalEquality.cpp @@ -169,11 +169,6 @@ bool SyntacticallyEqual::statementEqual(Label const&, Label const&) assertThrow(false, OptimizerException, ""); } -bool SyntacticallyEqual::statementEqual(StackAssignment const&, StackAssignment const&) -{ - assertThrow(false, OptimizerException, ""); -} - bool SyntacticallyEqual::statementEqual(Block const& _lhs, Block const& _rhs) { return containerEqual(_lhs.statements, _rhs.statements, [this](Statement const& _lhsStmt, Statement const& _rhsStmt) -> bool { diff --git a/libyul/optimiser/SyntacticalEquality.h b/libyul/optimiser/SyntacticalEquality.h index c5e722c74..117ce54a9 100644 --- a/libyul/optimiser/SyntacticalEquality.h +++ b/libyul/optimiser/SyntacticalEquality.h @@ -61,7 +61,6 @@ public: private: bool statementEqual(Instruction const& _lhs, Instruction const& _rhs); bool statementEqual(Label const& _lhs, Label const& _rhs); - bool statementEqual(StackAssignment const& _lhs, StackAssignment const& _rhs); bool visitDeclaration(TypedName const& _lhs, TypedName const& _rhs);