/* This file is part of solidity. solidity is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. solidity is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with solidity. If not, see . */ /** * Expression simplification pattern. */ #pragma once #include #include #include namespace solidity::evmasm { /** * Rule that contains a pattern, an action that can be applied * after the pattern has matched and a bool that indicates * whether the action would remove something from the expression * than is not a constant literal. */ template struct SimplificationRule { SimplificationRule( Pattern _pattern, std::function _action, bool _removesNonConstants, std::function _feasible = {} ): pattern(std::move(_pattern)), action(std::move(_action)), removesNonConstants(_removesNonConstants), feasible(std::move(_feasible)) {} Pattern pattern; std::function action; bool removesNonConstants; std::function feasible; }; template struct EVMBuiltins { using InstrType = Instruction; template struct PatternGenerator { template constexpr Pattern operator()(Args&&... _args) const { return {inst, {std::forward(_args)...}}; }; }; struct PatternGeneratorInstance { Instruction instruction; template constexpr Pattern operator()(Args&&... _args) const { return {instruction, {std::forward(_args)...}}; }; }; static auto constexpr STOP = PatternGenerator{}; static auto constexpr ADD = PatternGenerator{}; static auto constexpr SUB = PatternGenerator{}; static auto constexpr MUL = PatternGenerator{}; static auto constexpr DIV = PatternGenerator{}; static auto constexpr SDIV = PatternGenerator{}; static auto constexpr MOD = PatternGenerator{}; static auto constexpr SMOD = PatternGenerator{}; static auto constexpr EXP = PatternGenerator{}; static auto constexpr NOT = PatternGenerator{}; static auto constexpr LT = PatternGenerator{}; static auto constexpr GT = PatternGenerator{}; static auto constexpr SLT = PatternGenerator{}; static auto constexpr SGT = PatternGenerator{}; static auto constexpr EQ = PatternGenerator{}; static auto constexpr ISZERO = PatternGenerator{}; static auto constexpr AND = PatternGenerator{}; static auto constexpr OR = PatternGenerator{}; static auto constexpr XOR = PatternGenerator{}; static auto constexpr BYTE = PatternGenerator{}; static auto constexpr SHL = PatternGenerator{}; static auto constexpr SHR = PatternGenerator{}; static auto constexpr SAR = PatternGenerator{}; static auto constexpr ADDMOD = PatternGenerator{}; static auto constexpr MULMOD = PatternGenerator{}; static auto constexpr SIGNEXTEND = PatternGenerator{}; static auto constexpr KECCAK256 = PatternGenerator{}; static auto constexpr ADDRESS = PatternGenerator{}; static auto constexpr BALANCE = PatternGenerator{}; static auto constexpr ORIGIN = PatternGenerator{}; static auto constexpr CALLER = PatternGenerator{}; static auto constexpr CALLVALUE = PatternGenerator{}; static auto constexpr CALLDATALOAD = PatternGenerator{}; static auto constexpr CALLDATASIZE = PatternGenerator{}; static auto constexpr CALLDATACOPY = PatternGenerator{}; static auto constexpr CODESIZE = PatternGenerator{}; static auto constexpr CODECOPY = PatternGenerator{}; static auto constexpr GASPRICE = PatternGenerator{}; static auto constexpr EXTCODESIZE = PatternGenerator{}; static auto constexpr EXTCODECOPY = PatternGenerator{}; static auto constexpr RETURNDATASIZE = PatternGenerator{}; static auto constexpr RETURNDATACOPY = PatternGenerator{}; static auto constexpr EXTCODEHASH = PatternGenerator{}; static auto constexpr BLOCKHASH = PatternGenerator{}; static auto constexpr COINBASE = PatternGenerator{}; static auto constexpr TIMESTAMP = PatternGenerator{}; static auto constexpr NUMBER = PatternGenerator{}; static auto constexpr DIFFICULTY = PatternGenerator{}; static auto constexpr GASLIMIT = PatternGenerator{}; static auto constexpr CHAINID = PatternGenerator{}; static auto constexpr SELFBALANCE = PatternGenerator{}; static auto constexpr POP = PatternGenerator{}; static auto constexpr MLOAD = PatternGenerator{}; static auto constexpr MSTORE = PatternGenerator{}; static auto constexpr MSTORE8 = PatternGenerator{}; static auto constexpr SLOAD = PatternGenerator{}; static auto constexpr SSTORE = PatternGenerator{}; static auto constexpr PC = PatternGenerator{}; static auto constexpr MSIZE = PatternGenerator{}; static auto constexpr GAS = PatternGenerator{}; static auto constexpr LOG0 = PatternGenerator{}; static auto constexpr LOG1 = PatternGenerator{}; static auto constexpr LOG2 = PatternGenerator{}; static auto constexpr LOG3 = PatternGenerator{}; static auto constexpr LOG4 = PatternGenerator{}; static auto constexpr CREATE = PatternGenerator{}; static auto constexpr CALL = PatternGenerator{}; static auto constexpr CALLCODE = PatternGenerator{}; static auto constexpr STATICCALL = PatternGenerator{}; static auto constexpr RETURN = PatternGenerator{}; static auto constexpr DELEGATECALL = PatternGenerator{}; static auto constexpr CREATE2 = PatternGenerator{}; static auto constexpr REVERT = PatternGenerator{}; static auto constexpr INVALID = PatternGenerator{}; static auto constexpr SELFDESTRUCT = PatternGenerator{}; }; }