LCOV - code coverage report
Current view: top level - lib/Target/WebAssembly - WebAssemblyRuntimeLibcallSignatures.cpp (source / functions) Hit Total Coverage
Test: llvm-toolchain.info Lines: 434 624 69.6 %
Date: 2018-10-20 13:21:21 Functions: 4 4 100.0 %
Legend: Lines: hit not hit

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

Generated by: LCOV version 1.13