-
Notifications
You must be signed in to change notification settings - Fork 5.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #7797 from ethereum/allowTranslationInAssemblyMode
Allow EVM to EWasm translation in assembly mode.
- Loading branch information
Showing
9 changed files
with
192 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
--assemble --optimize --yul-dialect evm --machine ewasm |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Warning: Yul and its optimizer are still experimental. Please use the output with care. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
sstore(0, 1) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,104 @@ | ||
|
||
======= evm_to_wasm/input.sol (eWasm) ======= | ||
|
||
Pretty printed source: | ||
object "object" { | ||
code { { sstore(0, 1) } } | ||
} | ||
|
||
|
||
========================== | ||
|
||
Translated source: | ||
object "object" { | ||
code { | ||
function main() | ||
{ | ||
let _1 := 0 | ||
mstore_internal(0, _1, _1, _1, _1) | ||
mstore_internal(32, _1, _1, _1, 1) | ||
eth.storageStore(0, 32) | ||
} | ||
function endian_swap_16(x) -> y | ||
{ | ||
y := i64.or(i64.and(i64.shl(x, 8), 0xff00), i64.and(i64.shr_u(x, 8), 0xff)) | ||
} | ||
function endian_swap_32(x) -> y | ||
{ | ||
let hi := i64.shl(endian_swap_16(x), 16) | ||
y := i64.or(hi, endian_swap_16(i64.shr_u(x, 16))) | ||
} | ||
function endian_swap(x) -> y | ||
{ | ||
let hi := i64.shl(endian_swap_32(x), 32) | ||
y := i64.or(hi, endian_swap_32(i64.shr_u(x, 32))) | ||
} | ||
function mstore_internal(pos, y1, y2, y3, y4) | ||
{ | ||
i64.store(pos, endian_swap(y1)) | ||
i64.store(i64.add(pos, 8), endian_swap(y2)) | ||
i64.store(i64.add(pos, 16), endian_swap(y3)) | ||
i64.store(i64.add(pos, 24), endian_swap(y4)) | ||
} | ||
} | ||
} | ||
|
||
|
||
Binary representation: | ||
0061736d0100000001160460000060017e017e60057e7e7e7e7e0060027f7f0002190108657468657265756d0c73746f7261676553746f7265000303060500010101020503010001060100071102066d656d6f72790200046d61696e00010ab501052801017e420021004200200020002000200010054220200020002000420110054200a74220a710000b1c01017e20004208864280fe0383200042088842ff018384210120010b1b01027e20001002421086210220022000421088100284210120010b1b01027e20001003422086210220022000422088100384210120010b3501007e2000a720011004370300200042087ca720021004370300200042107ca720031004370300200042187ca7200410043703000b | ||
|
||
Text representation: | ||
(module | ||
(import "ethereum" "storageStore" (func $eth.storageStore (param i32 i32))) | ||
(memory $memory (export "memory") 1) | ||
(export "main" (func $main)) | ||
|
||
(func $main | ||
(local $_1 i64) | ||
(local.set $_1 (i64.const 0)) | ||
(call $mstore_internal (i64.const 0) (local.get $_1) (local.get $_1) (local.get $_1) (local.get $_1)) | ||
(call $mstore_internal (i64.const 32) (local.get $_1) (local.get $_1) (local.get $_1) (i64.const 1)) | ||
(call $eth.storageStore (i32.wrap_i64 (i64.const 0)) (i32.wrap_i64 (i64.const 32))) | ||
) | ||
|
||
(func $endian_swap_16 | ||
(param $x i64) | ||
(result i64) | ||
(local $y i64) | ||
(local.set $y (i64.or (i64.and (i64.shl (local.get $x) (i64.const 8)) (i64.const 65280)) (i64.and (i64.shr_u (local.get $x) (i64.const 8)) (i64.const 255)))) | ||
(local.get $y) | ||
) | ||
|
||
(func $endian_swap_32 | ||
(param $x i64) | ||
(result i64) | ||
(local $y i64) | ||
(local $hi i64) | ||
(local.set $hi (i64.shl (call $endian_swap_16 (local.get $x)) (i64.const 16))) | ||
(local.set $y (i64.or (local.get $hi) (call $endian_swap_16 (i64.shr_u (local.get $x) (i64.const 16))))) | ||
(local.get $y) | ||
) | ||
|
||
(func $endian_swap | ||
(param $x i64) | ||
(result i64) | ||
(local $y i64) | ||
(local $hi i64) | ||
(local.set $hi (i64.shl (call $endian_swap_32 (local.get $x)) (i64.const 32))) | ||
(local.set $y (i64.or (local.get $hi) (call $endian_swap_32 (i64.shr_u (local.get $x) (i64.const 32))))) | ||
(local.get $y) | ||
) | ||
|
||
(func $mstore_internal | ||
(param $pos i64) | ||
(param $y1 i64) | ||
(param $y2 i64) | ||
(param $y3 i64) | ||
(param $y4 i64) | ||
(i64.store (i32.wrap_i64 (local.get $pos)) (call $endian_swap (local.get $y1))) | ||
(i64.store (i32.wrap_i64 (i64.add (local.get $pos) (i64.const 8))) (call $endian_swap (local.get $y2))) | ||
(i64.store (i32.wrap_i64 (i64.add (local.get $pos) (i64.const 16))) (call $endian_swap (local.get $y3))) | ||
(i64.store (i32.wrap_i64 (i64.add (local.get $pos) (i64.const 24))) (call $endian_swap (local.get $y4))) | ||
) | ||
|
||
) |