File: multi-return.ll

package info (click to toggle)
llvm-toolchain-20 1%3A20.1.6-1~exp1
  • links: PTS, VCS
  • area: main
  • in suites: experimental
  • size: 2,111,304 kB
  • sloc: cpp: 7,438,677; ansic: 1,393,822; asm: 1,012,926; python: 241,650; f90: 86,635; objc: 75,479; lisp: 42,144; pascal: 17,286; sh: 10,027; ml: 5,082; perl: 4,730; awk: 3,523; makefile: 3,349; javascript: 2,251; xml: 892; fortran: 672
file content (260 lines) | stat: -rw-r--r-- 10,317 bytes parent folder | download | duplicates (6)
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
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --version 5
; RUN: llc < %s -wasm-disable-explicit-locals -wasm-keep-registers | FileCheck %s

target triple = "wasm32-unknown-unknown"

; Return multiple values, some of which will be legalized into multiple values.
declare { i64, i128, i192, i128, i64 } @return_multi_multi()

; Test returning a single value from @return_multi_multi.

define i64 @test0() {
; CHECK-LABEL: test0:
; CHECK:         .functype test0 () -> (i64)
; CHECK-NEXT:  # %bb.0:
; CHECK-NEXT:    global.get $push0=, __stack_pointer
; CHECK-NEXT:    i32.const $push1=, 96
; CHECK-NEXT:    i32.sub $push5=, $pop0, $pop1
; CHECK-NEXT:    local.tee $push4=, $1=, $pop5
; CHECK-NEXT:    global.set __stack_pointer, $pop4
; CHECK-NEXT:    call return_multi_multi, $1
; CHECK-NEXT:    i64.load $0=, 0($1)
; CHECK-NEXT:    i32.const $push2=, 96
; CHECK-NEXT:    i32.add $push3=, $1, $pop2
; CHECK-NEXT:    global.set __stack_pointer, $pop3
; CHECK-NEXT:    local.copy $push6=, $0
; CHECK-NEXT:    # fallthrough-return
  %t0 = call { i64, i128, i192, i128, i64 } @return_multi_multi()
  %t1 = extractvalue { i64, i128, i192, i128, i64 } %t0, 0
  ret i64 %t1
}

define i128 @test1() {
; CHECK-LABEL: test1:
; CHECK:         .functype test1 (i32) -> ()
; CHECK-NEXT:  # %bb.0:
; CHECK-NEXT:    global.get $push1=, __stack_pointer
; CHECK-NEXT:    i32.const $push2=, 96
; CHECK-NEXT:    i32.sub $push6=, $pop1, $pop2
; CHECK-NEXT:    local.tee $push5=, $2=, $pop6
; CHECK-NEXT:    global.set __stack_pointer, $pop5
; CHECK-NEXT:    call return_multi_multi, $2
; CHECK-NEXT:    i64.load $1=, 24($2)
; CHECK-NEXT:    i64.load $push0=, 16($2)
; CHECK-NEXT:    i64.store 0($0), $pop0
; CHECK-NEXT:    i64.store 8($0), $1
; CHECK-NEXT:    i32.const $push3=, 96
; CHECK-NEXT:    i32.add $push4=, $2, $pop3
; CHECK-NEXT:    global.set __stack_pointer, $pop4
; CHECK-NEXT:    # fallthrough-return
  %t0 = call { i64, i128, i192, i128, i64 } @return_multi_multi()
  %t1 = extractvalue { i64, i128, i192, i128, i64 } %t0, 1
  ret i128 %t1
}

