xref: /wasmtime-44.0.1/tests/disas/byteswap.wat (revision 7e0331c2)
1;;! target = "x86_64"
2;;! test = "optimize"
3
4(module
5  (func (export "bswap32") (param i32) (result i32)
6    local.get 0
7    i32.const 24
8    i32.shl
9    local.get 0
10    i32.const 65280
11    i32.and
12    i32.const 8
13    i32.shl
14    i32.or
15    local.get 0
16    i32.const 8
17    i32.shr_u
18    i32.const 65280
19    i32.and
20    local.get 0
21    i32.const 24
22    i32.shr_u
23    i32.or
24    i32.or
25  )
26
27  (func (export "bswap64") (param i64) (result i64)
28    local.get 0
29    i64.const 56
30    i64.shl
31    local.get 0
32    i64.const 65280
33    i64.and
34    i64.const 40
35    i64.shl
36    i64.or
37    local.get 0
38    i64.const 16711680
39    i64.and
40    i64.const 24
41    i64.shl
42    local.get 0
43    i64.const 4278190080
44    i64.and
45    i64.const 8
46    i64.shl
47    i64.or
48    i64.or
49    local.get 0
50    i64.const 8
51    i64.shr_u
52    i64.const 4278190080
53    i64.and
54    local.get 0
55    i64.const 24
56    i64.shr_u
57    i64.const 16711680
58    i64.and
59    i64.or
60    local.get 0
61    i64.const 40
62    i64.shr_u
63    i64.const 65280
64    i64.and
65    local.get 0
66    i64.const 56
67    i64.shr_u
68    i64.or
69    i64.or
70    i64.or
71  )
72)
73
74;; function u0:0(i64 vmctx, i64, i32) -> i32 tail {
75;;     gv0 = vmctx
76;;     gv1 = load.i64 notrap aligned readonly gv0+8
77;;     gv2 = load.i64 notrap aligned gv1+24
78;;     stack_limit = gv2
79;;
80;;                                 block0(v0: i64, v1: i64, v2: i32):
81;; @0057                               jump block1
82;;
83;;                                 block1:
84;;                                     v19 = bswap.i32 v2
85;; @0057                               return v19
86;; }
87;;
88;; function u0:1(i64 vmctx, i64, i64) -> i64 tail {
89;;     gv0 = vmctx
90;;     gv1 = load.i64 notrap aligned readonly gv0+8
91;;     gv2 = load.i64 notrap aligned gv1+24
92;;     stack_limit = gv2
93;;
94;;                                 block0(v0: i64, v1: i64, v2: i64):
95;; @00ad                               jump block1
96;;
97;;                                 block1:
98;;                                     v39 = bswap.i64 v2
99;; @00ad                               return v39
100;; }
101