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_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, 93 unsupported 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] = i32_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 419 Table[RTLIB::ATOMIC_LOAD] = unsupported; 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 426 Table[RTLIB::ATOMIC_STORE] = unsupported; 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 ManagedStatic<RuntimeLibcallSignatureTable> RuntimeLibcallSignatures; 486 487 // Maps libcall names to their RTLIB::Libcall number. Builds the map in a 488 // constructor for use with ManagedStatic 489 struct StaticLibcallNameMap { 490 StringMap<RTLIB::Libcall> Map; 491 StaticLibcallNameMap() { 492 static const std::pair<const char *, RTLIB::Libcall> NameLibcalls[] = { 493 #define HANDLE_LIBCALL(code, name) {(const char *)name, RTLIB::code}, 494 #include "llvm/IR/RuntimeLibcalls.def" 495 #undef HANDLE_LIBCALL 496 }; 497 for (const auto &NameLibcall : NameLibcalls) { 498 if (NameLibcall.first != nullptr && 499 RuntimeLibcallSignatures->Table[NameLibcall.second] != unsupported) { 500 assert(Map.find(NameLibcall.first) == Map.end() && 501 "duplicate libcall names in name map"); 502 Map[NameLibcall.first] = NameLibcall.second; 503 } 504 } 505 // Override the __gnu_f2h_ieee/__gnu_h2f_ieee names so that the f32 name is 506 // consistent with the f64 and f128 names. 507 Map["__extendhfsf2"] = RTLIB::FPEXT_F16_F32; 508 Map["__truncsfhf2"] = RTLIB::FPROUND_F32_F16; 509 510 Map["emscripten_return_address"] = RTLIB::RETURN_ADDRESS; 511 } 512 }; 513 514 } // end anonymous namespace 515 516 void llvm::getLibcallSignature(const WebAssemblySubtarget &Subtarget, 517 RTLIB::Libcall LC, 518 SmallVectorImpl<wasm::ValType> &Rets, 519 SmallVectorImpl<wasm::ValType> &Params) { 520 assert(Rets.empty()); 521 assert(Params.empty()); 522 523 wasm::ValType PtrTy = 524 Subtarget.hasAddr64() ? wasm::ValType::I64 : wasm::ValType::I32; 525 526 auto &Table = RuntimeLibcallSignatures->Table; 527 switch (Table[LC]) { 528 case func: 529 break; 530 case f32_func_f32: 531 Rets.push_back(wasm::ValType::F32); 532 Params.push_back(wasm::ValType::F32); 533 break; 534 case f32_func_f64: 535 Rets.push_back(wasm::ValType::F32); 536 Params.push_back(wasm::ValType::F64); 537 break; 538 case f32_func_i32: 539 Rets.push_back(wasm::ValType::F32); 540 Params.push_back(wasm::ValType::I32); 541 break; 542 case f32_func_i64: 543 Rets.push_back(wasm::ValType::F32); 544 Params.push_back(wasm::ValType::I64); 545 break; 546 case f32_func_i16: 547 Rets.push_back(wasm::ValType::F32); 548 Params.push_back(wasm::ValType::I32); 549 break; 550 case f64_func_f32: 551 Rets.push_back(wasm::ValType::F64); 552 Params.push_back(wasm::ValType::F32); 553 break; 554 case f64_func_f64: 555 Rets.push_back(wasm::ValType::F64); 556 Params.push_back(wasm::ValType::F64); 557 break; 558 case f64_func_i32: 559 Rets.push_back(wasm::ValType::F64); 560 Params.push_back(wasm::ValType::I32); 561 break; 562 case f64_func_i64: 563 Rets.push_back(wasm::ValType::F64); 564 Params.push_back(wasm::ValType::I64); 565 break; 566 case i32_func_f32: 567 Rets.push_back(wasm::ValType::I32); 568 Params.push_back(wasm::ValType::F32); 569 break; 570 case i32_func_f64: 571 Rets.push_back(wasm::ValType::I32); 572 Params.push_back(wasm::ValType::F64); 573 break; 574 case i32_func_i32: 575 Rets.push_back(wasm::ValType::I32); 576 Params.push_back(wasm::ValType::I32); 577 break; 578 case i64_func_f32: 579 Rets.push_back(wasm::ValType::I64); 580 Params.push_back(wasm::ValType::F32); 581 break; 582 case i64_func_f64: 583 Rets.push_back(wasm::ValType::I64); 584 Params.push_back(wasm::ValType::F64); 585 break; 586 case i64_func_i64: 587 Rets.push_back(wasm::ValType::I64); 588 Params.push_back(wasm::ValType::I64); 589 break; 590 case f32_func_f32_f32: 591 Rets.push_back(wasm::ValType::F32); 592 Params.push_back(wasm::ValType::F32); 593 Params.push_back(wasm::ValType::F32); 594 break; 595 case f32_func_f32_i32: 596 Rets.push_back(wasm::ValType::F32); 597 Params.push_back(wasm::ValType::F32); 598 Params.push_back(wasm::ValType::I32); 599 break; 600 case f32_func_i64_i64: 601 Rets.push_back(wasm::ValType::F32); 602 Params.push_back(wasm::ValType::I64); 603 Params.push_back(wasm::ValType::I64); 604 break; 605 case f64_func_f64_f64: 606 Rets.push_back(wasm::ValType::F64); 607 Params.push_back(wasm::ValType::F64); 608 Params.push_back(wasm::ValType::F64); 609 break; 610 case f64_func_f64_i32: 611 Rets.push_back(wasm::ValType::F64); 612 Params.push_back(wasm::ValType::F64); 613 Params.push_back(wasm::ValType::I32); 614 break; 615 case f64_func_i64_i64: 616 Rets.push_back(wasm::ValType::F64); 617 Params.push_back(wasm::ValType::I64); 618 Params.push_back(wasm::ValType::I64); 619 break; 620 case i16_func_f32: 621 Rets.push_back(wasm::ValType::I32); 622 Params.push_back(wasm::ValType::F32); 623 break; 624 case i16_func_f64: 625 Rets.push_back(wasm::ValType::I32); 626 Params.push_back(wasm::ValType::F64); 627 break; 628 case i16_func_i64_i64: 629 Rets.push_back(wasm::ValType::I32); 630 Params.push_back(wasm::ValType::I64); 631 Params.push_back(wasm::ValType::I64); 632 break; 633 case i8_func_i8_i8: 634 Rets.push_back(wasm::ValType::I32); 635 Params.push_back(wasm::ValType::I32); 636 Params.push_back(wasm::ValType::I32); 637 break; 638 case func_f32_iPTR_iPTR: 639 Params.push_back(wasm::ValType::F32); 640 Params.push_back(PtrTy); 641 Params.push_back(PtrTy); 642 break; 643 case func_f64_iPTR_iPTR: 644 Params.push_back(wasm::ValType::F64); 645 Params.push_back(PtrTy); 646 Params.push_back(PtrTy); 647 break; 648 case i16_func_i16_i16: 649 Rets.push_back(wasm::ValType::I32); 650 Params.push_back(wasm::ValType::I32); 651 Params.push_back(wasm::ValType::I32); 652 break; 653 case i32_func_f32_f32: 654 Rets.push_back(wasm::ValType::I32); 655 Params.push_back(wasm::ValType::F32); 656 Params.push_back(wasm::ValType::F32); 657 break; 658 case i32_func_f64_f64: 659 Rets.push_back(wasm::ValType::I32); 660 Params.push_back(wasm::ValType::F64); 661 Params.push_back(wasm::ValType::F64); 662 break; 663 case i32_func_i32_i32: 664 Rets.push_back(wasm::ValType::I32); 665 Params.push_back(wasm::ValType::I32); 666 Params.push_back(wasm::ValType::I32); 667 break; 668 case i32_func_i32_i32_iPTR: 669 Rets.push_back(wasm::ValType::I32); 670 Params.push_back(wasm::ValType::I32); 671 Params.push_back(wasm::ValType::I32); 672 Params.push_back(PtrTy); 673 break; 674 case i64_func_i64_i64: 675 Rets.push_back(wasm::ValType::I64); 676 Params.push_back(wasm::ValType::I64); 677 Params.push_back(wasm::ValType::I64); 678 break; 679 case i64_func_i64_i64_iPTR: 680 Rets.push_back(wasm::ValType::I64); 681 Params.push_back(wasm::ValType::I64); 682 Params.push_back(wasm::ValType::I64); 683 Params.push_back(PtrTy); 684 break; 685 case i64_i64_func_f32: 686 #if 0 // TODO: Enable this when wasm gets multiple-return-value support. 687 Rets.push_back(wasm::ValType::I64); 688 Rets.push_back(wasm::ValType::I64); 689 #else 690 Params.push_back(PtrTy); 691 #endif 692 Params.push_back(wasm::ValType::F32); 693 break; 694 case i64_i64_func_f64: 695 #if 0 // TODO: Enable this when wasm gets multiple-return-value support. 696 Rets.push_back(wasm::ValType::I64); 697 Rets.push_back(wasm::ValType::I64); 698 #else 699 Params.push_back(PtrTy); 700 #endif 701 Params.push_back(wasm::ValType::F64); 702 break; 703 case i16_i16_func_i16_i16: 704 #if 0 // TODO: Enable this when wasm gets multiple-return-value support. 705 Rets.push_back(wasm::ValType::I32); 706 Rets.push_back(wasm::ValType::I32); 707 #else 708 Params.push_back(PtrTy); 709 #endif 710 Params.push_back(wasm::ValType::I32); 711 Params.push_back(wasm::ValType::I32); 712 break; 713 case i32_i32_func_i32_i32: 714 #if 0 // TODO: Enable this when wasm gets multiple-return-value support. 715 Rets.push_back(wasm::ValType::I32); 716 Rets.push_back(wasm::ValType::I32); 717 #else 718 Params.push_back(PtrTy); 719 #endif 720 Params.push_back(wasm::ValType::I32); 721 Params.push_back(wasm::ValType::I32); 722 break; 723 case i64_i64_func_i64_i64: 724 #if 0 // TODO: Enable this when wasm gets multiple-return-value support. 725 Rets.push_back(wasm::ValType::I64); 726 Rets.push_back(wasm::ValType::I64); 727 #else 728 Params.push_back(PtrTy); 729 #endif 730 Params.push_back(wasm::ValType::I64); 731 Params.push_back(wasm::ValType::I64); 732 break; 733 case i64_i64_func_i64_i64_i64_i64: 734 #if 0 // TODO: Enable this when wasm gets multiple-return-value support. 735 Rets.push_back(wasm::ValType::I64); 736 Rets.push_back(wasm::ValType::I64); 737 #else 738 Params.push_back(PtrTy); 739 #endif 740 Params.push_back(wasm::ValType::I64); 741 Params.push_back(wasm::ValType::I64); 742 Params.push_back(wasm::ValType::I64); 743 Params.push_back(wasm::ValType::I64); 744 break; 745 case i64_i64_func_i64_i64_i64_i64_iPTR: 746 #if 0 // TODO: Enable this when wasm gets multiple-return-value support. 747 Rets.push_back(wasm::ValType::I64); 748 Rets.push_back(wasm::ValType::I64); 749 #else 750 Params.push_back(PtrTy); 751 #endif 752 Params.push_back(wasm::ValType::I64); 753 Params.push_back(wasm::ValType::I64); 754 Params.push_back(wasm::ValType::I64); 755 Params.push_back(wasm::ValType::I64); 756 Params.push_back(PtrTy); 757 break; 758 case i64_i64_i64_i64_func_i64_i64_i64_i64: 759 #if 0 // TODO: Enable this when wasm gets multiple-return-value support. 760 Rets.push_back(wasm::ValType::I64); 761 Rets.push_back(wasm::ValType::I64); 762 Rets.push_back(wasm::ValType::I64); 763 Rets.push_back(wasm::ValType::I64); 764 #else 765 Params.push_back(PtrTy); 766 #endif 767 Params.push_back(wasm::ValType::I64); 768 Params.push_back(wasm::ValType::I64); 769 Params.push_back(wasm::ValType::I64); 770 Params.push_back(wasm::ValType::I64); 771 break; 772 case i64_i64_func_i64_i64_i32: 773 #if 0 // TODO: Enable this when wasm gets multiple-return-value support. 774 Rets.push_back(wasm::ValType::I64); 775 Rets.push_back(wasm::ValType::I64); 776 Rets.push_back(wasm::ValType::I64); 777 Rets.push_back(wasm::ValType::I64); 778 #else 779 Params.push_back(PtrTy); 780 #endif 781 Params.push_back(wasm::ValType::I64); 782 Params.push_back(wasm::ValType::I64); 783 Params.push_back(wasm::ValType::I32); 784 break; 785 case iPTR_func_iPTR_i32_iPTR: 786 Rets.push_back(PtrTy); 787 Params.push_back(PtrTy); 788 Params.push_back(wasm::ValType::I32); 789 Params.push_back(PtrTy); 790 break; 791 case iPTR_func_iPTR_iPTR_iPTR: 792 Rets.push_back(PtrTy); 793 Params.push_back(PtrTy); 794 Params.push_back(PtrTy); 795 Params.push_back(PtrTy); 796 break; 797 case f32_func_f32_f32_f32: 798 Rets.push_back(wasm::ValType::F32); 799 Params.push_back(wasm::ValType::F32); 800 Params.push_back(wasm::ValType::F32); 801 Params.push_back(wasm::ValType::F32); 802 break; 803 case f64_func_f64_f64_f64: 804 Rets.push_back(wasm::ValType::F64); 805 Params.push_back(wasm::ValType::F64); 806 Params.push_back(wasm::ValType::F64); 807 Params.push_back(wasm::ValType::F64); 808 break; 809 case func_i64_i64_iPTR_iPTR: 810 Params.push_back(wasm::ValType::I64); 811 Params.push_back(wasm::ValType::I64); 812 Params.push_back(PtrTy); 813 Params.push_back(PtrTy); 814 break; 815 case func_iPTR_f32: 816 Params.push_back(PtrTy); 817 Params.push_back(wasm::ValType::F32); 818 break; 819 case func_iPTR_f64: 820 Params.push_back(PtrTy); 821 Params.push_back(wasm::ValType::F64); 822 break; 823 case func_iPTR_i32: 824 Params.push_back(PtrTy); 825 Params.push_back(wasm::ValType::I32); 826 break; 827 case func_iPTR_i64: 828 Params.push_back(PtrTy); 829 Params.push_back(wasm::ValType::I64); 830 break; 831 case func_iPTR_i64_i64: 832 Params.push_back(PtrTy); 833 Params.push_back(wasm::ValType::I64); 834 Params.push_back(wasm::ValType::I64); 835 break; 836 case func_iPTR_i64_i64_i32: 837 Params.push_back(PtrTy); 838 Params.push_back(wasm::ValType::I64); 839 Params.push_back(wasm::ValType::I64); 840 Params.push_back(wasm::ValType::I32); 841 break; 842 case func_iPTR_i64_i64_i64_i64: 843 Params.push_back(PtrTy); 844 Params.push_back(wasm::ValType::I64); 845 Params.push_back(wasm::ValType::I64); 846 Params.push_back(wasm::ValType::I64); 847 Params.push_back(wasm::ValType::I64); 848 break; 849 case func_iPTR_i64_i64_i64_i64_i64_i64: 850 Params.push_back(PtrTy); 851 Params.push_back(wasm::ValType::I64); 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 Params.push_back(wasm::ValType::I64); 857 break; 858 case i32_func_i64_i64: 859 Rets.push_back(wasm::ValType::I32); 860 Params.push_back(wasm::ValType::I64); 861 Params.push_back(wasm::ValType::I64); 862 break; 863 case i32_func_i64_i64_i64_i64: 864 Rets.push_back(wasm::ValType::I32); 865 Params.push_back(wasm::ValType::I64); 866 Params.push_back(wasm::ValType::I64); 867 Params.push_back(wasm::ValType::I64); 868 Params.push_back(wasm::ValType::I64); 869 break; 870 case iPTR_func_f32: 871 Rets.push_back(PtrTy); 872 Params.push_back(wasm::ValType::F32); 873 break; 874 case iPTR_func_f64: 875 Rets.push_back(PtrTy); 876 Params.push_back(wasm::ValType::F64); 877 break; 878 case iPTR_func_i64_i64: 879 Rets.push_back(PtrTy); 880 Params.push_back(wasm::ValType::I64); 881 Params.push_back(wasm::ValType::I64); 882 break; 883 case unsupported: 884 llvm_unreachable("unsupported runtime library signature"); 885 } 886 } 887 888 static ManagedStatic<StaticLibcallNameMap> LibcallNameMap; 889 // TODO: If the RTLIB::Libcall-taking flavor of GetSignature remains unsed 890 // other than here, just roll its logic into this version. 891 void llvm::getLibcallSignature(const WebAssemblySubtarget &Subtarget, 892 const char *Name, 893 SmallVectorImpl<wasm::ValType> &Rets, 894 SmallVectorImpl<wasm::ValType> &Params) { 895 auto &Map = LibcallNameMap->Map; 896 auto Val = Map.find(Name); 897 #ifndef NDEBUG 898 if (Val == Map.end()) { 899 auto message = std::string("unexpected runtime library name: ") + Name; 900 llvm_unreachable(message.c_str()); 901 } 902 #endif 903 return getLibcallSignature(Subtarget, Val->second, Rets, Params); 904 } 905