forked from llvm-mirror/llvm
-
Notifications
You must be signed in to change notification settings - Fork 21
Intrinsic Functions
Alan.Li edited this page Sep 2, 2019
·
1 revision
In order to produce EVM-specific instructions, a set of intrinsics must be specified for the frontend to emit so that the EVM backend understands to generate the corresponding instruction. Many of these instructions, in Solidity, are represented by built-in functions. NOTE: The argument ordering in these intrinsics may not fully match the order on which they must be pushed onto the EVM stack. Someone should double check. TODO: Double-check argument and return types as well.
-
Name:
llvm.evm_builtin_sha3
-
Arguments:
-
data: u256be
: byte pointer to buffer to hash -
len: u256be
: length of buffer
-
-
Return:
-
hash: bytes32
: resulting hash
-
-
Codegen details:
- SHA3 opcode:
0x20
- SHA3 opcode:
-
Name:
llvm.evm_builtin_address
- Arguments: None
-
Return:
-
address: bytes20
: Currently executing account
-
-
Codegen details:
- ADDRESS opcode:
0x30
- ADDRESS opcode:
-
Name:
llvm.evm_builtin_balance
-
Arguments:
-
address: bytes20
: Account to check balance of
-
-
Return:
-
balance: u256be
: Balance of given account
-
-
Codegen details:
- BALANCE opcode:
0x31
- BALANCE opcode:
-
Name:
llvm.evm_builtin_origin
- Arguments: None
-
Return:
-
address: bytes20
: Address of TX origin
-
-
Codegen details:
- ORIGIN opcode:
0x32
- ORIGIN opcode:
-
Name:
llvm.evm_builtin_caller
- Arguments: None
-
Return:
-
address: bytes20
: Address of caller
-
-
Codegen details:
- CALLER opcode:
0x33
- CALLER opcode:
-
Name:
llvm.evm_builtin_callvalue
- Arguments: None
-
Return:
-
value: u256be
: TX value sent
-
-
Codegen details:
- CALLVALUE opcode:
0x34
- CALLVALUE opcode:
-
Name:
llvm.evm_builtin_calldataload
-
Arguments:
-
offset: u256be
: Offset within call data buffer to load
-
-
Return:
-
data: bytes32
: 32 bytes of calldata beginning atoffset
-
-
Codegen details:
- CALLDATALOAD opcode:
0x35
- CALLDATALOAD opcode:
-
Name:
llvm.evm_builtin_calldatasize
- Arguments: None
-
Return:
-
size: u256be
: Length of call data buffer
-
-
Codegen details:
- CALLDATASIZE opcode:
0x36
- CALLDATASIZE opcode:
-
Name:
llvm.evm_builtin_calldatacopy
-
Arguments:
-
dst: u256be
: Pointer to destination buffer -
offset: u256be
: Offset within call data to copy -
len: u256be
: Number of bytes to copy beginning atoffset
-
- Return: None
-
Codegen details:
- CALLDATACOPY opcode:
0x37
- CALLDATACOPY opcode:
-
Name:
llvm.evm_builtin_codesize
- Arguments: None
-
Return:
-
size: u256be
: Size of code at currently executing account
-
-
Codegen details:
- CODESIZE opcode:
0x38
- CODESIZE opcode:
-
Name:
llvm.evm_builtin_codecopy
-
Arguments:
-
dst: u256be
: Pointer to destination buffer -
offset: u256be
: Offset within code to copy -
len: u256be
: Number of bytes to copy beginning atoffset
-
- Return: None
-
Codegen details:
- CODECOPY opcode:
0x39
- CODECOPY opcode:
-
Name:
llvm.evm_builtin_gasprice
- Arguments: None
-
Return:
-
price: u256
: Cost of gas in current environment
-
-
Codegen details:
- GASPRICE opcode:
0x3a
- GASPRICE opcode:
-
Name:
llvm.evm_builtin_extcodesize
-
Arguments:
-
address: bytes20
: Address whose code size to check
-
-
Return:
-
size: u256be
: Size of code at given account
-
-
Codegen details:
- EXTCODESIZE opcode:
0x3b
- EXTCODESIZE opcode:
-
Name:
llvm.evm_builtin_extcodecopy
-
Arguments:
-
address: bytes20
Address whose code to copy -
dst: u256be
: Pointer to destination buffer -
offset: u256be
: Offset within code to copy -
len: u256be
: Number of bytes to copy beginning atoffset
-
- Return: None
-
Codegen details:
- EXTCODECOPY opcode:
0x3C
- EXTCODECOPY opcode:
-
Name:
llvm.evm_builtin_returndatasize
- Arguments: None
-
Return:
-
size: u256be
: Size of return data buffer from last call
-
-
Codegen details:
- RETURNDATASIZE opcode:
0x3d
- RETURNDATASIZE opcode:
-
Name:
llvm.evm_builtin_returndatacopy
-
Arguments:
-
dst: u256be
: Pointer to destination buffer -
offset: u256be
: Offset within return buffer to copy -
len: u256be
: Number of bytes to copy beginning atoffset
-
- Return: None
-
Codegen details:
- RETURNDATACOPY opcode:
0x3e
- RETURNDATACOPY opcode:
-
Name:
llvm.evm_builtin_blockhash
-
Arguments:
-
age: u256be
: The age of the block, between 0 and 256 blocks old
-
-
Return:
-
hash: bytes32
: The hash of the requested block
-
-
Codegen details:
- BLOCKHASH opcode:
0x40
- BLOCKHASH opcode:
-
Name:
llvm.evm_builtin_coinbase
- Arguments: None
-
Return:
-
beneficiary: bytes20
: Current mining beneficiary
-
-
Codegen details:
- COINBASE opcode:
0x41
- COINBASE opcode:
-
Name:
llvm.evm_builtin_timestamp
- Arguments: None
-
Return:
-
stamp: u256be
: Timestamp of last block
-
-
Codegen details:
- TIMESTAMP opcode:
0x42
- TIMESTAMP opcode:
-
Name:
llvm.evm_builtin_blocknumber
- Arguments: None
-
Return:
-
blknum: u256be
: Current block number
-
-
Codegen details:
- NUMBER opcode:
0x43
- NUMBER opcode:
-
Name:
llvm.evm_builtin_difficulty
- Arguments: None
-
Return:
-
difficulty: u256be
: Current block difficulty
-
-
Codegen details:
- DIFFICULTY opcode:
0x44
- DIFFICULTY opcode:
-
Name:
llvm.evm_builtin_gaslimit
- Arguments: None
-
Return:
-
limit: u256be
: Block gas limit //NOTE: check type again
-
-
Codegen details:
- GASLIMIT opcode:
0x45
- GASLIMIT opcode:
-
Name:
llvm.evm_builtin_sload
-
Arguments:
-
key: u256be
: Storage key to access
-
-
Return:
-
value: u256be
: Storage value at key
-
-
Codegen details:
- SLOAD opcode:
0x54
- SLOAD opcode:
-
Name:
llvm.evm_builtin_sstore
-
Arguments:
-
key: u256be
: Storage key to writevalue
-
value: u256be
: Value to write
-
- Return: None
-
Codegen details:
- SSTORE opcode:
0x55
- SSTORE opcode:
-
Name:
llvm.evm_builtin_msize
- Arguments: None
-
Return:
-
size: u256be
: Size of active memory in bytes
-
-
Codegen details:
- MSIZE opcode:
0x59
- MSIZE opcode:
-
Name:
llvm.evm_builtin_gas
- Arguments: None
-
Return:
-
gasleft: u256be
: Amount of gas left in current execution
-
-
Name:
llvm.evm_builtin_log0
-
Arguments:
-
data: u256be
: Pointer to log data buffer -
len: u256be
: Size of log data buffer in bytes
-
- Return: None
-
Codegen details:
- LOG0 opcode:
0xa0
- LOG0 opcode:
-
Name:
llvm.evm_builtin_log0
-
Arguments:
-
data: u256be
: Pointer to log data buffer -
len: u256be
: Size of log data buffer in bytes -
topic1: u256be
: Log topic 1
-
- Return: None
-
Codegen details:
- LOG1 opcode:
0xa1
- LOG1 opcode:
-
Name:
llvm.evm_builtin_log2
-
Arguments:
-
data: u256be
: Pointer to log data buffer -
len: u256be
: Size of log data buffer in bytes -
topic1: u256be
: Log topic 1 -
topic2: u256be
: Log topic 2
-
- Return: None
-
Codegen details:
- LOG2 opcode:
0xa2
- LOG2 opcode:
-
Name:
llvm.evm_builtin_log3
-
Arguments:
-
data: u256be
: Pointer to log data buffer -
len: u256be
: Size of log data buffer in bytes -
topic1: u256be
: Log topic 1 -
topic2: u256be
: Log topic 2 -
topic3: u256be
: Log topic 3
-
- Return: None
-
Codegen details:
- LOG3 opcode:
0xa3
- LOG3 opcode:
-
Name:
llvm.evm_builtin_log4
-
Arguments:
-
data: u256be
: Pointer to log data buffer -
len: u256be
: Size of log data buffer in bytes -
topic1: u256be
: Log topic 1 -
topic2: u256be
: Log topic 2 -
topic3: u256be
: Log topic 3 -
topic4: u256be
: Log topic 4
-
- Return: None
-
Codegen details:
- LOG4 opcode:
0xa4
- LOG4 opcode:
-
Name:
llvm.evm_builtin_create
-
Arguments:
-
value: u256be
: Value in wei sent to new contract -
code: u256be
: Pointer to code buffer for new contract -
len: u256be
: Code buffer length
-
-
Return:
-
addr: bytes20
: Address of newly created contract
-
-
Codegen details:
- CREATE opcode:
0xf0
- CREATE opcode:
-
Name:
llvm.evm_builtin_create2
-
Arguments:
-
value: u256be
: Value in wei sent to new contract -
code: u256be
: Pointer to code buffer for new contract -
len: u256be
: Code buffer length -
salt: bytes32
: Salt for address creation
-
-
Return:
-
addr: bytes20
: Address of newly created contract
-
-
Codegen details:
- CREATE2 opcode:
0xf5
- CREATE2 opcode:
-
Name:
llvm.evm_builtin_call
-
Arguments:
-
gas: u256be
: Gas allowance for call -
address: bytes20
: Call destination address -
value: u256be
: Wei value sent with call -
input: u256be
: Input data pointer -
inputlen: u256be
: Input data buffer size -
output: u256be
: Output buffer pointer -
outputlen: u256be
: Output data buffer size
-
-
Return:
-
return: u256be
: Exit code
-
-
Codegen details:
- CALL opcode:
0xf1
- CALL opcode:
-
Name:
llvm.evm_builtin_callcode
-
Arguments:
-
gas: u256be
: Gas allowance for call -
address: bytes20
: Address of code to use -
value: u256be
: Wei value sent with call -
input: u256be
: Input data pointer -
inputlen: u256be
: Input data buffer size -
output: u256be
: Output buffer pointer -
outputlen: u256be
: Output data buffer size
-
-
Return:
-
return: u256be
: Exit code
-
-
Codegen details:
- CALL opcode:
0xf2
- CALL opcode:
-
Name:
llvm.evm_builtin_calldelegate
-
Arguments:
-
gas: u256be
: Gas allowance for call -
address: bytes20
: Address of code to use -
input: u256be
: Input data pointer -
inputlen: u256be
: Input data buffer size -
output: u256be
: Output buffer pointer -
outputlen: u256be
: Output data buffer size
-
-
Return:
-
return: u256be
: Exit code
-
-
Codegen details:
- CALLDELEGATE opcode:
0xf4
- CALLDELEGATE opcode:
-
Name:
llvm.evm_builtin_staticcall
-
Arguments:
-
gas: u256be
: Gas allowance for call -
address: bytes20
: Call destination address -
input: u256be
: Input data pointer -
inputlen: u256be
: Input data buffer size -
output: u256be
: Output buffer pointer -
outputlen: u256be
: Output data buffer size
-
-
Codegen details:
- STATICCALL opcode:
0xfa
- STATICCALL opcode:
-
Name:
llvm.evm_builtin_return
-
Arguments:
-
data: u256be
: Return data pointer -
len: u256be
: Return buffer size
-
- Return: Ends execution
-
Codegen details:
- RETURN opcode:
0xf3
- RETURN opcode:
-
Name:
llvm.evm_builtin_revert
-
Arguments:
-
data: u256be
: Return data pointer -
len: u256be
: Return buffer size
-
- Return: Ends execution
-
Codegen details
- REVERT opcode:
0xfd
- REVERT opcode:
-
Name:
llvm.evm_builtin_selfdestruct
-
Arguments:
-
beneficiary: bytes20
: Address to send funds to
-
- Return: Ends execution
-
Codegen details:
- SELFDESTRUCT opcode:
0xff
- SELFDESTRUCT opcode: