Use name prefix for EVM opcode enum items

This commit is contained in:
Paweł Bylica 2018-06-11 17:11:09 +02:00
parent 37cc64f5dc
commit 6f1f961f85
No known key found for this signature in database
GPG Key ID: 7A0C037434FE77EF
2 changed files with 156 additions and 158 deletions

View File

@ -14,159 +14,157 @@ extern "C" {
#endif #endif
/** /**
* The list of EVM 1 instructions from every EVM revision. * The list of EVM 1 opcodes from every EVM revision.
*/ */
enum evmc_instruction enum evmc_opcode
{ {
STOP = 0x00, OP_STOP = 0x00,
ADD, OP_ADD = 0x01,
MUL, OP_MUL = 0x02,
SUB, OP_SUB = 0x03,
DIV, OP_DIV = 0x04,
SDIV, OP_SDIV = 0x05,
MOD, OP_MOD = 0x06,
SMOD, OP_SMOD = 0x07,
ADDMOD, OP_ADDMOD = 0x08,
MULMOD, OP_MULMOD = 0x09,
EXP, OP_EXP = 0x0a,
SIGNEXTEND, OP_SIGNEXTEND = 0x0b,
LT = 0x10, OP_LT = 0x10,
GT, OP_GT = 0x11,
SLT, OP_SLT = 0x12,
SGT, OP_SGT = 0x13,
EQ, OP_EQ = 0x14,
ISZERO, OP_ISZERO = 0x15,
AND, OP_AND = 0x16,
OR, OP_OR = 0x17,
XOR, OP_XOR = 0x18,
NOT, OP_NOT = 0x19,
BYTE, OP_BYTE = 0x1a,
SHL, OP_SHL = 0x1b,
SHR, OP_SHR = 0x1c,
SAR, OP_SAR = 0x1d,
SHA3 = 0x20, OP_SHA3 = 0x20,
ADDRESS = 0x30, OP_ADDRESS = 0x30,
BALANCE, OP_BALANCE = 0x31,
ORIGIN, OP_ORIGIN = 0x32,
CALLER, OP_CALLER = 0x33,
CALLVALUE, OP_CALLVALUE = 0x34,
CALLDATALOAD, OP_CALLDATALOAD = 0x35,
CALLDATASIZE, OP_CALLDATASIZE = 0x36,
CALLDATACOPY, OP_CALLDATACOPY = 0x37,
CODESIZE, OP_CODESIZE = 0x38,
CODECOPY, OP_CODECOPY = 0x39,
GASPRICE, OP_GASPRICE = 0x3a,
EXTCODESIZE, OP_EXTCODESIZE = 0x3b,
EXTCODECOPY, OP_EXTCODECOPY = 0x3c,
RETURNDATASIZE = 0x3d, OP_RETURNDATASIZE = 0x3d,
RETURNDATACOPY = 0x3e, OP_RETURNDATACOPY = 0x3e,
BLOCKHASH = 0x40, OP_BLOCKHASH = 0x40,
COINBASE, OP_COINBASE = 0x41,
TIMESTAMP, OP_TIMESTAMP = 0x42,
NUMBER, OP_NUMBER = 0x43,
DIFFICULTY, OP_DIFFICULTY = 0x44,
GASLIMIT, OP_GASLIMIT = 0x45,
POP = 0x50, OP_POP = 0x50,
MLOAD, OP_MLOAD = 0x51,
MSTORE, OP_MSTORE = 0x52,
MSTORE8, OP_MSTORE8 = 0x53,
SLOAD, OP_SLOAD = 0x54,
SSTORE, OP_SSTORE = 0x55,
JUMP, OP_JUMP = 0x56,
JUMPI, OP_JUMPI = 0x57,
PC, OP_PC = 0x58,
MSIZE, OP_MSIZE = 0x59,
GAS, OP_GAS = 0x5a,
JUMPDEST, OP_JUMPDEST = 0x5b,
PUSH1 = 0x60, OP_PUSH1 = 0x60,
PUSH2, OP_PUSH2 = 0x61,
PUSH3, OP_PUSH3 = 0x62,
PUSH4, OP_PUSH4 = 0x63,
PUSH5, OP_PUSH5 = 0x64,
PUSH6, OP_PUSH6 = 0x65,
PUSH7, OP_PUSH7 = 0x66,
PUSH8, OP_PUSH8 = 0x67,
PUSH9, OP_PUSH9 = 0x68,
PUSH10, OP_PUSH10 = 0x69,
PUSH11, OP_PUSH11 = 0x6a,
PUSH12, OP_PUSH12 = 0x6b,
PUSH13, OP_PUSH13 = 0x6c,
PUSH14, OP_PUSH14 = 0x6d,
PUSH15, OP_PUSH15 = 0x6e,
PUSH16, OP_PUSH16 = 0x6f,
PUSH17, OP_PUSH17 = 0x70,
PUSH18, OP_PUSH18 = 0x71,
PUSH19, OP_PUSH19 = 0x72,
PUSH20, OP_PUSH20 = 0x73,
PUSH21, OP_PUSH21 = 0x74,
PUSH22, OP_PUSH22 = 0x75,
PUSH23, OP_PUSH23 = 0x76,
PUSH24, OP_PUSH24 = 0x77,
PUSH25, OP_PUSH25 = 0x78,
PUSH26, OP_PUSH26 = 0x79,
PUSH27, OP_PUSH27 = 0x7a,
PUSH28, OP_PUSH28 = 0x7b,
PUSH29, OP_PUSH29 = 0x7c,
PUSH30, OP_PUSH30 = 0x7d,
PUSH31, OP_PUSH31 = 0x7e,
PUSH32, OP_PUSH32 = 0x7f,
OP_DUP1 = 0x80,
OP_DUP2 = 0x81,
OP_DUP3 = 0x82,
OP_DUP4 = 0x83,
OP_DUP5 = 0x84,
OP_DUP6 = 0x85,
OP_DUP7 = 0x86,
OP_DUP8 = 0x87,
OP_DUP9 = 0x88,
OP_DUP10 = 0x89,
OP_DUP11 = 0x8a,
OP_DUP12 = 0x8b,
OP_DUP13 = 0x8c,
OP_DUP14 = 0x8d,
OP_DUP15 = 0x8e,
OP_DUP16 = 0x8f,
OP_SWAP1 = 0x90,
OP_SWAP2 = 0x91,
OP_SWAP3 = 0x92,
OP_SWAP4 = 0x93,
OP_SWAP5 = 0x94,
OP_SWAP6 = 0x95,
OP_SWAP7 = 0x96,
OP_SWAP8 = 0x97,
OP_SWAP9 = 0x98,
OP_SWAP10 = 0x99,
OP_SWAP11 = 0x9a,
OP_SWAP12 = 0x9b,
OP_SWAP13 = 0x9c,
OP_SWAP14 = 0x9d,
OP_SWAP15 = 0x9e,
OP_SWAP16 = 0x9f,
OP_LOG0 = 0xa0,
OP_LOG1 = 0xa1,
OP_LOG2 = 0xa2,
OP_LOG3 = 0xa3,
OP_LOG4 = 0xa4,
DUP1 = 0x80, OP_CREATE = 0xf0,
DUP2, OP_CALL = 0xf1,
DUP3, OP_CALLCODE = 0xf2,
DUP4, OP_RETURN = 0xf3,
DUP5, OP_DELEGATECALL = 0xf4,
DUP6,
DUP7,
DUP8,
DUP9,
DUP10,
DUP11,
DUP12,
DUP13,
DUP14,
DUP15,
DUP16,
SWAP1 = 0x90, OP_STATICCALL = 0xfa,
SWAP2,
SWAP3,
SWAP4,
SWAP5,
SWAP6,
SWAP7,
SWAP8,
SWAP9,
SWAP10,
SWAP11,
SWAP12,
SWAP13,
SWAP14,
SWAP15,
SWAP16,
LOG0 = 0xa0, OP_REVERT = 0xfd,
LOG1, OP_INVALID = 0xfe,
LOG2, OP_SELFDESTRUCT = 0xff,
LOG3,
LOG4,
CREATE = 0xf0,
CALL,
CALLCODE,
RETURN,
DELEGATECALL,
STATICCALL = 0xfa,
REVERT = 0xfd,
INVALID = 0xfe,
SELFDESTRUCT = 0xff,
}; };
/** /**

View File

@ -11,27 +11,27 @@ TEST(instructions, tangerine_whistle_hard_fork)
const auto h = evmc_get_instruction_metrics_table(EVMC_HOMESTEAD); const auto h = evmc_get_instruction_metrics_table(EVMC_HOMESTEAD);
const auto tw = evmc_get_instruction_metrics_table(EVMC_TANGERINE_WHISTLE); const auto tw = evmc_get_instruction_metrics_table(EVMC_TANGERINE_WHISTLE);
EXPECT_EQ(h[EXTCODESIZE].gas_cost, 20); EXPECT_EQ(h[OP_EXTCODESIZE].gas_cost, 20);
EXPECT_EQ(tw[EXTCODESIZE].gas_cost, 700); EXPECT_EQ(tw[OP_EXTCODESIZE].gas_cost, 700);
EXPECT_EQ(h[EXTCODECOPY].gas_cost, 20); EXPECT_EQ(h[OP_EXTCODECOPY].gas_cost, 20);
EXPECT_EQ(tw[EXTCODECOPY].gas_cost, 700); EXPECT_EQ(tw[OP_EXTCODECOPY].gas_cost, 700);
EXPECT_EQ(h[BALANCE].gas_cost, 20); EXPECT_EQ(h[OP_BALANCE].gas_cost, 20);
EXPECT_EQ(tw[BALANCE].gas_cost, 400); EXPECT_EQ(tw[OP_BALANCE].gas_cost, 400);
EXPECT_EQ(h[SLOAD].gas_cost, 50); EXPECT_EQ(h[OP_SLOAD].gas_cost, 50);
EXPECT_EQ(tw[SLOAD].gas_cost, 200); EXPECT_EQ(tw[OP_SLOAD].gas_cost, 200);
EXPECT_EQ(h[CALL].gas_cost, 40); EXPECT_EQ(h[OP_CALL].gas_cost, 40);
EXPECT_EQ(tw[CALL].gas_cost, 700); EXPECT_EQ(tw[OP_CALL].gas_cost, 700);
EXPECT_EQ(h[CALLCODE].gas_cost, 40); EXPECT_EQ(h[OP_CALLCODE].gas_cost, 40);
EXPECT_EQ(tw[CALLCODE].gas_cost, 700); EXPECT_EQ(tw[OP_CALLCODE].gas_cost, 700);
EXPECT_EQ(h[DELEGATECALL].gas_cost, 40); EXPECT_EQ(h[OP_DELEGATECALL].gas_cost, 40);
EXPECT_EQ(tw[DELEGATECALL].gas_cost, 700); EXPECT_EQ(tw[OP_DELEGATECALL].gas_cost, 700);
EXPECT_EQ(h[SELFDESTRUCT].gas_cost, 0); EXPECT_EQ(h[OP_SELFDESTRUCT].gas_cost, 0);
EXPECT_EQ(tw[SELFDESTRUCT].gas_cost, 5000); EXPECT_EQ(tw[OP_SELFDESTRUCT].gas_cost, 5000);
} }