aboutsummaryrefslogtreecommitdiff
path: root/llvm/test/CodeGen/WebAssembly/ref-test-func.ll
blob: e4014ba73119ba38d44957de1a5363f3017fdc2d (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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --version 5
; RUN: llc < %s --mtriple=wasm32-unknown-unknown -mcpu=mvp -mattr=+reference-types -verify-machineinstrs | FileCheck --check-prefixes CHECK,CHK32 %s
; RUN: llc < %s --mtriple=wasm64-unknown-unknown -mcpu=mvp -mattr=+reference-types -verify-machineinstrs | FileCheck --check-prefixes CHECK,CHK64 %s

define void @test_fpsig_void_void(ptr noundef %func) local_unnamed_addr #0 {
; CHECK-LABEL: test_fpsig_void_void:
; CHK32:         .functype test_fpsig_void_void (i32) -> ()
; CHK64:         .functype test_fpsig_void_void (i64) -> ()
; CHECK-NEXT:  # %bb.0: # %entry
; CHECK-NEXT:    local.get 0
; CHK64-NEXT:    i32.wrap_i64
; CHECK-NEXT:    table.get __indirect_function_table
; CHECK-NEXT:    ref.test () -> ()
; CHECK-NEXT:    call use
; CHECK-NEXT:    # fallthrough-return
entry:
  %res = tail call i32 (ptr, ...) @llvm.wasm.ref.test.func(ptr %func)
  tail call void @use(i32 noundef %res) #3
  ret void
}

define void @test_fpsig_return_i32(ptr noundef %func) local_unnamed_addr #0 {
; CHECK-LABEL: test_fpsig_return_i32:
; CHK32:         .functype test_fpsig_return_i32 (i32) -> ()
; CHK64:         .functype test_fpsig_return_i32 (i64) -> ()
; CHECK-NEXT:  # %bb.0: # %entry
; CHECK-NEXT:    local.get 0
; CHK64-NEXT:    i32.wrap_i64
; CHECK-NEXT:    table.get __indirect_function_table
; CHECK-NEXT:    ref.test () -> (i32)
; CHECK-NEXT:    call use
; CHECK-NEXT:    # fallthrough-return
entry:
  %res = tail call i32 (ptr, ...) @llvm.wasm.ref.test.func(ptr %func, i32 0)
  tail call void @use(i32 noundef %res) #3
  ret void
}

define void @test_fpsig_return_i64(ptr noundef %func) local_unnamed_addr #0 {
; CHECK-LABEL: test_fpsig_return_i64:
; CHK32:         .functype test_fpsig_return_i64 (i32) -> ()
; CHK64:         .functype test_fpsig_return_i64 (i64) -> ()
; CHECK-NEXT:  # %bb.0: # %entry
; CHECK-NEXT:    local.get 0
; CHK64-NEXT:    i32.wrap_i64
; CHECK-NEXT:    table.get __indirect_function_table
; CHECK-NEXT:    ref.test () -> (i64)
; CHECK-NEXT:    call use
; CHECK-NEXT:    # fallthrough-return
entry:
  %res = tail call i32 (ptr, ...) @llvm.wasm.ref.test.func(ptr %func, i64 0)
  tail call void @use(i32 noundef %res) #3
  ret void
}

define void @test_fpsig_return_f32(ptr noundef %func) local_unnamed_addr #0 {
; CHECK-LABEL: test_fpsig_return_f32:
; CHK32:         .functype test_fpsig_return_f32 (i32) -> ()
; CHK64:         .functype test_fpsig_return_f32 (i64) -> ()
; CHECK-NEXT:  # %bb.0: # %entry
; CHECK-NEXT:    local.get 0
; CHK64-NEXT:    i32.wrap_i64
; CHECK-NEXT:    table.get __indirect_function_table
; CHECK-NEXT:    ref.test () -> (f32)
; CHECK-NEXT:    call use
; CHECK-NEXT:    # fallthrough-return
entry:
  %res = tail call i32 (ptr, ...) @llvm.wasm.ref.test.func(ptr %func, float 0.)
  tail call void @use(i32 noundef %res) #3
  ret void
}

