Skip to content

Commit 8355a95

Browse files
authored
Merge pull request #119 from ethereum-optimism/tei/audit-16
Rename toU64(), toU256() for consistency with other functions
2 parents 3f1f5fc + 429e8cd commit 8355a95

File tree

6 files changed

+410
-410
lines changed

6 files changed

+410
-410
lines changed

rvgo/fast/parse.go

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -4,74 +4,74 @@ package fast
44
// These should 1:1 match with the same definitions in the slow package.
55

66
func parseImmTypeI(instr U64) U64 {
7-
return signExtend64(shr64(toU64(20), instr), toU64(11))
7+
return signExtend64(shr64(byteToU64(20), instr), byteToU64(11))
88
}
99

1010
func parseImmTypeS(instr U64) U64 {
1111
return signExtend64(
1212
or64(
13-
shl64(toU64(5), shr64(toU64(25), instr)),
14-
and64(shr64(toU64(7), instr), toU64(0x1F)),
13+
shl64(byteToU64(5), shr64(byteToU64(25), instr)),
14+
and64(shr64(byteToU64(7), instr), byteToU64(0x1F)),
1515
),
16-
toU64(11))
16+
byteToU64(11))
1717
}
1818

1919
func parseImmTypeB(instr U64) U64 {
2020
return signExtend64(
2121
or64(
2222
or64(
23-
shl64(toU64(1), and64(shr64(toU64(8), instr), toU64(0xF))),
24-
shl64(toU64(5), and64(shr64(toU64(25), instr), toU64(0x3F))),
23+
shl64(byteToU64(1), and64(shr64(byteToU64(8), instr), byteToU64(0xF))),
24+
shl64(byteToU64(5), and64(shr64(byteToU64(25), instr), byteToU64(0x3F))),
2525
),
2626
or64(
27-
shl64(toU64(11), and64(shr64(toU64(7), instr), toU64(1))),
28-
shl64(toU64(12), shr64(toU64(31), instr)),
27+
shl64(byteToU64(11), and64(shr64(byteToU64(7), instr), byteToU64(1))),
28+
shl64(byteToU64(12), shr64(byteToU64(31), instr)),
2929
),
3030
),
31-
toU64(12),
31+
byteToU64(12),
3232
)
3333
}
3434

3535
func parseImmTypeU(instr U64) U64 {
36-
return signExtend64(shr64(toU64(12), instr), toU64(19))
36+
return signExtend64(shr64(byteToU64(12), instr), byteToU64(19))
3737
}
3838

3939
func parseImmTypeJ(instr U64) U64 {
4040
return signExtend64(
4141
or64(
4242
or64(
43-
and64(shr64(toU64(21), instr), shortToU64(0x3FF)), // 10 bits for index 0:9
44-
shl64(toU64(10), and64(shr64(toU64(20), instr), toU64(1))), // 1 bit for index 10
43+
and64(shr64(byteToU64(21), instr), shortToU64(0x3FF)), // 10 bits for index 0:9
44+
shl64(byteToU64(10), and64(shr64(byteToU64(20), instr), byteToU64(1))), // 1 bit for index 10
4545
),
4646
or64(
47-
shl64(toU64(11), and64(shr64(toU64(12), instr), toU64(0xFF))), // 8 bits for index 11:18
48-
shl64(toU64(19), shr64(toU64(31), instr)), // 1 bit for index 19
47+
shl64(byteToU64(11), and64(shr64(byteToU64(12), instr), byteToU64(0xFF))), // 8 bits for index 11:18
48+
shl64(byteToU64(19), shr64(byteToU64(31), instr)), // 1 bit for index 19
4949
),
5050
),
51-
toU64(19),
51+
byteToU64(19),
5252
)
5353
}
5454

5555
func parseOpcode(instr U64) U64 {
56-
return and64(instr, toU64(0x7F))
56+
return and64(instr, byteToU64(0x7F))
5757
}
5858

5959
func parseRd(instr U64) U64 {
60-
return and64(shr64(toU64(7), instr), toU64(0x1F))
60+
return and64(shr64(byteToU64(7), instr), byteToU64(0x1F))
6161
}
6262

6363
func parseFunct3(instr U64) U64 {
64-
return and64(shr64(toU64(12), instr), toU64(0x7))
64+
return and64(shr64(byteToU64(12), instr), byteToU64(0x7))
6565
}
6666

6767
func parseRs1(instr U64) U64 {
68-
return and64(shr64(toU64(15), instr), toU64(0x1F))
68+
return and64(shr64(byteToU64(15), instr), byteToU64(0x1F))
6969
}
7070

7171
func parseRs2(instr U64) U64 {
72-
return and64(shr64(toU64(20), instr), toU64(0x1F))
72+
return and64(shr64(byteToU64(20), instr), byteToU64(0x1F))
7373
}
7474

7575
func parseFunct7(instr U64) U64 {
76-
return shr64(toU64(25), instr)
76+
return shr64(byteToU64(25), instr)
7777
}

0 commit comments

Comments
 (0)