Support solc v0.8.31 (#430)

- Support for solc v0.8.31.
- Support for the `clz` Yul builtin.

---------

Signed-off-by: xermicus <cyrill@parity.io>
This commit is contained in:
xermicus
2025-12-05 15:25:13 +01:00
committed by GitHub
parent d0c10e6d5c
commit 11f82c8488
16 changed files with 142 additions and 11 deletions
@@ -0,0 +1,57 @@
// 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
);
}
}