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