Coverage Report

Created: 2019-07-24 05:18

/Users/buildslave/jenkins/workspace/clang-stage2-coverage-R/llvm/lib/Target/WebAssembly/WebAssemblyRuntimeLibcallSignatures.cpp
Line
Count
Source (jump to first uncovered line)
1
// CodeGen/RuntimeLibcallSignatures.cpp - R.T. Lib. Call Signatures -*- C++ -*--
2
//
3
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4
// See https://llvm.org/LICENSE.txt for license information.
5
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6
//
7
//===----------------------------------------------------------------------===//
8
///
9
/// \file
10
/// This file contains signature information for runtime libcalls.
11
///
12
/// CodeGen uses external symbols, which it refers to by name. The WebAssembly
13
/// target needs type information for all functions. This file contains a big
14
/// table providing type signatures for all runtime library functions that LLVM
15
/// uses.
16
///
17
/// This is currently a fairly heavy-handed solution.
18
///
19
//===----------------------------------------------------------------------===//
20
21
#include "WebAssemblyRuntimeLibcallSignatures.h"
22
#include "WebAssemblySubtarget.h"
23
#include "llvm/CodeGen/RuntimeLibcalls.h"
24
#include "llvm/Support/ManagedStatic.h"
25
26
using namespace llvm;
27
28
namespace {
29
30
enum RuntimeLibcallSignature {
31
  func,
32
  f32_func_f32,
33
  f32_func_f64,
34
  f32_func_i32,
35
  f32_func_i64,
36
  f32_func_i16,
37
  f64_func_f32,
38
  f64_func_f64,
39
  f64_func_i32,
40
  f64_func_i64,
41
  i32_func_f32,
42
  i32_func_f64,
43
  i32_func_i32,
44
  i64_func_f32,
45
  i64_func_f64,
46
  i64_func_i64,
47
  f32_func_f32_f32,
48
  f32_func_f32_i32,
49
  f32_func_i64_i64,
50
  f64_func_f64_f64,
51
  f64_func_f64_i32,
52
  f64_func_i64_i64,
53
  i16_func_f32,
54
  i16_func_f64,
55
  i16_func_i64_i64,
56
  i8_func_i8_i8,
57
  func_f32_iPTR_iPTR,
58
  func_f64_iPTR_iPTR,
59
  i16_func_i16_i16,
60
  i32_func_f32_f32,
61
  i32_func_f64_f64,
62
  i32_func_i32_i32,
63
  i32_func_i32_i32_iPTR,
64
  i64_func_i64_i64,
65
  i64_func_i64_i64_iPTR,
66
  i64_i64_func_f32,
67
  i64_i64_func_f64,
68
  i16_i16_func_i16_i16,
69
  i32_i32_func_i32_i32,
70
  i64_i64_func_i64_i64,
71
  i64_i64_func_i64_i64_i64_i64,
72
  i64_i64_func_i64_i64_i64_i64_iPTR,
73
  i64_i64_i64_i64_func_i64_i64_i64_i64,
74
  i64_i64_func_i64_i64_i32,
75
  iPTR_func_iPTR_i32_iPTR,
76
  iPTR_func_iPTR_iPTR_iPTR,
77
  f32_func_f32_f32_f32,
78
  f64_func_f64_f64_f64,
79
  func_i64_i64_iPTR_iPTR,
80
  func_iPTR_f32,
81
  func_iPTR_f64,
82
  func_iPTR_i32,
83
  func_iPTR_i64,
84
  func_iPTR_i64_i64,
85
  func_iPTR_i64_i64_i64_i64,
86
  func_iPTR_i64_i64_i64_i64_i64_i64,
87
  i32_func_i64_i64,
88
  i32_func_i64_i64_i64_i64,
89
  iPTR_func_f32,
90
  iPTR_func_f64,
91
  iPTR_func_i64_i64,
92
  unsupported
93
};
94
95
struct RuntimeLibcallSignatureTable {
96
  std::vector<RuntimeLibcallSignature> Table;
97
98
  // Any newly-added libcalls will be unsupported by default.
99
24
  RuntimeLibcallSignatureTable() : Table(RTLIB::UNKNOWN_LIBCALL, unsupported) {
100
24
    // Integer
101
24
    Table[RTLIB::SHL_I16] = i16_func_i16_i16;
102
24
    Table[RTLIB::SHL_I32] = i32_func_i32_i32;
103
24
    Table[RTLIB::SHL_I64] = i64_func_i64_i64;
104
24
    Table[RTLIB::SHL_I128] = i64_i64_func_i64_i64_i32;
105
24
    Table[RTLIB::SRL_I16] = i16_func_i16_i16;
106
24
    Table[RTLIB::SRL_I32] = i32_func_i32_i32;
107
24
    Table[RTLIB::SRL_I64] = i64_func_i64_i64;
108
24
    Table[RTLIB::SRL_I128] = i64_i64_func_i64_i64_i32;
109
24
    Table[RTLIB::SRA_I16] = i16_func_i16_i16;
110
24
    Table[RTLIB::SRA_I32] = i32_func_i32_i32;
111
24
    Table[RTLIB::SRA_I64] = i64_func_i64_i64;
112
24
    Table[RTLIB::SRA_I128] = i64_i64_func_i64_i64_i32;
113
24
    Table[RTLIB::MUL_I8] = i8_func_i8_i8;
114
24
    Table[RTLIB::MUL_I16] = i16_func_i16_i16;
115
24
    Table[RTLIB::MUL_I32] = i32_func_i32_i32;
116
24
    Table[RTLIB::MUL_I64] = i64_func_i64_i64;
117
24
    Table[RTLIB::MUL_I128] = i64_i64_func_i64_i64_i64_i64;
118
24
    Table[RTLIB::MULO_I32] = i32_func_i32_i32_iPTR;
119
24
    Table[RTLIB::MULO_I64] = i64_func_i64_i64_iPTR;
120
24
    Table[RTLIB::MULO_I128] = i64_i64_func_i64_i64_i64_i64_iPTR;
121
24
    Table[RTLIB::SDIV_I8] = i8_func_i8_i8;
122
24
    Table[RTLIB::SDIV_I16] = i16_func_i16_i16;
123
24
    Table[RTLIB::SDIV_I32] = i32_func_i32_i32;
124
24
    Table[RTLIB::SDIV_I64] = i64_func_i64_i64;
125
24
    Table[RTLIB::SDIV_I128] = i64_i64_func_i64_i64_i64_i64;
126
24
    Table[RTLIB::UDIV_I8] = i8_func_i8_i8;
127
24
    Table[RTLIB::UDIV_I16] = i16_func_i16_i16;
128
24
    Table[RTLIB::UDIV_I32] = i32_func_i32_i32;
129
24
    Table[RTLIB::UDIV_I64] = i64_func_i64_i64;
130
24
    Table[RTLIB::UDIV_I128] = i64_i64_func_i64_i64_i64_i64;
131
24
    Table[RTLIB::SREM_I8] = i8_func_i8_i8;
132
24
    Table[RTLIB::SREM_I16] = i16_func_i16_i16;
133
24
    Table[RTLIB::SREM_I32] = i32_func_i32_i32;
134
24
    Table[RTLIB::SREM_I64] = i64_func_i64_i64;
135
24
    Table[RTLIB::SREM_I128] = i64_i64_func_i64_i64_i64_i64;
136
24
    Table[RTLIB::UREM_I8] = i8_func_i8_i8;
137
24
    Table[RTLIB::UREM_I16] = i16_func_i16_i16;
138
24
    Table[RTLIB::UREM_I32] = i32_func_i32_i32;
139
24
    Table[RTLIB::UREM_I64] = i64_func_i64_i64;
140
24
    Table[RTLIB::UREM_I128] = i64_i64_func_i64_i64_i64_i64;
141
24
    Table[RTLIB::SDIVREM_I8] = i8_func_i8_i8;
142
24
    Table[RTLIB::SDIVREM_I16] = i16_i16_func_i16_i16;
143
24
    Table[RTLIB::SDIVREM_I32] = i32_i32_func_i32_i32;
144
24
    Table[RTLIB::SDIVREM_I64] = i64_func_i64_i64;
145
24
    Table[RTLIB::SDIVREM_I128] = i64_i64_i64_i64_func_i64_i64_i64_i64;
146
24
    Table[RTLIB::UDIVREM_I8] = i8_func_i8_i8;
147
24
    Table[RTLIB::UDIVREM_I16] = i16_i16_func_i16_i16;
148
24
    Table[RTLIB::UDIVREM_I32] = i32_i32_func_i32_i32;
149
24
    Table[RTLIB::UDIVREM_I64] = i64_i64_func_i64_i64;
150
24
    Table[RTLIB::UDIVREM_I128] = i64_i64_i64_i64_func_i64_i64_i64_i64;
151
24
    Table[RTLIB::NEG_I32] = i32_func_i32;
152
24
    Table[RTLIB::NEG_I64] = i64_func_i64;
153
24
154
24
    // Floating-point.
155
24
    // All F80 and PPCF128 routines are unsupported.
156
24
    Table[RTLIB::ADD_F32] = f32_func_f32_f32;
157
24
    Table[RTLIB::ADD_F64] = f64_func_f64_f64;
158
24
    Table[RTLIB::ADD_F128] = func_iPTR_i64_i64_i64_i64;
159
24
    Table[RTLIB::SUB_F32] = f32_func_f32_f32;
160
24
    Table[RTLIB::SUB_F64] = f64_func_f64_f64;
161
24
    Table[RTLIB::SUB_F128] = func_iPTR_i64_i64_i64_i64;
162
24
    Table[RTLIB::MUL_F32] = f32_func_f32_f32;
163
24
    Table[RTLIB::MUL_F64] = f64_func_f64_f64;
164
24
    Table[RTLIB::MUL_F128] = func_iPTR_i64_i64_i64_i64;
165
24
    Table[RTLIB::DIV_F32] = f32_func_f32_f32;
166
24
    Table[RTLIB::DIV_F64] = f64_func_f64_f64;
167
24
    Table[RTLIB::DIV_F128] = func_iPTR_i64_i64_i64_i64;
168
24
    Table[RTLIB::REM_F32] = f32_func_f32_f32;
169
24
    Table[RTLIB::REM_F64] = f64_func_f64_f64;
170
24
    Table[RTLIB::REM_F128] = func_iPTR_i64_i64_i64_i64;
171
24
    Table[RTLIB::FMA_F32] = f32_func_f32_f32_f32;
172
24
    Table[RTLIB::FMA_F64] = f64_func_f64_f64_f64;
173
24
    Table[RTLIB::FMA_F128] = func_iPTR_i64_i64_i64_i64_i64_i64;
174
24
    Table[RTLIB::POWI_F32] = f32_func_f32_i32;
175
24
    Table[RTLIB::POWI_F64] = f64_func_f64_i32;
176
24
    Table[RTLIB::POWI_F128] = func_iPTR_i64_i64_i64_i64;
177
24
    Table[RTLIB::SQRT_F32] = f32_func_f32;
178
24
    Table[RTLIB::SQRT_F64] = f64_func_f64;
179
24
    Table[RTLIB::SQRT_F128] = func_iPTR_i64_i64;
180
24
    Table[RTLIB::LOG_F32] = f32_func_f32;
181
24
    Table[RTLIB::LOG_F64] = f64_func_f64;
182
24
    Table[RTLIB::LOG_F128] = func_iPTR_i64_i64;
183
24
    Table[RTLIB::LOG2_F32] = f32_func_f32;
184
24
    Table[RTLIB::LOG2_F64] = f64_func_f64;
185
24
    Table[RTLIB::LOG2_F128] = func_iPTR_i64_i64;
186
24
    Table[RTLIB::LOG10_F32] = f32_func_f32;
187
24
    Table[RTLIB::LOG10_F64] = f64_func_f64;
188
24
    Table[RTLIB::LOG10_F128] = func_iPTR_i64_i64;
189
24
    Table[RTLIB::EXP_F32] = f32_func_f32;
190
24
    Table[RTLIB::EXP_F64] = f64_func_f64;
191
24
    Table[RTLIB::EXP_F128] = func_iPTR_i64_i64;
192
24
    Table[RTLIB::EXP2_F32] = f32_func_f32;
193
24
    Table[RTLIB::EXP2_F64] = f64_func_f64;
194
24
    Table[RTLIB::EXP2_F128] = func_iPTR_i64_i64;
195
24
    Table[RTLIB::SIN_F32] = f32_func_f32;
196
24
    Table[RTLIB::SIN_F64] = f64_func_f64;
197
24
    Table[RTLIB::SIN_F128] = func_iPTR_i64_i64;
198
24
    Table[RTLIB::COS_F32] = f32_func_f32;
199
24
    Table[RTLIB::COS_F64] = f64_func_f64;
200
24
    Table[RTLIB::COS_F128] = func_iPTR_i64_i64;
201
24
    Table[RTLIB::SINCOS_F32] = func_f32_iPTR_iPTR;
202
24
    Table[RTLIB::SINCOS_F64] = func_f64_iPTR_iPTR;
203
24
    Table[RTLIB::SINCOS_F128] = func_i64_i64_iPTR_iPTR;
204
24
    Table[RTLIB::POW_F32] = f32_func_f32_f32;
205
24
    Table[RTLIB::POW_F64] = f64_func_f64_f64;
206
24
    Table[RTLIB::POW_F128] = func_iPTR_i64_i64_i64_i64;
207
24
    Table[RTLIB::CEIL_F32] = f32_func_f32;
208
24
    Table[RTLIB::CEIL_F64] = f64_func_f64;
209
24
    Table[RTLIB::CEIL_F128] = func_iPTR_i64_i64;
210
24
    Table[RTLIB::TRUNC_F32] = f32_func_f32;
211
24
    Table[RTLIB::TRUNC_F64] = f64_func_f64;
212
24
    Table[RTLIB::TRUNC_F128] = func_iPTR_i64_i64;
213
24
    Table[RTLIB::RINT_F32] = f32_func_f32;
214
24
    Table[RTLIB::RINT_F64] = f64_func_f64;
215
24
    Table[RTLIB::RINT_F128] = func_iPTR_i64_i64;
216
24
    Table[RTLIB::NEARBYINT_F32] = f32_func_f32;
217
24
    Table[RTLIB::NEARBYINT_F64] = f64_func_f64;
218
24
    Table[RTLIB::NEARBYINT_F128] = func_iPTR_i64_i64;
219
24
    Table[RTLIB::ROUND_F32] = f32_func_f32;
220
24
    Table[RTLIB::ROUND_F64] = f64_func_f64;
221
24
    Table[RTLIB::ROUND_F128] = func_iPTR_i64_i64;
222
24
    Table[RTLIB::LROUND_F32] = iPTR_func_f32;
223
24
    Table[RTLIB::LROUND_F64] = iPTR_func_f64;
224
24
    Table[RTLIB::LROUND_F128] = iPTR_func_i64_i64;
225
24
    Table[RTLIB::LLROUND_F32] = i64_func_f32;
226
24
    Table[RTLIB::LLROUND_F64] = i64_func_f64;
227
24
    Table[RTLIB::LLROUND_F128] = i64_func_i64_i64;
228
24
    Table[RTLIB::LRINT_F32] = iPTR_func_f32;
229
24
    Table[RTLIB::LRINT_F64] = iPTR_func_f64;
230
24
    Table[RTLIB::LRINT_F128] = iPTR_func_i64_i64;
231
24
    Table[RTLIB::LLRINT_F32] = i64_func_f32;
232
24
    Table[RTLIB::LLRINT_F64] = i64_func_f64;
233
24
    Table[RTLIB::LLRINT_F128] = i64_func_i64_i64;
234
24
    Table[RTLIB::FLOOR_F32] = f32_func_f32;
235
24
    Table[RTLIB::FLOOR_F64] = f64_func_f64;
236
24
    Table[RTLIB::FLOOR_F128] = func_iPTR_i64_i64;
237
24
    Table[RTLIB::COPYSIGN_F32] = f32_func_f32_f32;
238
24
    Table[RTLIB::COPYSIGN_F64] = f64_func_f64_f64;
239
24
    Table[RTLIB::COPYSIGN_F128] = func_iPTR_i64_i64_i64_i64;
240
24
    Table[RTLIB::FMIN_F32] = f32_func_f32_f32;
241
24
    Table[RTLIB::FMIN_F64] = f64_func_f64_f64;
242
24
    Table[RTLIB::FMIN_F128] = func_iPTR_i64_i64_i64_i64;
243
24
    Table[RTLIB::FMAX_F32] = f32_func_f32_f32;
244
24
    Table[RTLIB::FMAX_F64] = f64_func_f64_f64;
245
24
    Table[RTLIB::FMAX_F128] = func_iPTR_i64_i64_i64_i64;
246
24
247
24
    // Conversion
248
24
    // All F80 and PPCF128 routines are unsupported.
249
24
    Table[RTLIB::FPEXT_F64_F128] = func_iPTR_f64;
250
24
    Table[RTLIB::FPEXT_F32_F128] = func_iPTR_f32;
251
24
    Table[RTLIB::FPEXT_F32_F64] = f64_func_f32;
252
24
    Table[RTLIB::FPEXT_F16_F32] = f32_func_i16;
253
24
    Table[RTLIB::FPROUND_F32_F16] = i16_func_f32;
254
24
    Table[RTLIB::FPROUND_F64_F16] = i16_func_f64;
255
24
    Table[RTLIB::FPROUND_F64_F32] = f32_func_f64;
256
24
    Table[RTLIB::FPROUND_F128_F16] = i16_func_i64_i64;
257
24
    Table[RTLIB::FPROUND_F128_F32] = f32_func_i64_i64;
258
24
    Table[RTLIB::FPROUND_F128_F64] = f64_func_i64_i64;
259
24
    Table[RTLIB::FPTOSINT_F32_I32] = i32_func_f32;
260
24
    Table[RTLIB::FPTOSINT_F32_I64] = i64_func_f32;
261
24
    Table[RTLIB::FPTOSINT_F32_I128] = i64_i64_func_f32;
262
24
    Table[RTLIB::FPTOSINT_F64_I32] = i32_func_f64;
263
24
    Table[RTLIB::FPTOSINT_F64_I64] = i64_func_f64;
264
24
    Table[RTLIB::FPTOSINT_F64_I128] = i64_i64_func_f64;
265
24
    Table[RTLIB::FPTOSINT_F128_I32] = i32_func_i64_i64;
266
24
    Table[RTLIB::FPTOSINT_F128_I64] = i64_func_i64_i64;
267
24
    Table[RTLIB::FPTOSINT_F128_I128] = i64_i64_func_i64_i64;
268
24
    Table[RTLIB::FPTOUINT_F32_I32] = i32_func_f32;
269
24
    Table[RTLIB::FPTOUINT_F32_I64] = i64_func_f32;
270
24
    Table[RTLIB::FPTOUINT_F32_I128] = i64_i64_func_f32;
271
24
    Table[RTLIB::FPTOUINT_F64_I32] = i32_func_f64;
272
24
    Table[RTLIB::FPTOUINT_F64_I64] = i64_func_f64;
273
24
    Table[RTLIB::FPTOUINT_F64_I128] = i64_i64_func_f64;
274
24
    Table[RTLIB::FPTOUINT_F128_I32] = i32_func_i64_i64;
275
24
    Table[RTLIB::FPTOUINT_F128_I64] = i64_func_i64_i64;
276
24
    Table[RTLIB::FPTOUINT_F128_I128] = i64_i64_func_i64_i64;
277
24
    Table[RTLIB::SINTTOFP_I32_F32] = f32_func_i32;
278
24
    Table[RTLIB::SINTTOFP_I32_F64] = f64_func_i32;
279
24
    Table[RTLIB::SINTTOFP_I32_F128] = func_iPTR_i32;
280
24
    Table[RTLIB::SINTTOFP_I64_F32] = f32_func_i64;
281
24
    Table[RTLIB::SINTTOFP_I64_F64] = f64_func_i64;
282
24
    Table[RTLIB::SINTTOFP_I64_F128] = func_iPTR_i64;
283
24
    Table[RTLIB::SINTTOFP_I128_F32] = f32_func_i64_i64;
284
24
    Table[RTLIB::SINTTOFP_I128_F64] = f64_func_i64_i64;
285
24
    Table[RTLIB::SINTTOFP_I128_F128] = func_iPTR_i64_i64;
286
24
    Table[RTLIB::UINTTOFP_I32_F32] = f32_func_i32;
287
24
    Table[RTLIB::UINTTOFP_I32_F64] = f64_func_i64;
288
24
    Table[RTLIB::UINTTOFP_I32_F128] = func_iPTR_i32;
289
24
    Table[RTLIB::UINTTOFP_I64_F32] = f32_func_i64;
290
24
    Table[RTLIB::UINTTOFP_I64_F64] = f64_func_i64;
291
24
    Table[RTLIB::UINTTOFP_I64_F128] = func_iPTR_i64;
292
24
    Table[RTLIB::UINTTOFP_I128_F32] = f32_func_i64_i64;
293
24
    Table[RTLIB::UINTTOFP_I128_F64] = f64_func_i64_i64;
294
24
    Table[RTLIB::UINTTOFP_I128_F128] = func_iPTR_i64_i64;
295
24
296
24
    // Comparison
297
24
    // ALl F80 and PPCF128 routines are unsupported.
298
24
    Table[RTLIB::OEQ_F32] = i32_func_f32_f32;
299
24
    Table[RTLIB::OEQ_F64] = i32_func_f64_f64;
300
24
    Table[RTLIB::OEQ_F128] = i32_func_i64_i64_i64_i64;
301
24
    Table[RTLIB::UNE_F32] = i32_func_f32_f32;
302
24
    Table[RTLIB::UNE_F64] = i32_func_f64_f64;
303
24
    Table[RTLIB::UNE_F128] = i32_func_i64_i64_i64_i64;
304
24
    Table[RTLIB::OGE_F32] = i32_func_f32_f32;
305
24
    Table[RTLIB::OGE_F64] = i32_func_f64_f64;
306
24
    Table[RTLIB::OGE_F128] = i32_func_i64_i64_i64_i64;
307
24
    Table[RTLIB::OLT_F32] = i32_func_f32_f32;
308
24
    Table[RTLIB::OLT_F64] = i32_func_f64_f64;
309
24
    Table[RTLIB::OLT_F128] = i32_func_i64_i64_i64_i64;
310
24
    Table[RTLIB::OLE_F32] = i32_func_f32_f32;
311
24
    Table[RTLIB::OLE_F64] = i32_func_f64_f64;
312
24
    Table[RTLIB::OLE_F128] = i32_func_i64_i64_i64_i64;
313
24
    Table[RTLIB::OGT_F32] = i32_func_f32_f32;
314
24
    Table[RTLIB::OGT_F64] = i32_func_f64_f64;
315
24
    Table[RTLIB::OGT_F128] = i32_func_i64_i64_i64_i64;
316
24
    Table[RTLIB::UO_F32] = i32_func_f32_f32;
317
24
    Table[RTLIB::UO_F64] = i32_func_f64_f64;
318
24
    Table[RTLIB::UO_F128] = i32_func_i64_i64_i64_i64;
319
24
    // O_FXX has the weird property that it uses the same libcall name as UO_FXX
320
24
    // This breaks our name-based lookup. Fortunately only the UO family of
321
24
    // libcalls appears to be actually used.
322
24
    Table[RTLIB::O_F32] = unsupported;
323
24
    Table[RTLIB::O_F64] = unsupported;
324
24
    Table[RTLIB::O_F128] = unsupported;
325
24
326
24
    // Memory
327
24
    Table[RTLIB::MEMCPY] = iPTR_func_iPTR_iPTR_iPTR;
328
24
    Table[RTLIB::MEMSET] = iPTR_func_iPTR_i32_iPTR;
329
24
    Table[RTLIB::MEMMOVE] = iPTR_func_iPTR_iPTR_iPTR;
330
24
331
24
    // __stack_chk_fail
332
24
    Table[RTLIB::STACKPROTECTOR_CHECK_FAIL] = func;
333
24
334
24
    // Return address handling
335
24
    Table[RTLIB::RETURN_ADDRESS] = i32_func_i32;
336
24
337
24
    // Element-wise Atomic memory
338
24
    // TODO: Fix these when we implement atomic support
339
24
    Table[RTLIB::MEMCPY_ELEMENT_UNORDERED_ATOMIC_1] = unsupported;
340
24
    Table[RTLIB::MEMCPY_ELEMENT_UNORDERED_ATOMIC_2] = unsupported;
341
24
    Table[RTLIB::MEMCPY_ELEMENT_UNORDERED_ATOMIC_4] = unsupported;
342
24
    Table[RTLIB::MEMCPY_ELEMENT_UNORDERED_ATOMIC_8] = unsupported;
343
24
    Table[RTLIB::MEMCPY_ELEMENT_UNORDERED_ATOMIC_16] = unsupported;
344
24
    Table[RTLIB::MEMMOVE_ELEMENT_UNORDERED_ATOMIC_1] = unsupported;
345
24
    Table[RTLIB::MEMMOVE_ELEMENT_UNORDERED_ATOMIC_2] = unsupported;
346
24
    Table[RTLIB::MEMMOVE_ELEMENT_UNORDERED_ATOMIC_4] = unsupported;
347
24
    Table[RTLIB::MEMMOVE_ELEMENT_UNORDERED_ATOMIC_8] = unsupported;
348
24
    Table[RTLIB::MEMMOVE_ELEMENT_UNORDERED_ATOMIC_16] = unsupported;
349
24
350
24
    Table[RTLIB::MEMSET_ELEMENT_UNORDERED_ATOMIC_1] = unsupported;
351
24
    Table[RTLIB::MEMSET_ELEMENT_UNORDERED_ATOMIC_2] = unsupported;
352
24
    Table[RTLIB::MEMSET_ELEMENT_UNORDERED_ATOMIC_4] = unsupported;
353
24
    Table[RTLIB::MEMSET_ELEMENT_UNORDERED_ATOMIC_8] = unsupported;
354
24
    Table[RTLIB::MEMSET_ELEMENT_UNORDERED_ATOMIC_16] = unsupported;
355
24
356
24
    // Atomic '__sync_*' libcalls.
357
24
    // TODO: Fix these when we implement atomic support
358
24
    Table[RTLIB::SYNC_VAL_COMPARE_AND_SWAP_1] = unsupported;
359
24
    Table[RTLIB::SYNC_VAL_COMPARE_AND_SWAP_2] = unsupported;
360
24
    Table[RTLIB::SYNC_VAL_COMPARE_AND_SWAP_4] = unsupported;
361
24
    Table[RTLIB::SYNC_VAL_COMPARE_AND_SWAP_8] = unsupported;
362
24
    Table[RTLIB::SYNC_VAL_COMPARE_AND_SWAP_16] = unsupported;
363
24
    Table[RTLIB::SYNC_LOCK_TEST_AND_SET_1] = unsupported;
364
24
    Table[RTLIB::SYNC_LOCK_TEST_AND_SET_2] = unsupported;
365
24
    Table[RTLIB::SYNC_LOCK_TEST_AND_SET_4] = unsupported;
366
24
    Table[RTLIB::SYNC_LOCK_TEST_AND_SET_8] = unsupported;
367
24
    Table[RTLIB::SYNC_LOCK_TEST_AND_SET_16] = unsupported;
368
24
    Table[RTLIB::SYNC_FETCH_AND_ADD_1] = unsupported;
369
24
    Table[RTLIB::SYNC_FETCH_AND_ADD_2] = unsupported;
370
24
    Table[RTLIB::SYNC_FETCH_AND_ADD_4] = unsupported;
371
24
    Table[RTLIB::SYNC_FETCH_AND_ADD_8] = unsupported;
372
24
    Table[RTLIB::SYNC_FETCH_AND_ADD_16] = unsupported;
373
24
    Table[RTLIB::SYNC_FETCH_AND_SUB_1] = unsupported;
374
24
    Table[RTLIB::SYNC_FETCH_AND_SUB_2] = unsupported;
375
24
    Table[RTLIB::SYNC_FETCH_AND_SUB_4] = unsupported;
376
24
    Table[RTLIB::SYNC_FETCH_AND_SUB_8] = unsupported;
377
24
    Table[RTLIB::SYNC_FETCH_AND_SUB_16] = unsupported;
378
24
    Table[RTLIB::SYNC_FETCH_AND_AND_1] = unsupported;
379
24
    Table[RTLIB::SYNC_FETCH_AND_AND_2] = unsupported;
380
24
    Table[RTLIB::SYNC_FETCH_AND_AND_4] = unsupported;
381
24
    Table[RTLIB::SYNC_FETCH_AND_AND_8] = unsupported;
382
24
    Table[RTLIB::SYNC_FETCH_AND_AND_16] = unsupported;
383
24
    Table[RTLIB::SYNC_FETCH_AND_OR_1] = unsupported;
384
24
    Table[RTLIB::SYNC_FETCH_AND_OR_2] = unsupported;
385
24
    Table[RTLIB::SYNC_FETCH_AND_OR_4] = unsupported;
386
24
    Table[RTLIB::SYNC_FETCH_AND_OR_8] = unsupported;
387
24
    Table[RTLIB::SYNC_FETCH_AND_OR_16] = unsupported;
388
24
    Table[RTLIB::SYNC_FETCH_AND_XOR_1] = unsupported;
389
24
    Table[RTLIB::SYNC_FETCH_AND_XOR_2] = unsupported;
390
24
    Table[RTLIB::SYNC_FETCH_AND_XOR_4] = unsupported;
391
24
    Table[RTLIB::SYNC_FETCH_AND_XOR_8] = unsupported;
392
24
    Table[RTLIB::SYNC_FETCH_AND_XOR_16] = unsupported;
393
24
    Table[RTLIB::SYNC_FETCH_AND_NAND_1] = unsupported;
394
24
    Table[RTLIB::SYNC_FETCH_AND_NAND_2] = unsupported;
395
24
    Table[RTLIB::SYNC_FETCH_AND_NAND_4] = unsupported;
396
24
    Table[RTLIB::SYNC_FETCH_AND_NAND_8] = unsupported;
397
24
    Table[RTLIB::SYNC_FETCH_AND_NAND_16] = unsupported;
398
24
    Table[RTLIB::SYNC_FETCH_AND_MAX_1] = unsupported;
399
24
    Table[RTLIB::SYNC_FETCH_AND_MAX_2] = unsupported;
400
24
    Table[RTLIB::SYNC_FETCH_AND_MAX_4] = unsupported;
401
24
    Table[RTLIB::SYNC_FETCH_AND_MAX_8] = unsupported;
402
24
    Table[RTLIB::SYNC_FETCH_AND_MAX_16] = unsupported;
403
24
    Table[RTLIB::SYNC_FETCH_AND_UMAX_1] = unsupported;
404
24
    Table[RTLIB::SYNC_FETCH_AND_UMAX_2] = unsupported;
405
24
    Table[RTLIB::SYNC_FETCH_AND_UMAX_4] = unsupported;
406
24
    Table[RTLIB::SYNC_FETCH_AND_UMAX_8] = unsupported;
407
24
    Table[RTLIB::SYNC_FETCH_AND_UMAX_16] = unsupported;
408
24
    Table[RTLIB::SYNC_FETCH_AND_MIN_1] = unsupported;
409
24
    Table[RTLIB::SYNC_FETCH_AND_MIN_2] = unsupported;
410
24
    Table[RTLIB::SYNC_FETCH_AND_MIN_4] = unsupported;
411
24
    Table[RTLIB::SYNC_FETCH_AND_MIN_8] = unsupported;
412
24
    Table[RTLIB::SYNC_FETCH_AND_MIN_16] = unsupported;
413
24
    Table[RTLIB::SYNC_FETCH_AND_UMIN_1] = unsupported;
414
24
    Table[RTLIB::SYNC_FETCH_AND_UMIN_2] = unsupported;
415
24
    Table[RTLIB::SYNC_FETCH_AND_UMIN_4] = unsupported;
416
24
    Table[RTLIB::SYNC_FETCH_AND_UMIN_8] = unsupported;
417
24
    Table[RTLIB::SYNC_FETCH_AND_UMIN_16] = unsupported;
418
24
419
24
    // Atomic '__atomic_*' libcalls.
420
24
    // TODO: Fix these when we implement atomic support
421
24
    Table[RTLIB::ATOMIC_LOAD] = unsupported;
422
24
    Table[RTLIB::ATOMIC_LOAD_1] = unsupported;
423
24
    Table[RTLIB::ATOMIC_LOAD_2] = unsupported;
424
24
    Table[RTLIB::ATOMIC_LOAD_4] = unsupported;
425
24
    Table[RTLIB::ATOMIC_LOAD_8] = unsupported;
426
24
    Table[RTLIB::ATOMIC_LOAD_16] = unsupported;
427
24
428
24
    Table[RTLIB::ATOMIC_STORE] = unsupported;
429
24
    Table[RTLIB::ATOMIC_STORE_1] = unsupported;
430
24
    Table[RTLIB::ATOMIC_STORE_2] = unsupported;
431
24
    Table[RTLIB::ATOMIC_STORE_4] = unsupported;
432
24
    Table[RTLIB::ATOMIC_STORE_8] = unsupported;
433
24
    Table[RTLIB::ATOMIC_STORE_16] = unsupported;
434
24
435
24
    Table[RTLIB::ATOMIC_EXCHANGE] = unsupported;
436
24
    Table[RTLIB::ATOMIC_EXCHANGE_1] = unsupported;
437
24
    Table[RTLIB::ATOMIC_EXCHANGE_2] = unsupported;
438
24
    Table[RTLIB::ATOMIC_EXCHANGE_4] = unsupported;
439
24
    Table[RTLIB::ATOMIC_EXCHANGE_8] = unsupported;
440
24
    Table[RTLIB::ATOMIC_EXCHANGE_16] = unsupported;
441
24
442
24
    Table[RTLIB::ATOMIC_COMPARE_EXCHANGE] = unsupported;
443
24
    Table[RTLIB::ATOMIC_COMPARE_EXCHANGE_1] = unsupported;
444
24
    Table[RTLIB::ATOMIC_COMPARE_EXCHANGE_2] = unsupported;
445
24
    Table[RTLIB::ATOMIC_COMPARE_EXCHANGE_4] = unsupported;
446
24
    Table[RTLIB::ATOMIC_COMPARE_EXCHANGE_8] = unsupported;
447
24
    Table[RTLIB::ATOMIC_COMPARE_EXCHANGE_16] = unsupported;
448
24
449
24
    Table[RTLIB::ATOMIC_FETCH_ADD_1] = unsupported;
450
24
    Table[RTLIB::ATOMIC_FETCH_ADD_2] = unsupported;
451
24
    Table[RTLIB::ATOMIC_FETCH_ADD_4] = unsupported;
452
24
    Table[RTLIB::ATOMIC_FETCH_ADD_8] = unsupported;
453
24
    Table[RTLIB::ATOMIC_FETCH_ADD_16] = unsupported;
454
24
455
24
    Table[RTLIB::ATOMIC_FETCH_SUB_1] = unsupported;
456
24
    Table[RTLIB::ATOMIC_FETCH_SUB_2] = unsupported;
457
24
    Table[RTLIB::ATOMIC_FETCH_SUB_4] = unsupported;
458
24
    Table[RTLIB::ATOMIC_FETCH_SUB_8] = unsupported;
459
24
    Table[RTLIB::ATOMIC_FETCH_SUB_16] = unsupported;
460
24
461
24
    Table[RTLIB::ATOMIC_FETCH_AND_1] = unsupported;
462
24
    Table[RTLIB::ATOMIC_FETCH_AND_2] = unsupported;
463
24
    Table[RTLIB::ATOMIC_FETCH_AND_4] = unsupported;
464
24
    Table[RTLIB::ATOMIC_FETCH_AND_8] = unsupported;
465
24
    Table[RTLIB::ATOMIC_FETCH_AND_16] = unsupported;
466
24
467
24
    Table[RTLIB::ATOMIC_FETCH_OR_1] = unsupported;
468
24
    Table[RTLIB::ATOMIC_FETCH_OR_2] = unsupported;
469
24
    Table[RTLIB::ATOMIC_FETCH_OR_4] = unsupported;
470
24
    Table[RTLIB::ATOMIC_FETCH_OR_8] = unsupported;
471
24
    Table[RTLIB::ATOMIC_FETCH_OR_16] = unsupported;
472
24
473
24
    Table[RTLIB::ATOMIC_FETCH_XOR_1] = unsupported;
474
24
    Table[RTLIB::ATOMIC_FETCH_XOR_2] = unsupported;
475
24
    Table[RTLIB::ATOMIC_FETCH_XOR_4] = unsupported;
476
24
    Table[RTLIB::ATOMIC_FETCH_XOR_8] = unsupported;
477
24
    Table[RTLIB::ATOMIC_FETCH_XOR_16] = unsupported;
478
24
479
24
    Table[RTLIB::ATOMIC_FETCH_NAND_1] = unsupported;
480
24
    Table[RTLIB::ATOMIC_FETCH_NAND_2] = unsupported;
481
24
    Table[RTLIB::ATOMIC_FETCH_NAND_4] = unsupported;
482
24
    Table[RTLIB::ATOMIC_FETCH_NAND_8] = unsupported;
483
24
    Table[RTLIB::ATOMIC_FETCH_NAND_16] = unsupported;
484
24
  }
485
};
486
487
ManagedStatic<RuntimeLibcallSignatureTable> RuntimeLibcallSignatures;
488
489
// Maps libcall names to their RTLIB::Libcall number. Builds the map in a
490
// constructor for use with ManagedStatic
491
struct StaticLibcallNameMap {
492
  StringMap<RTLIB::Libcall> Map;
493
24
  StaticLibcallNameMap() {
494
24
    static const std::pair<const char *, RTLIB::Libcall> NameLibcalls[] = {
495
11.8k
#define HANDLE_LIBCALL(code, name) {(const char *)name, RTLIB::code},
496
24
#include "llvm/IR/RuntimeLibcalls.def"
497
24
#undef HANDLE_LIBCALL
498
24
    };
499
11.8k
    for (const auto &NameLibcall : NameLibcalls) {
500
11.8k
      if (NameLibcall.first != nullptr &&
501
11.8k
          
RuntimeLibcallSignatures->Table[NameLibcall.second] != unsupported11.3k
) {
502
4.80k
        assert(Map.find(NameLibcall.first) == Map.end() &&
503
4.80k
               "duplicate libcall names in name map");
504
4.80k
        Map[NameLibcall.first] = NameLibcall.second;
505
4.80k
      }
506
11.8k
    }
507
24
    // Override the __gnu_f2h_ieee/__gnu_h2f_ieee names so that the f32 name is
508
24
    // consistent with the f64 and f128 names.
509
24
    Map["__extendhfsf2"] = RTLIB::FPEXT_F16_F32;
510
24
    Map["__truncsfhf2"] = RTLIB::FPROUND_F32_F16;
511
24
512
24
    Map["emscripten_return_address"] = RTLIB::RETURN_ADDRESS;
513
24
  }
514
};
515
516
} // end anonymous namespace
517
518
void llvm::getLibcallSignature(const WebAssemblySubtarget &Subtarget,
519
                               RTLIB::Libcall LC,
520
                               SmallVectorImpl<wasm::ValType> &Rets,
521
226
                               SmallVectorImpl<wasm::ValType> &Params) {
522
226
  assert(Rets.empty());
523
226
  assert(Params.empty());
524
226
525
226
  wasm::ValType PtrTy =
526
226
      Subtarget.hasAddr64() ? 
wasm::ValType::I640
: wasm::ValType::I32;
527
226
528
226
  auto &Table = RuntimeLibcallSignatures->Table;
529
226
  switch (Table[LC]) {
530
226
  case func:
531
1
    break;
532
226
  case f32_func_f32:
533
32
    Rets.push_back(wasm::ValType::F32);
534
32
    Params.push_back(wasm::ValType::F32);
535
32
    break;
536
226
  case f32_func_f64:
537
0
    Rets.push_back(wasm::ValType::F32);
538
0
    Params.push_back(wasm::ValType::F64);
539
0
    break;
540
226
  case f32_func_i32:
541
0
    Rets.push_back(wasm::ValType::F32);
542
0
    Params.push_back(wasm::ValType::I32);
543
0
    break;
544
226
  case f32_func_i64:
545
0
    Rets.push_back(wasm::ValType::F32);
546
0
    Params.push_back(wasm::ValType::I64);
547
0
    break;
548
226
  case f32_func_i16:
549
6
    Rets.push_back(wasm::ValType::F32);
550
6
    Params.push_back(wasm::ValType::I32);
551
6
    break;
552
226
  case f64_func_f32:
553
0
    Rets.push_back(wasm::ValType::F64);
554
0
    Params.push_back(wasm::ValType::F32);
555
0
    break;
556
226
  case f64_func_f64:
557
20
    Rets.push_back(wasm::ValType::F64);
558
20
    Params.push_back(wasm::ValType::F64);
559
20
    break;
560
226
  case f64_func_i32:
561
0
    Rets.push_back(wasm::ValType::F64);
562
0
    Params.push_back(wasm::ValType::I32);
563
0
    break;
564
226
  case f64_func_i64:
565
0
    Rets.push_back(wasm::ValType::F64);
566
0
    Params.push_back(wasm::ValType::I64);
567
0
    break;
568
226
  case i32_func_f32:
569
0
    Rets.push_back(wasm::ValType::I32);
570
0
    Params.push_back(wasm::ValType::F32);
571
0
    break;
572
226
  case i32_func_f64:
573
0
    Rets.push_back(wasm::ValType::I32);
574
0
    Params.push_back(wasm::ValType::F64);
575
0
    break;
576
226
  case i32_func_i32:
577
1
    Rets.push_back(wasm::ValType::I32);
578
1
    Params.push_back(wasm::ValType::I32);
579
1
    break;
580
226
  case i64_func_f32:
581
1
    Rets.push_back(wasm::ValType::I64);
582
1
    Params.push_back(wasm::ValType::F32);
583
1
    break;
584
226
  case i64_func_f64:
585
1
    Rets.push_back(wasm::ValType::I64);
586
1
    Params.push_back(wasm::ValType::F64);
587
1
    break;
588
226
  case i64_func_i64:
589
0
    Rets.push_back(wasm::ValType::I64);
590
0
    Params.push_back(wasm::ValType::I64);
591
0
    break;
592
226
  case f32_func_f32_f32:
593
21
    Rets.push_back(wasm::ValType::F32);
594
21
    Params.push_back(wasm::ValType::F32);
595
21
    Params.push_back(wasm::ValType::F32);
596
21
    break;
597
226
  case f32_func_f32_i32:
598
4
    Rets.push_back(wasm::ValType::F32);
599
4
    Params.push_back(wasm::ValType::F32);
600
4
    Params.push_back(wasm::ValType::I32);
601
4
    break;
602
226
  case f32_func_i64_i64:
603
0
    Rets.push_back(wasm::ValType::F32);
604
0
    Params.push_back(wasm::ValType::I64);
605
0
    Params.push_back(wasm::ValType::I64);
606
0
    break;
607
226
  case f64_func_f64_f64:
608
4
    Rets.push_back(wasm::ValType::F64);
609
4
    Params.push_back(wasm::ValType::F64);
610
4
    Params.push_back(wasm::ValType::F64);
611
4
    break;
612
226
  case f64_func_f64_i32:
613
2
    Rets.push_back(wasm::ValType::F64);
614
2
    Params.push_back(wasm::ValType::F64);
615
2
    Params.push_back(wasm::ValType::I32);
616
2
    break;
617
226
  case f64_func_i64_i64:
618
0
    Rets.push_back(wasm::ValType::F64);
619
0
    Params.push_back(wasm::ValType::I64);
620
0
    Params.push_back(wasm::ValType::I64);
621
0
    break;
622
226
  case i16_func_f32:
623
2
    Rets.push_back(wasm::ValType::I32);
624
2
    Params.push_back(wasm::ValType::F32);
625
2
    break;
626
226
  case i16_func_f64:
627
2
    Rets.push_back(wasm::ValType::I32);
628
2
    Params.push_back(wasm::ValType::F64);
629
2
    break;
630
226
  case i16_func_i64_i64:
631
2
    Rets.push_back(wasm::ValType::I32);
632
2
    Params.push_back(wasm::ValType::I64);
633
2
    Params.push_back(wasm::ValType::I64);
634
2
    break;
635
226
  case i8_func_i8_i8:
636
0
    Rets.push_back(wasm::ValType::I32);
637
0
    Params.push_back(wasm::ValType::I32);
638
0
    Params.push_back(wasm::ValType::I32);
639
0
    break;
640
226
  case func_f32_iPTR_iPTR:
641
0
    Params.push_back(wasm::ValType::F32);
642
0
    Params.push_back(PtrTy);
643
0
    Params.push_back(PtrTy);
644
0
    break;
645
226
  case func_f64_iPTR_iPTR:
646
0
    Params.push_back(wasm::ValType::F64);
647
0
    Params.push_back(PtrTy);
648
0
    Params.push_back(PtrTy);
649
0
    break;
650
226
  case i16_func_i16_i16:
651
0
    Rets.push_back(wasm::ValType::I32);
652
0
    Params.push_back(wasm::ValType::I32);
653
0
    Params.push_back(wasm::ValType::I32);
654
0
    break;
655
226
  case i32_func_f32_f32:
656
0
    Rets.push_back(wasm::ValType::I32);
657
0
    Params.push_back(wasm::ValType::F32);
658
0
    Params.push_back(wasm::ValType::F32);
659
0
    break;
660
226
  case i32_func_f64_f64:
661
0
    Rets.push_back(wasm::ValType::I32);
662
0
    Params.push_back(wasm::ValType::F64);
663
0
    Params.push_back(wasm::ValType::F64);
664
0
    break;
665
226
  case i32_func_i32_i32:
666
0
    Rets.push_back(wasm::ValType::I32);
667
0
    Params.push_back(wasm::ValType::I32);
668
0
    Params.push_back(wasm::ValType::I32);
669
0
    break;
670
226
  case i32_func_i32_i32_iPTR:
671
0
    Rets.push_back(wasm::ValType::I32);
672
0
    Params.push_back(wasm::ValType::I32);
673
0
    Params.push_back(wasm::ValType::I32);
674
0
    Params.push_back(PtrTy);
675
0
    break;
676
226
  case i64_func_i64_i64:
677
0
    Rets.push_back(wasm::ValType::I64);
678
0
    Params.push_back(wasm::ValType::I64);
679
0
    Params.push_back(wasm::ValType::I64);
680
0
    break;
681
226
  case i64_func_i64_i64_iPTR:
682
0
    Rets.push_back(wasm::ValType::I64);
683
0
    Params.push_back(wasm::ValType::I64);
684
0
    Params.push_back(wasm::ValType::I64);
685
0
    Params.push_back(PtrTy);
686
0
    break;
687
226
  case i64_i64_func_f32:
688
#if 0 // TODO: Enable this when wasm gets multiple-return-value support.
689
    Rets.push_back(wasm::ValType::I64);
690
    Rets.push_back(wasm::ValType::I64);
691
#else
692
    Params.push_back(PtrTy);
693
0
#endif
694
0
    Params.push_back(wasm::ValType::F32);
695
0
    break;
696
226
  case i64_i64_func_f64:
697
#if 0 // TODO: Enable this when wasm gets multiple-return-value support.
698
    Rets.push_back(wasm::ValType::I64);
699
    Rets.push_back(wasm::ValType::I64);
700
#else
701
    Params.push_back(PtrTy);
702
0
#endif
703
0
    Params.push_back(wasm::ValType::F64);
704
0
    break;
705
226
  case i16_i16_func_i16_i16:
706
#if 0 // TODO: Enable this when wasm gets multiple-return-value support.
707
    Rets.push_back(wasm::ValType::I32);
708
    Rets.push_back(wasm::ValType::I32);
709
#else
710
    Params.push_back(PtrTy);
711
0
#endif
712
0
    Params.push_back(wasm::ValType::I32);
713
0
    Params.push_back(wasm::ValType::I32);
714
0
    break;
715
226
  case i32_i32_func_i32_i32:
716
#if 0 // TODO: Enable this when wasm gets multiple-return-value support.
717
    Rets.push_back(wasm::ValType::I32);
718
    Rets.push_back(wasm::ValType::I32);
719
#else
720
    Params.push_back(PtrTy);
721
0
#endif
722
0
    Params.push_back(wasm::ValType::I32);
723
0
    Params.push_back(wasm::ValType::I32);
724
0
    break;
725
226
  case i64_i64_func_i64_i64:
726
#if 0 // TODO: Enable this when wasm gets multiple-return-value support.
727
    Rets.push_back(wasm::ValType::I64);
728
    Rets.push_back(wasm::ValType::I64);
729
#else
730
    Params.push_back(PtrTy);
731
0
#endif
732
0
    Params.push_back(wasm::ValType::I64);
733
0
    Params.push_back(wasm::ValType::I64);
734
0
    break;
735
226
  case i64_i64_func_i64_i64_i64_i64:
736
#if 0 // TODO: Enable this when wasm gets multiple-return-value support.
737
    Rets.push_back(wasm::ValType::I64);
738
    Rets.push_back(wasm::ValType::I64);
739
#else
740
    Params.push_back(PtrTy);
741
12
#endif
742
12
    Params.push_back(wasm::ValType::I64);
743
12
    Params.push_back(wasm::ValType::I64);
744
12
    Params.push_back(wasm::ValType::I64);
745
12
    Params.push_back(wasm::ValType::I64);
746
12
    break;
747
226
  case i64_i64_func_i64_i64_i64_i64_iPTR:
748
#if 0 // TODO: Enable this when wasm gets multiple-return-value support.
749
    Rets.push_back(wasm::ValType::I64);
750
    Rets.push_back(wasm::ValType::I64);
751
#else
752
    Params.push_back(PtrTy);
753
1
#endif
754
1
    Params.push_back(wasm::ValType::I64);
755
1
    Params.push_back(wasm::ValType::I64);
756
1
    Params.push_back(wasm::ValType::I64);
757
1
    Params.push_back(wasm::ValType::I64);
758
1
    Params.push_back(PtrTy);
759
1
    break;
760
226
  case i64_i64_i64_i64_func_i64_i64_i64_i64:
761
#if 0 // TODO: Enable this when wasm gets multiple-return-value support.
762
    Rets.push_back(wasm::ValType::I64);
763
    Rets.push_back(wasm::ValType::I64);
764
    Rets.push_back(wasm::ValType::I64);
765
    Rets.push_back(wasm::ValType::I64);
766
#else
767
    Params.push_back(PtrTy);
768
0
#endif
769
0
    Params.push_back(wasm::ValType::I64);
770
0
    Params.push_back(wasm::ValType::I64);
771
0
    Params.push_back(wasm::ValType::I64);
772
0
    Params.push_back(wasm::ValType::I64);
773
0
    break;
774
226
  case i64_i64_func_i64_i64_i32:
775
#if 0 // TODO: Enable this when wasm gets multiple-return-value support.
776
    Rets.push_back(wasm::ValType::I64);
777
    Rets.push_back(wasm::ValType::I64);
778
    Rets.push_back(wasm::ValType::I64);
779
    Rets.push_back(wasm::ValType::I64);
780
#else
781
    Params.push_back(PtrTy);
782
75
#endif
783
75
    Params.push_back(wasm::ValType::I64);
784
75
    Params.push_back(wasm::ValType::I64);
785
75
    Params.push_back(wasm::ValType::I32);
786
75
    break;
787
226
  case iPTR_func_iPTR_i32_iPTR:
788
9
    Rets.push_back(PtrTy);
789
9
    Params.push_back(PtrTy);
790
9
    Params.push_back(wasm::ValType::I32);
791
9
    Params.push_back(PtrTy);
792
9
    break;
793
226
  case iPTR_func_iPTR_iPTR_iPTR:
794
15
    Rets.push_back(PtrTy);
795
15
    Params.push_back(PtrTy);
796
15
    Params.push_back(PtrTy);
797
15
    Params.push_back(PtrTy);
798
15
    break;
799
226
  case f32_func_f32_f32_f32:
800
1
    Rets.push_back(wasm::ValType::F32);
801
1
    Params.push_back(wasm::ValType::F32);
802
1
    Params.push_back(wasm::ValType::F32);
803
1
    Params.push_back(wasm::ValType::F32);
804
1
    break;
805
226
  case f64_func_f64_f64_f64:
806
1
    Rets.push_back(wasm::ValType::F64);
807
1
    Params.push_back(wasm::ValType::F64);
808
1
    Params.push_back(wasm::ValType::F64);
809
1
    Params.push_back(wasm::ValType::F64);
810
1
    break;
811
226
  case func_i64_i64_iPTR_iPTR:
812
0
    Params.push_back(wasm::ValType::I64);
813
0
    Params.push_back(wasm::ValType::I64);
814
0
    Params.push_back(PtrTy);
815
0
    Params.push_back(PtrTy);
816
0
    break;
817
226
  case func_iPTR_f32:
818
2
    Params.push_back(PtrTy);
819
2
    Params.push_back(wasm::ValType::F32);
820
2
    break;
821
226
  case func_iPTR_f64:
822
0
    Params.push_back(PtrTy);
823
0
    Params.push_back(wasm::ValType::F64);
824
0
    break;
825
226
  case func_iPTR_i32:
826
0
    Params.push_back(PtrTy);
827
0
    Params.push_back(wasm::ValType::I32);
828
0
    break;
829
226
  case func_iPTR_i64:
830
0
    Params.push_back(PtrTy);
831
0
    Params.push_back(wasm::ValType::I64);
832
0
    break;
833
226
  case func_iPTR_i64_i64:
834
4
    Params.push_back(PtrTy);
835
4
    Params.push_back(wasm::ValType::I64);
836
4
    Params.push_back(wasm::ValType::I64);
837
4
    break;
838
226
  case func_iPTR_i64_i64_i64_i64:
839
4
    Params.push_back(PtrTy);
840
4
    Params.push_back(wasm::ValType::I64);
841
4
    Params.push_back(wasm::ValType::I64);
842
4
    Params.push_back(wasm::ValType::I64);
843
4
    Params.push_back(wasm::ValType::I64);
844
4
    break;
845
226
  case func_iPTR_i64_i64_i64_i64_i64_i64:
846
0
    Params.push_back(PtrTy);
847
0
    Params.push_back(wasm::ValType::I64);
848
0
    Params.push_back(wasm::ValType::I64);
849
0
    Params.push_back(wasm::ValType::I64);
850
0
    Params.push_back(wasm::ValType::I64);
851
0
    Params.push_back(wasm::ValType::I64);
852
0
    Params.push_back(wasm::ValType::I64);
853
0
    break;
854
226
  case i32_func_i64_i64:
855
0
    Rets.push_back(wasm::ValType::I32);
856
0
    Params.push_back(wasm::ValType::I64);
857
0
    Params.push_back(wasm::ValType::I64);
858
0
    break;
859
226
  case i32_func_i64_i64_i64_i64:
860
2
    Rets.push_back(wasm::ValType::I32);
861
2
    Params.push_back(wasm::ValType::I64);
862
2
    Params.push_back(wasm::ValType::I64);
863
2
    Params.push_back(wasm::ValType::I64);
864
2
    Params.push_back(wasm::ValType::I64);
865
2
    break;
866
226
  case iPTR_func_f32:
867
0
    Rets.push_back(PtrTy);
868
0
    Params.push_back(wasm::ValType::F32);
869
0
    break;
870
226
  case iPTR_func_f64:
871
1
    Rets.push_back(PtrTy);
872
1
    Params.push_back(wasm::ValType::F64);
873
1
    break;
874
226
  case iPTR_func_i64_i64:
875
0
    Rets.push_back(PtrTy);
876
0
    Params.push_back(wasm::ValType::I64);
877
0
    Params.push_back(wasm::ValType::I64);
878
0
    break;
879
226
  case unsupported:
880
0
    llvm_unreachable("unsupported runtime library signature");
881
226
  }
882
226
}
883
884
static ManagedStatic<StaticLibcallNameMap> LibcallNameMap;
885
// TODO: If the RTLIB::Libcall-taking flavor of GetSignature remains unsed
886
// other than here, just roll its logic into this version.
887
void llvm::getLibcallSignature(const WebAssemblySubtarget &Subtarget,
888
                               const char *Name,
889
                               SmallVectorImpl<wasm::ValType> &Rets,
890
226
                               SmallVectorImpl<wasm::ValType> &Params) {
891
226
  auto &Map = LibcallNameMap->Map;
892
226
  auto Val = Map.find(Name);
893
#ifndef NDEBUG
894
  if (Val == Map.end()) {
895
    auto message = std::string("unexpected runtime library name: ") + Name;
896
    llvm_unreachable(message.c_str());
897
  }
898
#endif
899
  return getLibcallSignature(Subtarget, Val->second, Rets, Params);
900
226
}