Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
N
nebula
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
exchain
nebula
Commits
0d0f69d5
Unverified
Commit
0d0f69d5
authored
Dec 17, 2024
by
Inphi
Committed by
GitHub
Dec 17, 2024
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
cannon: Implement bltzal in the onchain MIPS64 FPVM (#13429)
parent
68f77aaa
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
18 additions
and
4 deletions
+18
-4
evm_common64_test.go
cannon/mipsevm/tests/evm_common64_test.go
+9
-0
semver-lock.json
packages/contracts-bedrock/snapshots/semver-lock.json
+2
-2
MIPS64.sol
packages/contracts-bedrock/src/cannon/MIPS64.sol
+2
-2
MIPS64Instructions.sol
...racts-bedrock/src/cannon/libraries/MIPS64Instructions.sol
+5
-0
No files found.
cannon/mipsevm/tests/evm_common64_test.go
View file @
0d0f69d5
...
@@ -484,6 +484,15 @@ func TestEVM_SingleStep_Branch64(t *testing.T) {
...
@@ -484,6 +484,15 @@ func TestEVM_SingleStep_Branch64(t *testing.T) {
{
name
:
"bltz sign-extended offset"
,
pc
:
0x10
,
opcode
:
0x1
,
regimm
:
0x0
,
rs
:
-
1
,
offset
:
0x80
_00
,
expectNextPC
:
0xFF
_FF_FF_FF_FF_FE_00_14
},
{
name
:
"bltz sign-extended offset"
,
pc
:
0x10
,
opcode
:
0x1
,
regimm
:
0x0
,
rs
:
-
1
,
offset
:
0x80
_00
,
expectNextPC
:
0xFF
_FF_FF_FF_FF_FE_00_14
},
{
name
:
"bltz large offset no-sign"
,
pc
:
0x10
,
opcode
:
0x1
,
regimm
:
0x0
,
rs
:
-
1
,
offset
:
0x7F
_FF
,
expectNextPC
:
0x2
_00_10
},
{
name
:
"bltz large offset no-sign"
,
pc
:
0x10
,
opcode
:
0x1
,
regimm
:
0x0
,
rs
:
-
1
,
offset
:
0x7F
_FF
,
expectNextPC
:
0x2
_00_10
},
// bltzal t0, $x
{
name
:
"bltzal"
,
pc
:
0
,
opcode
:
0x1
,
regimm
:
0x10
,
rs
:
0x5
,
offset
:
0x100
,
expectNextPC
:
0x8
,
expectLink
:
true
},
{
name
:
"bltzal large rs"
,
pc
:
0x10
,
opcode
:
0x1
,
regimm
:
0x10
,
rs
:
0x7F
_FF_FF_FF_FF_FF_FF_FF
,
offset
:
0x100
,
expectNextPC
:
0x18
,
expectLink
:
true
},
{
name
:
"bltzal zero rs"
,
pc
:
0x10
,
opcode
:
0x1
,
regimm
:
0x10
,
rs
:
0x0
,
offset
:
0x100
,
expectNextPC
:
0x18
,
expectLink
:
true
},
{
name
:
"bltzal sign rs"
,
pc
:
0x10
,
opcode
:
0x1
,
regimm
:
0x10
,
rs
:
-
1
,
offset
:
0x100
,
expectNextPC
:
0x414
,
expectLink
:
true
},
{
name
:
"bltzal rs only sign bit set"
,
pc
:
0x10
,
opcode
:
0x1
,
regimm
:
0x10
,
rs
:
testutil
.
ToSignedInteger
(
0x80
_00_00_00_00_00_00_00
),
offset
:
0x100
,
expectNextPC
:
0x414
,
expectLink
:
true
},
{
name
:
"bltzal sign-extended offset"
,
pc
:
0x10
,
opcode
:
0x1
,
regimm
:
0x10
,
rs
:
-
1
,
offset
:
0x80
_00
,
expectNextPC
:
0xFF
_FF_FF_FF_FF_FE_00_14
,
expectLink
:
true
},
{
name
:
"bltzal large offset no-sign"
,
pc
:
0x10
,
opcode
:
0x1
,
regimm
:
0x10
,
rs
:
-
1
,
offset
:
0x7F
_FF
,
expectNextPC
:
0x2
_00_10
,
expectLink
:
true
},
// bgez t0, $x
// bgez t0, $x
{
name
:
"bgez"
,
pc
:
0
,
opcode
:
0x1
,
regimm
:
0x1
,
rs
:
0x5
,
offset
:
0x100
,
expectNextPC
:
0x404
},
{
name
:
"bgez"
,
pc
:
0
,
opcode
:
0x1
,
regimm
:
0x1
,
rs
:
0x5
,
offset
:
0x100
,
expectNextPC
:
0x404
},
{
name
:
"bgez large rs"
,
pc
:
0x10
,
opcode
:
0x1
,
regimm
:
0x1
,
rs
:
0x7F
_FF_FF_FF_FF_FF_FF_FF
,
offset
:
0x100
,
expectNextPC
:
0x414
},
{
name
:
"bgez large rs"
,
pc
:
0x10
,
opcode
:
0x1
,
regimm
:
0x1
,
rs
:
0x7F
_FF_FF_FF_FF_FF_FF_FF
,
offset
:
0x100
,
expectNextPC
:
0x414
},
...
...
packages/contracts-bedrock/snapshots/semver-lock.json
View file @
0d0f69d5
...
@@ -144,8 +144,8 @@
...
@@ -144,8 +144,8 @@
"sourceCodeHash"
:
"0x8da8be0b7d60af0eb11bd58653f1854d56a8f0616f3aeaeba7ab9ec340d02ac7"
"sourceCodeHash"
:
"0x8da8be0b7d60af0eb11bd58653f1854d56a8f0616f3aeaeba7ab9ec340d02ac7"
},
},
"src/cannon/MIPS64.sol"
:
{
"src/cannon/MIPS64.sol"
:
{
"initCodeHash"
:
"0x
6516160f35a85abb65d8102fa71f03cb57518787f9af85bc951f27ee60e6bb8f
"
,
"initCodeHash"
:
"0x
def0bd64af2541644e1fba56cb443650749dee201a38053c02464584f2e806a9
"
,
"sourceCodeHash"
:
"0x
d0802842e5656639f33324ed6498c60013e6d9cd63c9f097090da9a0a61700a4
"
"sourceCodeHash"
:
"0x
16b46d17dff5b772675bdd280dddea482e85c707a8779694f10cc78b05de871d
"
},
},
"src/cannon/PreimageOracle.sol"
:
{
"src/cannon/PreimageOracle.sol"
:
{
"initCodeHash"
:
"0xf08736a5af9277a4f3498dfee84a40c9b05f1a2ba3177459bebe2b0b54f99343"
,
"initCodeHash"
:
"0xf08736a5af9277a4f3498dfee84a40c9b05f1a2ba3177459bebe2b0b54f99343"
,
...
...
packages/contracts-bedrock/src/cannon/MIPS64.sol
View file @
0d0f69d5
...
@@ -67,8 +67,8 @@ contract MIPS64 is ISemver {
...
@@ -67,8 +67,8 @@ contract MIPS64 is ISemver {
}
}
/// @notice The semantic version of the MIPS64 contract.
/// @notice The semantic version of the MIPS64 contract.
/// @custom:semver 1.0.0-beta.
7
/// @custom:semver 1.0.0-beta.
8
string public constant version = "1.0.0-beta.
7
";
string public constant version = "1.0.0-beta.
8
";
/// @notice The preimage oracle contract.
/// @notice The preimage oracle contract.
IPreimageOracle internal immutable ORACLE;
IPreimageOracle internal immutable ORACLE;
...
...
packages/contracts-bedrock/src/cannon/libraries/MIPS64Instructions.sol
View file @
0d0f69d5
...
@@ -644,6 +644,11 @@ library MIPS64Instructions {
...
@@ -644,6 +644,11 @@ library MIPS64Instructions {
if (rtv == 0) {
if (rtv == 0) {
shouldBranch = int64(_rs) < 0;
shouldBranch = int64(_rs) < 0;
}
}
// bltzal
if (rtv == 0x10) {
shouldBranch = int64(_rs) < 0;
_registers[REG_RA] = _cpu.pc + 8; // always set regardless of branch taken
}
if (rtv == 1) {
if (rtv == 1) {
shouldBranch = int64(_rs) >= 0;
shouldBranch = int64(_rs) >= 0;
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment