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