define i192 @test2() {
; CHECK-LABEL: test2:
; CHECK:         .functype test2 (i32) -> ()
; CHECK-NEXT:  # %bb.0:
; CHECK-NEXT:    global.get $push3=, __stack_pointer
; CHECK-NEXT:    i32.const $push4=, 96
; CHECK-NEXT:    i32.sub $push8=, $pop3, $pop4
; CHECK-NEXT:    local.tee $push7=, $3=, $pop8
; CHECK-NEXT:    global.set __stack_pointer, $pop7
; CHECK-NEXT:    call return_multi_multi, $3
; CHECK-NEXT:    i64.load $1=, 40($3)
; CHECK-NEXT:    i64.load $2=, 32($3)
; CHECK-NEXT:    i32.const $push0=, 48
; CHECK-NEXT:    i32.add $push1=, $3, $pop0
; CHECK-NEXT:    i64.load $push2=, 0($pop1)
; CHECK-NEXT:    i64.store 16($0), $pop2
; CHECK-NEXT:    i64.store 0($0), $2
; CHECK-NEXT:    i64.store 8($0), $1
; CHECK-NEXT:    i32.const $push5=, 96
; CHECK-NEXT:    i32.add $push6=, $3, $pop5
; CHECK-NEXT:    global.set __stack_pointer, $pop6
; CHECK-NEXT:    # fallthrough-return
  %t0 = call { i64, i128, i192, i128, i64 } @return_multi_multi()
  %t1 = extractvalue { i64, i128, i192, i128, i64 } %t0, 2
  ret i192 %t1
}

define i128 @test3() {
; CHECK-LABEL: test3:
; CHECK:         .functype test3 (i32) -> ()
; CHECK-NEXT:  # %bb.0:
; CHECK-NEXT:    global.get $push1=, __stack_pointer
; CHECK-NEXT:    i32.const $push2=, 96
; CHECK-NEXT:    i32.sub $push6=, $pop1, $pop2
; CHECK-NEXT:    local.tee $push5=, $2=, $pop6
; CHECK-NEXT:    global.set __stack_pointer, $pop5
; CHECK-NEXT:    call return_multi_multi, $2
; CHECK-NEXT:    i64.load $1=, 72($2)
; CHECK-NEXT:    i64.load $push0=, 64($2)
; CHECK-NEXT:    i64.store 0($0), $pop0
; CHECK-NEXT:    i64.store 8($0), $1
; CHECK-NEXT:    i32.const $push3=, 96
; CHECK-NEXT:    i32.add $push4=, $2, $pop3
; CHECK-NEXT:    global.set __stack_pointer, $pop4
; CHECK-NEXT:    # fallthrough-return
  %t0 = call { i64, i128, i192, i128, i64 } @return_multi_multi()
  %t1 = extractvalue { i64, i128, i192, i128, i64 } %t0, 3
  ret i128 %t1
}

define i64 @test4() {
; CHECK-LABEL: test4:
; CHECK:         .functype test4 () -> (i64)
; CHECK-NEXT:  # %bb.0:
; CHECK-NEXT:    global.get $push0=, __stack_pointer
; CHECK-NEXT:    i32.const $push1=, 96
; CHECK-NEXT:    i32.sub $push5=, $pop0, $pop1
; CHECK-NEXT:    local.tee $push4=, $1=, $pop5
; CHECK-NEXT:    global.set __stack_pointer, $pop4
; CHECK-NEXT:    call return_multi_multi, $1
; CHECK-NEXT:    i64.load $0=, 80($1)
; CHECK-NEXT:    i32.const $push2=, 96
; CHECK-NEXT:    i32.add $push3=, $1, $pop2
; CHECK-NEXT:    global.set __stack_pointer, $pop3
; CHECK-NEXT:    local.copy $push6=, $0
; CHECK-NEXT:    # fallthrough-return
  %t0 = call { i64, i128, i192, i128, i64 } @return_multi_multi()
  %t1 = extractvalue { i64, i128, i192, i128, i64 } %t0, 4
  ret i64 %t1
}

; Test returning multiple values from @return_multi_multi.

