mirror of
https://github.com/pezkuwichain/revive.git
synced 2026-04-22 02:07:55 +00:00
11f82c8488
- Support for solc v0.8.31. - Support for the `clz` Yul builtin. --------- Signed-off-by: xermicus <cyrill@parity.io>
58 lines
1.8 KiB
Solidity
58 lines
1.8 KiB
Solidity
// SPDX-License-Identifier: MIT
|
|
|
|
pragma solidity ^0.8.31;
|
|
|
|
/* runner.json
|
|
{
|
|
"differential": true,
|
|
"actions": [
|
|
{
|
|
"Instantiate": {
|
|
"code": {
|
|
"Solidity": {
|
|
"contract": "CountLeadingZeros"
|
|
}
|
|
}
|
|
}
|
|
}
|
|
]
|
|
}
|
|
*/
|
|
|
|
/// The EIP-7939 test vectors:
|
|
/// https://eips.ethereum.org/EIPS/eip-7939#test-cases
|
|
contract CountLeadingZeros {
|
|
function clz(uint256 x) internal pure returns (uint256 r) {
|
|
assembly {
|
|
r := clz(x)
|
|
}
|
|
}
|
|
|
|
constructor() payable {
|
|
assert(
|
|
clz(0x000000000000000000000000000000000000000000000000000000000000000)
|
|
== 0x0000000000000000000000000000000000000000000000000000000000000100
|
|
);
|
|
assert(
|
|
clz(0x8000000000000000000000000000000000000000000000000000000000000000)
|
|
== 0x0000000000000000000000000000000000000000000000000000000000000000
|
|
);
|
|
assert(
|
|
clz(0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff)
|
|
== 0x0000000000000000000000000000000000000000000000000000000000000000
|
|
);
|
|
assert(
|
|
clz(0x4000000000000000000000000000000000000000000000000000000000000000)
|
|
== 0x0000000000000000000000000000000000000000000000000000000000000001
|
|
);
|
|
assert(
|
|
clz(0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff)
|
|
== 0x0000000000000000000000000000000000000000000000000000000000000001
|
|
);
|
|
assert(
|
|
clz(0x0000000000000000000000000000000000000000000000000000000000000001)
|
|
== 0x00000000000000000000000000000000000000000000000000000000000000ff
|
|
);
|
|
}
|
|
}
|