| Chris Lattner | 0e125bb | 2011-02-18 21:50:34 +0000 | [diff] [blame] | 1 | //===-- TargetLibraryInfo.cpp - Runtime library information ----------------==// | 
|  | 2 | // | 
| Chandler Carruth | 2946cd7 | 2019-01-19 08:50:56 +0000 | [diff] [blame] | 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 | 
| Chris Lattner | 0e125bb | 2011-02-18 21:50:34 +0000 | [diff] [blame] | 6 | // | 
|  | 7 | //===----------------------------------------------------------------------===// | 
|  | 8 | // | 
|  | 9 | // This file implements the TargetLibraryInfo class. | 
|  | 10 | // | 
|  | 11 | //===----------------------------------------------------------------------===// | 
|  | 12 |  | 
| Chandler Carruth | 62d4215 | 2015-01-15 02:16:27 +0000 | [diff] [blame] | 13 | #include "llvm/Analysis/TargetLibraryInfo.h" | 
| Chris Lattner | 0e125bb | 2011-02-18 21:50:34 +0000 | [diff] [blame] | 14 | #include "llvm/ADT/Triple.h" | 
| Matthias Braun | 50ec0b5 | 2017-05-19 22:37:09 +0000 | [diff] [blame] | 15 | #include "llvm/IR/Constants.h" | 
| Michael Zolotukhin | 6d8a2aa | 2015-03-17 19:50:55 +0000 | [diff] [blame] | 16 | #include "llvm/Support/CommandLine.h" | 
| Chris Lattner | 0e125bb | 2011-02-18 21:50:34 +0000 | [diff] [blame] | 17 | using namespace llvm; | 
|  | 18 |  | 
| Michael Zolotukhin | 6d8a2aa | 2015-03-17 19:50:55 +0000 | [diff] [blame] | 19 | static cl::opt<TargetLibraryInfoImpl::VectorLibrary> ClVectorLibrary( | 
|  | 20 | "vector-library", cl::Hidden, cl::desc("Vector functions library"), | 
|  | 21 | cl::init(TargetLibraryInfoImpl::NoLibrary), | 
|  | 22 | cl::values(clEnumValN(TargetLibraryInfoImpl::NoLibrary, "none", | 
|  | 23 | "No vector functions library"), | 
|  | 24 | clEnumValN(TargetLibraryInfoImpl::Accelerate, "Accelerate", | 
|  | 25 | "Accelerate framework"), | 
| Matt Masten | a6669a1 | 2016-07-29 16:42:44 +0000 | [diff] [blame] | 26 | clEnumValN(TargetLibraryInfoImpl::SVML, "SVML", | 
| Joel Jones | 7459398 | 2018-11-24 07:26:55 +0000 | [diff] [blame] | 27 | "Intel SVML library"))); | 
| Michael Zolotukhin | 6d8a2aa | 2015-03-17 19:50:55 +0000 | [diff] [blame] | 28 |  | 
| Mehdi Amini | 9a72cd7 | 2016-10-01 03:10:48 +0000 | [diff] [blame] | 29 | StringRef const TargetLibraryInfoImpl::StandardNames[LibFunc::NumLibFuncs] = { | 
| Jan Wen Voung | cd3d25a | 2015-03-03 23:41:58 +0000 | [diff] [blame] | 30 | #define TLI_DEFINE_STRING | 
|  | 31 | #include "llvm/Analysis/TargetLibraryInfo.def" | 
| Benjamin Kramer | 57a3d08 | 2015-03-08 16:07:39 +0000 | [diff] [blame] | 32 | }; | 
| Eli Friedman | 489c0ff | 2011-11-17 01:27:36 +0000 | [diff] [blame] | 33 |  | 
| Bob Wilson | d8d92d9 | 2013-11-03 06:48:38 +0000 | [diff] [blame] | 34 | static bool hasSinCosPiStret(const Triple &T) { | 
|  | 35 | // Only Darwin variants have _stret versions of combined trig functions. | 
| Bob Wilson | 9868d71 | 2014-10-09 05:43:30 +0000 | [diff] [blame] | 36 | if (!T.isOSDarwin()) | 
| Bob Wilson | d8d92d9 | 2013-11-03 06:48:38 +0000 | [diff] [blame] | 37 | return false; | 
|  | 38 |  | 
|  | 39 | // The ABI is rather complicated on x86, so don't do anything special there. | 
|  | 40 | if (T.getArch() == Triple::x86) | 
|  | 41 | return false; | 
|  | 42 |  | 
|  | 43 | if (T.isMacOSX() && T.isMacOSXVersionLT(10, 9)) | 
|  | 44 | return false; | 
|  | 45 |  | 
| Bob Wilson | 9868d71 | 2014-10-09 05:43:30 +0000 | [diff] [blame] | 46 | if (T.isiOS() && T.isOSVersionLT(7, 0)) | 
| Bob Wilson | d8d92d9 | 2013-11-03 06:48:38 +0000 | [diff] [blame] | 47 | return false; | 
|  | 48 |  | 
|  | 49 | return true; | 
|  | 50 | } | 
|  | 51 |  | 
| Sanjay Patel | 600d24b | 2017-12-15 18:54:29 +0000 | [diff] [blame] | 52 | /// Initialize the set of available library functions based on the specified | 
|  | 53 | /// target triple. This should be carefully written so that a missing target | 
|  | 54 | /// triple gets a sane set of defaults. | 
| Chandler Carruth | c029186 | 2015-01-24 02:06:09 +0000 | [diff] [blame] | 55 | static void initialize(TargetLibraryInfoImpl &TLI, const Triple &T, | 
| Mehdi Amini | 9a72cd7 | 2016-10-01 03:10:48 +0000 | [diff] [blame] | 56 | ArrayRef<StringRef> StandardNames) { | 
| Bob Wilson | c740e3f | 2012-08-03 04:06:22 +0000 | [diff] [blame] | 57 | // Verify that the StandardNames array is in alphabetical order. | 
| Craig Topper | e30b8ca | 2016-01-03 19:43:40 +0000 | [diff] [blame] | 58 | assert(std::is_sorted(StandardNames.begin(), StandardNames.end(), | 
| Mehdi Amini | 9a72cd7 | 2016-10-01 03:10:48 +0000 | [diff] [blame] | 59 | [](StringRef LHS, StringRef RHS) { | 
|  | 60 | return LHS < RHS; | 
| Craig Topper | e30b8ca | 2016-01-03 19:43:40 +0000 | [diff] [blame] | 61 | }) && | 
|  | 62 | "TargetLibraryInfoImpl function names must be sorted"); | 
| Tom Stellard | 36a0318 | 2014-04-02 19:53:29 +0000 | [diff] [blame] | 63 |  | 
| David Bolvansky | ca22d42 | 2018-05-16 11:39:52 +0000 | [diff] [blame] | 64 | // Set IO unlocked variants as unavailable | 
|  | 65 | // Set them as available per system below | 
|  | 66 | TLI.setUnavailable(LibFunc_getchar_unlocked); | 
|  | 67 | TLI.setUnavailable(LibFunc_putc_unlocked); | 
|  | 68 | TLI.setUnavailable(LibFunc_putchar_unlocked); | 
|  | 69 | TLI.setUnavailable(LibFunc_fputc_unlocked); | 
|  | 70 | TLI.setUnavailable(LibFunc_fgetc_unlocked); | 
|  | 71 | TLI.setUnavailable(LibFunc_fread_unlocked); | 
|  | 72 | TLI.setUnavailable(LibFunc_fwrite_unlocked); | 
|  | 73 | TLI.setUnavailable(LibFunc_fputs_unlocked); | 
|  | 74 | TLI.setUnavailable(LibFunc_fgets_unlocked); | 
|  | 75 |  | 
| Marcin Koscielnicki | 6af8e6c | 2016-11-21 20:20:39 +0000 | [diff] [blame] | 76 | bool ShouldExtI32Param = false, ShouldExtI32Return = false, | 
|  | 77 | ShouldSignExtI32Param = false; | 
|  | 78 | // PowerPC64, Sparc64, SystemZ need signext/zeroext on i32 parameters and | 
|  | 79 | // returns corresponding to C-level ints and unsigned ints. | 
|  | 80 | if (T.getArch() == Triple::ppc64 || T.getArch() == Triple::ppc64le || | 
|  | 81 | T.getArch() == Triple::sparcv9 || T.getArch() == Triple::systemz) { | 
|  | 82 | ShouldExtI32Param = true; | 
|  | 83 | ShouldExtI32Return = true; | 
|  | 84 | } | 
|  | 85 | // Mips, on the other hand, needs signext on i32 parameters corresponding | 
|  | 86 | // to both signed and unsigned ints. | 
| Alexander Richardson | 85e200e | 2018-06-25 16:49:20 +0000 | [diff] [blame] | 87 | if (T.isMIPS()) { | 
| Marcin Koscielnicki | 6af8e6c | 2016-11-21 20:20:39 +0000 | [diff] [blame] | 88 | ShouldSignExtI32Param = true; | 
|  | 89 | } | 
|  | 90 | TLI.setShouldExtI32Param(ShouldExtI32Param); | 
|  | 91 | TLI.setShouldExtI32Return(ShouldExtI32Return); | 
|  | 92 | TLI.setShouldSignExtI32Param(ShouldSignExtI32Param); | 
|  | 93 |  | 
| Nicolai Hahnle | 78fd4f0 | 2015-12-15 17:24:15 +0000 | [diff] [blame] | 94 | if (T.getArch() == Triple::r600 || | 
|  | 95 | T.getArch() == Triple::amdgcn) { | 
| David L. Jones | d21529f | 2017-01-23 23:16:46 +0000 | [diff] [blame] | 96 | TLI.setUnavailable(LibFunc_ldexp); | 
|  | 97 | TLI.setUnavailable(LibFunc_ldexpf); | 
|  | 98 | TLI.setUnavailable(LibFunc_ldexpl); | 
|  | 99 | TLI.setUnavailable(LibFunc_exp10); | 
|  | 100 | TLI.setUnavailable(LibFunc_exp10f); | 
|  | 101 | TLI.setUnavailable(LibFunc_exp10l); | 
|  | 102 | TLI.setUnavailable(LibFunc_log10); | 
|  | 103 | TLI.setUnavailable(LibFunc_log10f); | 
|  | 104 | TLI.setUnavailable(LibFunc_log10l); | 
| Nicolai Hahnle | 78fd4f0 | 2015-12-15 17:24:15 +0000 | [diff] [blame] | 105 | } | 
|  | 106 |  | 
| Tom Stellard | d00a923 | 2015-01-07 01:17:37 +0000 | [diff] [blame] | 107 | // There are no library implementations of mempcy and memset for AMD gpus and | 
| Tom Stellard | 36a0318 | 2014-04-02 19:53:29 +0000 | [diff] [blame] | 108 | // these can be difficult to lower in the backend. | 
| Tom Stellard | d00a923 | 2015-01-07 01:17:37 +0000 | [diff] [blame] | 109 | if (T.getArch() == Triple::r600 || | 
| Dan Gohman | 0553299 | 2016-01-19 14:49:23 +0000 | [diff] [blame] | 110 | T.getArch() == Triple::amdgcn) { | 
| David L. Jones | d21529f | 2017-01-23 23:16:46 +0000 | [diff] [blame] | 111 | TLI.setUnavailable(LibFunc_memcpy); | 
|  | 112 | TLI.setUnavailable(LibFunc_memset); | 
|  | 113 | TLI.setUnavailable(LibFunc_memset_pattern16); | 
| Tom Stellard | 36a0318 | 2014-04-02 19:53:29 +0000 | [diff] [blame] | 114 | return; | 
|  | 115 | } | 
|  | 116 |  | 
| Nico Weber | ad15692 | 2014-03-07 18:08:54 +0000 | [diff] [blame] | 117 | // memset_pattern16 is only available on iOS 3.0 and Mac OS X 10.5 and later. | 
| Tim Northover | 8b40366 | 2015-10-28 22:51:16 +0000 | [diff] [blame] | 118 | // All versions of watchOS support it. | 
| Daniel Dunbar | cd01ed5 | 2011-04-20 00:14:25 +0000 | [diff] [blame] | 119 | if (T.isMacOSX()) { | 
| David Bolvansky | ca22d42 | 2018-05-16 11:39:52 +0000 | [diff] [blame] | 120 | // available IO unlocked variants on Mac OS X | 
|  | 121 | TLI.setAvailable(LibFunc_getc_unlocked); | 
|  | 122 | TLI.setAvailable(LibFunc_getchar_unlocked); | 
|  | 123 | TLI.setAvailable(LibFunc_putc_unlocked); | 
|  | 124 | TLI.setAvailable(LibFunc_putchar_unlocked); | 
|  | 125 |  | 
| Daniel Dunbar | cd01ed5 | 2011-04-20 00:14:25 +0000 | [diff] [blame] | 126 | if (T.isMacOSXVersionLT(10, 5)) | 
| David L. Jones | d21529f | 2017-01-23 23:16:46 +0000 | [diff] [blame] | 127 | TLI.setUnavailable(LibFunc_memset_pattern16); | 
| Cameron Esfahani | 943908b | 2013-08-29 20:23:14 +0000 | [diff] [blame] | 128 | } else if (T.isiOS()) { | 
| Daniel Dunbar | 9483bb6 | 2011-04-19 20:44:08 +0000 | [diff] [blame] | 129 | if (T.isOSVersionLT(3, 0)) | 
| David L. Jones | d21529f | 2017-01-23 23:16:46 +0000 | [diff] [blame] | 130 | TLI.setUnavailable(LibFunc_memset_pattern16); | 
| Tim Northover | 8b40366 | 2015-10-28 22:51:16 +0000 | [diff] [blame] | 131 | } else if (!T.isWatchOS()) { | 
| David L. Jones | d21529f | 2017-01-23 23:16:46 +0000 | [diff] [blame] | 132 | TLI.setUnavailable(LibFunc_memset_pattern16); | 
| Daniel Dunbar | 9483bb6 | 2011-04-19 20:44:08 +0000 | [diff] [blame] | 133 | } | 
| Richard Osborne | 815de53 | 2011-03-03 13:17:51 +0000 | [diff] [blame] | 134 |  | 
| Bob Wilson | d8d92d9 | 2013-11-03 06:48:38 +0000 | [diff] [blame] | 135 | if (!hasSinCosPiStret(T)) { | 
| David L. Jones | d21529f | 2017-01-23 23:16:46 +0000 | [diff] [blame] | 136 | TLI.setUnavailable(LibFunc_sinpi); | 
|  | 137 | TLI.setUnavailable(LibFunc_sinpif); | 
|  | 138 | TLI.setUnavailable(LibFunc_cospi); | 
|  | 139 | TLI.setUnavailable(LibFunc_cospif); | 
|  | 140 | TLI.setUnavailable(LibFunc_sincospi_stret); | 
|  | 141 | TLI.setUnavailable(LibFunc_sincospif_stret); | 
| Bob Wilson | d8d92d9 | 2013-11-03 06:48:38 +0000 | [diff] [blame] | 142 | } | 
|  | 143 |  | 
| Eli Friedman | 489c0ff | 2011-11-17 01:27:36 +0000 | [diff] [blame] | 144 | if (T.isMacOSX() && T.getArch() == Triple::x86 && | 
|  | 145 | !T.isMacOSXVersionLT(10, 7)) { | 
|  | 146 | // x86-32 OSX has a scheme where fwrite and fputs (and some other functions | 
|  | 147 | // we don't care about) have two versions; on recent OSX, the one we want | 
|  | 148 | // has a $UNIX2003 suffix. The two implementations are identical except | 
|  | 149 | // for the return value in some edge cases.  However, we don't want to | 
|  | 150 | // generate code that depends on the old symbols. | 
| David L. Jones | d21529f | 2017-01-23 23:16:46 +0000 | [diff] [blame] | 151 | TLI.setAvailableWithName(LibFunc_fwrite, "fwrite$UNIX2003"); | 
|  | 152 | TLI.setAvailableWithName(LibFunc_fputs, "fputs$UNIX2003"); | 
| Eli Friedman | 489c0ff | 2011-11-17 01:27:36 +0000 | [diff] [blame] | 153 | } | 
|  | 154 |  | 
| Duncan Sands | eeb50c8 | 2011-06-09 11:11:45 +0000 | [diff] [blame] | 155 | // iprintf and friends are only available on XCore and TCE. | 
|  | 156 | if (T.getArch() != Triple::xcore && T.getArch() != Triple::tce) { | 
| David L. Jones | d21529f | 2017-01-23 23:16:46 +0000 | [diff] [blame] | 157 | TLI.setUnavailable(LibFunc_iprintf); | 
|  | 158 | TLI.setUnavailable(LibFunc_siprintf); | 
|  | 159 | TLI.setUnavailable(LibFunc_fiprintf); | 
| Richard Osborne | 2dfb888 | 2011-03-03 14:09:28 +0000 | [diff] [blame] | 160 | } | 
| Joe Groff | a81bcbb | 2012-04-17 23:05:54 +0000 | [diff] [blame] | 161 |  | 
| Saleem Abdulrasool | 8dc8fb1 | 2014-07-24 22:09:06 +0000 | [diff] [blame] | 162 | if (T.isOSWindows() && !T.isOSCygMing()) { | 
| Evandro Menezes | 4b86c47 | 2019-02-11 19:02:28 +0000 | [diff] [blame] | 163 | // XXX: The earliest documentation available at the moment is for VS2015/VC19: | 
|  | 164 | // https://docs.microsoft.com/en-us/cpp/c-runtime-library/floating-point-support?view=vs-2015 | 
|  | 165 | // XXX: In order to use an MSVCRT older than VC19, | 
|  | 166 | // the specific library version must be explicit in the target triple, | 
|  | 167 | // e.g., x86_64-pc-windows-msvc18. | 
|  | 168 | bool hasPartialC99 = true; | 
|  | 169 | if (T.isKnownWindowsMSVCEnvironment()) { | 
|  | 170 | unsigned Major, Minor, Micro; | 
|  | 171 | T.getEnvironmentVersion(Major, Minor, Micro); | 
|  | 172 | hasPartialC99 = (Major == 0 || Major >= 19); | 
|  | 173 | } | 
|  | 174 |  | 
| Evandro Menezes | f4a3695 | 2019-02-11 22:12:01 +0000 | [diff] [blame] | 175 | // Latest targets support C89 math functions, in part. | 
|  | 176 | bool isARM = (T.getArch() == Triple::aarch64 || | 
|  | 177 | T.getArch() == Triple::arm); | 
|  | 178 | bool hasPartialFloat = (isARM || | 
| Evandro Menezes | 4b86c47 | 2019-02-11 19:02:28 +0000 | [diff] [blame] | 179 | T.getArch() == Triple::x86_64); | 
|  | 180 |  | 
| Evandro Menezes | f4a3695 | 2019-02-11 22:12:01 +0000 | [diff] [blame] | 181 | // Win32 does not support float C89 math functions, in general. | 
| Evandro Menezes | 4b86c47 | 2019-02-11 19:02:28 +0000 | [diff] [blame] | 182 | if (!hasPartialFloat) { | 
| Evandro Menezes | e5bb58b | 2019-02-05 20:24:21 +0000 | [diff] [blame] | 183 | TLI.setUnavailable(LibFunc_acosf); | 
|  | 184 | TLI.setUnavailable(LibFunc_asinf); | 
| Evandro Menezes | e5bb58b | 2019-02-05 20:24:21 +0000 | [diff] [blame] | 185 | TLI.setUnavailable(LibFunc_atan2f); | 
| Evandro Menezes | f4a3695 | 2019-02-11 22:12:01 +0000 | [diff] [blame] | 186 | TLI.setUnavailable(LibFunc_atanf); | 
| Evandro Menezes | e5bb58b | 2019-02-05 20:24:21 +0000 | [diff] [blame] | 187 | TLI.setUnavailable(LibFunc_ceilf); | 
| Evandro Menezes | e5bb58b | 2019-02-05 20:24:21 +0000 | [diff] [blame] | 188 | TLI.setUnavailable(LibFunc_cosf); | 
|  | 189 | TLI.setUnavailable(LibFunc_coshf); | 
|  | 190 | TLI.setUnavailable(LibFunc_expf); | 
|  | 191 | TLI.setUnavailable(LibFunc_floorf); | 
| Evandro Menezes | e5bb58b | 2019-02-05 20:24:21 +0000 | [diff] [blame] | 192 | TLI.setUnavailable(LibFunc_fmodf); | 
| Evandro Menezes | e5bb58b | 2019-02-05 20:24:21 +0000 | [diff] [blame] | 193 | TLI.setUnavailable(LibFunc_log10f); | 
| Evandro Menezes | f4a3695 | 2019-02-11 22:12:01 +0000 | [diff] [blame] | 194 | TLI.setUnavailable(LibFunc_logf); | 
| Evandro Menezes | e5bb58b | 2019-02-05 20:24:21 +0000 | [diff] [blame] | 195 | TLI.setUnavailable(LibFunc_modff); | 
|  | 196 | TLI.setUnavailable(LibFunc_powf); | 
|  | 197 | TLI.setUnavailable(LibFunc_sinf); | 
|  | 198 | TLI.setUnavailable(LibFunc_sinhf); | 
|  | 199 | TLI.setUnavailable(LibFunc_sqrtf); | 
|  | 200 | TLI.setUnavailable(LibFunc_tanf); | 
|  | 201 | TLI.setUnavailable(LibFunc_tanhf); | 
|  | 202 | } | 
| Evandro Menezes | f4a3695 | 2019-02-11 22:12:01 +0000 | [diff] [blame] | 203 | if (!isARM) | 
|  | 204 | TLI.setUnavailable(LibFunc_fabsf); | 
| Evandro Menezes | e5bb58b | 2019-02-05 20:24:21 +0000 | [diff] [blame] | 205 | TLI.setUnavailable(LibFunc_frexpf); | 
|  | 206 | TLI.setUnavailable(LibFunc_ldexpf); | 
|  | 207 |  | 
| Evandro Menezes | f4a3695 | 2019-02-11 22:12:01 +0000 | [diff] [blame] | 208 | // Win32 does not support long double C89 math functions. | 
| Evandro Menezes | 98f356c | 2019-02-04 23:34:50 +0000 | [diff] [blame] | 209 | TLI.setUnavailable(LibFunc_acosl); | 
|  | 210 | TLI.setUnavailable(LibFunc_asinl); | 
| Evandro Menezes | 98f356c | 2019-02-04 23:34:50 +0000 | [diff] [blame] | 211 | TLI.setUnavailable(LibFunc_atan2l); | 
| Evandro Menezes | f4a3695 | 2019-02-11 22:12:01 +0000 | [diff] [blame] | 212 | TLI.setUnavailable(LibFunc_atanl); | 
| Evandro Menezes | 98f356c | 2019-02-04 23:34:50 +0000 | [diff] [blame] | 213 | TLI.setUnavailable(LibFunc_ceill); | 
| Evandro Menezes | 98f356c | 2019-02-04 23:34:50 +0000 | [diff] [blame] | 214 | TLI.setUnavailable(LibFunc_cosl); | 
|  | 215 | TLI.setUnavailable(LibFunc_coshl); | 
|  | 216 | TLI.setUnavailable(LibFunc_expl); | 
| Evandro Menezes | 98f356c | 2019-02-04 23:34:50 +0000 | [diff] [blame] | 217 | TLI.setUnavailable(LibFunc_fabsl); | 
|  | 218 | TLI.setUnavailable(LibFunc_floorl); | 
| Evandro Menezes | 98f356c | 2019-02-04 23:34:50 +0000 | [diff] [blame] | 219 | TLI.setUnavailable(LibFunc_fmodl); | 
|  | 220 | TLI.setUnavailable(LibFunc_frexpl); | 
| Evandro Menezes | 98f356c | 2019-02-04 23:34:50 +0000 | [diff] [blame] | 221 | TLI.setUnavailable(LibFunc_ldexpl); | 
| Evandro Menezes | 4b86c47 | 2019-02-11 19:02:28 +0000 | [diff] [blame] | 222 | TLI.setUnavailable(LibFunc_log10l); | 
| Evandro Menezes | f4a3695 | 2019-02-11 22:12:01 +0000 | [diff] [blame] | 223 | TLI.setUnavailable(LibFunc_logl); | 
| Evandro Menezes | 98f356c | 2019-02-04 23:34:50 +0000 | [diff] [blame] | 224 | TLI.setUnavailable(LibFunc_modfl); | 
|  | 225 | TLI.setUnavailable(LibFunc_powl); | 
|  | 226 | TLI.setUnavailable(LibFunc_sinl); | 
|  | 227 | TLI.setUnavailable(LibFunc_sinhl); | 
|  | 228 | TLI.setUnavailable(LibFunc_sqrtl); | 
|  | 229 | TLI.setUnavailable(LibFunc_tanl); | 
|  | 230 | TLI.setUnavailable(LibFunc_tanhl); | 
| Joe Groff | a81bcbb | 2012-04-17 23:05:54 +0000 | [diff] [blame] | 231 |  | 
| Evandro Menezes | e5bb58b | 2019-02-05 20:24:21 +0000 | [diff] [blame] | 232 | // Win32 does not fully support C99 math functions. | 
| Evandro Menezes | 4b86c47 | 2019-02-11 19:02:28 +0000 | [diff] [blame] | 233 | if (!hasPartialC99) { | 
|  | 234 | TLI.setUnavailable(LibFunc_acosh); | 
| Evandro Menezes | f4a3695 | 2019-02-11 22:12:01 +0000 | [diff] [blame] | 235 | TLI.setUnavailable(LibFunc_acoshf); | 
| Evandro Menezes | 4b86c47 | 2019-02-11 19:02:28 +0000 | [diff] [blame] | 236 | TLI.setUnavailable(LibFunc_asinh); | 
| Evandro Menezes | f4a3695 | 2019-02-11 22:12:01 +0000 | [diff] [blame] | 237 | TLI.setUnavailable(LibFunc_asinhf); | 
| Evandro Menezes | 4b86c47 | 2019-02-11 19:02:28 +0000 | [diff] [blame] | 238 | TLI.setUnavailable(LibFunc_atanh); | 
| Evandro Menezes | f4a3695 | 2019-02-11 22:12:01 +0000 | [diff] [blame] | 239 | TLI.setUnavailable(LibFunc_atanhf); | 
|  | 240 | TLI.setAvailableWithName(LibFunc_cabs, "_cabs"); | 
|  | 241 | TLI.setUnavailable(LibFunc_cabsf); | 
| Evandro Menezes | 4b86c47 | 2019-02-11 19:02:28 +0000 | [diff] [blame] | 242 | TLI.setUnavailable(LibFunc_cbrt); | 
| Evandro Menezes | f4a3695 | 2019-02-11 22:12:01 +0000 | [diff] [blame] | 243 | TLI.setUnavailable(LibFunc_cbrtf); | 
|  | 244 | TLI.setAvailableWithName(LibFunc_copysign, "_copysign"); | 
|  | 245 | TLI.setAvailableWithName(LibFunc_copysignf, "_copysignf"); | 
| Evandro Menezes | 4b86c47 | 2019-02-11 19:02:28 +0000 | [diff] [blame] | 246 | TLI.setUnavailable(LibFunc_exp2); | 
| Evandro Menezes | f4a3695 | 2019-02-11 22:12:01 +0000 | [diff] [blame] | 247 | TLI.setUnavailable(LibFunc_exp2f); | 
| Evandro Menezes | 4b86c47 | 2019-02-11 19:02:28 +0000 | [diff] [blame] | 248 | TLI.setUnavailable(LibFunc_expm1); | 
| Evandro Menezes | f4a3695 | 2019-02-11 22:12:01 +0000 | [diff] [blame] | 249 | TLI.setUnavailable(LibFunc_expm1f); | 
|  | 250 | TLI.setUnavailable(LibFunc_fmax); | 
|  | 251 | TLI.setUnavailable(LibFunc_fmaxf); | 
|  | 252 | TLI.setUnavailable(LibFunc_fmin); | 
|  | 253 | TLI.setUnavailable(LibFunc_fminf); | 
| Evandro Menezes | 4b86c47 | 2019-02-11 19:02:28 +0000 | [diff] [blame] | 254 | TLI.setUnavailable(LibFunc_log1p); | 
| Evandro Menezes | f4a3695 | 2019-02-11 22:12:01 +0000 | [diff] [blame] | 255 | TLI.setUnavailable(LibFunc_log1pf); | 
| Evandro Menezes | 4b86c47 | 2019-02-11 19:02:28 +0000 | [diff] [blame] | 256 | TLI.setUnavailable(LibFunc_log2); | 
| Evandro Menezes | f4a3695 | 2019-02-11 22:12:01 +0000 | [diff] [blame] | 257 | TLI.setUnavailable(LibFunc_log2f); | 
|  | 258 | TLI.setAvailableWithName(LibFunc_logb, "_logb"); | 
|  | 259 | if (hasPartialFloat) | 
|  | 260 | TLI.setAvailableWithName(LibFunc_logbf, "_logbf"); | 
|  | 261 | else | 
|  | 262 | TLI.setUnavailable(LibFunc_logbf); | 
| Evandro Menezes | 4b86c47 | 2019-02-11 19:02:28 +0000 | [diff] [blame] | 263 | TLI.setUnavailable(LibFunc_rint); | 
| Evandro Menezes | f4a3695 | 2019-02-11 22:12:01 +0000 | [diff] [blame] | 264 | TLI.setUnavailable(LibFunc_rintf); | 
| Evandro Menezes | 4b86c47 | 2019-02-11 19:02:28 +0000 | [diff] [blame] | 265 | TLI.setUnavailable(LibFunc_round); | 
| Evandro Menezes | f4a3695 | 2019-02-11 22:12:01 +0000 | [diff] [blame] | 266 | TLI.setUnavailable(LibFunc_roundf); | 
| Evandro Menezes | 4b86c47 | 2019-02-11 19:02:28 +0000 | [diff] [blame] | 267 | TLI.setUnavailable(LibFunc_trunc); | 
| Evandro Menezes | f4a3695 | 2019-02-11 22:12:01 +0000 | [diff] [blame] | 268 | TLI.setUnavailable(LibFunc_truncf); | 
| Evandro Menezes | 4b86c47 | 2019-02-11 19:02:28 +0000 | [diff] [blame] | 269 | } | 
|  | 270 |  | 
| Evandro Menezes | 4b86c47 | 2019-02-11 19:02:28 +0000 | [diff] [blame] | 271 | // Win32 does not support long double C99 math functions. | 
|  | 272 | TLI.setUnavailable(LibFunc_acoshl); | 
|  | 273 | TLI.setUnavailable(LibFunc_asinhl); | 
|  | 274 | TLI.setUnavailable(LibFunc_atanhl); | 
|  | 275 | TLI.setUnavailable(LibFunc_cabsl); | 
|  | 276 | TLI.setUnavailable(LibFunc_cbrtl); | 
| Evandro Menezes | f4a3695 | 2019-02-11 22:12:01 +0000 | [diff] [blame] | 277 | TLI.setUnavailable(LibFunc_copysignl); | 
| Evandro Menezes | 4b86c47 | 2019-02-11 19:02:28 +0000 | [diff] [blame] | 278 | TLI.setUnavailable(LibFunc_exp2l); | 
|  | 279 | TLI.setUnavailable(LibFunc_expm1l); | 
| Evandro Menezes | f4a3695 | 2019-02-11 22:12:01 +0000 | [diff] [blame] | 280 | TLI.setUnavailable(LibFunc_fmaxl); | 
|  | 281 | TLI.setUnavailable(LibFunc_fminl); | 
| Evandro Menezes | 4b86c47 | 2019-02-11 19:02:28 +0000 | [diff] [blame] | 282 | TLI.setUnavailable(LibFunc_log1pl); | 
|  | 283 | TLI.setUnavailable(LibFunc_log2l); | 
|  | 284 | TLI.setUnavailable(LibFunc_logbl); | 
|  | 285 | TLI.setUnavailable(LibFunc_nearbyintl); | 
|  | 286 | TLI.setUnavailable(LibFunc_rintl); | 
|  | 287 | TLI.setUnavailable(LibFunc_roundl); | 
| Evandro Menezes | 98f356c | 2019-02-04 23:34:50 +0000 | [diff] [blame] | 288 | TLI.setUnavailable(LibFunc_truncl); | 
|  | 289 |  | 
| Evandro Menezes | e5bb58b | 2019-02-05 20:24:21 +0000 | [diff] [blame] | 290 | // Win32 does not support these functions, but | 
|  | 291 | // they are generally available on POSIX-compliant systems. | 
| David L. Jones | d21529f | 2017-01-23 23:16:46 +0000 | [diff] [blame] | 292 | TLI.setUnavailable(LibFunc_access); | 
|  | 293 | TLI.setUnavailable(LibFunc_bcmp); | 
|  | 294 | TLI.setUnavailable(LibFunc_bcopy); | 
|  | 295 | TLI.setUnavailable(LibFunc_bzero); | 
|  | 296 | TLI.setUnavailable(LibFunc_chmod); | 
|  | 297 | TLI.setUnavailable(LibFunc_chown); | 
|  | 298 | TLI.setUnavailable(LibFunc_closedir); | 
|  | 299 | TLI.setUnavailable(LibFunc_ctermid); | 
|  | 300 | TLI.setUnavailable(LibFunc_fdopen); | 
|  | 301 | TLI.setUnavailable(LibFunc_ffs); | 
|  | 302 | TLI.setUnavailable(LibFunc_fileno); | 
|  | 303 | TLI.setUnavailable(LibFunc_flockfile); | 
|  | 304 | TLI.setUnavailable(LibFunc_fseeko); | 
|  | 305 | TLI.setUnavailable(LibFunc_fstat); | 
|  | 306 | TLI.setUnavailable(LibFunc_fstatvfs); | 
|  | 307 | TLI.setUnavailable(LibFunc_ftello); | 
|  | 308 | TLI.setUnavailable(LibFunc_ftrylockfile); | 
|  | 309 | TLI.setUnavailable(LibFunc_funlockfile); | 
| David L. Jones | d21529f | 2017-01-23 23:16:46 +0000 | [diff] [blame] | 310 | TLI.setUnavailable(LibFunc_getitimer); | 
|  | 311 | TLI.setUnavailable(LibFunc_getlogin_r); | 
|  | 312 | TLI.setUnavailable(LibFunc_getpwnam); | 
|  | 313 | TLI.setUnavailable(LibFunc_gettimeofday); | 
|  | 314 | TLI.setUnavailable(LibFunc_htonl); | 
|  | 315 | TLI.setUnavailable(LibFunc_htons); | 
|  | 316 | TLI.setUnavailable(LibFunc_lchown); | 
|  | 317 | TLI.setUnavailable(LibFunc_lstat); | 
|  | 318 | TLI.setUnavailable(LibFunc_memccpy); | 
|  | 319 | TLI.setUnavailable(LibFunc_mkdir); | 
|  | 320 | TLI.setUnavailable(LibFunc_ntohl); | 
|  | 321 | TLI.setUnavailable(LibFunc_ntohs); | 
|  | 322 | TLI.setUnavailable(LibFunc_open); | 
|  | 323 | TLI.setUnavailable(LibFunc_opendir); | 
|  | 324 | TLI.setUnavailable(LibFunc_pclose); | 
|  | 325 | TLI.setUnavailable(LibFunc_popen); | 
|  | 326 | TLI.setUnavailable(LibFunc_pread); | 
|  | 327 | TLI.setUnavailable(LibFunc_pwrite); | 
|  | 328 | TLI.setUnavailable(LibFunc_read); | 
|  | 329 | TLI.setUnavailable(LibFunc_readlink); | 
|  | 330 | TLI.setUnavailable(LibFunc_realpath); | 
|  | 331 | TLI.setUnavailable(LibFunc_rmdir); | 
|  | 332 | TLI.setUnavailable(LibFunc_setitimer); | 
|  | 333 | TLI.setUnavailable(LibFunc_stat); | 
|  | 334 | TLI.setUnavailable(LibFunc_statvfs); | 
|  | 335 | TLI.setUnavailable(LibFunc_stpcpy); | 
|  | 336 | TLI.setUnavailable(LibFunc_stpncpy); | 
|  | 337 | TLI.setUnavailable(LibFunc_strcasecmp); | 
|  | 338 | TLI.setUnavailable(LibFunc_strncasecmp); | 
|  | 339 | TLI.setUnavailable(LibFunc_times); | 
|  | 340 | TLI.setUnavailable(LibFunc_uname); | 
|  | 341 | TLI.setUnavailable(LibFunc_unlink); | 
|  | 342 | TLI.setUnavailable(LibFunc_unsetenv); | 
|  | 343 | TLI.setUnavailable(LibFunc_utime); | 
|  | 344 | TLI.setUnavailable(LibFunc_utimes); | 
|  | 345 | TLI.setUnavailable(LibFunc_write); | 
| Meador Inge | 780a186 | 2012-11-22 15:36:42 +0000 | [diff] [blame] | 346 | } | 
|  | 347 |  | 
| Reid Kleckner | f4355ee | 2013-12-26 19:17:04 +0000 | [diff] [blame] | 348 | switch (T.getOS()) { | 
| Reid Kleckner | f4355ee | 2013-12-26 19:17:04 +0000 | [diff] [blame] | 349 | case Triple::MacOSX: | 
| Chandler Carruth | f5689f8 | 2013-12-28 02:40:19 +0000 | [diff] [blame] | 350 | // exp10 and exp10f are not available on OS X until 10.9 and iOS until 7.0 | 
|  | 351 | // and their names are __exp10 and __exp10f. exp10l is not available on | 
|  | 352 | // OS X or iOS. | 
| David L. Jones | d21529f | 2017-01-23 23:16:46 +0000 | [diff] [blame] | 353 | TLI.setUnavailable(LibFunc_exp10l); | 
| Reid Kleckner | f4355ee | 2013-12-26 19:17:04 +0000 | [diff] [blame] | 354 | if (T.isMacOSXVersionLT(10, 9)) { | 
| David L. Jones | d21529f | 2017-01-23 23:16:46 +0000 | [diff] [blame] | 355 | TLI.setUnavailable(LibFunc_exp10); | 
|  | 356 | TLI.setUnavailable(LibFunc_exp10f); | 
| Reid Kleckner | f4355ee | 2013-12-26 19:17:04 +0000 | [diff] [blame] | 357 | } else { | 
| David L. Jones | d21529f | 2017-01-23 23:16:46 +0000 | [diff] [blame] | 358 | TLI.setAvailableWithName(LibFunc_exp10, "__exp10"); | 
|  | 359 | TLI.setAvailableWithName(LibFunc_exp10f, "__exp10f"); | 
| Reid Kleckner | f4355ee | 2013-12-26 19:17:04 +0000 | [diff] [blame] | 360 | } | 
|  | 361 | break; | 
|  | 362 | case Triple::IOS: | 
| Tim Northover | 89a6eef | 2015-11-02 18:00:00 +0000 | [diff] [blame] | 363 | case Triple::TvOS: | 
| Tim Northover | 8b40366 | 2015-10-28 22:51:16 +0000 | [diff] [blame] | 364 | case Triple::WatchOS: | 
| David L. Jones | d21529f | 2017-01-23 23:16:46 +0000 | [diff] [blame] | 365 | TLI.setUnavailable(LibFunc_exp10l); | 
| Tim Northover | 8b40366 | 2015-10-28 22:51:16 +0000 | [diff] [blame] | 366 | if (!T.isWatchOS() && (T.isOSVersionLT(7, 0) || | 
|  | 367 | (T.isOSVersionLT(9, 0) && | 
|  | 368 | (T.getArch() == Triple::x86 || | 
|  | 369 | T.getArch() == Triple::x86_64)))) { | 
| David L. Jones | d21529f | 2017-01-23 23:16:46 +0000 | [diff] [blame] | 370 | TLI.setUnavailable(LibFunc_exp10); | 
|  | 371 | TLI.setUnavailable(LibFunc_exp10f); | 
| Reid Kleckner | f4355ee | 2013-12-26 19:17:04 +0000 | [diff] [blame] | 372 | } else { | 
| David L. Jones | d21529f | 2017-01-23 23:16:46 +0000 | [diff] [blame] | 373 | TLI.setAvailableWithName(LibFunc_exp10, "__exp10"); | 
|  | 374 | TLI.setAvailableWithName(LibFunc_exp10f, "__exp10f"); | 
| Reid Kleckner | f4355ee | 2013-12-26 19:17:04 +0000 | [diff] [blame] | 375 | } | 
|  | 376 | break; | 
| Chandler Carruth | f5689f8 | 2013-12-28 02:40:19 +0000 | [diff] [blame] | 377 | case Triple::Linux: | 
|  | 378 | // exp10, exp10f, exp10l is available on Linux (GLIBC) but are extremely | 
|  | 379 | // buggy prior to glibc version 2.18. Until this version is widely deployed | 
|  | 380 | // or we have a reasonable detection strategy, we cannot use exp10 reliably | 
|  | 381 | // on Linux. | 
|  | 382 | // | 
|  | 383 | // Fall through to disable all of them. | 
| Justin Bogner | cd1d5aa | 2016-08-17 20:30:52 +0000 | [diff] [blame] | 384 | LLVM_FALLTHROUGH; | 
| Reid Kleckner | f4355ee | 2013-12-26 19:17:04 +0000 | [diff] [blame] | 385 | default: | 
| David L. Jones | d21529f | 2017-01-23 23:16:46 +0000 | [diff] [blame] | 386 | TLI.setUnavailable(LibFunc_exp10); | 
|  | 387 | TLI.setUnavailable(LibFunc_exp10f); | 
|  | 388 | TLI.setUnavailable(LibFunc_exp10l); | 
| Reid Kleckner | f4355ee | 2013-12-26 19:17:04 +0000 | [diff] [blame] | 389 | } | 
|  | 390 |  | 
| Meador Inge | 780a186 | 2012-11-22 15:36:42 +0000 | [diff] [blame] | 391 | // ffsl is available on at least Darwin, Mac OS X, iOS, FreeBSD, and | 
|  | 392 | // Linux (GLIBC): | 
|  | 393 | // http://developer.apple.com/library/mac/#documentation/Darwin/Reference/ManPages/man3/ffsl.3.html | 
| Davide Italiano | 83b3481 | 2015-11-01 17:00:13 +0000 | [diff] [blame] | 394 | // http://svn.freebsd.org/base/head/lib/libc/string/ffsl.c | 
| Meador Inge | 780a186 | 2012-11-22 15:36:42 +0000 | [diff] [blame] | 395 | // http://www.gnu.org/software/gnulib/manual/html_node/ffsl.html | 
|  | 396 | switch (T.getOS()) { | 
|  | 397 | case Triple::Darwin: | 
|  | 398 | case Triple::MacOSX: | 
|  | 399 | case Triple::IOS: | 
| Tim Northover | 89a6eef | 2015-11-02 18:00:00 +0000 | [diff] [blame] | 400 | case Triple::TvOS: | 
| Tim Northover | 8b40366 | 2015-10-28 22:51:16 +0000 | [diff] [blame] | 401 | case Triple::WatchOS: | 
| Meador Inge | 780a186 | 2012-11-22 15:36:42 +0000 | [diff] [blame] | 402 | case Triple::FreeBSD: | 
|  | 403 | case Triple::Linux: | 
|  | 404 | break; | 
|  | 405 | default: | 
| David L. Jones | d21529f | 2017-01-23 23:16:46 +0000 | [diff] [blame] | 406 | TLI.setUnavailable(LibFunc_ffsl); | 
| Meador Inge | 780a186 | 2012-11-22 15:36:42 +0000 | [diff] [blame] | 407 | } | 
|  | 408 |  | 
|  | 409 | // ffsll is available on at least FreeBSD and Linux (GLIBC): | 
| Davide Italiano | 83b3481 | 2015-11-01 17:00:13 +0000 | [diff] [blame] | 410 | // http://svn.freebsd.org/base/head/lib/libc/string/ffsll.c | 
| Meador Inge | 780a186 | 2012-11-22 15:36:42 +0000 | [diff] [blame] | 411 | // http://www.gnu.org/software/gnulib/manual/html_node/ffsll.html | 
|  | 412 | switch (T.getOS()) { | 
| Tim Northover | 89a6eef | 2015-11-02 18:00:00 +0000 | [diff] [blame] | 413 | case Triple::Darwin: | 
|  | 414 | case Triple::MacOSX: | 
|  | 415 | case Triple::IOS: | 
|  | 416 | case Triple::TvOS: | 
|  | 417 | case Triple::WatchOS: | 
| Meador Inge | 780a186 | 2012-11-22 15:36:42 +0000 | [diff] [blame] | 418 | case Triple::FreeBSD: | 
|  | 419 | case Triple::Linux: | 
|  | 420 | break; | 
|  | 421 | default: | 
| David L. Jones | d21529f | 2017-01-23 23:16:46 +0000 | [diff] [blame] | 422 | TLI.setUnavailable(LibFunc_ffsll); | 
| Joe Groff | a81bcbb | 2012-04-17 23:05:54 +0000 | [diff] [blame] | 423 | } | 
| Meador Inge | b904e6e | 2013-03-05 21:47:40 +0000 | [diff] [blame] | 424 |  | 
| Davide Italiano | bfd3082 | 2015-11-09 23:23:20 +0000 | [diff] [blame] | 425 | // The following functions are available on at least FreeBSD: | 
|  | 426 | // http://svn.freebsd.org/base/head/lib/libc/string/fls.c | 
|  | 427 | // http://svn.freebsd.org/base/head/lib/libc/string/flsl.c | 
|  | 428 | // http://svn.freebsd.org/base/head/lib/libc/string/flsll.c | 
|  | 429 | if (!T.isOSFreeBSD()) { | 
| David L. Jones | d21529f | 2017-01-23 23:16:46 +0000 | [diff] [blame] | 430 | TLI.setUnavailable(LibFunc_fls); | 
|  | 431 | TLI.setUnavailable(LibFunc_flsl); | 
|  | 432 | TLI.setUnavailable(LibFunc_flsll); | 
| Davide Italiano | bfd3082 | 2015-11-09 23:23:20 +0000 | [diff] [blame] | 433 | } | 
|  | 434 |  | 
| Eli Friedman | e3a5fc6 | 2018-11-06 18:23:32 +0000 | [diff] [blame] | 435 | // The following functions are only available on GNU/Linux (using glibc). | 
|  | 436 | // Linux variants without glibc (eg: bionic, musl) may have some subset. | 
|  | 437 | if (!T.isOSLinux() || !T.isGNUEnvironment()) { | 
| David L. Jones | d21529f | 2017-01-23 23:16:46 +0000 | [diff] [blame] | 438 | TLI.setUnavailable(LibFunc_dunder_strdup); | 
|  | 439 | TLI.setUnavailable(LibFunc_dunder_strtok_r); | 
|  | 440 | TLI.setUnavailable(LibFunc_dunder_isoc99_scanf); | 
|  | 441 | TLI.setUnavailable(LibFunc_dunder_isoc99_sscanf); | 
|  | 442 | TLI.setUnavailable(LibFunc_under_IO_getc); | 
|  | 443 | TLI.setUnavailable(LibFunc_under_IO_putc); | 
| Eli Friedman | e3a5fc6 | 2018-11-06 18:23:32 +0000 | [diff] [blame] | 444 | // But, Android and musl have memalign. | 
|  | 445 | if (!T.isAndroid() && !T.isMusl()) | 
| Chih-Hung Hsieh | 60d1e79 | 2018-01-31 19:12:50 +0000 | [diff] [blame] | 446 | TLI.setUnavailable(LibFunc_memalign); | 
| David L. Jones | d21529f | 2017-01-23 23:16:46 +0000 | [diff] [blame] | 447 | TLI.setUnavailable(LibFunc_fopen64); | 
|  | 448 | TLI.setUnavailable(LibFunc_fseeko64); | 
|  | 449 | TLI.setUnavailable(LibFunc_fstat64); | 
|  | 450 | TLI.setUnavailable(LibFunc_fstatvfs64); | 
|  | 451 | TLI.setUnavailable(LibFunc_ftello64); | 
|  | 452 | TLI.setUnavailable(LibFunc_lstat64); | 
|  | 453 | TLI.setUnavailable(LibFunc_open64); | 
|  | 454 | TLI.setUnavailable(LibFunc_stat64); | 
|  | 455 | TLI.setUnavailable(LibFunc_statvfs64); | 
|  | 456 | TLI.setUnavailable(LibFunc_tmpfile64); | 
| Sanjay Patel | 52149f0 | 2018-01-08 17:38:09 +0000 | [diff] [blame] | 457 |  | 
|  | 458 | // Relaxed math functions are included in math-finite.h on Linux (GLIBC). | 
|  | 459 | TLI.setUnavailable(LibFunc_acos_finite); | 
|  | 460 | TLI.setUnavailable(LibFunc_acosf_finite); | 
|  | 461 | TLI.setUnavailable(LibFunc_acosl_finite); | 
|  | 462 | TLI.setUnavailable(LibFunc_acosh_finite); | 
|  | 463 | TLI.setUnavailable(LibFunc_acoshf_finite); | 
|  | 464 | TLI.setUnavailable(LibFunc_acoshl_finite); | 
|  | 465 | TLI.setUnavailable(LibFunc_asin_finite); | 
|  | 466 | TLI.setUnavailable(LibFunc_asinf_finite); | 
|  | 467 | TLI.setUnavailable(LibFunc_asinl_finite); | 
|  | 468 | TLI.setUnavailable(LibFunc_atan2_finite); | 
|  | 469 | TLI.setUnavailable(LibFunc_atan2f_finite); | 
|  | 470 | TLI.setUnavailable(LibFunc_atan2l_finite); | 
|  | 471 | TLI.setUnavailable(LibFunc_atanh_finite); | 
|  | 472 | TLI.setUnavailable(LibFunc_atanhf_finite); | 
|  | 473 | TLI.setUnavailable(LibFunc_atanhl_finite); | 
|  | 474 | TLI.setUnavailable(LibFunc_cosh_finite); | 
|  | 475 | TLI.setUnavailable(LibFunc_coshf_finite); | 
|  | 476 | TLI.setUnavailable(LibFunc_coshl_finite); | 
|  | 477 | TLI.setUnavailable(LibFunc_exp10_finite); | 
|  | 478 | TLI.setUnavailable(LibFunc_exp10f_finite); | 
|  | 479 | TLI.setUnavailable(LibFunc_exp10l_finite); | 
|  | 480 | TLI.setUnavailable(LibFunc_exp2_finite); | 
|  | 481 | TLI.setUnavailable(LibFunc_exp2f_finite); | 
|  | 482 | TLI.setUnavailable(LibFunc_exp2l_finite); | 
|  | 483 | TLI.setUnavailable(LibFunc_exp_finite); | 
|  | 484 | TLI.setUnavailable(LibFunc_expf_finite); | 
|  | 485 | TLI.setUnavailable(LibFunc_expl_finite); | 
|  | 486 | TLI.setUnavailable(LibFunc_log10_finite); | 
|  | 487 | TLI.setUnavailable(LibFunc_log10f_finite); | 
|  | 488 | TLI.setUnavailable(LibFunc_log10l_finite); | 
|  | 489 | TLI.setUnavailable(LibFunc_log2_finite); | 
|  | 490 | TLI.setUnavailable(LibFunc_log2f_finite); | 
|  | 491 | TLI.setUnavailable(LibFunc_log2l_finite); | 
|  | 492 | TLI.setUnavailable(LibFunc_log_finite); | 
|  | 493 | TLI.setUnavailable(LibFunc_logf_finite); | 
|  | 494 | TLI.setUnavailable(LibFunc_logl_finite); | 
|  | 495 | TLI.setUnavailable(LibFunc_pow_finite); | 
|  | 496 | TLI.setUnavailable(LibFunc_powf_finite); | 
|  | 497 | TLI.setUnavailable(LibFunc_powl_finite); | 
|  | 498 | TLI.setUnavailable(LibFunc_sinh_finite); | 
|  | 499 | TLI.setUnavailable(LibFunc_sinhf_finite); | 
|  | 500 | TLI.setUnavailable(LibFunc_sinhl_finite); | 
| Meador Inge | b904e6e | 2013-03-05 21:47:40 +0000 | [diff] [blame] | 501 | } | 
| Michael Zolotukhin | 6d8a2aa | 2015-03-17 19:50:55 +0000 | [diff] [blame] | 502 |  | 
| Martin Storsjo | c107887 | 2018-05-17 08:16:08 +0000 | [diff] [blame] | 503 | if ((T.isOSLinux() && T.isGNUEnvironment()) || | 
|  | 504 | (T.isAndroid() && !T.isAndroidVersionLT(28))) { | 
| David Bolvansky | ca22d42 | 2018-05-16 11:39:52 +0000 | [diff] [blame] | 505 | // available IO unlocked variants on GNU/Linux and Android P or later | 
|  | 506 | TLI.setAvailable(LibFunc_getc_unlocked); | 
|  | 507 | TLI.setAvailable(LibFunc_getchar_unlocked); | 
|  | 508 | TLI.setAvailable(LibFunc_putc_unlocked); | 
|  | 509 | TLI.setAvailable(LibFunc_putchar_unlocked); | 
|  | 510 | TLI.setAvailable(LibFunc_fputc_unlocked); | 
|  | 511 | TLI.setAvailable(LibFunc_fgetc_unlocked); | 
|  | 512 | TLI.setAvailable(LibFunc_fread_unlocked); | 
|  | 513 | TLI.setAvailable(LibFunc_fwrite_unlocked); | 
|  | 514 | TLI.setAvailable(LibFunc_fputs_unlocked); | 
|  | 515 | TLI.setAvailable(LibFunc_fgets_unlocked); | 
|  | 516 | } | 
|  | 517 |  | 
| Justin Lebar | 5113288 | 2016-01-26 23:51:06 +0000 | [diff] [blame] | 518 | // As currently implemented in clang, NVPTX code has no standard library to | 
|  | 519 | // speak of.  Headers provide a standard-ish library implementation, but many | 
|  | 520 | // of the signatures are wrong -- for example, many libm functions are not | 
|  | 521 | // extern "C". | 
|  | 522 | // | 
|  | 523 | // libdevice, an IR library provided by nvidia, is linked in by the front-end, | 
|  | 524 | // but only used functions are provided to llvm.  Moreover, most of the | 
|  | 525 | // functions in libdevice don't map precisely to standard library functions. | 
|  | 526 | // | 
|  | 527 | // FIXME: Having no standard library prevents e.g. many fastmath | 
|  | 528 | // optimizations, so this situation should be fixed. | 
| David Majnemer | ae272d7 | 2016-03-31 21:29:57 +0000 | [diff] [blame] | 529 | if (T.isNVPTX()) { | 
| Justin Lebar | 5113288 | 2016-01-26 23:51:06 +0000 | [diff] [blame] | 530 | TLI.disableAllFunctions(); | 
| David L. Jones | d21529f | 2017-01-23 23:16:46 +0000 | [diff] [blame] | 531 | TLI.setAvailable(LibFunc_nvvm_reflect); | 
| David Majnemer | ae272d7 | 2016-03-31 21:29:57 +0000 | [diff] [blame] | 532 | } else { | 
| David L. Jones | d21529f | 2017-01-23 23:16:46 +0000 | [diff] [blame] | 533 | TLI.setUnavailable(LibFunc_nvvm_reflect); | 
| David Majnemer | ae272d7 | 2016-03-31 21:29:57 +0000 | [diff] [blame] | 534 | } | 
| Justin Lebar | 5113288 | 2016-01-26 23:51:06 +0000 | [diff] [blame] | 535 |  | 
| Michael Zolotukhin | 6d8a2aa | 2015-03-17 19:50:55 +0000 | [diff] [blame] | 536 | TLI.addVectorizableFunctionsFromVecLib(ClVectorLibrary); | 
| Chris Lattner | 0e125bb | 2011-02-18 21:50:34 +0000 | [diff] [blame] | 537 | } | 
|  | 538 |  | 
| Chandler Carruth | c029186 | 2015-01-24 02:06:09 +0000 | [diff] [blame] | 539 | TargetLibraryInfoImpl::TargetLibraryInfoImpl() { | 
| Chris Lattner | 0e125bb | 2011-02-18 21:50:34 +0000 | [diff] [blame] | 540 | // Default to everything being available. | 
|  | 541 | memset(AvailableArray, -1, sizeof(AvailableArray)); | 
|  | 542 |  | 
| Bob Wilson | c740e3f | 2012-08-03 04:06:22 +0000 | [diff] [blame] | 543 | initialize(*this, Triple(), StandardNames); | 
| Chris Lattner | 0e125bb | 2011-02-18 21:50:34 +0000 | [diff] [blame] | 544 | } | 
|  | 545 |  | 
| Joel Jones | 7459398 | 2018-11-24 07:26:55 +0000 | [diff] [blame] | 546 | TargetLibraryInfoImpl::TargetLibraryInfoImpl(const Triple &T) { | 
| Chris Lattner | 0e125bb | 2011-02-18 21:50:34 +0000 | [diff] [blame] | 547 | // Default to everything being available. | 
|  | 548 | memset(AvailableArray, -1, sizeof(AvailableArray)); | 
| Chandler Carruth | b98f63d | 2015-01-15 10:41:28 +0000 | [diff] [blame] | 549 |  | 
| Bob Wilson | c740e3f | 2012-08-03 04:06:22 +0000 | [diff] [blame] | 550 | initialize(*this, T, StandardNames); | 
| Chris Lattner | 0e125bb | 2011-02-18 21:50:34 +0000 | [diff] [blame] | 551 | } | 
| Chris Lattner | 1341df9 | 2011-02-18 22:34:03 +0000 | [diff] [blame] | 552 |  | 
| Chandler Carruth | c029186 | 2015-01-24 02:06:09 +0000 | [diff] [blame] | 553 | TargetLibraryInfoImpl::TargetLibraryInfoImpl(const TargetLibraryInfoImpl &TLI) | 
| Joel Jones | 7459398 | 2018-11-24 07:26:55 +0000 | [diff] [blame] | 554 | : CustomNames(TLI.CustomNames), ShouldExtI32Param(TLI.ShouldExtI32Param), | 
| Marcin Koscielnicki | 5ae2c52 | 2016-11-21 11:57:11 +0000 | [diff] [blame] | 555 | ShouldExtI32Return(TLI.ShouldExtI32Return), | 
|  | 556 | ShouldSignExtI32Param(TLI.ShouldSignExtI32Param) { | 
| Chris Lattner | 4c0d9e2 | 2011-05-21 20:09:13 +0000 | [diff] [blame] | 557 | memcpy(AvailableArray, TLI.AvailableArray, sizeof(AvailableArray)); | 
| Michael Zolotukhin | e8f2551 | 2015-03-17 19:22:30 +0000 | [diff] [blame] | 558 | VectorDescs = TLI.VectorDescs; | 
|  | 559 | ScalarDescs = TLI.ScalarDescs; | 
| Chandler Carruth | 8ca4322 | 2015-01-15 11:39:46 +0000 | [diff] [blame] | 560 | } | 
|  | 561 |  | 
| Chandler Carruth | c029186 | 2015-01-24 02:06:09 +0000 | [diff] [blame] | 562 | TargetLibraryInfoImpl::TargetLibraryInfoImpl(TargetLibraryInfoImpl &&TLI) | 
| Joel Jones | 7459398 | 2018-11-24 07:26:55 +0000 | [diff] [blame] | 563 | : CustomNames(std::move(TLI.CustomNames)), | 
| Marcin Koscielnicki | 5ae2c52 | 2016-11-21 11:57:11 +0000 | [diff] [blame] | 564 | ShouldExtI32Param(TLI.ShouldExtI32Param), | 
|  | 565 | ShouldExtI32Return(TLI.ShouldExtI32Return), | 
|  | 566 | ShouldSignExtI32Param(TLI.ShouldSignExtI32Param) { | 
| Chandler Carruth | 8ca4322 | 2015-01-15 11:39:46 +0000 | [diff] [blame] | 567 | std::move(std::begin(TLI.AvailableArray), std::end(TLI.AvailableArray), | 
|  | 568 | AvailableArray); | 
| Michael Zolotukhin | e8f2551 | 2015-03-17 19:22:30 +0000 | [diff] [blame] | 569 | VectorDescs = TLI.VectorDescs; | 
|  | 570 | ScalarDescs = TLI.ScalarDescs; | 
| Chandler Carruth | 8ca4322 | 2015-01-15 11:39:46 +0000 | [diff] [blame] | 571 | } | 
|  | 572 |  | 
| Chandler Carruth | c029186 | 2015-01-24 02:06:09 +0000 | [diff] [blame] | 573 | TargetLibraryInfoImpl &TargetLibraryInfoImpl::operator=(const TargetLibraryInfoImpl &TLI) { | 
| Eli Friedman | 489c0ff | 2011-11-17 01:27:36 +0000 | [diff] [blame] | 574 | CustomNames = TLI.CustomNames; | 
| Marcin Koscielnicki | 5ae2c52 | 2016-11-21 11:57:11 +0000 | [diff] [blame] | 575 | ShouldExtI32Param = TLI.ShouldExtI32Param; | 
|  | 576 | ShouldExtI32Return = TLI.ShouldExtI32Return; | 
|  | 577 | ShouldSignExtI32Param = TLI.ShouldSignExtI32Param; | 
| Chandler Carruth | 8ca4322 | 2015-01-15 11:39:46 +0000 | [diff] [blame] | 578 | memcpy(AvailableArray, TLI.AvailableArray, sizeof(AvailableArray)); | 
|  | 579 | return *this; | 
|  | 580 | } | 
|  | 581 |  | 
| Chandler Carruth | c029186 | 2015-01-24 02:06:09 +0000 | [diff] [blame] | 582 | TargetLibraryInfoImpl &TargetLibraryInfoImpl::operator=(TargetLibraryInfoImpl &&TLI) { | 
| Chandler Carruth | 8ca4322 | 2015-01-15 11:39:46 +0000 | [diff] [blame] | 583 | CustomNames = std::move(TLI.CustomNames); | 
| Marcin Koscielnicki | 5ae2c52 | 2016-11-21 11:57:11 +0000 | [diff] [blame] | 584 | ShouldExtI32Param = TLI.ShouldExtI32Param; | 
|  | 585 | ShouldExtI32Return = TLI.ShouldExtI32Return; | 
|  | 586 | ShouldSignExtI32Param = TLI.ShouldSignExtI32Param; | 
| Chandler Carruth | 8ca4322 | 2015-01-15 11:39:46 +0000 | [diff] [blame] | 587 | std::move(std::begin(TLI.AvailableArray), std::end(TLI.AvailableArray), | 
|  | 588 | AvailableArray); | 
|  | 589 | return *this; | 
| Chris Lattner | 4c0d9e2 | 2011-05-21 20:09:13 +0000 | [diff] [blame] | 590 | } | 
|  | 591 |  | 
| Michael Zolotukhin | 21abdf9 | 2015-03-02 23:24:40 +0000 | [diff] [blame] | 592 | static StringRef sanitizeFunctionName(StringRef funcName) { | 
| Benjamin Kramer | 160f72d | 2013-03-09 13:48:23 +0000 | [diff] [blame] | 593 | // Filter out empty names and names containing null bytes, those can't be in | 
|  | 594 | // our table. | 
|  | 595 | if (funcName.empty() || funcName.find('\0') != StringRef::npos) | 
| Michael Zolotukhin | 21abdf9 | 2015-03-02 23:24:40 +0000 | [diff] [blame] | 596 | return StringRef(); | 
| Benjamin Kramer | 160f72d | 2013-03-09 13:48:23 +0000 | [diff] [blame] | 597 |  | 
| Meador Inge | b904e6e | 2013-03-05 21:47:40 +0000 | [diff] [blame] | 598 | // Check for \01 prefix that is used to mangle __asm declarations and | 
|  | 599 | // strip it if present. | 
| Peter Collingbourne | 6f0ecca | 2017-05-16 00:39:01 +0000 | [diff] [blame] | 600 | return GlobalValue::dropLLVMManglingEscape(funcName); | 
| Michael Zolotukhin | 21abdf9 | 2015-03-02 23:24:40 +0000 | [diff] [blame] | 601 | } | 
|  | 602 |  | 
|  | 603 | bool TargetLibraryInfoImpl::getLibFunc(StringRef funcName, | 
| David L. Jones | d21529f | 2017-01-23 23:16:46 +0000 | [diff] [blame] | 604 | LibFunc &F) const { | 
| Mehdi Amini | 9a72cd7 | 2016-10-01 03:10:48 +0000 | [diff] [blame] | 605 | StringRef const *Start = &StandardNames[0]; | 
| David L. Jones | d21529f | 2017-01-23 23:16:46 +0000 | [diff] [blame] | 606 | StringRef const *End = &StandardNames[NumLibFuncs]; | 
| Michael Zolotukhin | 21abdf9 | 2015-03-02 23:24:40 +0000 | [diff] [blame] | 607 |  | 
|  | 608 | funcName = sanitizeFunctionName(funcName); | 
|  | 609 | if (funcName.empty()) | 
|  | 610 | return false; | 
|  | 611 |  | 
| Mehdi Amini | 9a72cd7 | 2016-10-01 03:10:48 +0000 | [diff] [blame] | 612 | StringRef const *I = std::lower_bound( | 
|  | 613 | Start, End, funcName, [](StringRef LHS, StringRef RHS) { | 
|  | 614 | return LHS < RHS; | 
| Michael Zolotukhin | d3b76a3 | 2015-03-02 20:50:08 +0000 | [diff] [blame] | 615 | }); | 
| Bob Wilson | c740e3f | 2012-08-03 04:06:22 +0000 | [diff] [blame] | 616 | if (I != End && *I == funcName) { | 
| David L. Jones | d21529f | 2017-01-23 23:16:46 +0000 | [diff] [blame] | 617 | F = (LibFunc)(I - Start); | 
| Bob Wilson | c740e3f | 2012-08-03 04:06:22 +0000 | [diff] [blame] | 618 | return true; | 
|  | 619 | } | 
|  | 620 | return false; | 
|  | 621 | } | 
| Chris Lattner | 4c0d9e2 | 2011-05-21 20:09:13 +0000 | [diff] [blame] | 622 |  | 
| Ahmed Bougacha | d765a82 | 2016-04-27 19:04:35 +0000 | [diff] [blame] | 623 | bool TargetLibraryInfoImpl::isValidProtoForLibFunc(const FunctionType &FTy, | 
| David L. Jones | d21529f | 2017-01-23 23:16:46 +0000 | [diff] [blame] | 624 | LibFunc F, | 
| Ahmed Bougacha | d765a82 | 2016-04-27 19:04:35 +0000 | [diff] [blame] | 625 | const DataLayout *DL) const { | 
|  | 626 | LLVMContext &Ctx = FTy.getContext(); | 
|  | 627 | Type *PCharTy = Type::getInt8PtrTy(Ctx); | 
|  | 628 | Type *SizeTTy = DL ? DL->getIntPtrType(Ctx, /*AS=*/0) : nullptr; | 
|  | 629 | auto IsSizeTTy = [SizeTTy](Type *Ty) { | 
|  | 630 | return SizeTTy ? Ty == SizeTTy : Ty->isIntegerTy(); | 
|  | 631 | }; | 
|  | 632 | unsigned NumParams = FTy.getNumParams(); | 
|  | 633 |  | 
|  | 634 | switch (F) { | 
| Calixte Denizet | c3bed1e | 2018-11-07 13:49:17 +0000 | [diff] [blame] | 635 | case LibFunc_execl: | 
|  | 636 | case LibFunc_execlp: | 
| Calixte Denizet | 8f07efc | 2018-11-07 14:46:26 +0000 | [diff] [blame] | 637 | case LibFunc_execle: | 
| Calixte Denizet | c3bed1e | 2018-11-07 13:49:17 +0000 | [diff] [blame] | 638 | return (NumParams >= 2 && FTy.getParamType(0)->isPointerTy() && | 
|  | 639 | FTy.getParamType(1)->isPointerTy() && | 
|  | 640 | FTy.getReturnType()->isIntegerTy(32)); | 
| Calixte Denizet | c3bed1e | 2018-11-07 13:49:17 +0000 | [diff] [blame] | 641 | case LibFunc_execv: | 
|  | 642 | case LibFunc_execvp: | 
|  | 643 | return (NumParams == 2 && FTy.getParamType(0)->isPointerTy() && | 
|  | 644 | FTy.getParamType(1)->isPointerTy() && | 
|  | 645 | FTy.getReturnType()->isIntegerTy(32)); | 
|  | 646 | case LibFunc_execvP: | 
|  | 647 | case LibFunc_execvpe: | 
|  | 648 | case LibFunc_execve: | 
|  | 649 | return (NumParams == 3 && FTy.getParamType(0)->isPointerTy() && | 
|  | 650 | FTy.getParamType(1)->isPointerTy() && | 
|  | 651 | FTy.getParamType(2)->isPointerTy() && | 
|  | 652 | FTy.getReturnType()->isIntegerTy(32)); | 
| David L. Jones | d21529f | 2017-01-23 23:16:46 +0000 | [diff] [blame] | 653 | case LibFunc_strlen: | 
| Ahmed Bougacha | d765a82 | 2016-04-27 19:04:35 +0000 | [diff] [blame] | 654 | return (NumParams == 1 && FTy.getParamType(0)->isPointerTy() && | 
|  | 655 | FTy.getReturnType()->isIntegerTy()); | 
|  | 656 |  | 
| David L. Jones | d21529f | 2017-01-23 23:16:46 +0000 | [diff] [blame] | 657 | case LibFunc_strchr: | 
|  | 658 | case LibFunc_strrchr: | 
| Ahmed Bougacha | d765a82 | 2016-04-27 19:04:35 +0000 | [diff] [blame] | 659 | return (NumParams == 2 && FTy.getReturnType()->isPointerTy() && | 
|  | 660 | FTy.getParamType(0) == FTy.getReturnType() && | 
|  | 661 | FTy.getParamType(1)->isIntegerTy()); | 
|  | 662 |  | 
| David L. Jones | d21529f | 2017-01-23 23:16:46 +0000 | [diff] [blame] | 663 | case LibFunc_strtol: | 
|  | 664 | case LibFunc_strtod: | 
|  | 665 | case LibFunc_strtof: | 
|  | 666 | case LibFunc_strtoul: | 
|  | 667 | case LibFunc_strtoll: | 
|  | 668 | case LibFunc_strtold: | 
|  | 669 | case LibFunc_strtoull: | 
| Ahmed Bougacha | d765a82 | 2016-04-27 19:04:35 +0000 | [diff] [blame] | 670 | return ((NumParams == 2 || NumParams == 3) && | 
|  | 671 | FTy.getParamType(0)->isPointerTy() && | 
|  | 672 | FTy.getParamType(1)->isPointerTy()); | 
| David L. Jones | d21529f | 2017-01-23 23:16:46 +0000 | [diff] [blame] | 673 | case LibFunc_strcat: | 
| Ahmed Bougacha | d765a82 | 2016-04-27 19:04:35 +0000 | [diff] [blame] | 674 | return (NumParams == 2 && FTy.getReturnType()->isPointerTy() && | 
|  | 675 | FTy.getParamType(0) == FTy.getReturnType() && | 
|  | 676 | FTy.getParamType(1) == FTy.getReturnType()); | 
|  | 677 |  | 
| David L. Jones | d21529f | 2017-01-23 23:16:46 +0000 | [diff] [blame] | 678 | case LibFunc_strncat: | 
| Ahmed Bougacha | d765a82 | 2016-04-27 19:04:35 +0000 | [diff] [blame] | 679 | return (NumParams == 3 && FTy.getReturnType()->isPointerTy() && | 
|  | 680 | FTy.getParamType(0) == FTy.getReturnType() && | 
|  | 681 | FTy.getParamType(1) == FTy.getReturnType() && | 
| Igor Laevsky | 7bd3fb1 | 2017-12-18 10:31:58 +0000 | [diff] [blame] | 682 | IsSizeTTy(FTy.getParamType(2))); | 
| Ahmed Bougacha | d765a82 | 2016-04-27 19:04:35 +0000 | [diff] [blame] | 683 |  | 
| David L. Jones | d21529f | 2017-01-23 23:16:46 +0000 | [diff] [blame] | 684 | case LibFunc_strcpy_chk: | 
|  | 685 | case LibFunc_stpcpy_chk: | 
| Ahmed Bougacha | d765a82 | 2016-04-27 19:04:35 +0000 | [diff] [blame] | 686 | --NumParams; | 
|  | 687 | if (!IsSizeTTy(FTy.getParamType(NumParams))) | 
|  | 688 | return false; | 
| Justin Bogner | b03fd12 | 2016-08-17 05:10:15 +0000 | [diff] [blame] | 689 | LLVM_FALLTHROUGH; | 
| David L. Jones | d21529f | 2017-01-23 23:16:46 +0000 | [diff] [blame] | 690 | case LibFunc_strcpy: | 
|  | 691 | case LibFunc_stpcpy: | 
| Ahmed Bougacha | d765a82 | 2016-04-27 19:04:35 +0000 | [diff] [blame] | 692 | return (NumParams == 2 && FTy.getReturnType() == FTy.getParamType(0) && | 
|  | 693 | FTy.getParamType(0) == FTy.getParamType(1) && | 
|  | 694 | FTy.getParamType(0) == PCharTy); | 
|  | 695 |  | 
| David L. Jones | d21529f | 2017-01-23 23:16:46 +0000 | [diff] [blame] | 696 | case LibFunc_strncpy_chk: | 
|  | 697 | case LibFunc_stpncpy_chk: | 
| Ahmed Bougacha | d765a82 | 2016-04-27 19:04:35 +0000 | [diff] [blame] | 698 | --NumParams; | 
|  | 699 | if (!IsSizeTTy(FTy.getParamType(NumParams))) | 
|  | 700 | return false; | 
| Justin Bogner | b03fd12 | 2016-08-17 05:10:15 +0000 | [diff] [blame] | 701 | LLVM_FALLTHROUGH; | 
| David L. Jones | d21529f | 2017-01-23 23:16:46 +0000 | [diff] [blame] | 702 | case LibFunc_strncpy: | 
|  | 703 | case LibFunc_stpncpy: | 
| Ahmed Bougacha | d765a82 | 2016-04-27 19:04:35 +0000 | [diff] [blame] | 704 | return (NumParams == 3 && FTy.getReturnType() == FTy.getParamType(0) && | 
|  | 705 | FTy.getParamType(0) == FTy.getParamType(1) && | 
|  | 706 | FTy.getParamType(0) == PCharTy && | 
| Igor Laevsky | 7bd3fb1 | 2017-12-18 10:31:58 +0000 | [diff] [blame] | 707 | IsSizeTTy(FTy.getParamType(2))); | 
| Ahmed Bougacha | d765a82 | 2016-04-27 19:04:35 +0000 | [diff] [blame] | 708 |  | 
| David L. Jones | d21529f | 2017-01-23 23:16:46 +0000 | [diff] [blame] | 709 | case LibFunc_strxfrm: | 
| Ahmed Bougacha | d765a82 | 2016-04-27 19:04:35 +0000 | [diff] [blame] | 710 | return (NumParams == 3 && FTy.getParamType(0)->isPointerTy() && | 
|  | 711 | FTy.getParamType(1)->isPointerTy()); | 
|  | 712 |  | 
| David L. Jones | d21529f | 2017-01-23 23:16:46 +0000 | [diff] [blame] | 713 | case LibFunc_strcmp: | 
| Ahmed Bougacha | d765a82 | 2016-04-27 19:04:35 +0000 | [diff] [blame] | 714 | return (NumParams == 2 && FTy.getReturnType()->isIntegerTy(32) && | 
|  | 715 | FTy.getParamType(0)->isPointerTy() && | 
|  | 716 | FTy.getParamType(0) == FTy.getParamType(1)); | 
|  | 717 |  | 
| David L. Jones | d21529f | 2017-01-23 23:16:46 +0000 | [diff] [blame] | 718 | case LibFunc_strncmp: | 
| Ahmed Bougacha | d765a82 | 2016-04-27 19:04:35 +0000 | [diff] [blame] | 719 | return (NumParams == 3 && FTy.getReturnType()->isIntegerTy(32) && | 
|  | 720 | FTy.getParamType(0)->isPointerTy() && | 
|  | 721 | FTy.getParamType(0) == FTy.getParamType(1) && | 
| Igor Laevsky | 7bd3fb1 | 2017-12-18 10:31:58 +0000 | [diff] [blame] | 722 | IsSizeTTy(FTy.getParamType(2))); | 
| Ahmed Bougacha | d765a82 | 2016-04-27 19:04:35 +0000 | [diff] [blame] | 723 |  | 
| David L. Jones | d21529f | 2017-01-23 23:16:46 +0000 | [diff] [blame] | 724 | case LibFunc_strspn: | 
|  | 725 | case LibFunc_strcspn: | 
| Ahmed Bougacha | d765a82 | 2016-04-27 19:04:35 +0000 | [diff] [blame] | 726 | return (NumParams == 2 && FTy.getParamType(0)->isPointerTy() && | 
|  | 727 | FTy.getParamType(0) == FTy.getParamType(1) && | 
|  | 728 | FTy.getReturnType()->isIntegerTy()); | 
|  | 729 |  | 
| David L. Jones | d21529f | 2017-01-23 23:16:46 +0000 | [diff] [blame] | 730 | case LibFunc_strcoll: | 
|  | 731 | case LibFunc_strcasecmp: | 
|  | 732 | case LibFunc_strncasecmp: | 
| Ahmed Bougacha | d765a82 | 2016-04-27 19:04:35 +0000 | [diff] [blame] | 733 | return (NumParams >= 2 && FTy.getParamType(0)->isPointerTy() && | 
|  | 734 | FTy.getParamType(1)->isPointerTy()); | 
|  | 735 |  | 
| David L. Jones | d21529f | 2017-01-23 23:16:46 +0000 | [diff] [blame] | 736 | case LibFunc_strstr: | 
| Ahmed Bougacha | d765a82 | 2016-04-27 19:04:35 +0000 | [diff] [blame] | 737 | return (NumParams == 2 && FTy.getReturnType()->isPointerTy() && | 
|  | 738 | FTy.getParamType(0)->isPointerTy() && | 
|  | 739 | FTy.getParamType(1)->isPointerTy()); | 
|  | 740 |  | 
| David L. Jones | d21529f | 2017-01-23 23:16:46 +0000 | [diff] [blame] | 741 | case LibFunc_strpbrk: | 
| Ahmed Bougacha | d765a82 | 2016-04-27 19:04:35 +0000 | [diff] [blame] | 742 | return (NumParams == 2 && FTy.getParamType(0)->isPointerTy() && | 
|  | 743 | FTy.getReturnType() == FTy.getParamType(0) && | 
|  | 744 | FTy.getParamType(0) == FTy.getParamType(1)); | 
|  | 745 |  | 
| David L. Jones | d21529f | 2017-01-23 23:16:46 +0000 | [diff] [blame] | 746 | case LibFunc_strtok: | 
|  | 747 | case LibFunc_strtok_r: | 
| Ahmed Bougacha | d765a82 | 2016-04-27 19:04:35 +0000 | [diff] [blame] | 748 | return (NumParams >= 2 && FTy.getParamType(1)->isPointerTy()); | 
| David L. Jones | d21529f | 2017-01-23 23:16:46 +0000 | [diff] [blame] | 749 | case LibFunc_scanf: | 
|  | 750 | case LibFunc_setbuf: | 
|  | 751 | case LibFunc_setvbuf: | 
| Ahmed Bougacha | d765a82 | 2016-04-27 19:04:35 +0000 | [diff] [blame] | 752 | return (NumParams >= 1 && FTy.getParamType(0)->isPointerTy()); | 
| David L. Jones | d21529f | 2017-01-23 23:16:46 +0000 | [diff] [blame] | 753 | case LibFunc_strdup: | 
|  | 754 | case LibFunc_strndup: | 
| Ahmed Bougacha | d765a82 | 2016-04-27 19:04:35 +0000 | [diff] [blame] | 755 | return (NumParams >= 1 && FTy.getReturnType()->isPointerTy() && | 
|  | 756 | FTy.getParamType(0)->isPointerTy()); | 
| David L. Jones | d21529f | 2017-01-23 23:16:46 +0000 | [diff] [blame] | 757 | case LibFunc_sscanf: | 
|  | 758 | case LibFunc_stat: | 
|  | 759 | case LibFunc_statvfs: | 
|  | 760 | case LibFunc_siprintf: | 
|  | 761 | case LibFunc_sprintf: | 
| Ahmed Bougacha | d765a82 | 2016-04-27 19:04:35 +0000 | [diff] [blame] | 762 | return (NumParams >= 2 && FTy.getParamType(0)->isPointerTy() && | 
| Martin Storsjo | 0d7c377 | 2018-05-11 16:53:56 +0000 | [diff] [blame] | 763 | FTy.getParamType(1)->isPointerTy() && | 
|  | 764 | FTy.getReturnType()->isIntegerTy(32)); | 
| David L. Jones | d21529f | 2017-01-23 23:16:46 +0000 | [diff] [blame] | 765 | case LibFunc_snprintf: | 
| Ahmed Bougacha | d765a82 | 2016-04-27 19:04:35 +0000 | [diff] [blame] | 766 | return (NumParams == 3 && FTy.getParamType(0)->isPointerTy() && | 
| Martin Storsjo | 0d7c377 | 2018-05-11 16:53:56 +0000 | [diff] [blame] | 767 | FTy.getParamType(2)->isPointerTy() && | 
|  | 768 | FTy.getReturnType()->isIntegerTy(32)); | 
| David L. Jones | d21529f | 2017-01-23 23:16:46 +0000 | [diff] [blame] | 769 | case LibFunc_setitimer: | 
| Ahmed Bougacha | d765a82 | 2016-04-27 19:04:35 +0000 | [diff] [blame] | 770 | return (NumParams == 3 && FTy.getParamType(1)->isPointerTy() && | 
|  | 771 | FTy.getParamType(2)->isPointerTy()); | 
| David L. Jones | d21529f | 2017-01-23 23:16:46 +0000 | [diff] [blame] | 772 | case LibFunc_system: | 
| Ahmed Bougacha | d765a82 | 2016-04-27 19:04:35 +0000 | [diff] [blame] | 773 | return (NumParams == 1 && FTy.getParamType(0)->isPointerTy()); | 
| David L. Jones | d21529f | 2017-01-23 23:16:46 +0000 | [diff] [blame] | 774 | case LibFunc_malloc: | 
| Ahmed Bougacha | d765a82 | 2016-04-27 19:04:35 +0000 | [diff] [blame] | 775 | return (NumParams == 1 && FTy.getReturnType()->isPointerTy()); | 
| David L. Jones | d21529f | 2017-01-23 23:16:46 +0000 | [diff] [blame] | 776 | case LibFunc_memcmp: | 
| Ahmed Bougacha | 6b9be1d | 2017-01-17 03:10:02 +0000 | [diff] [blame] | 777 | return (NumParams == 3 && FTy.getReturnType()->isIntegerTy(32) && | 
|  | 778 | FTy.getParamType(0)->isPointerTy() && | 
|  | 779 | FTy.getParamType(1)->isPointerTy()); | 
| Ahmed Bougacha | d765a82 | 2016-04-27 19:04:35 +0000 | [diff] [blame] | 780 |  | 
| David L. Jones | d21529f | 2017-01-23 23:16:46 +0000 | [diff] [blame] | 781 | case LibFunc_memchr: | 
|  | 782 | case LibFunc_memrchr: | 
| Ahmed Bougacha | 6b9be1d | 2017-01-17 03:10:02 +0000 | [diff] [blame] | 783 | return (NumParams == 3 && FTy.getReturnType()->isPointerTy() && | 
|  | 784 | FTy.getReturnType() == FTy.getParamType(0) && | 
| Ahmed Bougacha | d765a82 | 2016-04-27 19:04:35 +0000 | [diff] [blame] | 785 | FTy.getParamType(1)->isIntegerTy(32) && | 
| Ahmed Bougacha | 6b9be1d | 2017-01-17 03:10:02 +0000 | [diff] [blame] | 786 | IsSizeTTy(FTy.getParamType(2))); | 
| David L. Jones | d21529f | 2017-01-23 23:16:46 +0000 | [diff] [blame] | 787 | case LibFunc_modf: | 
|  | 788 | case LibFunc_modff: | 
|  | 789 | case LibFunc_modfl: | 
| Ahmed Bougacha | d765a82 | 2016-04-27 19:04:35 +0000 | [diff] [blame] | 790 | return (NumParams >= 2 && FTy.getParamType(1)->isPointerTy()); | 
|  | 791 |  | 
| David L. Jones | d21529f | 2017-01-23 23:16:46 +0000 | [diff] [blame] | 792 | case LibFunc_memcpy_chk: | 
|  | 793 | case LibFunc_memmove_chk: | 
| Ahmed Bougacha | d765a82 | 2016-04-27 19:04:35 +0000 | [diff] [blame] | 794 | --NumParams; | 
|  | 795 | if (!IsSizeTTy(FTy.getParamType(NumParams))) | 
|  | 796 | return false; | 
| Justin Bogner | b03fd12 | 2016-08-17 05:10:15 +0000 | [diff] [blame] | 797 | LLVM_FALLTHROUGH; | 
| David L. Jones | d21529f | 2017-01-23 23:16:46 +0000 | [diff] [blame] | 798 | case LibFunc_memcpy: | 
|  | 799 | case LibFunc_mempcpy: | 
|  | 800 | case LibFunc_memmove: | 
| Ahmed Bougacha | d765a82 | 2016-04-27 19:04:35 +0000 | [diff] [blame] | 801 | return (NumParams == 3 && FTy.getReturnType() == FTy.getParamType(0) && | 
|  | 802 | FTy.getParamType(0)->isPointerTy() && | 
|  | 803 | FTy.getParamType(1)->isPointerTy() && | 
|  | 804 | IsSizeTTy(FTy.getParamType(2))); | 
|  | 805 |  | 
| David L. Jones | d21529f | 2017-01-23 23:16:46 +0000 | [diff] [blame] | 806 | case LibFunc_memset_chk: | 
| Ahmed Bougacha | d765a82 | 2016-04-27 19:04:35 +0000 | [diff] [blame] | 807 | --NumParams; | 
|  | 808 | if (!IsSizeTTy(FTy.getParamType(NumParams))) | 
|  | 809 | return false; | 
| Justin Bogner | b03fd12 | 2016-08-17 05:10:15 +0000 | [diff] [blame] | 810 | LLVM_FALLTHROUGH; | 
| David L. Jones | d21529f | 2017-01-23 23:16:46 +0000 | [diff] [blame] | 811 | case LibFunc_memset: | 
| Ahmed Bougacha | d765a82 | 2016-04-27 19:04:35 +0000 | [diff] [blame] | 812 | return (NumParams == 3 && FTy.getReturnType() == FTy.getParamType(0) && | 
|  | 813 | FTy.getParamType(0)->isPointerTy() && | 
|  | 814 | FTy.getParamType(1)->isIntegerTy() && | 
|  | 815 | IsSizeTTy(FTy.getParamType(2))); | 
|  | 816 |  | 
| David L. Jones | d21529f | 2017-01-23 23:16:46 +0000 | [diff] [blame] | 817 | case LibFunc_memccpy: | 
| Ahmed Bougacha | d765a82 | 2016-04-27 19:04:35 +0000 | [diff] [blame] | 818 | return (NumParams >= 2 && FTy.getParamType(1)->isPointerTy()); | 
| David L. Jones | d21529f | 2017-01-23 23:16:46 +0000 | [diff] [blame] | 819 | case LibFunc_memalign: | 
| Ahmed Bougacha | d765a82 | 2016-04-27 19:04:35 +0000 | [diff] [blame] | 820 | return (FTy.getReturnType()->isPointerTy()); | 
| David L. Jones | d21529f | 2017-01-23 23:16:46 +0000 | [diff] [blame] | 821 | case LibFunc_realloc: | 
|  | 822 | case LibFunc_reallocf: | 
| Ahmed Bougacha | 6b9be1d | 2017-01-17 03:10:02 +0000 | [diff] [blame] | 823 | return (NumParams == 2 && FTy.getReturnType() == PCharTy && | 
|  | 824 | FTy.getParamType(0) == FTy.getReturnType() && | 
|  | 825 | IsSizeTTy(FTy.getParamType(1))); | 
| David L. Jones | d21529f | 2017-01-23 23:16:46 +0000 | [diff] [blame] | 826 | case LibFunc_read: | 
| Ahmed Bougacha | d765a82 | 2016-04-27 19:04:35 +0000 | [diff] [blame] | 827 | return (NumParams == 3 && FTy.getParamType(1)->isPointerTy()); | 
| David L. Jones | d21529f | 2017-01-23 23:16:46 +0000 | [diff] [blame] | 828 | case LibFunc_rewind: | 
|  | 829 | case LibFunc_rmdir: | 
|  | 830 | case LibFunc_remove: | 
|  | 831 | case LibFunc_realpath: | 
| Ahmed Bougacha | d765a82 | 2016-04-27 19:04:35 +0000 | [diff] [blame] | 832 | return (NumParams >= 1 && FTy.getParamType(0)->isPointerTy()); | 
| David L. Jones | d21529f | 2017-01-23 23:16:46 +0000 | [diff] [blame] | 833 | case LibFunc_rename: | 
| Ahmed Bougacha | d765a82 | 2016-04-27 19:04:35 +0000 | [diff] [blame] | 834 | return (NumParams >= 2 && FTy.getParamType(0)->isPointerTy() && | 
|  | 835 | FTy.getParamType(1)->isPointerTy()); | 
| David L. Jones | d21529f | 2017-01-23 23:16:46 +0000 | [diff] [blame] | 836 | case LibFunc_readlink: | 
| Ahmed Bougacha | d765a82 | 2016-04-27 19:04:35 +0000 | [diff] [blame] | 837 | return (NumParams >= 2 && FTy.getParamType(0)->isPointerTy() && | 
|  | 838 | FTy.getParamType(1)->isPointerTy()); | 
| David L. Jones | d21529f | 2017-01-23 23:16:46 +0000 | [diff] [blame] | 839 | case LibFunc_write: | 
| Ahmed Bougacha | d765a82 | 2016-04-27 19:04:35 +0000 | [diff] [blame] | 840 | return (NumParams == 3 && FTy.getParamType(1)->isPointerTy()); | 
| David L. Jones | d21529f | 2017-01-23 23:16:46 +0000 | [diff] [blame] | 841 | case LibFunc_bcopy: | 
|  | 842 | case LibFunc_bcmp: | 
| Ahmed Bougacha | d765a82 | 2016-04-27 19:04:35 +0000 | [diff] [blame] | 843 | return (NumParams == 3 && FTy.getParamType(0)->isPointerTy() && | 
|  | 844 | FTy.getParamType(1)->isPointerTy()); | 
| David L. Jones | d21529f | 2017-01-23 23:16:46 +0000 | [diff] [blame] | 845 | case LibFunc_bzero: | 
| Ahmed Bougacha | d765a82 | 2016-04-27 19:04:35 +0000 | [diff] [blame] | 846 | return (NumParams == 2 && FTy.getParamType(0)->isPointerTy()); | 
| David L. Jones | d21529f | 2017-01-23 23:16:46 +0000 | [diff] [blame] | 847 | case LibFunc_calloc: | 
| Ahmed Bougacha | d765a82 | 2016-04-27 19:04:35 +0000 | [diff] [blame] | 848 | return (NumParams == 2 && FTy.getReturnType()->isPointerTy()); | 
| Ahmed Bougacha | 1fe3f1c | 2016-05-25 20:22:45 +0000 | [diff] [blame] | 849 |  | 
| David L. Jones | d21529f | 2017-01-23 23:16:46 +0000 | [diff] [blame] | 850 | case LibFunc_atof: | 
|  | 851 | case LibFunc_atoi: | 
|  | 852 | case LibFunc_atol: | 
|  | 853 | case LibFunc_atoll: | 
|  | 854 | case LibFunc_ferror: | 
|  | 855 | case LibFunc_getenv: | 
|  | 856 | case LibFunc_getpwnam: | 
|  | 857 | case LibFunc_iprintf: | 
|  | 858 | case LibFunc_pclose: | 
|  | 859 | case LibFunc_perror: | 
|  | 860 | case LibFunc_printf: | 
|  | 861 | case LibFunc_puts: | 
|  | 862 | case LibFunc_uname: | 
|  | 863 | case LibFunc_under_IO_getc: | 
|  | 864 | case LibFunc_unlink: | 
|  | 865 | case LibFunc_unsetenv: | 
| Ahmed Bougacha | d765a82 | 2016-04-27 19:04:35 +0000 | [diff] [blame] | 866 | return (NumParams == 1 && FTy.getParamType(0)->isPointerTy()); | 
| Ahmed Bougacha | 1fe3f1c | 2016-05-25 20:22:45 +0000 | [diff] [blame] | 867 |  | 
| David L. Jones | d21529f | 2017-01-23 23:16:46 +0000 | [diff] [blame] | 868 | case LibFunc_access: | 
|  | 869 | case LibFunc_chmod: | 
|  | 870 | case LibFunc_chown: | 
|  | 871 | case LibFunc_clearerr: | 
|  | 872 | case LibFunc_closedir: | 
|  | 873 | case LibFunc_ctermid: | 
|  | 874 | case LibFunc_fclose: | 
|  | 875 | case LibFunc_feof: | 
|  | 876 | case LibFunc_fflush: | 
|  | 877 | case LibFunc_fgetc: | 
| David Bolvansky | ca22d42 | 2018-05-16 11:39:52 +0000 | [diff] [blame] | 878 | case LibFunc_fgetc_unlocked: | 
| David L. Jones | d21529f | 2017-01-23 23:16:46 +0000 | [diff] [blame] | 879 | case LibFunc_fileno: | 
|  | 880 | case LibFunc_flockfile: | 
|  | 881 | case LibFunc_free: | 
|  | 882 | case LibFunc_fseek: | 
|  | 883 | case LibFunc_fseeko64: | 
|  | 884 | case LibFunc_fseeko: | 
|  | 885 | case LibFunc_fsetpos: | 
|  | 886 | case LibFunc_ftell: | 
|  | 887 | case LibFunc_ftello64: | 
|  | 888 | case LibFunc_ftello: | 
|  | 889 | case LibFunc_ftrylockfile: | 
|  | 890 | case LibFunc_funlockfile: | 
|  | 891 | case LibFunc_getc: | 
|  | 892 | case LibFunc_getc_unlocked: | 
|  | 893 | case LibFunc_getlogin_r: | 
|  | 894 | case LibFunc_mkdir: | 
|  | 895 | case LibFunc_mktime: | 
|  | 896 | case LibFunc_times: | 
| Ahmed Bougacha | 1fe3f1c | 2016-05-25 20:22:45 +0000 | [diff] [blame] | 897 | return (NumParams != 0 && FTy.getParamType(0)->isPointerTy()); | 
|  | 898 |  | 
| David L. Jones | d21529f | 2017-01-23 23:16:46 +0000 | [diff] [blame] | 899 | case LibFunc_fopen: | 
| Ahmed Bougacha | d765a82 | 2016-04-27 19:04:35 +0000 | [diff] [blame] | 900 | return (NumParams == 2 && FTy.getReturnType()->isPointerTy() && | 
|  | 901 | FTy.getParamType(0)->isPointerTy() && | 
|  | 902 | FTy.getParamType(1)->isPointerTy()); | 
| Calixte Denizet | c3bed1e | 2018-11-07 13:49:17 +0000 | [diff] [blame] | 903 | case LibFunc_fork: | 
|  | 904 | return (NumParams == 0 && FTy.getReturnType()->isIntegerTy(32)); | 
| David L. Jones | d21529f | 2017-01-23 23:16:46 +0000 | [diff] [blame] | 905 | case LibFunc_fdopen: | 
| Ahmed Bougacha | d765a82 | 2016-04-27 19:04:35 +0000 | [diff] [blame] | 906 | return (NumParams == 2 && FTy.getReturnType()->isPointerTy() && | 
|  | 907 | FTy.getParamType(1)->isPointerTy()); | 
| David L. Jones | d21529f | 2017-01-23 23:16:46 +0000 | [diff] [blame] | 908 | case LibFunc_fputc: | 
| David Bolvansky | ca22d42 | 2018-05-16 11:39:52 +0000 | [diff] [blame] | 909 | case LibFunc_fputc_unlocked: | 
| David L. Jones | d21529f | 2017-01-23 23:16:46 +0000 | [diff] [blame] | 910 | case LibFunc_fstat: | 
|  | 911 | case LibFunc_frexp: | 
|  | 912 | case LibFunc_frexpf: | 
|  | 913 | case LibFunc_frexpl: | 
|  | 914 | case LibFunc_fstatvfs: | 
| Ahmed Bougacha | d765a82 | 2016-04-27 19:04:35 +0000 | [diff] [blame] | 915 | return (NumParams == 2 && FTy.getParamType(1)->isPointerTy()); | 
| David L. Jones | d21529f | 2017-01-23 23:16:46 +0000 | [diff] [blame] | 916 | case LibFunc_fgets: | 
| David Bolvansky | ca22d42 | 2018-05-16 11:39:52 +0000 | [diff] [blame] | 917 | case LibFunc_fgets_unlocked: | 
| Ahmed Bougacha | d765a82 | 2016-04-27 19:04:35 +0000 | [diff] [blame] | 918 | return (NumParams == 3 && FTy.getParamType(0)->isPointerTy() && | 
|  | 919 | FTy.getParamType(2)->isPointerTy()); | 
| David L. Jones | d21529f | 2017-01-23 23:16:46 +0000 | [diff] [blame] | 920 | case LibFunc_fread: | 
| David Bolvansky | ca22d42 | 2018-05-16 11:39:52 +0000 | [diff] [blame] | 921 | case LibFunc_fread_unlocked: | 
| Ahmed Bougacha | d765a82 | 2016-04-27 19:04:35 +0000 | [diff] [blame] | 922 | return (NumParams == 4 && FTy.getParamType(0)->isPointerTy() && | 
|  | 923 | FTy.getParamType(3)->isPointerTy()); | 
| David L. Jones | d21529f | 2017-01-23 23:16:46 +0000 | [diff] [blame] | 924 | case LibFunc_fwrite: | 
| David Bolvansky | ca22d42 | 2018-05-16 11:39:52 +0000 | [diff] [blame] | 925 | case LibFunc_fwrite_unlocked: | 
| Ahmed Bougacha | d765a82 | 2016-04-27 19:04:35 +0000 | [diff] [blame] | 926 | return (NumParams == 4 && FTy.getReturnType()->isIntegerTy() && | 
|  | 927 | FTy.getParamType(0)->isPointerTy() && | 
|  | 928 | FTy.getParamType(1)->isIntegerTy() && | 
|  | 929 | FTy.getParamType(2)->isIntegerTy() && | 
|  | 930 | FTy.getParamType(3)->isPointerTy()); | 
| David L. Jones | d21529f | 2017-01-23 23:16:46 +0000 | [diff] [blame] | 931 | case LibFunc_fputs: | 
| David Bolvansky | ca22d42 | 2018-05-16 11:39:52 +0000 | [diff] [blame] | 932 | case LibFunc_fputs_unlocked: | 
| Ahmed Bougacha | d765a82 | 2016-04-27 19:04:35 +0000 | [diff] [blame] | 933 | return (NumParams >= 2 && FTy.getParamType(0)->isPointerTy() && | 
|  | 934 | FTy.getParamType(1)->isPointerTy()); | 
| David L. Jones | d21529f | 2017-01-23 23:16:46 +0000 | [diff] [blame] | 935 | case LibFunc_fscanf: | 
|  | 936 | case LibFunc_fiprintf: | 
|  | 937 | case LibFunc_fprintf: | 
| Ahmed Bougacha | 6b9be1d | 2017-01-17 03:10:02 +0000 | [diff] [blame] | 938 | return (NumParams >= 2 && FTy.getReturnType()->isIntegerTy() && | 
|  | 939 | FTy.getParamType(0)->isPointerTy() && | 
| Ahmed Bougacha | d765a82 | 2016-04-27 19:04:35 +0000 | [diff] [blame] | 940 | FTy.getParamType(1)->isPointerTy()); | 
| David L. Jones | d21529f | 2017-01-23 23:16:46 +0000 | [diff] [blame] | 941 | case LibFunc_fgetpos: | 
| Ahmed Bougacha | d765a82 | 2016-04-27 19:04:35 +0000 | [diff] [blame] | 942 | return (NumParams >= 2 && FTy.getParamType(0)->isPointerTy() && | 
|  | 943 | FTy.getParamType(1)->isPointerTy()); | 
| David L. Jones | d21529f | 2017-01-23 23:16:46 +0000 | [diff] [blame] | 944 | case LibFunc_getchar: | 
| David Bolvansky | ca22d42 | 2018-05-16 11:39:52 +0000 | [diff] [blame] | 945 | case LibFunc_getchar_unlocked: | 
| Ahmed Bougacha | 6b9be1d | 2017-01-17 03:10:02 +0000 | [diff] [blame] | 946 | return (NumParams == 0 && FTy.getReturnType()->isIntegerTy()); | 
| David L. Jones | d21529f | 2017-01-23 23:16:46 +0000 | [diff] [blame] | 947 | case LibFunc_gets: | 
| Ahmed Bougacha | 6b9be1d | 2017-01-17 03:10:02 +0000 | [diff] [blame] | 948 | return (NumParams == 1 && FTy.getParamType(0) == PCharTy); | 
| David L. Jones | d21529f | 2017-01-23 23:16:46 +0000 | [diff] [blame] | 949 | case LibFunc_getitimer: | 
| Ahmed Bougacha | d765a82 | 2016-04-27 19:04:35 +0000 | [diff] [blame] | 950 | return (NumParams == 2 && FTy.getParamType(1)->isPointerTy()); | 
| David L. Jones | d21529f | 2017-01-23 23:16:46 +0000 | [diff] [blame] | 951 | case LibFunc_ungetc: | 
| Ahmed Bougacha | d765a82 | 2016-04-27 19:04:35 +0000 | [diff] [blame] | 952 | return (NumParams == 2 && FTy.getParamType(1)->isPointerTy()); | 
| David L. Jones | d21529f | 2017-01-23 23:16:46 +0000 | [diff] [blame] | 953 | case LibFunc_utime: | 
|  | 954 | case LibFunc_utimes: | 
| Ahmed Bougacha | d765a82 | 2016-04-27 19:04:35 +0000 | [diff] [blame] | 955 | return (NumParams == 2 && FTy.getParamType(0)->isPointerTy() && | 
|  | 956 | FTy.getParamType(1)->isPointerTy()); | 
| David L. Jones | d21529f | 2017-01-23 23:16:46 +0000 | [diff] [blame] | 957 | case LibFunc_putc: | 
| David Bolvansky | ca22d42 | 2018-05-16 11:39:52 +0000 | [diff] [blame] | 958 | case LibFunc_putc_unlocked: | 
| Ahmed Bougacha | d765a82 | 2016-04-27 19:04:35 +0000 | [diff] [blame] | 959 | return (NumParams == 2 && FTy.getParamType(1)->isPointerTy()); | 
| David L. Jones | d21529f | 2017-01-23 23:16:46 +0000 | [diff] [blame] | 960 | case LibFunc_pread: | 
|  | 961 | case LibFunc_pwrite: | 
| Ahmed Bougacha | d765a82 | 2016-04-27 19:04:35 +0000 | [diff] [blame] | 962 | return (NumParams == 4 && FTy.getParamType(1)->isPointerTy()); | 
| David L. Jones | d21529f | 2017-01-23 23:16:46 +0000 | [diff] [blame] | 963 | case LibFunc_popen: | 
| Ahmed Bougacha | d765a82 | 2016-04-27 19:04:35 +0000 | [diff] [blame] | 964 | return (NumParams == 2 && FTy.getReturnType()->isPointerTy() && | 
|  | 965 | FTy.getParamType(0)->isPointerTy() && | 
|  | 966 | FTy.getParamType(1)->isPointerTy()); | 
| David L. Jones | d21529f | 2017-01-23 23:16:46 +0000 | [diff] [blame] | 967 | case LibFunc_vscanf: | 
| Ahmed Bougacha | d765a82 | 2016-04-27 19:04:35 +0000 | [diff] [blame] | 968 | return (NumParams == 2 && FTy.getParamType(1)->isPointerTy()); | 
| David L. Jones | d21529f | 2017-01-23 23:16:46 +0000 | [diff] [blame] | 969 | case LibFunc_vsscanf: | 
| Ahmed Bougacha | d765a82 | 2016-04-27 19:04:35 +0000 | [diff] [blame] | 970 | return (NumParams == 3 && FTy.getParamType(1)->isPointerTy() && | 
|  | 971 | FTy.getParamType(2)->isPointerTy()); | 
| David L. Jones | d21529f | 2017-01-23 23:16:46 +0000 | [diff] [blame] | 972 | case LibFunc_vfscanf: | 
| Ahmed Bougacha | d765a82 | 2016-04-27 19:04:35 +0000 | [diff] [blame] | 973 | return (NumParams == 3 && FTy.getParamType(1)->isPointerTy() && | 
|  | 974 | FTy.getParamType(2)->isPointerTy()); | 
| David L. Jones | d21529f | 2017-01-23 23:16:46 +0000 | [diff] [blame] | 975 | case LibFunc_valloc: | 
| Ahmed Bougacha | d765a82 | 2016-04-27 19:04:35 +0000 | [diff] [blame] | 976 | return (FTy.getReturnType()->isPointerTy()); | 
| David L. Jones | d21529f | 2017-01-23 23:16:46 +0000 | [diff] [blame] | 977 | case LibFunc_vprintf: | 
| Ahmed Bougacha | d765a82 | 2016-04-27 19:04:35 +0000 | [diff] [blame] | 978 | return (NumParams == 2 && FTy.getParamType(0)->isPointerTy()); | 
| David L. Jones | d21529f | 2017-01-23 23:16:46 +0000 | [diff] [blame] | 979 | case LibFunc_vfprintf: | 
|  | 980 | case LibFunc_vsprintf: | 
| Ahmed Bougacha | d765a82 | 2016-04-27 19:04:35 +0000 | [diff] [blame] | 981 | return (NumParams == 3 && FTy.getParamType(0)->isPointerTy() && | 
|  | 982 | FTy.getParamType(1)->isPointerTy()); | 
| David L. Jones | d21529f | 2017-01-23 23:16:46 +0000 | [diff] [blame] | 983 | case LibFunc_vsnprintf: | 
| Ahmed Bougacha | d765a82 | 2016-04-27 19:04:35 +0000 | [diff] [blame] | 984 | return (NumParams == 4 && FTy.getParamType(0)->isPointerTy() && | 
|  | 985 | FTy.getParamType(2)->isPointerTy()); | 
| David L. Jones | d21529f | 2017-01-23 23:16:46 +0000 | [diff] [blame] | 986 | case LibFunc_open: | 
| Ahmed Bougacha | d765a82 | 2016-04-27 19:04:35 +0000 | [diff] [blame] | 987 | return (NumParams >= 2 && FTy.getParamType(0)->isPointerTy()); | 
| David L. Jones | d21529f | 2017-01-23 23:16:46 +0000 | [diff] [blame] | 988 | case LibFunc_opendir: | 
| Ahmed Bougacha | d765a82 | 2016-04-27 19:04:35 +0000 | [diff] [blame] | 989 | return (NumParams == 1 && FTy.getReturnType()->isPointerTy() && | 
|  | 990 | FTy.getParamType(0)->isPointerTy()); | 
| David L. Jones | d21529f | 2017-01-23 23:16:46 +0000 | [diff] [blame] | 991 | case LibFunc_tmpfile: | 
| Ahmed Bougacha | d765a82 | 2016-04-27 19:04:35 +0000 | [diff] [blame] | 992 | return (FTy.getReturnType()->isPointerTy()); | 
| David L. Jones | d21529f | 2017-01-23 23:16:46 +0000 | [diff] [blame] | 993 | case LibFunc_htonl: | 
|  | 994 | case LibFunc_ntohl: | 
| Ahmed Bougacha | 6b9be1d | 2017-01-17 03:10:02 +0000 | [diff] [blame] | 995 | return (NumParams == 1 && FTy.getReturnType()->isIntegerTy(32) && | 
|  | 996 | FTy.getReturnType() == FTy.getParamType(0)); | 
| David L. Jones | d21529f | 2017-01-23 23:16:46 +0000 | [diff] [blame] | 997 | case LibFunc_htons: | 
|  | 998 | case LibFunc_ntohs: | 
| Ahmed Bougacha | 6b9be1d | 2017-01-17 03:10:02 +0000 | [diff] [blame] | 999 | return (NumParams == 1 && FTy.getReturnType()->isIntegerTy(16) && | 
|  | 1000 | FTy.getReturnType() == FTy.getParamType(0)); | 
| David L. Jones | d21529f | 2017-01-23 23:16:46 +0000 | [diff] [blame] | 1001 | case LibFunc_lstat: | 
| Ahmed Bougacha | d765a82 | 2016-04-27 19:04:35 +0000 | [diff] [blame] | 1002 | return (NumParams == 2 && FTy.getParamType(0)->isPointerTy() && | 
|  | 1003 | FTy.getParamType(1)->isPointerTy()); | 
| David L. Jones | d21529f | 2017-01-23 23:16:46 +0000 | [diff] [blame] | 1004 | case LibFunc_lchown: | 
| Ahmed Bougacha | d765a82 | 2016-04-27 19:04:35 +0000 | [diff] [blame] | 1005 | return (NumParams == 3 && FTy.getParamType(0)->isPointerTy()); | 
| David L. Jones | d21529f | 2017-01-23 23:16:46 +0000 | [diff] [blame] | 1006 | case LibFunc_qsort: | 
| Ahmed Bougacha | d765a82 | 2016-04-27 19:04:35 +0000 | [diff] [blame] | 1007 | return (NumParams == 4 && FTy.getParamType(3)->isPointerTy()); | 
| David L. Jones | d21529f | 2017-01-23 23:16:46 +0000 | [diff] [blame] | 1008 | case LibFunc_dunder_strdup: | 
|  | 1009 | case LibFunc_dunder_strndup: | 
| Ahmed Bougacha | d765a82 | 2016-04-27 19:04:35 +0000 | [diff] [blame] | 1010 | return (NumParams >= 1 && FTy.getReturnType()->isPointerTy() && | 
|  | 1011 | FTy.getParamType(0)->isPointerTy()); | 
| David L. Jones | d21529f | 2017-01-23 23:16:46 +0000 | [diff] [blame] | 1012 | case LibFunc_dunder_strtok_r: | 
| Ahmed Bougacha | d765a82 | 2016-04-27 19:04:35 +0000 | [diff] [blame] | 1013 | return (NumParams == 3 && FTy.getParamType(1)->isPointerTy()); | 
| David L. Jones | d21529f | 2017-01-23 23:16:46 +0000 | [diff] [blame] | 1014 | case LibFunc_under_IO_putc: | 
| Ahmed Bougacha | d765a82 | 2016-04-27 19:04:35 +0000 | [diff] [blame] | 1015 | return (NumParams == 2 && FTy.getParamType(1)->isPointerTy()); | 
| David L. Jones | d21529f | 2017-01-23 23:16:46 +0000 | [diff] [blame] | 1016 | case LibFunc_dunder_isoc99_scanf: | 
| Ahmed Bougacha | d765a82 | 2016-04-27 19:04:35 +0000 | [diff] [blame] | 1017 | return (NumParams >= 1 && FTy.getParamType(0)->isPointerTy()); | 
| David L. Jones | d21529f | 2017-01-23 23:16:46 +0000 | [diff] [blame] | 1018 | case LibFunc_stat64: | 
|  | 1019 | case LibFunc_lstat64: | 
|  | 1020 | case LibFunc_statvfs64: | 
| Michael Kuperstein | 79dcc27 | 2016-09-20 23:10:31 +0000 | [diff] [blame] | 1021 | return (NumParams == 2 && FTy.getParamType(0)->isPointerTy() && | 
| Ahmed Bougacha | d765a82 | 2016-04-27 19:04:35 +0000 | [diff] [blame] | 1022 | FTy.getParamType(1)->isPointerTy()); | 
| David L. Jones | d21529f | 2017-01-23 23:16:46 +0000 | [diff] [blame] | 1023 | case LibFunc_dunder_isoc99_sscanf: | 
| Michael Kuperstein | 79dcc27 | 2016-09-20 23:10:31 +0000 | [diff] [blame] | 1024 | return (NumParams >= 2 && FTy.getParamType(0)->isPointerTy() && | 
| Ahmed Bougacha | d765a82 | 2016-04-27 19:04:35 +0000 | [diff] [blame] | 1025 | FTy.getParamType(1)->isPointerTy()); | 
| David L. Jones | d21529f | 2017-01-23 23:16:46 +0000 | [diff] [blame] | 1026 | case LibFunc_fopen64: | 
| Ahmed Bougacha | d765a82 | 2016-04-27 19:04:35 +0000 | [diff] [blame] | 1027 | return (NumParams == 2 && FTy.getReturnType()->isPointerTy() && | 
|  | 1028 | FTy.getParamType(0)->isPointerTy() && | 
|  | 1029 | FTy.getParamType(1)->isPointerTy()); | 
| David L. Jones | d21529f | 2017-01-23 23:16:46 +0000 | [diff] [blame] | 1030 | case LibFunc_tmpfile64: | 
| Ahmed Bougacha | d765a82 | 2016-04-27 19:04:35 +0000 | [diff] [blame] | 1031 | return (FTy.getReturnType()->isPointerTy()); | 
| David L. Jones | d21529f | 2017-01-23 23:16:46 +0000 | [diff] [blame] | 1032 | case LibFunc_fstat64: | 
|  | 1033 | case LibFunc_fstatvfs64: | 
| Ahmed Bougacha | d765a82 | 2016-04-27 19:04:35 +0000 | [diff] [blame] | 1034 | return (NumParams == 2 && FTy.getParamType(1)->isPointerTy()); | 
| David L. Jones | d21529f | 2017-01-23 23:16:46 +0000 | [diff] [blame] | 1035 | case LibFunc_open64: | 
| Ahmed Bougacha | d765a82 | 2016-04-27 19:04:35 +0000 | [diff] [blame] | 1036 | return (NumParams >= 2 && FTy.getParamType(0)->isPointerTy()); | 
| David L. Jones | d21529f | 2017-01-23 23:16:46 +0000 | [diff] [blame] | 1037 | case LibFunc_gettimeofday: | 
| Ahmed Bougacha | d765a82 | 2016-04-27 19:04:35 +0000 | [diff] [blame] | 1038 | return (NumParams == 2 && FTy.getParamType(0)->isPointerTy() && | 
|  | 1039 | FTy.getParamType(1)->isPointerTy()); | 
|  | 1040 |  | 
| Ahmed Bougacha | 6b9be1d | 2017-01-17 03:10:02 +0000 | [diff] [blame] | 1041 | // new(unsigned int); | 
| David L. Jones | d21529f | 2017-01-23 23:16:46 +0000 | [diff] [blame] | 1042 | case LibFunc_Znwj: | 
| Ahmed Bougacha | 6b9be1d | 2017-01-17 03:10:02 +0000 | [diff] [blame] | 1043 | // new(unsigned long); | 
| David L. Jones | d21529f | 2017-01-23 23:16:46 +0000 | [diff] [blame] | 1044 | case LibFunc_Znwm: | 
| Ahmed Bougacha | 6b9be1d | 2017-01-17 03:10:02 +0000 | [diff] [blame] | 1045 | // new[](unsigned int); | 
| David L. Jones | d21529f | 2017-01-23 23:16:46 +0000 | [diff] [blame] | 1046 | case LibFunc_Znaj: | 
| Ahmed Bougacha | 6b9be1d | 2017-01-17 03:10:02 +0000 | [diff] [blame] | 1047 | // new[](unsigned long); | 
| David L. Jones | d21529f | 2017-01-23 23:16:46 +0000 | [diff] [blame] | 1048 | case LibFunc_Znam: | 
| Ahmed Bougacha | 6b9be1d | 2017-01-17 03:10:02 +0000 | [diff] [blame] | 1049 | // new(unsigned int); | 
| David L. Jones | d21529f | 2017-01-23 23:16:46 +0000 | [diff] [blame] | 1050 | case LibFunc_msvc_new_int: | 
| Ahmed Bougacha | 6b9be1d | 2017-01-17 03:10:02 +0000 | [diff] [blame] | 1051 | // new(unsigned long long); | 
| David L. Jones | d21529f | 2017-01-23 23:16:46 +0000 | [diff] [blame] | 1052 | case LibFunc_msvc_new_longlong: | 
| Ahmed Bougacha | 6b9be1d | 2017-01-17 03:10:02 +0000 | [diff] [blame] | 1053 | // new[](unsigned int); | 
| David L. Jones | d21529f | 2017-01-23 23:16:46 +0000 | [diff] [blame] | 1054 | case LibFunc_msvc_new_array_int: | 
| Ahmed Bougacha | 6b9be1d | 2017-01-17 03:10:02 +0000 | [diff] [blame] | 1055 | // new[](unsigned long long); | 
| David L. Jones | d21529f | 2017-01-23 23:16:46 +0000 | [diff] [blame] | 1056 | case LibFunc_msvc_new_array_longlong: | 
| Ahmed Bougacha | 6b9be1d | 2017-01-17 03:10:02 +0000 | [diff] [blame] | 1057 | return (NumParams == 1 && FTy.getReturnType()->isPointerTy()); | 
|  | 1058 |  | 
|  | 1059 | // new(unsigned int, nothrow); | 
| David L. Jones | d21529f | 2017-01-23 23:16:46 +0000 | [diff] [blame] | 1060 | case LibFunc_ZnwjRKSt9nothrow_t: | 
| Ahmed Bougacha | 6b9be1d | 2017-01-17 03:10:02 +0000 | [diff] [blame] | 1061 | // new(unsigned long, nothrow); | 
| David L. Jones | d21529f | 2017-01-23 23:16:46 +0000 | [diff] [blame] | 1062 | case LibFunc_ZnwmRKSt9nothrow_t: | 
| Ahmed Bougacha | 6b9be1d | 2017-01-17 03:10:02 +0000 | [diff] [blame] | 1063 | // new[](unsigned int, nothrow); | 
| David L. Jones | d21529f | 2017-01-23 23:16:46 +0000 | [diff] [blame] | 1064 | case LibFunc_ZnajRKSt9nothrow_t: | 
| Ahmed Bougacha | 6b9be1d | 2017-01-17 03:10:02 +0000 | [diff] [blame] | 1065 | // new[](unsigned long, nothrow); | 
| David L. Jones | d21529f | 2017-01-23 23:16:46 +0000 | [diff] [blame] | 1066 | case LibFunc_ZnamRKSt9nothrow_t: | 
| Ahmed Bougacha | 6b9be1d | 2017-01-17 03:10:02 +0000 | [diff] [blame] | 1067 | // new(unsigned int, nothrow); | 
| David L. Jones | d21529f | 2017-01-23 23:16:46 +0000 | [diff] [blame] | 1068 | case LibFunc_msvc_new_int_nothrow: | 
| Ahmed Bougacha | 6b9be1d | 2017-01-17 03:10:02 +0000 | [diff] [blame] | 1069 | // new(unsigned long long, nothrow); | 
| David L. Jones | d21529f | 2017-01-23 23:16:46 +0000 | [diff] [blame] | 1070 | case LibFunc_msvc_new_longlong_nothrow: | 
| Ahmed Bougacha | 6b9be1d | 2017-01-17 03:10:02 +0000 | [diff] [blame] | 1071 | // new[](unsigned int, nothrow); | 
| David L. Jones | d21529f | 2017-01-23 23:16:46 +0000 | [diff] [blame] | 1072 | case LibFunc_msvc_new_array_int_nothrow: | 
| Ahmed Bougacha | 6b9be1d | 2017-01-17 03:10:02 +0000 | [diff] [blame] | 1073 | // new[](unsigned long long, nothrow); | 
| David L. Jones | d21529f | 2017-01-23 23:16:46 +0000 | [diff] [blame] | 1074 | case LibFunc_msvc_new_array_longlong_nothrow: | 
| Eric Fiselier | 96bbec7 | 2018-04-04 19:01:51 +0000 | [diff] [blame] | 1075 | // new(unsigned int, align_val_t) | 
|  | 1076 | case LibFunc_ZnwjSt11align_val_t: | 
|  | 1077 | // new(unsigned long, align_val_t) | 
|  | 1078 | case LibFunc_ZnwmSt11align_val_t: | 
|  | 1079 | // new[](unsigned int, align_val_t) | 
|  | 1080 | case LibFunc_ZnajSt11align_val_t: | 
|  | 1081 | // new[](unsigned long, align_val_t) | 
|  | 1082 | case LibFunc_ZnamSt11align_val_t: | 
| Ahmed Bougacha | 6b9be1d | 2017-01-17 03:10:02 +0000 | [diff] [blame] | 1083 | return (NumParams == 2 && FTy.getReturnType()->isPointerTy()); | 
|  | 1084 |  | 
| Eric Fiselier | 96bbec7 | 2018-04-04 19:01:51 +0000 | [diff] [blame] | 1085 | // new(unsigned int, align_val_t, nothrow) | 
|  | 1086 | case LibFunc_ZnwjSt11align_val_tRKSt9nothrow_t: | 
|  | 1087 | // new(unsigned long, align_val_t, nothrow) | 
|  | 1088 | case LibFunc_ZnwmSt11align_val_tRKSt9nothrow_t: | 
|  | 1089 | // new[](unsigned int, align_val_t, nothrow) | 
|  | 1090 | case LibFunc_ZnajSt11align_val_tRKSt9nothrow_t: | 
|  | 1091 | // new[](unsigned long, align_val_t, nothrow) | 
|  | 1092 | case LibFunc_ZnamSt11align_val_tRKSt9nothrow_t: | 
|  | 1093 | return (NumParams == 3 && FTy.getReturnType()->isPointerTy()); | 
|  | 1094 |  | 
| Ahmed Bougacha | 6b9be1d | 2017-01-17 03:10:02 +0000 | [diff] [blame] | 1095 | // void operator delete[](void*); | 
| David L. Jones | d21529f | 2017-01-23 23:16:46 +0000 | [diff] [blame] | 1096 | case LibFunc_ZdaPv: | 
| Ahmed Bougacha | 6b9be1d | 2017-01-17 03:10:02 +0000 | [diff] [blame] | 1097 | // void operator delete(void*); | 
| David L. Jones | d21529f | 2017-01-23 23:16:46 +0000 | [diff] [blame] | 1098 | case LibFunc_ZdlPv: | 
| Ahmed Bougacha | 6b9be1d | 2017-01-17 03:10:02 +0000 | [diff] [blame] | 1099 | // void operator delete[](void*); | 
| David L. Jones | d21529f | 2017-01-23 23:16:46 +0000 | [diff] [blame] | 1100 | case LibFunc_msvc_delete_array_ptr32: | 
| Ahmed Bougacha | 6b9be1d | 2017-01-17 03:10:02 +0000 | [diff] [blame] | 1101 | // void operator delete[](void*); | 
| David L. Jones | d21529f | 2017-01-23 23:16:46 +0000 | [diff] [blame] | 1102 | case LibFunc_msvc_delete_array_ptr64: | 
| Ahmed Bougacha | 6b9be1d | 2017-01-17 03:10:02 +0000 | [diff] [blame] | 1103 | // void operator delete(void*); | 
| David L. Jones | d21529f | 2017-01-23 23:16:46 +0000 | [diff] [blame] | 1104 | case LibFunc_msvc_delete_ptr32: | 
| Ahmed Bougacha | 6b9be1d | 2017-01-17 03:10:02 +0000 | [diff] [blame] | 1105 | // void operator delete(void*); | 
| David L. Jones | d21529f | 2017-01-23 23:16:46 +0000 | [diff] [blame] | 1106 | case LibFunc_msvc_delete_ptr64: | 
| Ahmed Bougacha | 6b9be1d | 2017-01-17 03:10:02 +0000 | [diff] [blame] | 1107 | return (NumParams == 1 && FTy.getParamType(0)->isPointerTy()); | 
|  | 1108 |  | 
|  | 1109 | // void operator delete[](void*, nothrow); | 
| David L. Jones | d21529f | 2017-01-23 23:16:46 +0000 | [diff] [blame] | 1110 | case LibFunc_ZdaPvRKSt9nothrow_t: | 
| Ahmed Bougacha | 6b9be1d | 2017-01-17 03:10:02 +0000 | [diff] [blame] | 1111 | // void operator delete[](void*, unsigned int); | 
| David L. Jones | d21529f | 2017-01-23 23:16:46 +0000 | [diff] [blame] | 1112 | case LibFunc_ZdaPvj: | 
| Ahmed Bougacha | 6b9be1d | 2017-01-17 03:10:02 +0000 | [diff] [blame] | 1113 | // void operator delete[](void*, unsigned long); | 
| David L. Jones | d21529f | 2017-01-23 23:16:46 +0000 | [diff] [blame] | 1114 | case LibFunc_ZdaPvm: | 
| Ahmed Bougacha | 6b9be1d | 2017-01-17 03:10:02 +0000 | [diff] [blame] | 1115 | // void operator delete(void*, nothrow); | 
| David L. Jones | d21529f | 2017-01-23 23:16:46 +0000 | [diff] [blame] | 1116 | case LibFunc_ZdlPvRKSt9nothrow_t: | 
| Ahmed Bougacha | 6b9be1d | 2017-01-17 03:10:02 +0000 | [diff] [blame] | 1117 | // void operator delete(void*, unsigned int); | 
| David L. Jones | d21529f | 2017-01-23 23:16:46 +0000 | [diff] [blame] | 1118 | case LibFunc_ZdlPvj: | 
| Ahmed Bougacha | 6b9be1d | 2017-01-17 03:10:02 +0000 | [diff] [blame] | 1119 | // void operator delete(void*, unsigned long); | 
| David L. Jones | d21529f | 2017-01-23 23:16:46 +0000 | [diff] [blame] | 1120 | case LibFunc_ZdlPvm: | 
| Eric Fiselier | 96bbec7 | 2018-04-04 19:01:51 +0000 | [diff] [blame] | 1121 | // void operator delete(void*, align_val_t) | 
|  | 1122 | case LibFunc_ZdlPvSt11align_val_t: | 
|  | 1123 | // void operator delete[](void*, align_val_t) | 
|  | 1124 | case LibFunc_ZdaPvSt11align_val_t: | 
| Ahmed Bougacha | 6b9be1d | 2017-01-17 03:10:02 +0000 | [diff] [blame] | 1125 | // void operator delete[](void*, unsigned int); | 
| David L. Jones | d21529f | 2017-01-23 23:16:46 +0000 | [diff] [blame] | 1126 | case LibFunc_msvc_delete_array_ptr32_int: | 
| Ahmed Bougacha | 6b9be1d | 2017-01-17 03:10:02 +0000 | [diff] [blame] | 1127 | // void operator delete[](void*, nothrow); | 
| David L. Jones | d21529f | 2017-01-23 23:16:46 +0000 | [diff] [blame] | 1128 | case LibFunc_msvc_delete_array_ptr32_nothrow: | 
| Ahmed Bougacha | 6b9be1d | 2017-01-17 03:10:02 +0000 | [diff] [blame] | 1129 | // void operator delete[](void*, unsigned long long); | 
| David L. Jones | d21529f | 2017-01-23 23:16:46 +0000 | [diff] [blame] | 1130 | case LibFunc_msvc_delete_array_ptr64_longlong: | 
| Ahmed Bougacha | 6b9be1d | 2017-01-17 03:10:02 +0000 | [diff] [blame] | 1131 | // void operator delete[](void*, nothrow); | 
| David L. Jones | d21529f | 2017-01-23 23:16:46 +0000 | [diff] [blame] | 1132 | case LibFunc_msvc_delete_array_ptr64_nothrow: | 
| Ahmed Bougacha | 6b9be1d | 2017-01-17 03:10:02 +0000 | [diff] [blame] | 1133 | // void operator delete(void*, unsigned int); | 
| David L. Jones | d21529f | 2017-01-23 23:16:46 +0000 | [diff] [blame] | 1134 | case LibFunc_msvc_delete_ptr32_int: | 
| Ahmed Bougacha | 6b9be1d | 2017-01-17 03:10:02 +0000 | [diff] [blame] | 1135 | // void operator delete(void*, nothrow); | 
| David L. Jones | d21529f | 2017-01-23 23:16:46 +0000 | [diff] [blame] | 1136 | case LibFunc_msvc_delete_ptr32_nothrow: | 
| Ahmed Bougacha | 6b9be1d | 2017-01-17 03:10:02 +0000 | [diff] [blame] | 1137 | // void operator delete(void*, unsigned long long); | 
| David L. Jones | d21529f | 2017-01-23 23:16:46 +0000 | [diff] [blame] | 1138 | case LibFunc_msvc_delete_ptr64_longlong: | 
| Ahmed Bougacha | 6b9be1d | 2017-01-17 03:10:02 +0000 | [diff] [blame] | 1139 | // void operator delete(void*, nothrow); | 
| David L. Jones | d21529f | 2017-01-23 23:16:46 +0000 | [diff] [blame] | 1140 | case LibFunc_msvc_delete_ptr64_nothrow: | 
| Ahmed Bougacha | 6b9be1d | 2017-01-17 03:10:02 +0000 | [diff] [blame] | 1141 | return (NumParams == 2 && FTy.getParamType(0)->isPointerTy()); | 
| Ahmed Bougacha | d765a82 | 2016-04-27 19:04:35 +0000 | [diff] [blame] | 1142 |  | 
| Eric Fiselier | 96bbec7 | 2018-04-04 19:01:51 +0000 | [diff] [blame] | 1143 | // void operator delete(void*, align_val_t, nothrow) | 
|  | 1144 | case LibFunc_ZdlPvSt11align_val_tRKSt9nothrow_t: | 
|  | 1145 | // void operator delete[](void*, align_val_t, nothrow) | 
|  | 1146 | case LibFunc_ZdaPvSt11align_val_tRKSt9nothrow_t: | 
|  | 1147 | return (NumParams == 3 && FTy.getParamType(0)->isPointerTy()); | 
|  | 1148 |  | 
| David L. Jones | d21529f | 2017-01-23 23:16:46 +0000 | [diff] [blame] | 1149 | case LibFunc_memset_pattern16: | 
| Ahmed Bougacha | d765a82 | 2016-04-27 19:04:35 +0000 | [diff] [blame] | 1150 | return (!FTy.isVarArg() && NumParams == 3 && | 
| Ahmed Bougacha | 6b9be1d | 2017-01-17 03:10:02 +0000 | [diff] [blame] | 1151 | FTy.getParamType(0)->isPointerTy() && | 
|  | 1152 | FTy.getParamType(1)->isPointerTy() && | 
|  | 1153 | FTy.getParamType(2)->isIntegerTy()); | 
| Ahmed Bougacha | d765a82 | 2016-04-27 19:04:35 +0000 | [diff] [blame] | 1154 |  | 
| David L. Jones | d21529f | 2017-01-23 23:16:46 +0000 | [diff] [blame] | 1155 | case LibFunc_cxa_guard_abort: | 
|  | 1156 | case LibFunc_cxa_guard_acquire: | 
|  | 1157 | case LibFunc_cxa_guard_release: | 
|  | 1158 | case LibFunc_nvvm_reflect: | 
| Ahmed Bougacha | 6b9be1d | 2017-01-17 03:10:02 +0000 | [diff] [blame] | 1159 | return (NumParams == 1 && FTy.getParamType(0)->isPointerTy()); | 
| Ahmed Bougacha | d765a82 | 2016-04-27 19:04:35 +0000 | [diff] [blame] | 1160 |  | 
| David L. Jones | d21529f | 2017-01-23 23:16:46 +0000 | [diff] [blame] | 1161 | case LibFunc_sincospi_stret: | 
|  | 1162 | case LibFunc_sincospif_stret: | 
| Ahmed Bougacha | 6b9be1d | 2017-01-17 03:10:02 +0000 | [diff] [blame] | 1163 | return (NumParams == 1 && FTy.getParamType(0)->isFloatingPointTy()); | 
|  | 1164 |  | 
| David L. Jones | d21529f | 2017-01-23 23:16:46 +0000 | [diff] [blame] | 1165 | case LibFunc_acos: | 
| Andrew Kaylor | 3cd8c16 | 2017-05-12 22:11:12 +0000 | [diff] [blame] | 1166 | case LibFunc_acos_finite: | 
| David L. Jones | d21529f | 2017-01-23 23:16:46 +0000 | [diff] [blame] | 1167 | case LibFunc_acosf: | 
| Andrew Kaylor | 3cd8c16 | 2017-05-12 22:11:12 +0000 | [diff] [blame] | 1168 | case LibFunc_acosf_finite: | 
| David L. Jones | d21529f | 2017-01-23 23:16:46 +0000 | [diff] [blame] | 1169 | case LibFunc_acosh: | 
| Andrew Kaylor | 3cd8c16 | 2017-05-12 22:11:12 +0000 | [diff] [blame] | 1170 | case LibFunc_acosh_finite: | 
| David L. Jones | d21529f | 2017-01-23 23:16:46 +0000 | [diff] [blame] | 1171 | case LibFunc_acoshf: | 
| Andrew Kaylor | 3cd8c16 | 2017-05-12 22:11:12 +0000 | [diff] [blame] | 1172 | case LibFunc_acoshf_finite: | 
| David L. Jones | d21529f | 2017-01-23 23:16:46 +0000 | [diff] [blame] | 1173 | case LibFunc_acoshl: | 
| Andrew Kaylor | 3cd8c16 | 2017-05-12 22:11:12 +0000 | [diff] [blame] | 1174 | case LibFunc_acoshl_finite: | 
| David L. Jones | d21529f | 2017-01-23 23:16:46 +0000 | [diff] [blame] | 1175 | case LibFunc_acosl: | 
| Andrew Kaylor | 3cd8c16 | 2017-05-12 22:11:12 +0000 | [diff] [blame] | 1176 | case LibFunc_acosl_finite: | 
| David L. Jones | d21529f | 2017-01-23 23:16:46 +0000 | [diff] [blame] | 1177 | case LibFunc_asin: | 
| Andrew Kaylor | 3cd8c16 | 2017-05-12 22:11:12 +0000 | [diff] [blame] | 1178 | case LibFunc_asin_finite: | 
| David L. Jones | d21529f | 2017-01-23 23:16:46 +0000 | [diff] [blame] | 1179 | case LibFunc_asinf: | 
| Andrew Kaylor | 3cd8c16 | 2017-05-12 22:11:12 +0000 | [diff] [blame] | 1180 | case LibFunc_asinf_finite: | 
| David L. Jones | d21529f | 2017-01-23 23:16:46 +0000 | [diff] [blame] | 1181 | case LibFunc_asinh: | 
|  | 1182 | case LibFunc_asinhf: | 
|  | 1183 | case LibFunc_asinhl: | 
|  | 1184 | case LibFunc_asinl: | 
| Andrew Kaylor | 3cd8c16 | 2017-05-12 22:11:12 +0000 | [diff] [blame] | 1185 | case LibFunc_asinl_finite: | 
| David L. Jones | d21529f | 2017-01-23 23:16:46 +0000 | [diff] [blame] | 1186 | case LibFunc_atan: | 
|  | 1187 | case LibFunc_atanf: | 
|  | 1188 | case LibFunc_atanh: | 
| Andrew Kaylor | 3cd8c16 | 2017-05-12 22:11:12 +0000 | [diff] [blame] | 1189 | case LibFunc_atanh_finite: | 
| David L. Jones | d21529f | 2017-01-23 23:16:46 +0000 | [diff] [blame] | 1190 | case LibFunc_atanhf: | 
| Andrew Kaylor | 3cd8c16 | 2017-05-12 22:11:12 +0000 | [diff] [blame] | 1191 | case LibFunc_atanhf_finite: | 
| David L. Jones | d21529f | 2017-01-23 23:16:46 +0000 | [diff] [blame] | 1192 | case LibFunc_atanhl: | 
| Andrew Kaylor | 3cd8c16 | 2017-05-12 22:11:12 +0000 | [diff] [blame] | 1193 | case LibFunc_atanhl_finite: | 
| David L. Jones | d21529f | 2017-01-23 23:16:46 +0000 | [diff] [blame] | 1194 | case LibFunc_atanl: | 
|  | 1195 | case LibFunc_cbrt: | 
|  | 1196 | case LibFunc_cbrtf: | 
|  | 1197 | case LibFunc_cbrtl: | 
|  | 1198 | case LibFunc_ceil: | 
|  | 1199 | case LibFunc_ceilf: | 
|  | 1200 | case LibFunc_ceill: | 
|  | 1201 | case LibFunc_cos: | 
|  | 1202 | case LibFunc_cosf: | 
|  | 1203 | case LibFunc_cosh: | 
| Andrew Kaylor | 3cd8c16 | 2017-05-12 22:11:12 +0000 | [diff] [blame] | 1204 | case LibFunc_cosh_finite: | 
| David L. Jones | d21529f | 2017-01-23 23:16:46 +0000 | [diff] [blame] | 1205 | case LibFunc_coshf: | 
| Andrew Kaylor | 3cd8c16 | 2017-05-12 22:11:12 +0000 | [diff] [blame] | 1206 | case LibFunc_coshf_finite: | 
| David L. Jones | d21529f | 2017-01-23 23:16:46 +0000 | [diff] [blame] | 1207 | case LibFunc_coshl: | 
| Andrew Kaylor | 3cd8c16 | 2017-05-12 22:11:12 +0000 | [diff] [blame] | 1208 | case LibFunc_coshl_finite: | 
| David L. Jones | d21529f | 2017-01-23 23:16:46 +0000 | [diff] [blame] | 1209 | case LibFunc_cosl: | 
|  | 1210 | case LibFunc_exp10: | 
| Andrew Kaylor | 3cd8c16 | 2017-05-12 22:11:12 +0000 | [diff] [blame] | 1211 | case LibFunc_exp10_finite: | 
| David L. Jones | d21529f | 2017-01-23 23:16:46 +0000 | [diff] [blame] | 1212 | case LibFunc_exp10f: | 
| Andrew Kaylor | 3cd8c16 | 2017-05-12 22:11:12 +0000 | [diff] [blame] | 1213 | case LibFunc_exp10f_finite: | 
| David L. Jones | d21529f | 2017-01-23 23:16:46 +0000 | [diff] [blame] | 1214 | case LibFunc_exp10l: | 
| Andrew Kaylor | 3cd8c16 | 2017-05-12 22:11:12 +0000 | [diff] [blame] | 1215 | case LibFunc_exp10l_finite: | 
| David L. Jones | d21529f | 2017-01-23 23:16:46 +0000 | [diff] [blame] | 1216 | case LibFunc_exp2: | 
| Andrew Kaylor | 3cd8c16 | 2017-05-12 22:11:12 +0000 | [diff] [blame] | 1217 | case LibFunc_exp2_finite: | 
| David L. Jones | d21529f | 2017-01-23 23:16:46 +0000 | [diff] [blame] | 1218 | case LibFunc_exp2f: | 
| Andrew Kaylor | 3cd8c16 | 2017-05-12 22:11:12 +0000 | [diff] [blame] | 1219 | case LibFunc_exp2f_finite: | 
| David L. Jones | d21529f | 2017-01-23 23:16:46 +0000 | [diff] [blame] | 1220 | case LibFunc_exp2l: | 
| Andrew Kaylor | 3cd8c16 | 2017-05-12 22:11:12 +0000 | [diff] [blame] | 1221 | case LibFunc_exp2l_finite: | 
| David L. Jones | d21529f | 2017-01-23 23:16:46 +0000 | [diff] [blame] | 1222 | case LibFunc_exp: | 
| Andrew Kaylor | 3cd8c16 | 2017-05-12 22:11:12 +0000 | [diff] [blame] | 1223 | case LibFunc_exp_finite: | 
| David L. Jones | d21529f | 2017-01-23 23:16:46 +0000 | [diff] [blame] | 1224 | case LibFunc_expf: | 
| Andrew Kaylor | 3cd8c16 | 2017-05-12 22:11:12 +0000 | [diff] [blame] | 1225 | case LibFunc_expf_finite: | 
| David L. Jones | d21529f | 2017-01-23 23:16:46 +0000 | [diff] [blame] | 1226 | case LibFunc_expl: | 
| Andrew Kaylor | 3cd8c16 | 2017-05-12 22:11:12 +0000 | [diff] [blame] | 1227 | case LibFunc_expl_finite: | 
| David L. Jones | d21529f | 2017-01-23 23:16:46 +0000 | [diff] [blame] | 1228 | case LibFunc_expm1: | 
|  | 1229 | case LibFunc_expm1f: | 
|  | 1230 | case LibFunc_expm1l: | 
|  | 1231 | case LibFunc_fabs: | 
|  | 1232 | case LibFunc_fabsf: | 
|  | 1233 | case LibFunc_fabsl: | 
|  | 1234 | case LibFunc_floor: | 
|  | 1235 | case LibFunc_floorf: | 
|  | 1236 | case LibFunc_floorl: | 
|  | 1237 | case LibFunc_log10: | 
| Andrew Kaylor | 3cd8c16 | 2017-05-12 22:11:12 +0000 | [diff] [blame] | 1238 | case LibFunc_log10_finite: | 
| David L. Jones | d21529f | 2017-01-23 23:16:46 +0000 | [diff] [blame] | 1239 | case LibFunc_log10f: | 
| Andrew Kaylor | 3cd8c16 | 2017-05-12 22:11:12 +0000 | [diff] [blame] | 1240 | case LibFunc_log10f_finite: | 
| David L. Jones | d21529f | 2017-01-23 23:16:46 +0000 | [diff] [blame] | 1241 | case LibFunc_log10l: | 
| Andrew Kaylor | 3cd8c16 | 2017-05-12 22:11:12 +0000 | [diff] [blame] | 1242 | case LibFunc_log10l_finite: | 
| David L. Jones | d21529f | 2017-01-23 23:16:46 +0000 | [diff] [blame] | 1243 | case LibFunc_log1p: | 
|  | 1244 | case LibFunc_log1pf: | 
|  | 1245 | case LibFunc_log1pl: | 
|  | 1246 | case LibFunc_log2: | 
| Andrew Kaylor | 3cd8c16 | 2017-05-12 22:11:12 +0000 | [diff] [blame] | 1247 | case LibFunc_log2_finite: | 
| David L. Jones | d21529f | 2017-01-23 23:16:46 +0000 | [diff] [blame] | 1248 | case LibFunc_log2f: | 
| Andrew Kaylor | 3cd8c16 | 2017-05-12 22:11:12 +0000 | [diff] [blame] | 1249 | case LibFunc_log2f_finite: | 
| David L. Jones | d21529f | 2017-01-23 23:16:46 +0000 | [diff] [blame] | 1250 | case LibFunc_log2l: | 
| Andrew Kaylor | 3cd8c16 | 2017-05-12 22:11:12 +0000 | [diff] [blame] | 1251 | case LibFunc_log2l_finite: | 
| David L. Jones | d21529f | 2017-01-23 23:16:46 +0000 | [diff] [blame] | 1252 | case LibFunc_log: | 
| Andrew Kaylor | 3cd8c16 | 2017-05-12 22:11:12 +0000 | [diff] [blame] | 1253 | case LibFunc_log_finite: | 
| David L. Jones | d21529f | 2017-01-23 23:16:46 +0000 | [diff] [blame] | 1254 | case LibFunc_logb: | 
|  | 1255 | case LibFunc_logbf: | 
|  | 1256 | case LibFunc_logbl: | 
|  | 1257 | case LibFunc_logf: | 
| Andrew Kaylor | 3cd8c16 | 2017-05-12 22:11:12 +0000 | [diff] [blame] | 1258 | case LibFunc_logf_finite: | 
| David L. Jones | d21529f | 2017-01-23 23:16:46 +0000 | [diff] [blame] | 1259 | case LibFunc_logl: | 
| Andrew Kaylor | 3cd8c16 | 2017-05-12 22:11:12 +0000 | [diff] [blame] | 1260 | case LibFunc_logl_finite: | 
| David L. Jones | d21529f | 2017-01-23 23:16:46 +0000 | [diff] [blame] | 1261 | case LibFunc_nearbyint: | 
|  | 1262 | case LibFunc_nearbyintf: | 
|  | 1263 | case LibFunc_nearbyintl: | 
|  | 1264 | case LibFunc_rint: | 
|  | 1265 | case LibFunc_rintf: | 
|  | 1266 | case LibFunc_rintl: | 
|  | 1267 | case LibFunc_round: | 
|  | 1268 | case LibFunc_roundf: | 
|  | 1269 | case LibFunc_roundl: | 
|  | 1270 | case LibFunc_sin: | 
|  | 1271 | case LibFunc_sinf: | 
|  | 1272 | case LibFunc_sinh: | 
| Andrew Kaylor | 3cd8c16 | 2017-05-12 22:11:12 +0000 | [diff] [blame] | 1273 | case LibFunc_sinh_finite: | 
| David L. Jones | d21529f | 2017-01-23 23:16:46 +0000 | [diff] [blame] | 1274 | case LibFunc_sinhf: | 
| Andrew Kaylor | 3cd8c16 | 2017-05-12 22:11:12 +0000 | [diff] [blame] | 1275 | case LibFunc_sinhf_finite: | 
| David L. Jones | d21529f | 2017-01-23 23:16:46 +0000 | [diff] [blame] | 1276 | case LibFunc_sinhl: | 
| Andrew Kaylor | 3cd8c16 | 2017-05-12 22:11:12 +0000 | [diff] [blame] | 1277 | case LibFunc_sinhl_finite: | 
| David L. Jones | d21529f | 2017-01-23 23:16:46 +0000 | [diff] [blame] | 1278 | case LibFunc_sinl: | 
|  | 1279 | case LibFunc_sqrt: | 
|  | 1280 | case LibFunc_sqrt_finite: | 
|  | 1281 | case LibFunc_sqrtf: | 
|  | 1282 | case LibFunc_sqrtf_finite: | 
|  | 1283 | case LibFunc_sqrtl: | 
|  | 1284 | case LibFunc_sqrtl_finite: | 
|  | 1285 | case LibFunc_tan: | 
|  | 1286 | case LibFunc_tanf: | 
|  | 1287 | case LibFunc_tanh: | 
|  | 1288 | case LibFunc_tanhf: | 
|  | 1289 | case LibFunc_tanhl: | 
|  | 1290 | case LibFunc_tanl: | 
|  | 1291 | case LibFunc_trunc: | 
|  | 1292 | case LibFunc_truncf: | 
|  | 1293 | case LibFunc_truncl: | 
| Ahmed Bougacha | d765a82 | 2016-04-27 19:04:35 +0000 | [diff] [blame] | 1294 | return (NumParams == 1 && FTy.getReturnType()->isFloatingPointTy() && | 
|  | 1295 | FTy.getReturnType() == FTy.getParamType(0)); | 
|  | 1296 |  | 
| David L. Jones | d21529f | 2017-01-23 23:16:46 +0000 | [diff] [blame] | 1297 | case LibFunc_atan2: | 
| Andrew Kaylor | 3cd8c16 | 2017-05-12 22:11:12 +0000 | [diff] [blame] | 1298 | case LibFunc_atan2_finite: | 
| David L. Jones | d21529f | 2017-01-23 23:16:46 +0000 | [diff] [blame] | 1299 | case LibFunc_atan2f: | 
| Andrew Kaylor | 3cd8c16 | 2017-05-12 22:11:12 +0000 | [diff] [blame] | 1300 | case LibFunc_atan2f_finite: | 
| David L. Jones | d21529f | 2017-01-23 23:16:46 +0000 | [diff] [blame] | 1301 | case LibFunc_atan2l: | 
| Andrew Kaylor | 3cd8c16 | 2017-05-12 22:11:12 +0000 | [diff] [blame] | 1302 | case LibFunc_atan2l_finite: | 
| David L. Jones | d21529f | 2017-01-23 23:16:46 +0000 | [diff] [blame] | 1303 | case LibFunc_fmin: | 
|  | 1304 | case LibFunc_fminf: | 
|  | 1305 | case LibFunc_fminl: | 
|  | 1306 | case LibFunc_fmax: | 
|  | 1307 | case LibFunc_fmaxf: | 
|  | 1308 | case LibFunc_fmaxl: | 
|  | 1309 | case LibFunc_fmod: | 
|  | 1310 | case LibFunc_fmodf: | 
|  | 1311 | case LibFunc_fmodl: | 
|  | 1312 | case LibFunc_copysign: | 
|  | 1313 | case LibFunc_copysignf: | 
|  | 1314 | case LibFunc_copysignl: | 
|  | 1315 | case LibFunc_pow: | 
| Andrew Kaylor | 3cd8c16 | 2017-05-12 22:11:12 +0000 | [diff] [blame] | 1316 | case LibFunc_pow_finite: | 
| David L. Jones | d21529f | 2017-01-23 23:16:46 +0000 | [diff] [blame] | 1317 | case LibFunc_powf: | 
| Andrew Kaylor | 3cd8c16 | 2017-05-12 22:11:12 +0000 | [diff] [blame] | 1318 | case LibFunc_powf_finite: | 
| David L. Jones | d21529f | 2017-01-23 23:16:46 +0000 | [diff] [blame] | 1319 | case LibFunc_powl: | 
| Andrew Kaylor | 3cd8c16 | 2017-05-12 22:11:12 +0000 | [diff] [blame] | 1320 | case LibFunc_powl_finite: | 
| Ahmed Bougacha | d765a82 | 2016-04-27 19:04:35 +0000 | [diff] [blame] | 1321 | return (NumParams == 2 && FTy.getReturnType()->isFloatingPointTy() && | 
|  | 1322 | FTy.getReturnType() == FTy.getParamType(0) && | 
|  | 1323 | FTy.getReturnType() == FTy.getParamType(1)); | 
|  | 1324 |  | 
| David L. Jones | d21529f | 2017-01-23 23:16:46 +0000 | [diff] [blame] | 1325 | case LibFunc_ldexp: | 
|  | 1326 | case LibFunc_ldexpf: | 
|  | 1327 | case LibFunc_ldexpl: | 
| Ahmed Bougacha | 6b9be1d | 2017-01-17 03:10:02 +0000 | [diff] [blame] | 1328 | return (NumParams == 2 && FTy.getReturnType()->isFloatingPointTy() && | 
|  | 1329 | FTy.getReturnType() == FTy.getParamType(0) && | 
|  | 1330 | FTy.getParamType(1)->isIntegerTy(32)); | 
|  | 1331 |  | 
| David L. Jones | d21529f | 2017-01-23 23:16:46 +0000 | [diff] [blame] | 1332 | case LibFunc_ffs: | 
|  | 1333 | case LibFunc_ffsl: | 
|  | 1334 | case LibFunc_ffsll: | 
|  | 1335 | case LibFunc_fls: | 
|  | 1336 | case LibFunc_flsl: | 
|  | 1337 | case LibFunc_flsll: | 
| Sanjay Patel | 04949faf | 2016-09-23 18:44:09 +0000 | [diff] [blame] | 1338 | return (NumParams == 1 && FTy.getReturnType()->isIntegerTy(32) && | 
|  | 1339 | FTy.getParamType(0)->isIntegerTy()); | 
|  | 1340 |  | 
| David L. Jones | d21529f | 2017-01-23 23:16:46 +0000 | [diff] [blame] | 1341 | case LibFunc_isdigit: | 
|  | 1342 | case LibFunc_isascii: | 
|  | 1343 | case LibFunc_toascii: | 
|  | 1344 | case LibFunc_putchar: | 
| David Bolvansky | ca22d42 | 2018-05-16 11:39:52 +0000 | [diff] [blame] | 1345 | case LibFunc_putchar_unlocked: | 
| Ahmed Bougacha | d765a82 | 2016-04-27 19:04:35 +0000 | [diff] [blame] | 1346 | return (NumParams == 1 && FTy.getReturnType()->isIntegerTy(32) && | 
| Sanjay Patel | 04949faf | 2016-09-23 18:44:09 +0000 | [diff] [blame] | 1347 | FTy.getReturnType() == FTy.getParamType(0)); | 
| Ahmed Bougacha | d765a82 | 2016-04-27 19:04:35 +0000 | [diff] [blame] | 1348 |  | 
| David L. Jones | d21529f | 2017-01-23 23:16:46 +0000 | [diff] [blame] | 1349 | case LibFunc_abs: | 
|  | 1350 | case LibFunc_labs: | 
|  | 1351 | case LibFunc_llabs: | 
| Ahmed Bougacha | d765a82 | 2016-04-27 19:04:35 +0000 | [diff] [blame] | 1352 | return (NumParams == 1 && FTy.getReturnType()->isIntegerTy() && | 
|  | 1353 | FTy.getReturnType() == FTy.getParamType(0)); | 
|  | 1354 |  | 
| David L. Jones | d21529f | 2017-01-23 23:16:46 +0000 | [diff] [blame] | 1355 | case LibFunc_cxa_atexit: | 
| Ahmed Bougacha | d765a82 | 2016-04-27 19:04:35 +0000 | [diff] [blame] | 1356 | return (NumParams == 3 && FTy.getReturnType()->isIntegerTy() && | 
|  | 1357 | FTy.getParamType(0)->isPointerTy() && | 
|  | 1358 | FTy.getParamType(1)->isPointerTy() && | 
|  | 1359 | FTy.getParamType(2)->isPointerTy()); | 
|  | 1360 |  | 
| David L. Jones | d21529f | 2017-01-23 23:16:46 +0000 | [diff] [blame] | 1361 | case LibFunc_sinpi: | 
|  | 1362 | case LibFunc_cospi: | 
| Ahmed Bougacha | d765a82 | 2016-04-27 19:04:35 +0000 | [diff] [blame] | 1363 | return (NumParams == 1 && FTy.getReturnType()->isDoubleTy() && | 
|  | 1364 | FTy.getReturnType() == FTy.getParamType(0)); | 
|  | 1365 |  | 
| David L. Jones | d21529f | 2017-01-23 23:16:46 +0000 | [diff] [blame] | 1366 | case LibFunc_sinpif: | 
|  | 1367 | case LibFunc_cospif: | 
| Ahmed Bougacha | d765a82 | 2016-04-27 19:04:35 +0000 | [diff] [blame] | 1368 | return (NumParams == 1 && FTy.getReturnType()->isFloatTy() && | 
|  | 1369 | FTy.getReturnType() == FTy.getParamType(0)); | 
|  | 1370 |  | 
| David L. Jones | d21529f | 2017-01-23 23:16:46 +0000 | [diff] [blame] | 1371 | case LibFunc_strnlen: | 
| Ahmed Bougacha | 6b9be1d | 2017-01-17 03:10:02 +0000 | [diff] [blame] | 1372 | return (NumParams == 2 && FTy.getReturnType() == FTy.getParamType(1) && | 
|  | 1373 | FTy.getParamType(0) == PCharTy && | 
|  | 1374 | FTy.getParamType(1) == SizeTTy); | 
|  | 1375 |  | 
| David L. Jones | d21529f | 2017-01-23 23:16:46 +0000 | [diff] [blame] | 1376 | case LibFunc_posix_memalign: | 
| Ahmed Bougacha | 6b9be1d | 2017-01-17 03:10:02 +0000 | [diff] [blame] | 1377 | return (NumParams == 3 && FTy.getReturnType()->isIntegerTy(32) && | 
|  | 1378 | FTy.getParamType(0)->isPointerTy() && | 
|  | 1379 | FTy.getParamType(1) == SizeTTy && FTy.getParamType(2) == SizeTTy); | 
|  | 1380 |  | 
| Matthias Braun | 60b40b8 | 2017-05-05 20:25:50 +0000 | [diff] [blame] | 1381 | case LibFunc_wcslen: | 
|  | 1382 | return (NumParams == 1 && FTy.getParamType(0)->isPointerTy() && | 
|  | 1383 | FTy.getReturnType()->isIntegerTy()); | 
|  | 1384 |  | 
| Hal Finkel | 2ff2473 | 2017-12-16 01:26:25 +0000 | [diff] [blame] | 1385 | case LibFunc_cabs: | 
|  | 1386 | case LibFunc_cabsf: | 
|  | 1387 | case LibFunc_cabsl: { | 
|  | 1388 | Type* RetTy = FTy.getReturnType(); | 
|  | 1389 | if (!RetTy->isFloatingPointTy()) | 
|  | 1390 | return false; | 
|  | 1391 |  | 
|  | 1392 | // NOTE: These prototypes are target specific and currently support | 
|  | 1393 | // "complex" passed as an array or discrete real & imaginary parameters. | 
|  | 1394 | // Add other calling conventions to enable libcall optimizations. | 
|  | 1395 | if (NumParams == 1) | 
|  | 1396 | return (FTy.getParamType(0)->isArrayTy() && | 
|  | 1397 | FTy.getParamType(0)->getArrayNumElements() == 2 && | 
|  | 1398 | FTy.getParamType(0)->getArrayElementType() == RetTy); | 
|  | 1399 | else if (NumParams == 2) | 
|  | 1400 | return (FTy.getParamType(0) == RetTy && FTy.getParamType(1) == RetTy); | 
|  | 1401 | else | 
|  | 1402 | return false; | 
|  | 1403 | } | 
| Ahmed Bougacha | 6b9be1d | 2017-01-17 03:10:02 +0000 | [diff] [blame] | 1404 | case LibFunc::NumLibFuncs: | 
| Ahmed Bougacha | 86b680a | 2017-01-17 19:54:18 +0000 | [diff] [blame] | 1405 | break; | 
| Ahmed Bougacha | d765a82 | 2016-04-27 19:04:35 +0000 | [diff] [blame] | 1406 | } | 
| Ahmed Bougacha | 6b9be1d | 2017-01-17 03:10:02 +0000 | [diff] [blame] | 1407 |  | 
| Ahmed Bougacha | 86b680a | 2017-01-17 19:54:18 +0000 | [diff] [blame] | 1408 | llvm_unreachable("Invalid libfunc"); | 
| Ahmed Bougacha | d765a82 | 2016-04-27 19:04:35 +0000 | [diff] [blame] | 1409 | } | 
|  | 1410 |  | 
|  | 1411 | bool TargetLibraryInfoImpl::getLibFunc(const Function &FDecl, | 
| David L. Jones | d21529f | 2017-01-23 23:16:46 +0000 | [diff] [blame] | 1412 | LibFunc &F) const { | 
| Ahmed Bougacha | d765a82 | 2016-04-27 19:04:35 +0000 | [diff] [blame] | 1413 | const DataLayout *DL = | 
|  | 1414 | FDecl.getParent() ? &FDecl.getParent()->getDataLayout() : nullptr; | 
|  | 1415 | return getLibFunc(FDecl.getName(), F) && | 
|  | 1416 | isValidProtoForLibFunc(*FDecl.getFunctionType(), F, DL); | 
|  | 1417 | } | 
|  | 1418 |  | 
| Chandler Carruth | c029186 | 2015-01-24 02:06:09 +0000 | [diff] [blame] | 1419 | void TargetLibraryInfoImpl::disableAllFunctions() { | 
| Chris Lattner | 1341df9 | 2011-02-18 22:34:03 +0000 | [diff] [blame] | 1420 | memset(AvailableArray, 0, sizeof(AvailableArray)); | 
|  | 1421 | } | 
| Chandler Carruth | b98f63d | 2015-01-15 10:41:28 +0000 | [diff] [blame] | 1422 |  | 
| Michael Zolotukhin | e8f2551 | 2015-03-17 19:22:30 +0000 | [diff] [blame] | 1423 | static bool compareByScalarFnName(const VecDesc &LHS, const VecDesc &RHS) { | 
| Mehdi Amini | 9a72cd7 | 2016-10-01 03:10:48 +0000 | [diff] [blame] | 1424 | return LHS.ScalarFnName < RHS.ScalarFnName; | 
| Michael Zolotukhin | e8f2551 | 2015-03-17 19:22:30 +0000 | [diff] [blame] | 1425 | } | 
|  | 1426 |  | 
|  | 1427 | static bool compareByVectorFnName(const VecDesc &LHS, const VecDesc &RHS) { | 
| Mehdi Amini | 9a72cd7 | 2016-10-01 03:10:48 +0000 | [diff] [blame] | 1428 | return LHS.VectorFnName < RHS.VectorFnName; | 
| Michael Zolotukhin | e8f2551 | 2015-03-17 19:22:30 +0000 | [diff] [blame] | 1429 | } | 
|  | 1430 |  | 
|  | 1431 | static bool compareWithScalarFnName(const VecDesc &LHS, StringRef S) { | 
| Mehdi Amini | 9a72cd7 | 2016-10-01 03:10:48 +0000 | [diff] [blame] | 1432 | return LHS.ScalarFnName < S; | 
| Michael Zolotukhin | e8f2551 | 2015-03-17 19:22:30 +0000 | [diff] [blame] | 1433 | } | 
|  | 1434 |  | 
|  | 1435 | static bool compareWithVectorFnName(const VecDesc &LHS, StringRef S) { | 
| Mehdi Amini | 9a72cd7 | 2016-10-01 03:10:48 +0000 | [diff] [blame] | 1436 | return LHS.VectorFnName < S; | 
| Michael Zolotukhin | e8f2551 | 2015-03-17 19:22:30 +0000 | [diff] [blame] | 1437 | } | 
|  | 1438 |  | 
|  | 1439 | void TargetLibraryInfoImpl::addVectorizableFunctions(ArrayRef<VecDesc> Fns) { | 
|  | 1440 | VectorDescs.insert(VectorDescs.end(), Fns.begin(), Fns.end()); | 
| Fangrui Song | 0cac726 | 2018-09-27 02:13:45 +0000 | [diff] [blame] | 1441 | llvm::sort(VectorDescs, compareByScalarFnName); | 
| Michael Zolotukhin | e8f2551 | 2015-03-17 19:22:30 +0000 | [diff] [blame] | 1442 |  | 
|  | 1443 | ScalarDescs.insert(ScalarDescs.end(), Fns.begin(), Fns.end()); | 
| Fangrui Song | 0cac726 | 2018-09-27 02:13:45 +0000 | [diff] [blame] | 1444 | llvm::sort(ScalarDescs, compareByVectorFnName); | 
| Michael Zolotukhin | e8f2551 | 2015-03-17 19:22:30 +0000 | [diff] [blame] | 1445 | } | 
|  | 1446 |  | 
| Michael Zolotukhin | 6d8a2aa | 2015-03-17 19:50:55 +0000 | [diff] [blame] | 1447 | void TargetLibraryInfoImpl::addVectorizableFunctionsFromVecLib( | 
|  | 1448 | enum VectorLibrary VecLib) { | 
|  | 1449 | switch (VecLib) { | 
|  | 1450 | case Accelerate: { | 
|  | 1451 | const VecDesc VecFuncs[] = { | 
| Michael Zolotukhin | de63aac | 2015-05-07 17:11:51 +0000 | [diff] [blame] | 1452 | // Floating-Point Arithmetic and Auxiliary Functions | 
|  | 1453 | {"ceilf", "vceilf", 4}, | 
| Michael Zolotukhin | 6d8a2aa | 2015-03-17 19:50:55 +0000 | [diff] [blame] | 1454 | {"fabsf", "vfabsf", 4}, | 
|  | 1455 | {"llvm.fabs.f32", "vfabsf", 4}, | 
| Michael Zolotukhin | de63aac | 2015-05-07 17:11:51 +0000 | [diff] [blame] | 1456 | {"floorf", "vfloorf", 4}, | 
|  | 1457 | {"sqrtf", "vsqrtf", 4}, | 
|  | 1458 | {"llvm.sqrt.f32", "vsqrtf", 4}, | 
|  | 1459 |  | 
|  | 1460 | // Exponential and Logarithmic Functions | 
|  | 1461 | {"expf", "vexpf", 4}, | 
|  | 1462 | {"llvm.exp.f32", "vexpf", 4}, | 
|  | 1463 | {"expm1f", "vexpm1f", 4}, | 
|  | 1464 | {"logf", "vlogf", 4}, | 
|  | 1465 | {"llvm.log.f32", "vlogf", 4}, | 
|  | 1466 | {"log1pf", "vlog1pf", 4}, | 
|  | 1467 | {"log10f", "vlog10f", 4}, | 
|  | 1468 | {"llvm.log10.f32", "vlog10f", 4}, | 
|  | 1469 | {"logbf", "vlogbf", 4}, | 
|  | 1470 |  | 
|  | 1471 | // Trigonometric Functions | 
|  | 1472 | {"sinf", "vsinf", 4}, | 
|  | 1473 | {"llvm.sin.f32", "vsinf", 4}, | 
|  | 1474 | {"cosf", "vcosf", 4}, | 
|  | 1475 | {"llvm.cos.f32", "vcosf", 4}, | 
|  | 1476 | {"tanf", "vtanf", 4}, | 
|  | 1477 | {"asinf", "vasinf", 4}, | 
|  | 1478 | {"acosf", "vacosf", 4}, | 
|  | 1479 | {"atanf", "vatanf", 4}, | 
|  | 1480 |  | 
|  | 1481 | // Hyperbolic Functions | 
|  | 1482 | {"sinhf", "vsinhf", 4}, | 
|  | 1483 | {"coshf", "vcoshf", 4}, | 
|  | 1484 | {"tanhf", "vtanhf", 4}, | 
|  | 1485 | {"asinhf", "vasinhf", 4}, | 
|  | 1486 | {"acoshf", "vacoshf", 4}, | 
|  | 1487 | {"atanhf", "vatanhf", 4}, | 
| Michael Zolotukhin | 6d8a2aa | 2015-03-17 19:50:55 +0000 | [diff] [blame] | 1488 | }; | 
|  | 1489 | addVectorizableFunctions(VecFuncs); | 
|  | 1490 | break; | 
|  | 1491 | } | 
| Matt Masten | a6669a1 | 2016-07-29 16:42:44 +0000 | [diff] [blame] | 1492 | case SVML: { | 
|  | 1493 | const VecDesc VecFuncs[] = { | 
|  | 1494 | {"sin", "__svml_sin2", 2}, | 
|  | 1495 | {"sin", "__svml_sin4", 4}, | 
|  | 1496 | {"sin", "__svml_sin8", 8}, | 
|  | 1497 |  | 
|  | 1498 | {"sinf", "__svml_sinf4", 4}, | 
|  | 1499 | {"sinf", "__svml_sinf8", 8}, | 
|  | 1500 | {"sinf", "__svml_sinf16", 16}, | 
|  | 1501 |  | 
| Sanjay Patel | 4b1205b | 2018-06-07 18:21:24 +0000 | [diff] [blame] | 1502 | {"llvm.sin.f64", "__svml_sin2", 2}, | 
|  | 1503 | {"llvm.sin.f64", "__svml_sin4", 4}, | 
|  | 1504 | {"llvm.sin.f64", "__svml_sin8", 8}, | 
|  | 1505 |  | 
|  | 1506 | {"llvm.sin.f32", "__svml_sinf4", 4}, | 
|  | 1507 | {"llvm.sin.f32", "__svml_sinf8", 8}, | 
|  | 1508 | {"llvm.sin.f32", "__svml_sinf16", 16}, | 
|  | 1509 |  | 
| Matt Masten | a6669a1 | 2016-07-29 16:42:44 +0000 | [diff] [blame] | 1510 | {"cos", "__svml_cos2", 2}, | 
|  | 1511 | {"cos", "__svml_cos4", 4}, | 
|  | 1512 | {"cos", "__svml_cos8", 8}, | 
|  | 1513 |  | 
|  | 1514 | {"cosf", "__svml_cosf4", 4}, | 
|  | 1515 | {"cosf", "__svml_cosf8", 8}, | 
|  | 1516 | {"cosf", "__svml_cosf16", 16}, | 
|  | 1517 |  | 
| Sanjay Patel | 4b1205b | 2018-06-07 18:21:24 +0000 | [diff] [blame] | 1518 | {"llvm.cos.f64", "__svml_cos2", 2}, | 
|  | 1519 | {"llvm.cos.f64", "__svml_cos4", 4}, | 
|  | 1520 | {"llvm.cos.f64", "__svml_cos8", 8}, | 
|  | 1521 |  | 
|  | 1522 | {"llvm.cos.f32", "__svml_cosf4", 4}, | 
|  | 1523 | {"llvm.cos.f32", "__svml_cosf8", 8}, | 
|  | 1524 | {"llvm.cos.f32", "__svml_cosf16", 16}, | 
|  | 1525 |  | 
| Matt Masten | a6669a1 | 2016-07-29 16:42:44 +0000 | [diff] [blame] | 1526 | {"pow", "__svml_pow2", 2}, | 
|  | 1527 | {"pow", "__svml_pow4", 4}, | 
|  | 1528 | {"pow", "__svml_pow8", 8}, | 
|  | 1529 |  | 
|  | 1530 | {"powf", "__svml_powf4", 4}, | 
|  | 1531 | {"powf", "__svml_powf8", 8}, | 
|  | 1532 | {"powf", "__svml_powf16", 16}, | 
|  | 1533 |  | 
| Andrew Kaylor | b01e94e | 2017-05-12 22:11:26 +0000 | [diff] [blame] | 1534 | { "__pow_finite", "__svml_pow2", 2 }, | 
|  | 1535 | { "__pow_finite", "__svml_pow4", 4 }, | 
|  | 1536 | { "__pow_finite", "__svml_pow8", 8 }, | 
|  | 1537 |  | 
|  | 1538 | { "__powf_finite", "__svml_powf4", 4 }, | 
|  | 1539 | { "__powf_finite", "__svml_powf8", 8 }, | 
|  | 1540 | { "__powf_finite", "__svml_powf16", 16 }, | 
|  | 1541 |  | 
| Matt Masten | a6669a1 | 2016-07-29 16:42:44 +0000 | [diff] [blame] | 1542 | {"llvm.pow.f64", "__svml_pow2", 2}, | 
|  | 1543 | {"llvm.pow.f64", "__svml_pow4", 4}, | 
|  | 1544 | {"llvm.pow.f64", "__svml_pow8", 8}, | 
|  | 1545 |  | 
|  | 1546 | {"llvm.pow.f32", "__svml_powf4", 4}, | 
|  | 1547 | {"llvm.pow.f32", "__svml_powf8", 8}, | 
|  | 1548 | {"llvm.pow.f32", "__svml_powf16", 16}, | 
|  | 1549 |  | 
|  | 1550 | {"exp", "__svml_exp2", 2}, | 
|  | 1551 | {"exp", "__svml_exp4", 4}, | 
|  | 1552 | {"exp", "__svml_exp8", 8}, | 
|  | 1553 |  | 
|  | 1554 | {"expf", "__svml_expf4", 4}, | 
|  | 1555 | {"expf", "__svml_expf8", 8}, | 
|  | 1556 | {"expf", "__svml_expf16", 16}, | 
|  | 1557 |  | 
| Andrew Kaylor | b01e94e | 2017-05-12 22:11:26 +0000 | [diff] [blame] | 1558 | { "__exp_finite", "__svml_exp2", 2 }, | 
|  | 1559 | { "__exp_finite", "__svml_exp4", 4 }, | 
|  | 1560 | { "__exp_finite", "__svml_exp8", 8 }, | 
|  | 1561 |  | 
|  | 1562 | { "__expf_finite", "__svml_expf4", 4 }, | 
|  | 1563 | { "__expf_finite", "__svml_expf8", 8 }, | 
|  | 1564 | { "__expf_finite", "__svml_expf16", 16 }, | 
|  | 1565 |  | 
| Matt Masten | a6669a1 | 2016-07-29 16:42:44 +0000 | [diff] [blame] | 1566 | {"llvm.exp.f64", "__svml_exp2", 2}, | 
|  | 1567 | {"llvm.exp.f64", "__svml_exp4", 4}, | 
|  | 1568 | {"llvm.exp.f64", "__svml_exp8", 8}, | 
|  | 1569 |  | 
|  | 1570 | {"llvm.exp.f32", "__svml_expf4", 4}, | 
|  | 1571 | {"llvm.exp.f32", "__svml_expf8", 8}, | 
|  | 1572 | {"llvm.exp.f32", "__svml_expf16", 16}, | 
|  | 1573 |  | 
|  | 1574 | {"log", "__svml_log2", 2}, | 
|  | 1575 | {"log", "__svml_log4", 4}, | 
|  | 1576 | {"log", "__svml_log8", 8}, | 
|  | 1577 |  | 
|  | 1578 | {"logf", "__svml_logf4", 4}, | 
|  | 1579 | {"logf", "__svml_logf8", 8}, | 
|  | 1580 | {"logf", "__svml_logf16", 16}, | 
|  | 1581 |  | 
| Andrew Kaylor | b01e94e | 2017-05-12 22:11:26 +0000 | [diff] [blame] | 1582 | { "__log_finite", "__svml_log2", 2 }, | 
|  | 1583 | { "__log_finite", "__svml_log4", 4 }, | 
|  | 1584 | { "__log_finite", "__svml_log8", 8 }, | 
|  | 1585 |  | 
|  | 1586 | { "__logf_finite", "__svml_logf4", 4 }, | 
|  | 1587 | { "__logf_finite", "__svml_logf8", 8 }, | 
|  | 1588 | { "__logf_finite", "__svml_logf16", 16 }, | 
|  | 1589 |  | 
| Matt Masten | a6669a1 | 2016-07-29 16:42:44 +0000 | [diff] [blame] | 1590 | {"llvm.log.f64", "__svml_log2", 2}, | 
|  | 1591 | {"llvm.log.f64", "__svml_log4", 4}, | 
|  | 1592 | {"llvm.log.f64", "__svml_log8", 8}, | 
|  | 1593 |  | 
|  | 1594 | {"llvm.log.f32", "__svml_logf4", 4}, | 
|  | 1595 | {"llvm.log.f32", "__svml_logf8", 8}, | 
|  | 1596 | {"llvm.log.f32", "__svml_logf16", 16}, | 
|  | 1597 | }; | 
|  | 1598 | addVectorizableFunctions(VecFuncs); | 
|  | 1599 | break; | 
|  | 1600 | } | 
| Michael Zolotukhin | 6d8a2aa | 2015-03-17 19:50:55 +0000 | [diff] [blame] | 1601 | case NoLibrary: | 
|  | 1602 | break; | 
|  | 1603 | } | 
|  | 1604 | } | 
|  | 1605 |  | 
| Michael Zolotukhin | e8f2551 | 2015-03-17 19:22:30 +0000 | [diff] [blame] | 1606 | bool TargetLibraryInfoImpl::isFunctionVectorizable(StringRef funcName) const { | 
|  | 1607 | funcName = sanitizeFunctionName(funcName); | 
|  | 1608 | if (funcName.empty()) | 
|  | 1609 | return false; | 
|  | 1610 |  | 
|  | 1611 | std::vector<VecDesc>::const_iterator I = std::lower_bound( | 
|  | 1612 | VectorDescs.begin(), VectorDescs.end(), funcName, | 
|  | 1613 | compareWithScalarFnName); | 
|  | 1614 | return I != VectorDescs.end() && StringRef(I->ScalarFnName) == funcName; | 
|  | 1615 | } | 
|  | 1616 |  | 
|  | 1617 | StringRef TargetLibraryInfoImpl::getVectorizedFunction(StringRef F, | 
|  | 1618 | unsigned VF) const { | 
|  | 1619 | F = sanitizeFunctionName(F); | 
|  | 1620 | if (F.empty()) | 
|  | 1621 | return F; | 
|  | 1622 | std::vector<VecDesc>::const_iterator I = std::lower_bound( | 
|  | 1623 | VectorDescs.begin(), VectorDescs.end(), F, compareWithScalarFnName); | 
|  | 1624 | while (I != VectorDescs.end() && StringRef(I->ScalarFnName) == F) { | 
|  | 1625 | if (I->VectorizationFactor == VF) | 
|  | 1626 | return I->VectorFnName; | 
|  | 1627 | ++I; | 
|  | 1628 | } | 
|  | 1629 | return StringRef(); | 
|  | 1630 | } | 
|  | 1631 |  | 
|  | 1632 | StringRef TargetLibraryInfoImpl::getScalarizedFunction(StringRef F, | 
|  | 1633 | unsigned &VF) const { | 
|  | 1634 | F = sanitizeFunctionName(F); | 
|  | 1635 | if (F.empty()) | 
|  | 1636 | return F; | 
|  | 1637 |  | 
|  | 1638 | std::vector<VecDesc>::const_iterator I = std::lower_bound( | 
|  | 1639 | ScalarDescs.begin(), ScalarDescs.end(), F, compareWithVectorFnName); | 
|  | 1640 | if (I == VectorDescs.end() || StringRef(I->VectorFnName) != F) | 
|  | 1641 | return StringRef(); | 
|  | 1642 | VF = I->VectorizationFactor; | 
|  | 1643 | return I->ScalarFnName; | 
|  | 1644 | } | 
|  | 1645 |  | 
| Chandler Carruth | 164a2aa6 | 2016-06-17 00:11:01 +0000 | [diff] [blame] | 1646 | TargetLibraryInfo TargetLibraryAnalysis::run(Module &M, | 
|  | 1647 | ModuleAnalysisManager &) { | 
| Chandler Carruth | c029186 | 2015-01-24 02:06:09 +0000 | [diff] [blame] | 1648 | if (PresetInfoImpl) | 
|  | 1649 | return TargetLibraryInfo(*PresetInfoImpl); | 
|  | 1650 |  | 
|  | 1651 | return TargetLibraryInfo(lookupInfoImpl(Triple(M.getTargetTriple()))); | 
|  | 1652 | } | 
|  | 1653 |  | 
| Chandler Carruth | 164a2aa6 | 2016-06-17 00:11:01 +0000 | [diff] [blame] | 1654 | TargetLibraryInfo TargetLibraryAnalysis::run(Function &F, | 
|  | 1655 | FunctionAnalysisManager &) { | 
| Chandler Carruth | c029186 | 2015-01-24 02:06:09 +0000 | [diff] [blame] | 1656 | if (PresetInfoImpl) | 
|  | 1657 | return TargetLibraryInfo(*PresetInfoImpl); | 
|  | 1658 |  | 
|  | 1659 | return TargetLibraryInfo( | 
|  | 1660 | lookupInfoImpl(Triple(F.getParent()->getTargetTriple()))); | 
|  | 1661 | } | 
|  | 1662 |  | 
| Benjamin Kramer | c321e53 | 2016-06-08 19:09:22 +0000 | [diff] [blame] | 1663 | TargetLibraryInfoImpl &TargetLibraryAnalysis::lookupInfoImpl(const Triple &T) { | 
| Chandler Carruth | c029186 | 2015-01-24 02:06:09 +0000 | [diff] [blame] | 1664 | std::unique_ptr<TargetLibraryInfoImpl> &Impl = | 
|  | 1665 | Impls[T.normalize()]; | 
|  | 1666 | if (!Impl) | 
|  | 1667 | Impl.reset(new TargetLibraryInfoImpl(T)); | 
|  | 1668 |  | 
|  | 1669 | return *Impl; | 
|  | 1670 | } | 
|  | 1671 |  | 
| Matthias Braun | 50ec0b5 | 2017-05-19 22:37:09 +0000 | [diff] [blame] | 1672 | unsigned TargetLibraryInfoImpl::getWCharSize(const Module &M) const { | 
|  | 1673 | if (auto *ShortWChar = cast_or_null<ConstantAsMetadata>( | 
|  | 1674 | M.getModuleFlag("wchar_size"))) | 
|  | 1675 | return cast<ConstantInt>(ShortWChar->getValue())->getZExtValue(); | 
| Matthias Braun | cc603ee | 2017-09-26 02:36:57 +0000 | [diff] [blame] | 1676 | return 0; | 
| Matthias Braun | 50ec0b5 | 2017-05-19 22:37:09 +0000 | [diff] [blame] | 1677 | } | 
| Chandler Carruth | c029186 | 2015-01-24 02:06:09 +0000 | [diff] [blame] | 1678 |  | 
| Chandler Carruth | b98f63d | 2015-01-15 10:41:28 +0000 | [diff] [blame] | 1679 | TargetLibraryInfoWrapperPass::TargetLibraryInfoWrapperPass() | 
| Chandler Carruth | c029186 | 2015-01-24 02:06:09 +0000 | [diff] [blame] | 1680 | : ImmutablePass(ID), TLIImpl(), TLI(TLIImpl) { | 
| Chandler Carruth | b98f63d | 2015-01-15 10:41:28 +0000 | [diff] [blame] | 1681 | initializeTargetLibraryInfoWrapperPassPass(*PassRegistry::getPassRegistry()); | 
|  | 1682 | } | 
|  | 1683 |  | 
|  | 1684 | TargetLibraryInfoWrapperPass::TargetLibraryInfoWrapperPass(const Triple &T) | 
| Chandler Carruth | c029186 | 2015-01-24 02:06:09 +0000 | [diff] [blame] | 1685 | : ImmutablePass(ID), TLIImpl(T), TLI(TLIImpl) { | 
| Chandler Carruth | b98f63d | 2015-01-15 10:41:28 +0000 | [diff] [blame] | 1686 | initializeTargetLibraryInfoWrapperPassPass(*PassRegistry::getPassRegistry()); | 
|  | 1687 | } | 
|  | 1688 |  | 
|  | 1689 | TargetLibraryInfoWrapperPass::TargetLibraryInfoWrapperPass( | 
| Chandler Carruth | c029186 | 2015-01-24 02:06:09 +0000 | [diff] [blame] | 1690 | const TargetLibraryInfoImpl &TLIImpl) | 
|  | 1691 | : ImmutablePass(ID), TLIImpl(TLIImpl), TLI(this->TLIImpl) { | 
| Chandler Carruth | b98f63d | 2015-01-15 10:41:28 +0000 | [diff] [blame] | 1692 | initializeTargetLibraryInfoWrapperPassPass(*PassRegistry::getPassRegistry()); | 
|  | 1693 | } | 
|  | 1694 |  | 
| Chandler Carruth | dab4eae | 2016-11-23 17:53:26 +0000 | [diff] [blame] | 1695 | AnalysisKey TargetLibraryAnalysis::Key; | 
| NAKAMURA Takumi | df0cd72 | 2016-02-28 17:17:00 +0000 | [diff] [blame] | 1696 |  | 
| Chandler Carruth | b98f63d | 2015-01-15 10:41:28 +0000 | [diff] [blame] | 1697 | // Register the basic pass. | 
|  | 1698 | INITIALIZE_PASS(TargetLibraryInfoWrapperPass, "targetlibinfo", | 
|  | 1699 | "Target Library Information", false, true) | 
|  | 1700 | char TargetLibraryInfoWrapperPass::ID = 0; | 
|  | 1701 |  | 
|  | 1702 | void TargetLibraryInfoWrapperPass::anchor() {} |