summaryrefslogtreecommitdiff
path: root/test/lit/passes/intrinsic-lowering.wast
blob: e8897ff0b25bceb2b9fd79ea45a41c87bf7c7c7b (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
;; NOTE: Assertions have been generated by update_lit_checks.py and should not be edited.
;; RUN: wasm-opt %s --intrinsic-lowering -all -S -o - | filecheck %s

(module
  ;; CHECK:      (type $none (func))
  (type $none (func))

  ;; call.without.effects with no params.
  ;; CHECK:      (import "binaryen-intrinsics" "call.without.effects" (func $cwe-v (type $1) (param funcref) (result i32)))
  (import "binaryen-intrinsics" "call.without.effects" (func $cwe-v (param funcref) (result i32)))

  ;; call.without.effects with some params.
  ;; CHECK:      (import "binaryen-intrinsics" "call.without.effects" (func $cwe-dif (type $2) (param f64 i32 funcref) (result f32)))
  (import "binaryen-intrinsics" "call.without.effects" (func $cwe-dif (param f64) (param i32) (param funcref) (result f32)))

  ;; call.without.effects with no result.
  ;; CHECK:      (import "binaryen-intrinsics" "call.without.effects" (func $cwe-n (type $3) (param funcref)))
  (import "binaryen-intrinsics" "call.without.effects" (func $cwe-n (param funcref)))

  ;; CHECK:      (func $test (type $4) (param $none (ref null $none))
  ;; CHECK-NEXT:  (drop
  ;; CHECK-NEXT:   (call $make-i32)
  ;; CHECK-NEXT:  )
  ;; CHECK-NEXT:  (drop
  ;; CHECK-NEXT:   (call $dif
  ;; CHECK-NEXT:    (f64.const 3.14159)
  ;; CHECK-NEXT:    (i32.const 42)
  ;; CHECK-NEXT:   )
  ;; CHECK-NEXT:  )
  ;; CHECK-NEXT:  (call_ref $none
  ;; CHECK-NEXT:   (local.get $none)
  ;; CHECK-NEXT:  )
  ;; CHECK-NEXT: )
  (func $test (param $none (ref null $none))
    ;; These will be lowered into calls.
    (drop (call $cwe-v (ref.func $make-i32)))
    (drop (call $cwe-dif (f64.const 3.14159) (i32.const 42) (ref.func $dif)))
    ;; The last must be a call_ref, as we don't see a constant ref.func
    (call $cwe-n (local.get $none))
  )

  ;; CHECK:      (func $make-i32 (type $5) (result i32)
  ;; CHECK-NEXT:  (i32.const 1)
  ;; CHECK-NEXT: )
  (func $make-i32 (result i32)
    (i32.const 1)
  )

  ;; CHECK:      (func $dif (type $6) (param $0 f64) (param $1 i32) (result f32)
  ;; CHECK-NEXT:  (unreachable)
  ;; CHECK-NEXT: )
  (func $dif (param f64) (param i32) (result f32)
    ;; Helper function for the above.
    (unreachable)
  )
)