1 //===-- llvm/Target/TargetLibraryInfo.h - Library information ---*- C++ -*-===// 2 // 3 // The LLVM Compiler Infrastructure 4 // 5 // This file is distributed under the University of Illinois Open Source 6 // License. See LICENSE.TXT for details. 7 // 8 //===----------------------------------------------------------------------===// 9 10 #ifndef LLVM_TARGET_TARGETLIBRARYINFO_H 11 #define LLVM_TARGET_TARGETLIBRARYINFO_H 12 13 #include "llvm/ADT/DenseMap.h" 14 #include "llvm/Pass.h" 15 16 namespace llvm { 17 class Triple; 18 19 namespace LibFunc { 20 enum Func { 21 /// int _IO_getc(_IO_FILE * __fp); 22 under_IO_getc, 23 /// int _IO_putc(int __c, _IO_FILE * __fp); 24 under_IO_putc, 25 /// void operator delete[](void*); 26 ZdaPv, 27 /// void operator delete[](void*, nothrow); 28 ZdaPvRKSt9nothrow_t, 29 /// void operator delete(void*); 30 ZdlPv, 31 /// void operator delete(void*, nothrow); 32 ZdlPvRKSt9nothrow_t, 33 /// void *new[](unsigned int); 34 Znaj, 35 /// void *new[](unsigned int, nothrow); 36 ZnajRKSt9nothrow_t, 37 /// void *new[](unsigned long); 38 Znam, 39 /// void *new[](unsigned long, nothrow); 40 ZnamRKSt9nothrow_t, 41 /// void *new(unsigned int); 42 Znwj, 43 /// void *new(unsigned int, nothrow); 44 ZnwjRKSt9nothrow_t, 45 /// void *new(unsigned long); 46 Znwm, 47 /// void *new(unsigned long, nothrow); 48 ZnwmRKSt9nothrow_t, 49 /// int __cxa_atexit(void (*f)(void *), void *p, void *d); 50 cxa_atexit, 51 /// void __cxa_guard_abort(guard_t *guard); 52 /// guard_t is int64_t in Itanium ABI or int32_t on ARM eabi. 53 cxa_guard_abort, 54 /// int __cxa_guard_acquire(guard_t *guard); 55 cxa_guard_acquire, 56 /// void __cxa_guard_release(guard_t *guard); 57 cxa_guard_release, 58 /// int __isoc99_scanf (const char *format, ...) 59 dunder_isoc99_scanf, 60 /// int __isoc99_sscanf(const char *s, const char *format, ...) 61 dunder_isoc99_sscanf, 62 /// void *__memcpy_chk(void *s1, const void *s2, size_t n, size_t s1size); 63 memcpy_chk, 64 /// double __sqrt_finite(double x); 65 sqrt_finite, 66 /// float __sqrt_finite(float x); 67 sqrtf_finite, 68 /// long double __sqrt_finite(long double x); 69 sqrtl_finite, 70 /// char * __strdup(const char *s); 71 dunder_strdup, 72 /// char *__strndup(const char *s, size_t n); 73 dunder_strndup, 74 /// char * __strtok_r(char *s, const char *delim, char **save_ptr); 75 dunder_strtok_r, 76 /// int abs(int j); 77 abs, 78 /// int access(const char *path, int amode); 79 access, 80 /// double acos(double x); 81 acos, 82 /// float acosf(float x); 83 acosf, 84 /// double acosh(double x); 85 acosh, 86 /// float acoshf(float x); 87 acoshf, 88 /// long double acoshl(long double x); 89 acoshl, 90 /// long double acosl(long double x); 91 acosl, 92 /// double asin(double x); 93 asin, 94 /// float asinf(float x); 95 asinf, 96 /// double asinh(double x); 97 asinh, 98 /// float asinhf(float x); 99 asinhf, 100 /// long double asinhl(long double x); 101 asinhl, 102 /// long double asinl(long double x); 103 asinl, 104 /// double atan(double x); 105 atan, 106 /// double atan2(double y, double x); 107 atan2, 108 /// float atan2f(float y, float x); 109 atan2f, 110 /// long double atan2l(long double y, long double x); 111 atan2l, 112 /// float atanf(float x); 113 atanf, 114 /// double atanh(double x); 115 atanh, 116 /// float atanhf(float x); 117 atanhf, 118 /// long double atanhl(long double x); 119 atanhl, 120 /// long double atanl(long double x); 121 atanl, 122 /// double atof(const char *str); 123 atof, 124 /// int atoi(const char *str); 125 atoi, 126 /// long atol(const char *str); 127 atol, 128 /// long long atoll(const char *nptr); 129 atoll, 130 /// int bcmp(const void *s1, const void *s2, size_t n); 131 bcmp, 132 /// void bcopy(const void *s1, void *s2, size_t n); 133 bcopy, 134 /// void bzero(void *s, size_t n); 135 bzero, 136 /// void *calloc(size_t count, size_t size); 137 calloc, 138 /// double cbrt(double x); 139 cbrt, 140 /// float cbrtf(float x); 141 cbrtf, 142 /// long double cbrtl(long double x); 143 cbrtl, 144 /// double ceil(double x); 145 ceil, 146 /// float ceilf(float x); 147 ceilf, 148 /// long double ceill(long double x); 149 ceill, 150 /// int chmod(const char *path, mode_t mode); 151 chmod, 152 /// int chown(const char *path, uid_t owner, gid_t group); 153 chown, 154 /// void clearerr(FILE *stream); 155 clearerr, 156 /// int closedir(DIR *dirp); 157 closedir, 158 /// double copysign(double x, double y); 159 copysign, 160 /// float copysignf(float x, float y); 161 copysignf, 162 /// long double copysignl(long double x, long double y); 163 copysignl, 164 /// double cos(double x); 165 cos, 166 /// float cosf(float x); 167 cosf, 168 /// double cosh(double x); 169 cosh, 170 /// float coshf(float x); 171 coshf, 172 /// long double coshl(long double x); 173 coshl, 174 /// long double cosl(long double x); 175 cosl, 176 /// char *ctermid(char *s); 177 ctermid, 178 /// double exp(double x); 179 exp, 180 /// double exp10(double x); 181 exp10, 182 /// float exp10f(float x); 183 exp10f, 184 /// long double exp10l(long double x); 185 exp10l, 186 /// double exp2(double x); 187 exp2, 188 /// float exp2f(float x); 189 exp2f, 190 /// long double exp2l(long double x); 191 exp2l, 192 /// float expf(float x); 193 expf, 194 /// long double expl(long double x); 195 expl, 196 /// double expm1(double x); 197 expm1, 198 /// float expm1f(float x); 199 expm1f, 200 /// long double expm1l(long double x); 201 expm1l, 202 /// double fabs(double x); 203 fabs, 204 /// float fabsf(float x); 205 fabsf, 206 /// long double fabsl(long double x); 207 fabsl, 208 /// int fclose(FILE *stream); 209 fclose, 210 /// FILE *fdopen(int fildes, const char *mode); 211 fdopen, 212 /// int feof(FILE *stream); 213 feof, 214 /// int ferror(FILE *stream); 215 ferror, 216 /// int fflush(FILE *stream); 217 fflush, 218 /// int ffs(int i); 219 ffs, 220 /// int ffsl(long int i); 221 ffsl, 222 /// int ffsll(long long int i); 223 ffsll, 224 /// int fgetc(FILE *stream); 225 fgetc, 226 /// int fgetpos(FILE *stream, fpos_t *pos); 227 fgetpos, 228 /// char *fgets(char *s, int n, FILE *stream); 229 fgets, 230 /// int fileno(FILE *stream); 231 fileno, 232 /// int fiprintf(FILE *stream, const char *format, ...); 233 fiprintf, 234 /// void flockfile(FILE *file); 235 flockfile, 236 /// double floor(double x); 237 floor, 238 /// float floorf(float x); 239 floorf, 240 /// long double floorl(long double x); 241 floorl, 242 /// double fmod(double x, double y); 243 fmod, 244 /// float fmodf(float x, float y); 245 fmodf, 246 /// long double fmodl(long double x, long double y); 247 fmodl, 248 /// FILE *fopen(const char *filename, const char *mode); 249 fopen, 250 /// FILE *fopen64(const char *filename, const char *opentype) 251 fopen64, 252 /// int fprintf(FILE *stream, const char *format, ...); 253 fprintf, 254 /// int fputc(int c, FILE *stream); 255 fputc, 256 /// int fputs(const char *s, FILE *stream); 257 fputs, 258 /// size_t fread(void *ptr, size_t size, size_t nitems, FILE *stream); 259 fread, 260 /// void free(void *ptr); 261 free, 262 /// double frexp(double num, int *exp); 263 frexp, 264 /// float frexpf(float num, int *exp); 265 frexpf, 266 /// long double frexpl(long double num, int *exp); 267 frexpl, 268 /// int fscanf(FILE *stream, const char *format, ... ); 269 fscanf, 270 /// int fseek(FILE *stream, long offset, int whence); 271 fseek, 272 /// int fseeko(FILE *stream, off_t offset, int whence); 273 fseeko, 274 /// int fseeko64(FILE *stream, off64_t offset, int whence) 275 fseeko64, 276 /// int fsetpos(FILE *stream, const fpos_t *pos); 277 fsetpos, 278 /// int fstat(int fildes, struct stat *buf); 279 fstat, 280 /// int fstat64(int filedes, struct stat64 *buf) 281 fstat64, 282 /// int fstatvfs(int fildes, struct statvfs *buf); 283 fstatvfs, 284 /// int fstatvfs64(int fildes, struct statvfs64 *buf); 285 fstatvfs64, 286 /// long ftell(FILE *stream); 287 ftell, 288 /// off_t ftello(FILE *stream); 289 ftello, 290 /// off64_t ftello64(FILE *stream) 291 ftello64, 292 /// int ftrylockfile(FILE *file); 293 ftrylockfile, 294 /// void funlockfile(FILE *file); 295 funlockfile, 296 /// size_t fwrite(const void *ptr, size_t size, size_t nitems, 297 /// FILE *stream); 298 fwrite, 299 /// int getc(FILE *stream); 300 getc, 301 /// int getc_unlocked(FILE *stream); 302 getc_unlocked, 303 /// int getchar(void); 304 getchar, 305 /// char *getenv(const char *name); 306 getenv, 307 /// int getitimer(int which, struct itimerval *value); 308 getitimer, 309 /// int getlogin_r(char *name, size_t namesize); 310 getlogin_r, 311 /// struct passwd *getpwnam(const char *name); 312 getpwnam, 313 /// char *gets(char *s); 314 gets, 315 /// int gettimeofday(struct timeval *tp, void *tzp); 316 gettimeofday, 317 /// uint32_t htonl(uint32_t hostlong); 318 htonl, 319 /// uint16_t htons(uint16_t hostshort); 320 htons, 321 /// int iprintf(const char *format, ...); 322 iprintf, 323 /// int isascii(int c); 324 isascii, 325 /// int isdigit(int c); 326 isdigit, 327 /// long int labs(long int j); 328 labs, 329 /// int lchown(const char *path, uid_t owner, gid_t group); 330 lchown, 331 /// long long int llabs(long long int j); 332 llabs, 333 /// double log(double x); 334 log, 335 /// double log10(double x); 336 log10, 337 /// float log10f(float x); 338 log10f, 339 /// long double log10l(long double x); 340 log10l, 341 /// double log1p(double x); 342 log1p, 343 /// float log1pf(float x); 344 log1pf, 345 /// long double log1pl(long double x); 346 log1pl, 347 /// double log2(double x); 348 log2, 349 /// float log2f(float x); 350 log2f, 351 /// double long double log2l(long double x); 352 log2l, 353 /// double logb(double x); 354 logb, 355 /// float logbf(float x); 356 logbf, 357 /// long double logbl(long double x); 358 logbl, 359 /// float logf(float x); 360 logf, 361 /// long double logl(long double x); 362 logl, 363 /// int lstat(const char *path, struct stat *buf); 364 lstat, 365 /// int lstat64(const char *path, struct stat64 *buf); 366 lstat64, 367 /// void *malloc(size_t size); 368 malloc, 369 /// void *memalign(size_t boundary, size_t size); 370 memalign, 371 /// void *memccpy(void *s1, const void *s2, int c, size_t n); 372 memccpy, 373 /// void *memchr(const void *s, int c, size_t n); 374 memchr, 375 /// int memcmp(const void *s1, const void *s2, size_t n); 376 memcmp, 377 /// void *memcpy(void *s1, const void *s2, size_t n); 378 memcpy, 379 /// void *memmove(void *s1, const void *s2, size_t n); 380 memmove, 381 // void *memrchr(const void *s, int c, size_t n); 382 memrchr, 383 /// void *memset(void *b, int c, size_t len); 384 memset, 385 /// void memset_pattern16(void *b, const void *pattern16, size_t len); 386 memset_pattern16, 387 /// int mkdir(const char *path, mode_t mode); 388 mkdir, 389 /// time_t mktime(struct tm *timeptr); 390 mktime, 391 /// double modf(double x, double *iptr); 392 modf, 393 /// float modff(float, float *iptr); 394 modff, 395 /// long double modfl(long double value, long double *iptr); 396 modfl, 397 /// double nearbyint(double x); 398 nearbyint, 399 /// float nearbyintf(float x); 400 nearbyintf, 401 /// long double nearbyintl(long double x); 402 nearbyintl, 403 /// uint32_t ntohl(uint32_t netlong); 404 ntohl, 405 /// uint16_t ntohs(uint16_t netshort); 406 ntohs, 407 /// int open(const char *path, int oflag, ... ); 408 open, 409 /// int open64(const char *filename, int flags[, mode_t mode]) 410 open64, 411 /// DIR *opendir(const char *dirname); 412 opendir, 413 /// int pclose(FILE *stream); 414 pclose, 415 /// void perror(const char *s); 416 perror, 417 /// FILE *popen(const char *command, const char *mode); 418 popen, 419 /// int posix_memalign(void **memptr, size_t alignment, size_t size); 420 posix_memalign, 421 /// double pow(double x, double y); 422 pow, 423 /// float powf(float x, float y); 424 powf, 425 /// long double powl(long double x, long double y); 426 powl, 427 /// ssize_t pread(int fildes, void *buf, size_t nbyte, off_t offset); 428 pread, 429 /// int printf(const char *format, ...); 430 printf, 431 /// int putc(int c, FILE *stream); 432 putc, 433 /// int putchar(int c); 434 putchar, 435 /// int puts(const char *s); 436 puts, 437 /// ssize_t pwrite(int fildes, const void *buf, size_t nbyte, 438 /// off_t offset); 439 pwrite, 440 /// void qsort(void *base, size_t nel, size_t width, 441 /// int (*compar)(const void *, const void *)); 442 qsort, 443 /// ssize_t read(int fildes, void *buf, size_t nbyte); 444 read, 445 /// ssize_t readlink(const char *path, char *buf, size_t bufsize); 446 readlink, 447 /// void *realloc(void *ptr, size_t size); 448 realloc, 449 /// void *reallocf(void *ptr, size_t size); 450 reallocf, 451 /// char *realpath(const char *file_name, char *resolved_name); 452 realpath, 453 /// int remove(const char *path); 454 remove, 455 /// int rename(const char *old, const char *new); 456 rename, 457 /// void rewind(FILE *stream); 458 rewind, 459 /// double rint(double x); 460 rint, 461 /// float rintf(float x); 462 rintf, 463 /// long double rintl(long double x); 464 rintl, 465 /// int rmdir(const char *path); 466 rmdir, 467 /// double round(double x); 468 round, 469 /// float roundf(float x); 470 roundf, 471 /// long double roundl(long double x); 472 roundl, 473 /// int scanf(const char *restrict format, ... ); 474 scanf, 475 /// void setbuf(FILE *stream, char *buf); 476 setbuf, 477 /// int setitimer(int which, const struct itimerval *value, 478 /// struct itimerval *ovalue); 479 setitimer, 480 /// int setvbuf(FILE *stream, char *buf, int type, size_t size); 481 setvbuf, 482 /// double sin(double x); 483 sin, 484 /// float sinf(float x); 485 sinf, 486 /// double sinh(double x); 487 sinh, 488 /// float sinhf(float x); 489 sinhf, 490 /// long double sinhl(long double x); 491 sinhl, 492 /// long double sinl(long double x); 493 sinl, 494 /// int siprintf(char *str, const char *format, ...); 495 siprintf, 496 /// int snprintf(char *s, size_t n, const char *format, ...); 497 snprintf, 498 /// int sprintf(char *str, const char *format, ...); 499 sprintf, 500 /// double sqrt(double x); 501 sqrt, 502 /// float sqrtf(float x); 503 sqrtf, 504 /// long double sqrtl(long double x); 505 sqrtl, 506 /// int sscanf(const char *s, const char *format, ... ); 507 sscanf, 508 /// int stat(const char *path, struct stat *buf); 509 stat, 510 /// int stat64(const char *path, struct stat64 *buf); 511 stat64, 512 /// int statvfs(const char *path, struct statvfs *buf); 513 statvfs, 514 /// int statvfs64(const char *path, struct statvfs64 *buf) 515 statvfs64, 516 /// char *stpcpy(char *s1, const char *s2); 517 stpcpy, 518 /// char *stpncpy(char *s1, const char *s2, size_t n); 519 stpncpy, 520 /// int strcasecmp(const char *s1, const char *s2); 521 strcasecmp, 522 /// char *strcat(char *s1, const char *s2); 523 strcat, 524 /// char *strchr(const char *s, int c); 525 strchr, 526 /// int strcmp(const char *s1, const char *s2); 527 strcmp, 528 /// int strcoll(const char *s1, const char *s2); 529 strcoll, 530 /// char *strcpy(char *s1, const char *s2); 531 strcpy, 532 /// size_t strcspn(const char *s1, const char *s2); 533 strcspn, 534 /// char *strdup(const char *s1); 535 strdup, 536 /// size_t strlen(const char *s); 537 strlen, 538 /// int strncasecmp(const char *s1, const char *s2, size_t n); 539 strncasecmp, 540 /// char *strncat(char *s1, const char *s2, size_t n); 541 strncat, 542 /// int strncmp(const char *s1, const char *s2, size_t n); 543 strncmp, 544 /// char *strncpy(char *s1, const char *s2, size_t n); 545 strncpy, 546 /// char *strndup(const char *s1, size_t n); 547 strndup, 548 /// size_t strnlen(const char *s, size_t maxlen); 549 strnlen, 550 /// char *strpbrk(const char *s1, const char *s2); 551 strpbrk, 552 /// char *strrchr(const char *s, int c); 553 strrchr, 554 /// size_t strspn(const char *s1, const char *s2); 555 strspn, 556 /// char *strstr(const char *s1, const char *s2); 557 strstr, 558 /// double strtod(const char *nptr, char **endptr); 559 strtod, 560 /// float strtof(const char *nptr, char **endptr); 561 strtof, 562 // char *strtok(char *s1, const char *s2); 563 strtok, 564 // char *strtok_r(char *s, const char *sep, char **lasts); 565 strtok_r, 566 /// long int strtol(const char *nptr, char **endptr, int base); 567 strtol, 568 /// long double strtold(const char *nptr, char **endptr); 569 strtold, 570 /// long long int strtoll(const char *nptr, char **endptr, int base); 571 strtoll, 572 /// unsigned long int strtoul(const char *nptr, char **endptr, int base); 573 strtoul, 574 /// unsigned long long int strtoull(const char *nptr, char **endptr, 575 /// int base); 576 strtoull, 577 /// size_t strxfrm(char *s1, const char *s2, size_t n); 578 strxfrm, 579 /// int system(const char *command); 580 system, 581 /// double tan(double x); 582 tan, 583 /// float tanf(float x); 584 tanf, 585 /// double tanh(double x); 586 tanh, 587 /// float tanhf(float x); 588 tanhf, 589 /// long double tanhl(long double x); 590 tanhl, 591 /// long double tanl(long double x); 592 tanl, 593 /// clock_t times(struct tms *buffer); 594 times, 595 /// FILE *tmpfile(void); 596 tmpfile, 597 /// FILE *tmpfile64(void) 598 tmpfile64, 599 /// int toascii(int c); 600 toascii, 601 /// double trunc(double x); 602 trunc, 603 /// float truncf(float x); 604 truncf, 605 /// long double truncl(long double x); 606 truncl, 607 /// int uname(struct utsname *name); 608 uname, 609 /// int ungetc(int c, FILE *stream); 610 ungetc, 611 /// int unlink(const char *path); 612 unlink, 613 /// int unsetenv(const char *name); 614 unsetenv, 615 /// int utime(const char *path, const struct utimbuf *times); 616 utime, 617 /// int utimes(const char *path, const struct timeval times[2]); 618 utimes, 619 /// void *valloc(size_t size); 620 valloc, 621 /// int vfprintf(FILE *stream, const char *format, va_list ap); 622 vfprintf, 623 /// int vfscanf(FILE *stream, const char *format, va_list arg); 624 vfscanf, 625 /// int vprintf(const char *restrict format, va_list ap); 626 vprintf, 627 /// int vscanf(const char *format, va_list arg); 628 vscanf, 629 /// int vsnprintf(char *s, size_t n, const char *format, va_list ap); 630 vsnprintf, 631 /// int vsprintf(char *s, const char *format, va_list ap); 632 vsprintf, 633 /// int vsscanf(const char *s, const char *format, va_list arg); 634 vsscanf, 635 /// ssize_t write(int fildes, const void *buf, size_t nbyte); 636 write, 637 638 NumLibFuncs 639 }; 640 } 641 642 /// TargetLibraryInfo - This immutable pass captures information about what 643 /// library functions are available for the current target, and allows a 644 /// frontend to disable optimizations through -fno-builtin etc. 645 class TargetLibraryInfo : public ImmutablePass { 646 virtual void anchor(); 647 unsigned char AvailableArray[(LibFunc::NumLibFuncs+3)/4]; 648 llvm::DenseMap<unsigned, std::string> CustomNames; 649 static const char* StandardNames[LibFunc::NumLibFuncs]; 650 651 enum AvailabilityState { 652 StandardName = 3, // (memset to all ones) 653 CustomName = 1, 654 Unavailable = 0 // (memset to all zeros) 655 }; setState(LibFunc::Func F,AvailabilityState State)656 void setState(LibFunc::Func F, AvailabilityState State) { 657 AvailableArray[F/4] &= ~(3 << 2*(F&3)); 658 AvailableArray[F/4] |= State << 2*(F&3); 659 } getState(LibFunc::Func F)660 AvailabilityState getState(LibFunc::Func F) const { 661 return static_cast<AvailabilityState>((AvailableArray[F/4] >> 2*(F&3)) & 3); 662 } 663 664 public: 665 static char ID; 666 TargetLibraryInfo(); 667 TargetLibraryInfo(const Triple &T); 668 explicit TargetLibraryInfo(const TargetLibraryInfo &TLI); 669 670 /// getLibFunc - Search for a particular function name. If it is one of the 671 /// known library functions, return true and set F to the corresponding value. 672 bool getLibFunc(StringRef funcName, LibFunc::Func &F) const; 673 674 /// has - This function is used by optimizations that want to match on or form 675 /// a given library function. has(LibFunc::Func F)676 bool has(LibFunc::Func F) const { 677 return getState(F) != Unavailable; 678 } 679 680 /// hasOptimizedCodeGen - Return true if the function is both available as 681 /// a builtin and a candidate for optimized code generation. hasOptimizedCodeGen(LibFunc::Func F)682 bool hasOptimizedCodeGen(LibFunc::Func F) const { 683 if (getState(F) == Unavailable) 684 return false; 685 switch (F) { 686 default: break; 687 case LibFunc::copysign: case LibFunc::copysignf: case LibFunc::copysignl: 688 case LibFunc::fabs: case LibFunc::fabsf: case LibFunc::fabsl: 689 case LibFunc::sin: case LibFunc::sinf: case LibFunc::sinl: 690 case LibFunc::cos: case LibFunc::cosf: case LibFunc::cosl: 691 case LibFunc::sqrt: case LibFunc::sqrtf: case LibFunc::sqrtl: 692 case LibFunc::sqrt_finite: case LibFunc::sqrtf_finite: 693 case LibFunc::sqrtl_finite: 694 case LibFunc::floor: case LibFunc::floorf: case LibFunc::floorl: 695 case LibFunc::nearbyint: case LibFunc::nearbyintf: case LibFunc::nearbyintl: 696 case LibFunc::ceil: case LibFunc::ceilf: case LibFunc::ceill: 697 case LibFunc::rint: case LibFunc::rintf: case LibFunc::rintl: 698 case LibFunc::trunc: case LibFunc::truncf: case LibFunc::truncl: 699 case LibFunc::log2: case LibFunc::log2f: case LibFunc::log2l: 700 case LibFunc::exp2: case LibFunc::exp2f: case LibFunc::exp2l: 701 case LibFunc::memcmp: 702 return true; 703 } 704 return false; 705 } 706 getName(LibFunc::Func F)707 StringRef getName(LibFunc::Func F) const { 708 AvailabilityState State = getState(F); 709 if (State == Unavailable) 710 return StringRef(); 711 if (State == StandardName) 712 return StandardNames[F]; 713 assert(State == CustomName); 714 return CustomNames.find(F)->second; 715 } 716 717 /// setUnavailable - this can be used by whatever sets up TargetLibraryInfo to 718 /// ban use of specific library functions. setUnavailable(LibFunc::Func F)719 void setUnavailable(LibFunc::Func F) { 720 setState(F, Unavailable); 721 } 722 setAvailable(LibFunc::Func F)723 void setAvailable(LibFunc::Func F) { 724 setState(F, StandardName); 725 } 726 setAvailableWithName(LibFunc::Func F,StringRef Name)727 void setAvailableWithName(LibFunc::Func F, StringRef Name) { 728 if (StandardNames[F] != Name) { 729 setState(F, CustomName); 730 CustomNames[F] = Name; 731 assert(CustomNames.find(F) != CustomNames.end()); 732 } else { 733 setState(F, StandardName); 734 } 735 } 736 737 /// disableAllFunctions - This disables all builtins, which is used for 738 /// options like -fno-builtin. 739 void disableAllFunctions(); 740 }; 741 742 } // end namespace llvm 743 744 #endif 745