2019-11-28 15:22:24 +00:00
|
|
|
|
2020-11-04 18:20:49 +00:00
|
|
|
======= evm_to_wasm/input.yul (Ewasm) =======
|
2019-11-28 15:22:24 +00:00
|
|
|
|
|
|
|
Pretty printed source:
|
|
|
|
object "object" {
|
|
|
|
code { { sstore(0, 1) } }
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
==========================
|
|
|
|
|
|
|
|
Translated source:
|
|
|
|
object "object" {
|
|
|
|
code {
|
|
|
|
function main()
|
|
|
|
{
|
|
|
|
let _1 := 0
|
2020-02-04 21:43:40 +00:00
|
|
|
mstore_internal(0:i32, _1, _1, _1, _1)
|
|
|
|
mstore_internal(32:i32, _1, _1, _1, 1)
|
|
|
|
eth.storageStore(0:i32, 32:i32)
|
2019-11-28 15:22:24 +00:00
|
|
|
}
|
2020-11-18 02:30:06 +00:00
|
|
|
function bswap16(x) -> y
|
2019-11-28 15:22:24 +00:00
|
|
|
{
|
2020-01-29 17:14:03 +00:00
|
|
|
y := i64.or(i64.and(i64.shl(x, 8), 0xff00), i64.and(i64.shr_u(x, 8), 0xff))
|
2019-11-28 15:22:24 +00:00
|
|
|
}
|
2020-11-18 02:30:06 +00:00
|
|
|
function bswap32(x) -> y
|
2019-11-28 15:22:24 +00:00
|
|
|
{
|
2020-11-18 02:30:06 +00:00
|
|
|
let hi := i64.shl(bswap16(x), 16)
|
|
|
|
y := i64.or(hi, bswap16(i64.shr_u(x, 16)))
|
2019-11-28 15:22:24 +00:00
|
|
|
}
|
2020-11-18 02:30:06 +00:00
|
|
|
function bswap64(x) -> y
|
2019-11-28 15:22:24 +00:00
|
|
|
{
|
2020-11-18 02:30:06 +00:00
|
|
|
let hi := i64.shl(bswap32(x), 32)
|
|
|
|
y := i64.or(hi, bswap32(i64.shr_u(x, 32)))
|
2019-11-28 15:22:24 +00:00
|
|
|
}
|
2020-02-04 21:43:40 +00:00
|
|
|
function mstore_internal(pos:i32, y1, y2, y3, y4)
|
2019-11-28 15:22:24 +00:00
|
|
|
{
|
2020-11-18 02:30:06 +00:00
|
|
|
i64.store(pos, bswap64(y1))
|
|
|
|
i64.store(i32.add(pos, 8:i32), bswap64(y2))
|
|
|
|
i64.store(i32.add(pos, 16:i32), bswap64(y3))
|
|
|
|
i64.store(i32.add(pos, 24:i32), bswap64(y4))
|
2019-11-28 15:22:24 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
Binary representation:
|
2020-06-05 19:36:44 +00:00
|
|
|
0061736d0100000001160460000060017e017e60057f7e7e7e7e0060027f7f0002190108657468657265756d0c73746f7261676553746f7265000303060500010101020503010001060100071102066d656d6f72790200046d61696e00010abc01052901017e0240420021004100200020002000200010054120200020002000420110054100412010000b0b1f01017e024020004208864280fe0383200042088842ff01838421010b20010b1e01027e02402000100242108621022002200042108810028421010b20010b1e01027e02402000100342208621022002200042208810038421010b20010b32000240200020011004370000200041086a20021004370000200041106a20031004370000200041186a200410043700000b0b
|
2019-11-28 15:22:24 +00:00
|
|
|
|
|
|
|
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)
|
2020-05-25 21:33:59 +00:00
|
|
|
(block $label_
|
|
|
|
(local.set $_1 (i64.const 0))
|
2020-06-05 19:36:44 +00:00
|
|
|
(call $mstore_internal (i32.const 0) (local.get $_1) (local.get $_1) (local.get $_1) (local.get $_1))
|
|
|
|
(call $mstore_internal (i32.const 32) (local.get $_1) (local.get $_1) (local.get $_1) (i64.const 1))
|
|
|
|
(call $eth.storageStore (i32.const 0) (i32.const 32))
|
2020-05-25 21:33:59 +00:00
|
|
|
)
|
2019-11-28 15:22:24 +00:00
|
|
|
)
|
|
|
|
|
2020-11-18 02:30:06 +00:00
|
|
|
(func $bswap16
|
2019-11-28 15:22:24 +00:00
|
|
|
(param $x i64)
|
|
|
|
(result i64)
|
|
|
|
(local $y i64)
|
2020-05-25 21:33:59 +00:00
|
|
|
(block $label__1
|
|
|
|
(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))))
|
|
|
|
|
|
|
|
)
|
2019-11-28 15:22:24 +00:00
|
|
|
(local.get $y)
|
|
|
|
)
|
|
|
|
|
2020-11-18 02:30:06 +00:00
|
|
|
(func $bswap32
|
2019-11-28 15:22:24 +00:00
|
|
|
(param $x i64)
|
|
|
|
(result i64)
|
|
|
|
(local $y i64)
|
|
|
|
(local $hi i64)
|
2020-05-25 21:33:59 +00:00
|
|
|
(block $label__2
|
2020-11-18 02:30:06 +00:00
|
|
|
(local.set $hi (i64.shl (call $bswap16 (local.get $x)) (i64.const 16)))
|
|
|
|
(local.set $y (i64.or (local.get $hi) (call $bswap16 (i64.shr_u (local.get $x) (i64.const 16)))))
|
2020-05-25 21:33:59 +00:00
|
|
|
|
|
|
|
)
|
2019-11-28 15:22:24 +00:00
|
|
|
(local.get $y)
|
|
|
|
)
|
|
|
|
|
2020-11-18 02:30:06 +00:00
|
|
|
(func $bswap64
|
2019-11-28 15:22:24 +00:00
|
|
|
(param $x i64)
|
|
|
|
(result i64)
|
|
|
|
(local $y i64)
|
|
|
|
(local $hi i64)
|
2020-05-25 21:33:59 +00:00
|
|
|
(block $label__3
|
2020-11-18 02:30:06 +00:00
|
|
|
(local.set $hi (i64.shl (call $bswap32 (local.get $x)) (i64.const 32)))
|
|
|
|
(local.set $y (i64.or (local.get $hi) (call $bswap32 (i64.shr_u (local.get $x) (i64.const 32)))))
|
2020-05-25 21:33:59 +00:00
|
|
|
|
|
|
|
)
|
2019-11-28 15:22:24 +00:00
|
|
|
(local.get $y)
|
|
|
|
)
|
|
|
|
|
|
|
|
(func $mstore_internal
|
2020-06-05 19:36:44 +00:00
|
|
|
(param $pos i32)
|
2019-11-28 15:22:24 +00:00
|
|
|
(param $y1 i64)
|
|
|
|
(param $y2 i64)
|
|
|
|
(param $y3 i64)
|
|
|
|
(param $y4 i64)
|
2020-05-25 21:33:59 +00:00
|
|
|
(block $label__4
|
2020-11-18 02:30:06 +00:00
|
|
|
(i64.store (local.get $pos) (call $bswap64 (local.get $y1)))
|
|
|
|
(i64.store (i32.add (local.get $pos) (i32.const 8)) (call $bswap64 (local.get $y2)))
|
|
|
|
(i64.store (i32.add (local.get $pos) (i32.const 16)) (call $bswap64 (local.get $y3)))
|
|
|
|
(i64.store (i32.add (local.get $pos) (i32.const 24)) (call $bswap64 (local.get $y4)))
|
2020-05-25 21:33:59 +00:00
|
|
|
)
|
2019-11-28 15:22:24 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
)
|