define void @test_fpsig_return_f64(ptr noundef %func) local_unnamed_addr #0 {
; CHECK-LABEL: test_fpsig_return_f64:
; CHK32:         .functype test_fpsig_return_f64 (i32) -> ()
; CHK64:         .functype test_fpsig_return_f64 (i64) -> ()
; CHECK-NEXT:  # %bb.0: # %entry
; CHECK-NEXT:    local.get 0
; CHK64-NEXT:    i32.wrap_i64
; CHECK-NEXT:    table.get __indirect_function_table
; CHECK-NEXT:    ref.test () -> (f64)
; CHECK-NEXT:    call use
; CHECK-NEXT:    # fallthrough-return
entry:
  %res = tail call i32 (ptr, ...) @llvm.wasm.ref.test.func(ptr %func, double 0.)
  tail call void @use(i32 noundef %res) #3
  ret void
}


define void @test_fpsig_param_i32(ptr noundef %func) local_unnamed_addr #0 {
; CHECK-LABEL: test_fpsig_param_i32:
; CHK32:         .functype test_fpsig_param_i32 (i32) -> ()
; CHK64:         .functype test_fpsig_param_i32 (i64) -> ()
; CHECK-NEXT:  # %bb.0: # %entry
; CHECK-NEXT:    local.get 0
; CHK64-NEXT:    i32.wrap_i64
; CHECK-NEXT:    table.get __indirect_function_table
; CHECK-NEXT:    ref.test (f64) -> ()
; CHECK-NEXT:    call use
; CHECK-NEXT:    # fallthrough-return
entry:
  %res = tail call i32 (ptr, ...) @llvm.wasm.ref.test.func(ptr %func, token poison, double 0.)
  tail call void @use(i32 noundef %res) #3
  ret void
}


define void @test_fpsig_multiple_params_and_returns(ptr noundef %func) local_unnamed_addr #0 {
; CHECK-LABEL: test_fpsig_multiple_params_and_returns:
; CHK32:         .functype test_fpsig_multiple_params_and_returns (i32) -> ()
; CHK64:         .functype test_fpsig_multiple_params_and_returns (i64) -> ()
; CHECK-NEXT:  # %bb.0: # %entry
; CHECK-NEXT:    local.get 0
; CHK64-NEXT:    i32.wrap_i64
; CHECK-NEXT:    table.get __indirect_function_table
; CHECK-NEXT:    ref.test (i64, f32, i64) -> (i32, i64, f32, f64)
; CHECK-NEXT:    call use
; CHECK-NEXT:    # fallthrough-return
entry:
  %res = tail call i32 (ptr, ...) @llvm.wasm.ref.test.func(ptr %func, i32 0, i64 0, float 0., double 0., token poison, i64 0, float 0., i64 0)
  tail call void @use(i32 noundef %res) #3
  ret void
}


define void @test_fpsig_ptrs(ptr noundef %func) local_unnamed_addr #0 {
; CHECK-LABEL: test_fpsig_ptrs:
; CHK32:         .functype test_fpsig_ptrs (i32) -> ()
; CHK64:         .functype test_fpsig_ptrs (i64) -> ()
; CHECK-NEXT:  # %bb.0: # %entry
; CHECK-NEXT:    local.get 0
; CHK64-NEXT:    i32.wrap_i64
; CHECK-NEXT:    table.get __indirect_function_table
; CHK32-NEXT:    ref.test (i32, i32) -> (i32)
; CHK64-NEXT:    ref.test (i64, i64) -> (i64)
; CHECK-NEXT:    call use
; CHECK-NEXT:    # fallthrough-return
entry:
  %res = tail call i32 (ptr, ...) @llvm.wasm.ref.test.func(ptr %func, ptr null, token poison, ptr null, ptr null)
  tail call void @use(i32 noundef %res) #3
  ret void
}


declare void @use(i32 noundef) local_unnamed_addr #1