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
73094cb3
Unverified
Commit
73094cb3
authored
Oct 28, 2024
by
Inphi
Committed by
GitHub
Oct 28, 2024
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
cannon: Implement bltzal (#12594)
parent
2cf297da
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
28 additions
and
8 deletions
+28
-8
README.md
cannon/mipsevm/README.md
+1
-0
mips_instructions.go
cannon/mipsevm/exec/mips_instructions.go
+5
-0
evm_common_test.go
cannon/mipsevm/tests/evm_common_test.go
+9
-0
semver-lock.json
packages/contracts-bedrock/semver-lock.json
+4
-4
MIPS.sol
packages/contracts-bedrock/src/cannon/MIPS.sol
+2
-2
MIPS2.sol
packages/contracts-bedrock/src/cannon/MIPS2.sol
+2
-2
MIPSInstructions.sol
...ntracts-bedrock/src/cannon/libraries/MIPSInstructions.sol
+5
-0
No files found.
cannon/mipsevm/README.md
View file @
73094cb3
...
...
@@ -15,6 +15,7 @@ Supported 63 instructions:
|
`Conditional Branch`
|
`bgezal`
| Branch and link on greater than or equal to zero. |
|
`Conditional Branch`
|
`blez`
| Branch on less than or equal to zero. |
|
`Conditional Branch`
|
`bltz`
| Branch on less than zero. |
|
`Conditional Branch`
|
`bltzal`
| Branch and link on less than zero. |
|
`Conditional Branch`
|
`bne`
| Branch on not equal. |
|
`Logical`
|
`clo`
| Count leading ones. |
|
`Logical`
|
`clz`
| Count leading zeros. |
...
...
cannon/mipsevm/exec/mips_instructions.go
View file @
73094cb3
...
...
@@ -486,6 +486,11 @@ func HandleBranch(cpu *mipsevm.CpuScalars, registers *[32]Word, opcode uint32, i
if
rtv
==
0
{
// bltz
shouldBranch
=
arch
.
SignedInteger
(
rs
)
<
0
}
if
rtv
==
0x10
{
// bltzal
shouldBranch
=
arch
.
SignedInteger
(
rs
)
<
0
registers
[
31
]
=
cpu
.
PC
+
8
// always set regardless of branch taken
linked
=
true
}
if
rtv
==
1
{
// bgez
shouldBranch
=
arch
.
SignedInteger
(
rs
)
>=
0
}
...
...
cannon/mipsevm/tests/evm_common_test.go
View file @
73094cb3
...
...
@@ -1032,6 +1032,15 @@ func TestEVMSingleStepBranch(t *testing.T) {
{
name
:
"bltz sign-extended offset"
,
pc
:
0x10
,
opcode
:
0x1
,
regimm
:
0x0
,
rs
:
-
1
,
offset
:
0x80
_00
,
expectNextPC
:
0xFF
_FE_00_14
},
{
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
,
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
),
offset
:
0x100
,
expectNextPC
:
0x414
,
expectLink
:
true
},
{
name
:
"bltzal sign-extended offset"
,
pc
:
0x10
,
opcode
:
0x1
,
regimm
:
0x10
,
rs
:
-
1
,
offset
:
0x80
_00
,
expectNextPC
:
0xFF
_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
{
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
,
offset
:
0x100
,
expectNextPC
:
0x414
},
...
...
packages/contracts-bedrock/semver-lock.json
View file @
73094cb3
...
...
@@ -140,12 +140,12 @@
"sourceCodeHash"
:
"0x0fa0633a769e73f5937514c0003ba7947a1c275bbe5b85d78879c42f0ed8895b"
},
"src/cannon/MIPS.sol"
:
{
"initCodeHash"
:
"0x
94f2e8f7818a990c009cccb501216a7f6df29b05d8f178cfff10a40288bf588e
"
,
"sourceCodeHash"
:
"0x
786d4947488a771a426cc38de307ae99b2c2af1efca38b7655c60be7c019371f
"
"initCodeHash"
:
"0x
a3cbf121bad13c00227ea4fef128853d9a86b7ec9158de894f99b58d38d7630a
"
,
"sourceCodeHash"
:
"0x
d8467700c80b3e62fa37193dc6513bac35282094b686b50e162e157f704dde00
"
},
"src/cannon/MIPS2.sol"
:
{
"initCodeHash"
:
"0x
3744036fa240c7d57f39307c0bf27cb7027d05d6b4f52142d5122b6e538ee0b2
"
,
"sourceCodeHash"
:
"0x
5f79a0f99a288d570df243ea9560e67a319d1685b3209ae457fc714a76ff2908
"
"initCodeHash"
:
"0x
478fdad3eccd158822ce2025971a9242c37c976024f419fba417fe54158269b7
"
,
"sourceCodeHash"
:
"0x
81dc3329c1644afa30ecd2684f44f8b96b5a17612dcfa6476432eed697209e63
"
},
"src/cannon/PreimageOracle.sol"
:
{
"initCodeHash"
:
"0x5d7e8ae64f802bd9d760e3d52c0a620bd02405dc2c8795818db9183792ffe81c"
,
...
...
packages/contracts-bedrock/src/cannon/MIPS.sol
View file @
73094cb3
...
...
@@ -44,8 +44,8 @@ contract MIPS is ISemver {
}
/// @notice The semantic version of the MIPS contract.
/// @custom:semver 1.2.1-beta.
6
string public constant version = "1.2.1-beta.
6
";
/// @custom:semver 1.2.1-beta.
7
string public constant version = "1.2.1-beta.
7
";
/// @notice The preimage oracle contract.
IPreimageOracle internal immutable ORACLE;
...
...
packages/contracts-bedrock/src/cannon/MIPS2.sol
View file @
73094cb3
...
...
@@ -60,8 +60,8 @@ contract MIPS2 is ISemver {
}
/// @notice The semantic version of the MIPS2 contract.
/// @custom:semver 1.0.0-beta.
19
string public constant version = "1.0.0-beta.
19
";
/// @custom:semver 1.0.0-beta.
20
string public constant version = "1.0.0-beta.
20
";
/// @notice The preimage oracle contract.
IPreimageOracle internal immutable ORACLE;
...
...
packages/contracts-bedrock/src/cannon/libraries/MIPSInstructions.sol
View file @
73094cb3
...
...
@@ -495,6 +495,11 @@ library MIPSInstructions {
if (rtv == 0) {
shouldBranch = int32(_rs) < 0;
}
// bltzal
if (rtv == 0x10) {
shouldBranch = int32(_rs) < 0;
_registers[31] = _cpu.pc + 8; // always set regardless of branch taken
}
if (rtv == 1) {
shouldBranch = int32(_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