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