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