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