This chapter lists all Yul builtin functions supported by solx and how each is lowered to LLVM IR for the EVM backend.
Yul builtins are lowered through one of three strategies:
Direct LLVM IR : the builtin maps to native LLVM integer or memory operations on i256.
LLVM intrinsic : the builtin maps to an llvm.evm.* intrinsic that the EVM backend expands to opcodes.
Address space access : the builtin maps to a load or store in a typed LLVM address space (see EVM Instructions: Address Space Model ).
Builtin Lowering Notes
addDirect LLVM IR add i256
subDirect LLVM IR sub i256
mulDirect LLVM IR mul i256
divDirect LLVM IR Unsigned; returns 0 when divisor is 0
sdivDirect LLVM IR Signed; returns 0 when divisor is 0
modDirect LLVM IR Unsigned; returns 0 when divisor is 0
smodDirect LLVM IR Signed; returns 0 when divisor is 0
addmodIntrinsic llvm.evm.addmod (x + y) % m without intermediate overflow
mulmodIntrinsic llvm.evm.mulmod (x * y) % m without intermediate overflow
expIntrinsic llvm.evm.exp Exponentiation
signextendIntrinsic llvm.evm.signextend Sign extend from bit (i*8+7)
Builtin Lowering Notes
ltDirect LLVM IR Unsigned less-than
gtDirect LLVM IR Unsigned greater-than
sltDirect LLVM IR Signed less-than
sgtDirect LLVM IR Signed greater-than
eqDirect LLVM IR Equality
iszeroDirect LLVM IR Check if zero
Builtin Lowering Notes
andDirect LLVM IR Bitwise AND
orDirect LLVM IR Bitwise OR
xorDirect LLVM IR Bitwise XOR
notDirect LLVM IR Bitwise NOT
shlDirect LLVM IR Shift left; shift >= 256 yields 0
shrDirect LLVM IR Logical shift right; shift >= 256 yields 0
sarDirect LLVM IR Arithmetic shift right; shift >= 256 yields sign-extended value
byteIntrinsic llvm.evm.byte Extract nth byte
clzIntrinsic llvm.ctlz Count leading zeros (requires Osaka EVM version)
Builtin Lowering Notes
keccak256Intrinsic llvm.evm.sha3 Keccak-256 over memory range
Builtin Lowering Notes
mloadAddress space 1 load Load 32 bytes from heap memory
mstoreAddress space 1 store Store 32 bytes to heap memory
mstore8Intrinsic llvm.evm.mstore8 Store single byte to memory
mcopymemcpy in address space 1 EIP-5656 memory copy
msizeIntrinsic llvm.evm.msize Highest accessed memory index
Memory builtins are subject to LLVM memory optimizations. Operations that do not change memory contents may be removed even when they would have affected gas or msize(). See Optimizer and Assembly Semantics .
Builtin Lowering Notes
sloadAddress space 5 load Load from persistent storage
sstoreAddress space 5 store Store to persistent storage
tloadAddress space 6 load Load from transient storage (EIP-1153)
tstoreAddress space 6 store Store to transient storage (EIP-1153)
Builtin Lowering Notes
loadimmutableIntrinsic llvm.evm.loadimmutable Load immutable value with metadata identifier
setimmutableSpecial Set immutable value during deployment
Builtin Lowering Notes
calldataloadAddress space 2 load Load 32 bytes from calldata
calldatasizeIntrinsic llvm.evm.calldatasize Size of calldata
calldatacopymemcpy from address space 2 to 1 Copy calldata to memory
returndatasizeIntrinsic llvm.evm.returndatasize Size of return data
returndatacopymemcpy from address space 3 to 1 Copy return data to memory
Builtin Lowering Notes
codesizeIntrinsic llvm.evm.codesize Current contract code size
codecopymemcpy from address space 4 to 1 Copy code to memory
extcodesizeIntrinsic llvm.evm.extcodesize External contract code size
extcodecopyIntrinsic llvm.evm.extcodecopy Copy external code to memory
extcodehashIntrinsic llvm.evm.extcodehash Hash of external contract code
Builtin Lowering Notes
datasizeIntrinsic llvm.evm.datasize Size of a named data object
dataoffsetIntrinsic llvm.evm.dataoffset Offset of a named data object
datacopySame as codecopy Copy data to memory
These builtins are used by deploy stubs to reference embedded runtime and dependency objects. See Binary Layout for details.
Builtin Lowering Notes
log0Intrinsic llvm.evm.log0 Log with 0 topics
log1Intrinsic llvm.evm.log1 Log with 1 topic
log2Intrinsic llvm.evm.log2 Log with 2 topics
log3Intrinsic llvm.evm.log3 Log with 3 topics
log4Intrinsic llvm.evm.log4 Log with 4 topics
Builtin Lowering Notes
callIntrinsic llvm.evm.call Call with value transfer
delegatecallIntrinsic llvm.evm.delegatecall Call preserving caller and callvalue
staticcallIntrinsic llvm.evm.staticcall Read-only call
Note: callcode is rejected at compile time. Use delegatecall instead.
Builtin Lowering Notes
createIntrinsic llvm.evm.create Create new contract
create2Intrinsic llvm.evm.create2 Create at deterministic address
Builtin Lowering Notes
returnIntrinsic llvm.evm.return Return data from execution
revertIntrinsic llvm.evm.revert Revert with return data
stopIntrinsic llvm.evm.stop Stop execution
invalidIntrinsic llvm.evm.invalid Invalid instruction (consumes all gas)
Note: selfdestruct is rejected at compile time (deprecated by EIP-6049).
Builtin Lowering Notes
addressIntrinsic llvm.evm.address Current contract address
callerIntrinsic llvm.evm.caller Message sender
callvalueIntrinsic llvm.evm.callvalue Wei sent with call
gasIntrinsic llvm.evm.gas Remaining gas
gaspriceIntrinsic llvm.evm.gasprice Gas price of transaction
balanceIntrinsic llvm.evm.balance Balance of address
selfbalanceIntrinsic llvm.evm.selfbalance Current contract balance
originIntrinsic llvm.evm.origin Transaction sender
Builtin Lowering Notes
blockhashIntrinsic llvm.evm.blockhash Hash of given block
numberIntrinsic llvm.evm.number Current block number
timestampIntrinsic llvm.evm.timestamp Block timestamp
coinbaseIntrinsic llvm.evm.coinbase Block beneficiary
difficultyIntrinsic llvm.evm.difficulty Block difficulty (pre-merge)
prevrandaoIntrinsic llvm.evm.difficulty Previous RANDAO value (EIP-4399, reuses difficulty)
gaslimitIntrinsic llvm.evm.gaslimit Block gas limit
chainidIntrinsic llvm.evm.chainid Chain ID (EIP-1344)
basefeeIntrinsic llvm.evm.basefee Base fee per gas (EIP-1559)
blobhashRejected at compile time Versioned hash of transaction's i-th blob (EIP-4844)
blobbasefeeRejected at compile time Current block's blob base fee (EIP-7516/EIP-4844)
Note: blobhash and blobbasefee are not yet supported and will produce a compile error.
Builtin Lowering Notes
popOptimized away No code generated
linkersymbolIntrinsic llvm.evm.linkersymbol Library linker placeholder
memoryguardSpecial Reserves a memory region; used by solx to configure the spill area for stack-too-deep mitigation