define { i64, i128 } @test5() {
; CHECK-LABEL: test5:
; CHECK:         .functype test5 (i32) -> ()
; CHECK-NEXT:  # %bb.0:
; CHECK-NEXT:    global.get $push1=, __stack_pointer
; CHECK-NEXT:    i32.const $push2=, 96
; CHECK-NEXT:    i32.sub $push6=, $pop1, $pop2
; CHECK-NEXT:    local.tee $push5=, $3=, $pop6
; CHECK-NEXT:    global.set __stack_pointer, $pop5
; CHECK-NEXT:    call return_multi_multi, $3
; CHECK-NEXT:    i64.load $1=, 24($3)
; CHECK-NEXT:    i64.load $2=, 16($3)
; CHECK-NEXT:    i64.load $push0=, 0($3)
; CHECK-NEXT:    i64.store 0($0), $pop0
; CHECK-NEXT:    i64.store 16($0), $2
; CHECK-NEXT:    i64.store 24($0), $1
; CHECK-NEXT:    i32.const $push3=, 96
; CHECK-NEXT:    i32.add $push4=, $3, $pop3
; CHECK-NEXT:    global.set __stack_pointer, $pop4
; CHECK-NEXT:    # fallthrough-return
  %t0 = call { i64, i128, i192, i128, i64 } @return_multi_multi()
  %r0 = extractvalue { i64, i128, i192, i128, i64 } %t0, 0
  %r1 = extractvalue { i64, i128, i192, i128, i64 } %t0, 1
  %s0 = insertvalue { i64, i128 } undef, i64 %r0, 0
  %s1 = insertvalue { i64, i128 } %s0, i128 %r1, 1
  ret { i64, i128 } %s1
}

define { i128, i128 } @test6() {
; CHECK-LABEL: test6:
; CHECK:         .functype test6 (i32) -> ()
; CHECK-NEXT:  # %bb.0:
; CHECK-NEXT:    global.get $push1=, __stack_pointer
; CHECK-NEXT:    i32.const $push2=, 96
; CHECK-NEXT:    i32.sub $push6=, $pop1, $pop2
; CHECK-NEXT:    local.tee $push5=, $4=, $pop6
; CHECK-NEXT:    global.set __stack_pointer, $pop5
; CHECK-NEXT:    call return_multi_multi, $4
; CHECK-NEXT:    i64.load $1=, 24($4)
; CHECK-NEXT:    i64.load $2=, 16($4)
; CHECK-NEXT:    i64.load $3=, 72($4)
; CHECK-NEXT:    i64.load $push0=, 64($4)
; CHECK-NEXT:    i64.store 16($0), $pop0
; CHECK-NEXT:    i64.store 24($0), $3
; CHECK-NEXT:    i64.store 0($0), $2
; CHECK-NEXT:    i64.store 8($0), $1
; CHECK-NEXT:    i32.const $push3=, 96
; CHECK-NEXT:    i32.add $push4=, $4, $pop3
; CHECK-NEXT:    global.set __stack_pointer, $pop4
; CHECK-NEXT:    # fallthrough-return
  %t0 = call { i64, i128, i192, i128, i64 } @return_multi_multi()
  %r1 = extractvalue { i64, i128, i192, i128, i64 } %t0, 1
  %r3 = extractvalue { i64, i128, i192, i128, i64 } %t0, 3
  %s0 = insertvalue { i128, i128 } undef, i128 %r1, 0
  %s1 = insertvalue { i128, i128 } %s0, i128 %r3, 1
  ret { i128, i128 } %s1
}

