Skip to content

Commit

Permalink
Yul: copy verbatim functions into no output assembly
Browse files Browse the repository at this point in the history
  • Loading branch information
clonker committed Aug 26, 2024
1 parent 737b75f commit dec3a9d
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
2 changes: 2 additions & 0 deletions libyul/backends/evm/EVMDialect.h
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,8 @@ struct EVMDialect: public Dialect

static SideEffects sideEffectsOfInstruction(evmasm::Instruction _instruction);

std::map<std::pair<size_t, size_t>, BuiltinFunctionForEVM> const& verbatimFunctions() const { return m_verbatimFunctions; }

protected:
VerbatimHandle verbatimFunction(size_t _arguments, size_t _returnVariables) const;

Expand Down
13 changes: 13 additions & 0 deletions libyul/backends/evm/NoOutputAssembly.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -148,4 +148,17 @@ NoOutputEVMDialect::NoOutputEVMDialect(EVMDialect const& _copyFrom):
};
}
}

m_verbatimFunctions = _copyFrom.verbatimFunctions();
for (auto &[numArgsRets, fun]: m_verbatimFunctions)
{
fun.generateCode = [numArgs=numArgsRets.first, numRets=numArgsRets.second](FunctionCall const&, AbstractAssembly& _assembly, BuiltinContext&)
{
for (size_t i = 0; i < numArgs; i++)
_assembly.appendInstruction(evmasm::Instruction::POP);

for (size_t i = 0; i < numRets; i++)
_assembly.appendConstant(u256(0));
};
}
}

0 comments on commit dec3a9d

Please sign in to comment.