solidity/test/cmdlineTests/evm_to_wasm/output
Daniel Kirchner 8bb371ffa9 Update tests.
2021-04-06 14:14:47 +02:00

109 lines
4.7 KiB
Plaintext

======= evm_to_wasm/input.yul (Ewasm) =======
Pretty printed source:
object "object" {
code {
{ sstore(returndatasize(), 1) }
}
}
==========================
Translated source:
object "object" {
code {
function main()
{
let _1 := i64.extend_i32_u(eth.getReturnDataSize())
let _2 := 32
let hi := i64.shl(i64.extend_i32_u(bswap32(i32.wrap_i64(0))), _2)
let y := i64.or(hi, i64.extend_i32_u(bswap32(i32.wrap_i64(i64.shr_u(0, _2)))))
i64.store(0:i32, y)
i64.store(i32.add(0:i32, 8:i32), y)
i64.store(i32.add(0:i32, 16:i32), y)
let hi_1 := i64.shl(i64.extend_i32_u(bswap32(i32.wrap_i64(_1))), _2)
i64.store(i32.add(0:i32, 24:i32), i64.or(hi_1, i64.extend_i32_u(bswap32(i32.wrap_i64(i64.shr_u(_1, _2))))))
i64.store(32:i32, y)
i64.store(i32.add(32:i32, 8:i32), y)
i64.store(i32.add(32:i32, 16:i32), y)
let hi_2 := i64.shl(i64.extend_i32_u(bswap32(i32.wrap_i64(1))), _2)
i64.store(i32.add(32:i32, 24:i32), i64.or(hi_2, i64.extend_i32_u(bswap32(i32.wrap_i64(i64.shr_u(1, _2))))))
eth.storageStore(0:i32, 32:i32)
}
function bswap16(x:i32) -> y:i32
{
y := i32.or(i32.and(i32.shl(x, 8:i32), 0xff00:i32), i32.and(i32.shr_u(x, 8:i32), 0xff:i32))
}
function bswap32(x:i32) -> y:i32
{
let hi:i32 := i32.shl(bswap16(x), 16:i32)
y := i32.or(hi, bswap16(i32.shr_u(x, 16:i32)))
}
}
}
Binary representation:
0061736d010000000112046000006000017f60017f017f60027f7f0002360208657468657265756d0c73746f7261676553746f7265000308657468657265756d1167657452657475726e4461746153697a6500010304030002020503010001060100071102066d656d6f72790200046d61696e00020ae50103a30101067e02401001ad2100422021014200a71004ad200186210220024200200188a71004ad84210341002003370000410041086a2003370000410041106a20033700002000a71004ad2001862104410041186a20042000200188a71004ad8437000041202003370000412041086a2003370000412041106a20033700004201a71004ad2001862105412041186a20054201200188a71004ad843700004100412010000b0b1f01017f024020004108744180fe0371200041087641ff01717221010b20010b1e01027f02402000100341107421022002200041107610037221010b20010b
Text representation:
(module
(import "ethereum" "storageStore" (func $eth.storageStore (param i32 i32)))
(import "ethereum" "getReturnDataSize" (func $eth.getReturnDataSize (result i32)))
(memory $memory (export "memory") 1)
(export "main" (func $main))
(func $main
(local $_1 i64)
(local $_2 i64)
(local $hi i64)
(local $y i64)
(local $hi_1 i64)
(local $hi_2 i64)
(block $label_
(local.set $_1 (i64.extend_i32_u (call $eth.getReturnDataSize)))
(local.set $_2 (i64.const 32))
(local.set $hi (i64.shl (i64.extend_i32_u (call $bswap32 (i32.wrap_i64 (i64.const 0)))) (local.get $_2)))
(local.set $y (i64.or (local.get $hi) (i64.extend_i32_u (call $bswap32 (i32.wrap_i64 (i64.shr_u (i64.const 0) (local.get $_2)))))))
(i64.store (i32.const 0) (local.get $y))
(i64.store (i32.add (i32.const 0) (i32.const 8)) (local.get $y))
(i64.store (i32.add (i32.const 0) (i32.const 16)) (local.get $y))
(local.set $hi_1 (i64.shl (i64.extend_i32_u (call $bswap32 (i32.wrap_i64 (local.get $_1)))) (local.get $_2)))
(i64.store (i32.add (i32.const 0) (i32.const 24)) (i64.or (local.get $hi_1) (i64.extend_i32_u (call $bswap32 (i32.wrap_i64 (i64.shr_u (local.get $_1) (local.get $_2)))))))
(i64.store (i32.const 32) (local.get $y))
(i64.store (i32.add (i32.const 32) (i32.const 8)) (local.get $y))
(i64.store (i32.add (i32.const 32) (i32.const 16)) (local.get $y))
(local.set $hi_2 (i64.shl (i64.extend_i32_u (call $bswap32 (i32.wrap_i64 (i64.const 1)))) (local.get $_2)))
(i64.store (i32.add (i32.const 32) (i32.const 24)) (i64.or (local.get $hi_2) (i64.extend_i32_u (call $bswap32 (i32.wrap_i64 (i64.shr_u (i64.const 1) (local.get $_2)))))))
(call $eth.storageStore (i32.const 0) (i32.const 32))
)
)
(func $bswap16
(param $x i32)
(result i32)
(local $y i32)
(block $label__1
(local.set $y (i32.or (i32.and (i32.shl (local.get $x) (i32.const 8)) (i32.const 65280)) (i32.and (i32.shr_u (local.get $x) (i32.const 8)) (i32.const 255))))
)
(local.get $y)
)
(func $bswap32
(param $x i32)
(result i32)
(local $y i32)
(local $hi i32)
(block $label__2
(local.set $hi (i32.shl (call $bswap16 (local.get $x)) (i32.const 16)))
(local.set $y (i32.or (local.get $hi) (call $bswap16 (i32.shr_u (local.get $x) (i32.const 16)))))
)
(local.get $y)
)
)