define { i64, i192 } @test7() {
; CHECK-LABEL: test7:
; CHECK:         .functype test7 (i32) -> ()
; CHECK-NEXT:  # %bb.0:
; CHECK-NEXT:    global.get $push3=, __stack_pointer
; CHECK-NEXT:    i32.const $push4=, 96
; CHECK-NEXT:    i32.sub $push8=, $pop3, $pop4
; CHECK-NEXT:    local.tee $push7=, $4=, $pop8
; CHECK-NEXT:    global.set __stack_pointer, $pop7
; CHECK-NEXT:    call return_multi_multi, $4
; CHECK-NEXT:    i32.const $push0=, 48
; CHECK-NEXT:    i32.add $push1=, $4, $pop0
; CHECK-NEXT:    i64.load $1=, 0($pop1)
; CHECK-NEXT:    i64.load $2=, 40($4)
; CHECK-NEXT:    i64.load $3=, 32($4)
; CHECK-NEXT:    i64.load $push2=, 0($4)
; CHECK-NEXT:    i64.store 0($0), $pop2
; CHECK-NEXT:    i64.store 32($0), $1
; CHECK-NEXT:    i64.store 16($0), $3
; CHECK-NEXT:    i64.store 24($0), $2
; CHECK-NEXT:    i32.const $push5=, 96
; CHECK-NEXT:    i32.add $push6=, $4, $pop5
; CHECK-NEXT:    global.set __stack_pointer, $pop6
; CHECK-NEXT:    # fallthrough-return
  %t0 = call { i64, i128, i192, i128, i64 } @return_multi_multi()
  %r0 = extractvalue { i64, i128, i192, i128, i64 } %t0, 0
  %r2 = extractvalue { i64, i128, i192, i128, i64 } %t0, 2
  %s0 = insertvalue { i64, i192 } undef, i64 %r0, 0
  %s1 = insertvalue { i64, i192 } %s0, i192 %r2, 1
  ret { i64, i192 } %s1
}

define { i128, i192, i128, i64 } @test8() {
; CHECK-LABEL: test8:
; CHECK:         .functype test8 (i32) -> ()
; CHECK-NEXT:  # %bb.0:
; CHECK-NEXT:    global.get $push3=, __stack_pointer
; CHECK-NEXT:    i32.const $push4=, 96
; CHECK-NEXT:    i32.sub $push8=, $pop3, $pop4
; CHECK-NEXT:    local.tee $push7=, $8=, $pop8
; CHECK-NEXT:    global.set __stack_pointer, $pop7
; CHECK-NEXT:    call return_multi_multi, $8
; CHECK-NEXT:    i32.const $push0=, 48
; CHECK-NEXT:    i32.add $push1=, $8, $pop0
; CHECK-NEXT:    i64.load $1=, 0($pop1)
; CHECK-NEXT:    i64.load $2=, 72($8)
; CHECK-NEXT:    i64.load $3=, 64($8)
; CHECK-NEXT:    i64.load $4=, 40($8)
; CHECK-NEXT:    i64.load $5=, 32($8)
; CHECK-NEXT:    i64.load $6=, 24($8)
; CHECK-NEXT:    i64.load $7=, 16($8)
; CHECK-NEXT:    i64.load $push2=, 0($8)
; CHECK-NEXT:    i64.store 64($0), $pop2
; CHECK-NEXT:    i64.store 48($0), $7
; CHECK-NEXT:    i64.store 56($0), $6
; CHECK-NEXT:    i64.store 32($0), $1
; CHECK-NEXT:    i64.store 16($0), $5
; CHECK-NEXT:    i64.store 24($0), $4
; CHECK-NEXT:    i64.store 0($0), $3
; CHECK-NEXT:    i64.store 8($0), $2
; CHECK-NEXT:    i32.const $push5=, 96
; CHECK-NEXT:    i32.add $push6=, $8, $pop5
; CHECK-NEXT:    global.set __stack_pointer, $pop6
; CHECK-NEXT:    # fallthrough-return
  %t0 = call { i64, i128, i192, i128, i64 } @return_multi_multi()
  %r0 = extractvalue { i64, i128, i192, i128, i64 } %t0, 0
  %r1 = extractvalue { i64, i128, i192, i128, i64 } %t0, 1
  %r2 = extractvalue { i64, i128, i192, i128, i64 } %t0, 2
  %r3 = extractvalue { i64, i128, i192, i128, i64 } %t0, 3
  %s0 = insertvalue { i128, i192, i128, i64 } undef, i128 %r3, 0
  %s1 = insertvalue { i128, i192, i128, i64 } %s0, i192 %r2, 1
  %s2 = insertvalue { i128, i192, i128, i64 } %s1, i128 %r1, 2
  %s3 = insertvalue { i128, i192, i128, i64 } %s2, i64 %r0, 3
  ret { i128, i192, i128, i64 } %s3
}