summaryrefslogtreecommitdiff
path: root/test/lit/passes/legalize-js-interface-exported-helpers.wast
blob: bed768f1a0d90d71ec742409006bf4e340a622ba (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
;; NOTE: Assertions have been generated by update_lit_checks.py --all-items and should not be edited.
;; NOTE: This test was ported using port_test.py and could be cleaned up.

;; Check that legalize-js-interface-exported-helpers ends up using the
;; existing __set_temp_ret/__get_temp_ret helpers.
;; RUN: wasm-opt %s --legalize-js-interface --pass-arg=legalize-js-interface-exported-helpers -S -o - | filecheck %s

(module
  (export "get_i64" (func $get_i64))
  (import "env" "imported" (func $imported (result i64)))
  (export "__set_temp_ret" (func $__set_temp_ret))
  (export "__get_temp_ret" (func $__get_temp_ret))
  ;; CHECK:      (type $0 (func (result i32)))

  ;; CHECK:      (type $1 (func (result i64)))

  ;; CHECK:      (type $2 (func (param i32)))

  ;; CHECK:      (import "env" "imported" (func $legalimport$imported (result i32)))

  ;; CHECK:      (export "get_i64" (func $legalstub$get_i64))

  ;; CHECK:      (func $get_i64 (result i64)
  ;; CHECK-NEXT:  (drop
  ;; CHECK-NEXT:   (call $legalfunc$imported)
  ;; CHECK-NEXT:  )
  ;; CHECK-NEXT:  (i64.const 0)
  ;; CHECK-NEXT: )
  (func $get_i64 (result i64)
    (drop (call $imported))
    (i64.const 0)
  )
  ;; CHECK:      (func $__set_temp_ret (param $0 i32)
  ;; CHECK-NEXT: )
  (func $__set_temp_ret (param i32))
  ;; CHECK:      (func $__get_temp_ret (result i32)
  ;; CHECK-NEXT:  (i32.const 0)
  ;; CHECK-NEXT: )
  (func $__get_temp_ret (result i32)
    (i32.const 0)
  )
)
;; CHECK:      (func $legalstub$get_i64 (result i32)
;; CHECK-NEXT:  (local $0 i64)
;; CHECK-NEXT:  (local.set $0
;; CHECK-NEXT:   (call $get_i64)
;; CHECK-NEXT:  )
;; CHECK-NEXT:  (call $__set_temp_ret
;; CHECK-NEXT:   (i32.wrap_i64
;; CHECK-NEXT:    (i64.shr_u
;; CHECK-NEXT:     (local.get $0)
;; CHECK-NEXT:     (i64.const 32)
;; CHECK-NEXT:    )
;; CHECK-NEXT:   )
;; CHECK-NEXT:  )
;; CHECK-NEXT:  (i32.wrap_i64
;; CHECK-NEXT:   (local.get $0)
;; CHECK-NEXT:  )
;; CHECK-NEXT: )

;; CHECK:      (func $legalfunc$imported (result i64)
;; CHECK-NEXT:  (i64.or
;; CHECK-NEXT:   (i64.extend_i32_u
;; CHECK-NEXT:    (call $legalimport$imported)
;; CHECK-NEXT:   )
;; CHECK-NEXT:   (i64.shl
;; CHECK-NEXT:    (i64.extend_i32_u
;; CHECK-NEXT:     (call $__get_temp_ret)
;; CHECK-NEXT:    )
;; CHECK-NEXT:    (i64.const 32)
;; CHECK-NEXT:   )
;; CHECK-NEXT:  )
;; CHECK-NEXT: )