LLVM API Documentation
00001 //===-- llvm/Target/TargetLibraryInfo.h - Library information ---*- C++ -*-===// 00002 // 00003 // The LLVM Compiler Infrastructure 00004 // 00005 // This file is distributed under the University of Illinois Open Source 00006 // License. See LICENSE.TXT for details. 00007 // 00008 //===----------------------------------------------------------------------===// 00009 00010 #ifndef LLVM_TARGET_TARGETLIBRARYINFO_H 00011 #define LLVM_TARGET_TARGETLIBRARYINFO_H 00012 00013 #include "llvm/ADT/DenseMap.h" 00014 #include "llvm/Pass.h" 00015 00016 namespace llvm { 00017 class Triple; 00018 00019 namespace LibFunc { 00020 enum Func { 00021 /// int _IO_getc(_IO_FILE * __fp); 00022 under_IO_getc, 00023 /// int _IO_putc(int __c, _IO_FILE * __fp); 00024 under_IO_putc, 00025 /// void operator delete[](void*); 00026 ZdaPv, 00027 /// void operator delete[](void*, nothrow); 00028 ZdaPvRKSt9nothrow_t, 00029 /// void operator delete(void*); 00030 ZdlPv, 00031 /// void operator delete(void*, nothrow); 00032 ZdlPvRKSt9nothrow_t, 00033 /// void *new[](unsigned int); 00034 Znaj, 00035 /// void *new[](unsigned int, nothrow); 00036 ZnajRKSt9nothrow_t, 00037 /// void *new[](unsigned long); 00038 Znam, 00039 /// void *new[](unsigned long, nothrow); 00040 ZnamRKSt9nothrow_t, 00041 /// void *new(unsigned int); 00042 Znwj, 00043 /// void *new(unsigned int, nothrow); 00044 ZnwjRKSt9nothrow_t, 00045 /// void *new(unsigned long); 00046 Znwm, 00047 /// void *new(unsigned long, nothrow); 00048 ZnwmRKSt9nothrow_t, 00049 /// double __cospi(double x); 00050 cospi, 00051 /// float __cospif(float x); 00052 cospif, 00053 /// int __cxa_atexit(void (*f)(void *), void *p, void *d); 00054 cxa_atexit, 00055 /// void __cxa_guard_abort(guard_t *guard); 00056 /// guard_t is int64_t in Itanium ABI or int32_t on ARM eabi. 00057 cxa_guard_abort, 00058 /// int __cxa_guard_acquire(guard_t *guard); 00059 cxa_guard_acquire, 00060 /// void __cxa_guard_release(guard_t *guard); 00061 cxa_guard_release, 00062 /// int __isoc99_scanf (const char *format, ...) 00063 dunder_isoc99_scanf, 00064 /// int __isoc99_sscanf(const char *s, const char *format, ...) 00065 dunder_isoc99_sscanf, 00066 /// void *__memcpy_chk(void *s1, const void *s2, size_t n, size_t s1size); 00067 memcpy_chk, 00068 /// double __sincospi_stret(double x); 00069 sincospi_stret, 00070 /// float __sincospif_stret(float x); 00071 sincospif_stret, 00072 /// double __sinpi(double x); 00073 sinpi, 00074 /// float __sinpif(float x); 00075 sinpif, 00076 /// double __sqrt_finite(double x); 00077 sqrt_finite, 00078 /// float __sqrt_finite(float x); 00079 sqrtf_finite, 00080 /// long double __sqrt_finite(long double x); 00081 sqrtl_finite, 00082 /// char * __strdup(const char *s); 00083 dunder_strdup, 00084 /// char *__strndup(const char *s, size_t n); 00085 dunder_strndup, 00086 /// char * __strtok_r(char *s, const char *delim, char **save_ptr); 00087 dunder_strtok_r, 00088 /// int abs(int j); 00089 abs, 00090 /// int access(const char *path, int amode); 00091 access, 00092 /// double acos(double x); 00093 acos, 00094 /// float acosf(float x); 00095 acosf, 00096 /// double acosh(double x); 00097 acosh, 00098 /// float acoshf(float x); 00099 acoshf, 00100 /// long double acoshl(long double x); 00101 acoshl, 00102 /// long double acosl(long double x); 00103 acosl, 00104 /// double asin(double x); 00105 asin, 00106 /// float asinf(float x); 00107 asinf, 00108 /// double asinh(double x); 00109 asinh, 00110 /// float asinhf(float x); 00111 asinhf, 00112 /// long double asinhl(long double x); 00113 asinhl, 00114 /// long double asinl(long double x); 00115 asinl, 00116 /// double atan(double x); 00117 atan, 00118 /// double atan2(double y, double x); 00119 atan2, 00120 /// float atan2f(float y, float x); 00121 atan2f, 00122 /// long double atan2l(long double y, long double x); 00123 atan2l, 00124 /// float atanf(float x); 00125 atanf, 00126 /// double atanh(double x); 00127 atanh, 00128 /// float atanhf(float x); 00129 atanhf, 00130 /// long double atanhl(long double x); 00131 atanhl, 00132 /// long double atanl(long double x); 00133 atanl, 00134 /// double atof(const char *str); 00135 atof, 00136 /// int atoi(const char *str); 00137 atoi, 00138 /// long atol(const char *str); 00139 atol, 00140 /// long long atoll(const char *nptr); 00141 atoll, 00142 /// int bcmp(const void *s1, const void *s2, size_t n); 00143 bcmp, 00144 /// void bcopy(const void *s1, void *s2, size_t n); 00145 bcopy, 00146 /// void bzero(void *s, size_t n); 00147 bzero, 00148 /// void *calloc(size_t count, size_t size); 00149 calloc, 00150 /// double cbrt(double x); 00151 cbrt, 00152 /// float cbrtf(float x); 00153 cbrtf, 00154 /// long double cbrtl(long double x); 00155 cbrtl, 00156 /// double ceil(double x); 00157 ceil, 00158 /// float ceilf(float x); 00159 ceilf, 00160 /// long double ceill(long double x); 00161 ceill, 00162 /// int chmod(const char *path, mode_t mode); 00163 chmod, 00164 /// int chown(const char *path, uid_t owner, gid_t group); 00165 chown, 00166 /// void clearerr(FILE *stream); 00167 clearerr, 00168 /// int closedir(DIR *dirp); 00169 closedir, 00170 /// double copysign(double x, double y); 00171 copysign, 00172 /// float copysignf(float x, float y); 00173 copysignf, 00174 /// long double copysignl(long double x, long double y); 00175 copysignl, 00176 /// double cos(double x); 00177 cos, 00178 /// float cosf(float x); 00179 cosf, 00180 /// double cosh(double x); 00181 cosh, 00182 /// float coshf(float x); 00183 coshf, 00184 /// long double coshl(long double x); 00185 coshl, 00186 /// long double cosl(long double x); 00187 cosl, 00188 /// char *ctermid(char *s); 00189 ctermid, 00190 /// double exp(double x); 00191 exp, 00192 /// double exp10(double x); 00193 exp10, 00194 /// float exp10f(float x); 00195 exp10f, 00196 /// long double exp10l(long double x); 00197 exp10l, 00198 /// double exp2(double x); 00199 exp2, 00200 /// float exp2f(float x); 00201 exp2f, 00202 /// long double exp2l(long double x); 00203 exp2l, 00204 /// float expf(float x); 00205 expf, 00206 /// long double expl(long double x); 00207 expl, 00208 /// double expm1(double x); 00209 expm1, 00210 /// float expm1f(float x); 00211 expm1f, 00212 /// long double expm1l(long double x); 00213 expm1l, 00214 /// double fabs(double x); 00215 fabs, 00216 /// float fabsf(float x); 00217 fabsf, 00218 /// long double fabsl(long double x); 00219 fabsl, 00220 /// int fclose(FILE *stream); 00221 fclose, 00222 /// FILE *fdopen(int fildes, const char *mode); 00223 fdopen, 00224 /// int feof(FILE *stream); 00225 feof, 00226 /// int ferror(FILE *stream); 00227 ferror, 00228 /// int fflush(FILE *stream); 00229 fflush, 00230 /// int ffs(int i); 00231 ffs, 00232 /// int ffsl(long int i); 00233 ffsl, 00234 /// int ffsll(long long int i); 00235 ffsll, 00236 /// int fgetc(FILE *stream); 00237 fgetc, 00238 /// int fgetpos(FILE *stream, fpos_t *pos); 00239 fgetpos, 00240 /// char *fgets(char *s, int n, FILE *stream); 00241 fgets, 00242 /// int fileno(FILE *stream); 00243 fileno, 00244 /// int fiprintf(FILE *stream, const char *format, ...); 00245 fiprintf, 00246 /// void flockfile(FILE *file); 00247 flockfile, 00248 /// double floor(double x); 00249 floor, 00250 /// float floorf(float x); 00251 floorf, 00252 /// long double floorl(long double x); 00253 floorl, 00254 /// double fmax(double x, double y); 00255 fmax, 00256 /// float fmaxf(float x, float y); 00257 fmaxf, 00258 /// long double fmaxl(long double x, long double y); 00259 fmaxl, 00260 /// double fmin(double x, double y); 00261 fmin, 00262 /// float fminf(float x, float y); 00263 fminf, 00264 /// long double fminl(long double x, long double y); 00265 fminl, 00266 /// double fmod(double x, double y); 00267 fmod, 00268 /// float fmodf(float x, float y); 00269 fmodf, 00270 /// long double fmodl(long double x, long double y); 00271 fmodl, 00272 /// FILE *fopen(const char *filename, const char *mode); 00273 fopen, 00274 /// FILE *fopen64(const char *filename, const char *opentype) 00275 fopen64, 00276 /// int fprintf(FILE *stream, const char *format, ...); 00277 fprintf, 00278 /// int fputc(int c, FILE *stream); 00279 fputc, 00280 /// int fputs(const char *s, FILE *stream); 00281 fputs, 00282 /// size_t fread(void *ptr, size_t size, size_t nitems, FILE *stream); 00283 fread, 00284 /// void free(void *ptr); 00285 free, 00286 /// double frexp(double num, int *exp); 00287 frexp, 00288 /// float frexpf(float num, int *exp); 00289 frexpf, 00290 /// long double frexpl(long double num, int *exp); 00291 frexpl, 00292 /// int fscanf(FILE *stream, const char *format, ... ); 00293 fscanf, 00294 /// int fseek(FILE *stream, long offset, int whence); 00295 fseek, 00296 /// int fseeko(FILE *stream, off_t offset, int whence); 00297 fseeko, 00298 /// int fseeko64(FILE *stream, off64_t offset, int whence) 00299 fseeko64, 00300 /// int fsetpos(FILE *stream, const fpos_t *pos); 00301 fsetpos, 00302 /// int fstat(int fildes, struct stat *buf); 00303 fstat, 00304 /// int fstat64(int filedes, struct stat64 *buf) 00305 fstat64, 00306 /// int fstatvfs(int fildes, struct statvfs *buf); 00307 fstatvfs, 00308 /// int fstatvfs64(int fildes, struct statvfs64 *buf); 00309 fstatvfs64, 00310 /// long ftell(FILE *stream); 00311 ftell, 00312 /// off_t ftello(FILE *stream); 00313 ftello, 00314 /// off64_t ftello64(FILE *stream) 00315 ftello64, 00316 /// int ftrylockfile(FILE *file); 00317 ftrylockfile, 00318 /// void funlockfile(FILE *file); 00319 funlockfile, 00320 /// size_t fwrite(const void *ptr, size_t size, size_t nitems, 00321 /// FILE *stream); 00322 fwrite, 00323 /// int getc(FILE *stream); 00324 getc, 00325 /// int getc_unlocked(FILE *stream); 00326 getc_unlocked, 00327 /// int getchar(void); 00328 getchar, 00329 /// char *getenv(const char *name); 00330 getenv, 00331 /// int getitimer(int which, struct itimerval *value); 00332 getitimer, 00333 /// int getlogin_r(char *name, size_t namesize); 00334 getlogin_r, 00335 /// struct passwd *getpwnam(const char *name); 00336 getpwnam, 00337 /// char *gets(char *s); 00338 gets, 00339 /// int gettimeofday(struct timeval *tp, void *tzp); 00340 gettimeofday, 00341 /// uint32_t htonl(uint32_t hostlong); 00342 htonl, 00343 /// uint16_t htons(uint16_t hostshort); 00344 htons, 00345 /// int iprintf(const char *format, ...); 00346 iprintf, 00347 /// int isascii(int c); 00348 isascii, 00349 /// int isdigit(int c); 00350 isdigit, 00351 /// long int labs(long int j); 00352 labs, 00353 /// int lchown(const char *path, uid_t owner, gid_t group); 00354 lchown, 00355 /// double ldexp(double x, int n); 00356 ldexp, 00357 /// float ldexpf(float x, int n); 00358 ldexpf, 00359 /// long double ldexpl(long double x, int n); 00360 ldexpl, 00361 /// long long int llabs(long long int j); 00362 llabs, 00363 /// double log(double x); 00364 log, 00365 /// double log10(double x); 00366 log10, 00367 /// float log10f(float x); 00368 log10f, 00369 /// long double log10l(long double x); 00370 log10l, 00371 /// double log1p(double x); 00372 log1p, 00373 /// float log1pf(float x); 00374 log1pf, 00375 /// long double log1pl(long double x); 00376 log1pl, 00377 /// double log2(double x); 00378 log2, 00379 /// float log2f(float x); 00380 log2f, 00381 /// double long double log2l(long double x); 00382 log2l, 00383 /// double logb(double x); 00384 logb, 00385 /// float logbf(float x); 00386 logbf, 00387 /// long double logbl(long double x); 00388 logbl, 00389 /// float logf(float x); 00390 logf, 00391 /// long double logl(long double x); 00392 logl, 00393 /// int lstat(const char *path, struct stat *buf); 00394 lstat, 00395 /// int lstat64(const char *path, struct stat64 *buf); 00396 lstat64, 00397 /// void *malloc(size_t size); 00398 malloc, 00399 /// void *memalign(size_t boundary, size_t size); 00400 memalign, 00401 /// void *memccpy(void *s1, const void *s2, int c, size_t n); 00402 memccpy, 00403 /// void *memchr(const void *s, int c, size_t n); 00404 memchr, 00405 /// int memcmp(const void *s1, const void *s2, size_t n); 00406 memcmp, 00407 /// void *memcpy(void *s1, const void *s2, size_t n); 00408 memcpy, 00409 /// void *memmove(void *s1, const void *s2, size_t n); 00410 memmove, 00411 // void *memrchr(const void *s, int c, size_t n); 00412 memrchr, 00413 /// void *memset(void *b, int c, size_t len); 00414 memset, 00415 /// void memset_pattern16(void *b, const void *pattern16, size_t len); 00416 memset_pattern16, 00417 /// int mkdir(const char *path, mode_t mode); 00418 mkdir, 00419 /// time_t mktime(struct tm *timeptr); 00420 mktime, 00421 /// double modf(double x, double *iptr); 00422 modf, 00423 /// float modff(float, float *iptr); 00424 modff, 00425 /// long double modfl(long double value, long double *iptr); 00426 modfl, 00427 /// double nearbyint(double x); 00428 nearbyint, 00429 /// float nearbyintf(float x); 00430 nearbyintf, 00431 /// long double nearbyintl(long double x); 00432 nearbyintl, 00433 /// uint32_t ntohl(uint32_t netlong); 00434 ntohl, 00435 /// uint16_t ntohs(uint16_t netshort); 00436 ntohs, 00437 /// int open(const char *path, int oflag, ... ); 00438 open, 00439 /// int open64(const char *filename, int flags[, mode_t mode]) 00440 open64, 00441 /// DIR *opendir(const char *dirname); 00442 opendir, 00443 /// int pclose(FILE *stream); 00444 pclose, 00445 /// void perror(const char *s); 00446 perror, 00447 /// FILE *popen(const char *command, const char *mode); 00448 popen, 00449 /// int posix_memalign(void **memptr, size_t alignment, size_t size); 00450 posix_memalign, 00451 /// double pow(double x, double y); 00452 pow, 00453 /// float powf(float x, float y); 00454 powf, 00455 /// long double powl(long double x, long double y); 00456 powl, 00457 /// ssize_t pread(int fildes, void *buf, size_t nbyte, off_t offset); 00458 pread, 00459 /// int printf(const char *format, ...); 00460 printf, 00461 /// int putc(int c, FILE *stream); 00462 putc, 00463 /// int putchar(int c); 00464 putchar, 00465 /// int puts(const char *s); 00466 puts, 00467 /// ssize_t pwrite(int fildes, const void *buf, size_t nbyte, 00468 /// off_t offset); 00469 pwrite, 00470 /// void qsort(void *base, size_t nel, size_t width, 00471 /// int (*compar)(const void *, const void *)); 00472 qsort, 00473 /// ssize_t read(int fildes, void *buf, size_t nbyte); 00474 read, 00475 /// ssize_t readlink(const char *path, char *buf, size_t bufsize); 00476 readlink, 00477 /// void *realloc(void *ptr, size_t size); 00478 realloc, 00479 /// void *reallocf(void *ptr, size_t size); 00480 reallocf, 00481 /// char *realpath(const char *file_name, char *resolved_name); 00482 realpath, 00483 /// int remove(const char *path); 00484 remove, 00485 /// int rename(const char *old, const char *new); 00486 rename, 00487 /// void rewind(FILE *stream); 00488 rewind, 00489 /// double rint(double x); 00490 rint, 00491 /// float rintf(float x); 00492 rintf, 00493 /// long double rintl(long double x); 00494 rintl, 00495 /// int rmdir(const char *path); 00496 rmdir, 00497 /// double round(double x); 00498 round, 00499 /// float roundf(float x); 00500 roundf, 00501 /// long double roundl(long double x); 00502 roundl, 00503 /// int scanf(const char *restrict format, ... ); 00504 scanf, 00505 /// void setbuf(FILE *stream, char *buf); 00506 setbuf, 00507 /// int setitimer(int which, const struct itimerval *value, 00508 /// struct itimerval *ovalue); 00509 setitimer, 00510 /// int setvbuf(FILE *stream, char *buf, int type, size_t size); 00511 setvbuf, 00512 /// double sin(double x); 00513 sin, 00514 /// float sinf(float x); 00515 sinf, 00516 /// double sinh(double x); 00517 sinh, 00518 /// float sinhf(float x); 00519 sinhf, 00520 /// long double sinhl(long double x); 00521 sinhl, 00522 /// long double sinl(long double x); 00523 sinl, 00524 /// int siprintf(char *str, const char *format, ...); 00525 siprintf, 00526 /// int snprintf(char *s, size_t n, const char *format, ...); 00527 snprintf, 00528 /// int sprintf(char *str, const char *format, ...); 00529 sprintf, 00530 /// double sqrt(double x); 00531 sqrt, 00532 /// float sqrtf(float x); 00533 sqrtf, 00534 /// long double sqrtl(long double x); 00535 sqrtl, 00536 /// int sscanf(const char *s, const char *format, ... ); 00537 sscanf, 00538 /// int stat(const char *path, struct stat *buf); 00539 stat, 00540 /// int stat64(const char *path, struct stat64 *buf); 00541 stat64, 00542 /// int statvfs(const char *path, struct statvfs *buf); 00543 statvfs, 00544 /// int statvfs64(const char *path, struct statvfs64 *buf) 00545 statvfs64, 00546 /// char *stpcpy(char *s1, const char *s2); 00547 stpcpy, 00548 /// char *stpncpy(char *s1, const char *s2, size_t n); 00549 stpncpy, 00550 /// int strcasecmp(const char *s1, const char *s2); 00551 strcasecmp, 00552 /// char *strcat(char *s1, const char *s2); 00553 strcat, 00554 /// char *strchr(const char *s, int c); 00555 strchr, 00556 /// int strcmp(const char *s1, const char *s2); 00557 strcmp, 00558 /// int strcoll(const char *s1, const char *s2); 00559 strcoll, 00560 /// char *strcpy(char *s1, const char *s2); 00561 strcpy, 00562 /// size_t strcspn(const char *s1, const char *s2); 00563 strcspn, 00564 /// char *strdup(const char *s1); 00565 strdup, 00566 /// size_t strlen(const char *s); 00567 strlen, 00568 /// int strncasecmp(const char *s1, const char *s2, size_t n); 00569 strncasecmp, 00570 /// char *strncat(char *s1, const char *s2, size_t n); 00571 strncat, 00572 /// int strncmp(const char *s1, const char *s2, size_t n); 00573 strncmp, 00574 /// char *strncpy(char *s1, const char *s2, size_t n); 00575 strncpy, 00576 /// char *strndup(const char *s1, size_t n); 00577 strndup, 00578 /// size_t strnlen(const char *s, size_t maxlen); 00579 strnlen, 00580 /// char *strpbrk(const char *s1, const char *s2); 00581 strpbrk, 00582 /// char *strrchr(const char *s, int c); 00583 strrchr, 00584 /// size_t strspn(const char *s1, const char *s2); 00585 strspn, 00586 /// char *strstr(const char *s1, const char *s2); 00587 strstr, 00588 /// double strtod(const char *nptr, char **endptr); 00589 strtod, 00590 /// float strtof(const char *nptr, char **endptr); 00591 strtof, 00592 // char *strtok(char *s1, const char *s2); 00593 strtok, 00594 // char *strtok_r(char *s, const char *sep, char **lasts); 00595 strtok_r, 00596 /// long int strtol(const char *nptr, char **endptr, int base); 00597 strtol, 00598 /// long double strtold(const char *nptr, char **endptr); 00599 strtold, 00600 /// long long int strtoll(const char *nptr, char **endptr, int base); 00601 strtoll, 00602 /// unsigned long int strtoul(const char *nptr, char **endptr, int base); 00603 strtoul, 00604 /// unsigned long long int strtoull(const char *nptr, char **endptr, 00605 /// int base); 00606 strtoull, 00607 /// size_t strxfrm(char *s1, const char *s2, size_t n); 00608 strxfrm, 00609 /// int system(const char *command); 00610 system, 00611 /// double tan(double x); 00612 tan, 00613 /// float tanf(float x); 00614 tanf, 00615 /// double tanh(double x); 00616 tanh, 00617 /// float tanhf(float x); 00618 tanhf, 00619 /// long double tanhl(long double x); 00620 tanhl, 00621 /// long double tanl(long double x); 00622 tanl, 00623 /// clock_t times(struct tms *buffer); 00624 times, 00625 /// FILE *tmpfile(void); 00626 tmpfile, 00627 /// FILE *tmpfile64(void) 00628 tmpfile64, 00629 /// int toascii(int c); 00630 toascii, 00631 /// double trunc(double x); 00632 trunc, 00633 /// float truncf(float x); 00634 truncf, 00635 /// long double truncl(long double x); 00636 truncl, 00637 /// int uname(struct utsname *name); 00638 uname, 00639 /// int ungetc(int c, FILE *stream); 00640 ungetc, 00641 /// int unlink(const char *path); 00642 unlink, 00643 /// int unsetenv(const char *name); 00644 unsetenv, 00645 /// int utime(const char *path, const struct utimbuf *times); 00646 utime, 00647 /// int utimes(const char *path, const struct timeval times[2]); 00648 utimes, 00649 /// void *valloc(size_t size); 00650 valloc, 00651 /// int vfprintf(FILE *stream, const char *format, va_list ap); 00652 vfprintf, 00653 /// int vfscanf(FILE *stream, const char *format, va_list arg); 00654 vfscanf, 00655 /// int vprintf(const char *restrict format, va_list ap); 00656 vprintf, 00657 /// int vscanf(const char *format, va_list arg); 00658 vscanf, 00659 /// int vsnprintf(char *s, size_t n, const char *format, va_list ap); 00660 vsnprintf, 00661 /// int vsprintf(char *s, const char *format, va_list ap); 00662 vsprintf, 00663 /// int vsscanf(const char *s, const char *format, va_list arg); 00664 vsscanf, 00665 /// ssize_t write(int fildes, const void *buf, size_t nbyte); 00666 write, 00667 00668 NumLibFuncs 00669 }; 00670 } 00671 00672 /// TargetLibraryInfo - This immutable pass captures information about what 00673 /// library functions are available for the current target, and allows a 00674 /// frontend to disable optimizations through -fno-builtin etc. 00675 class TargetLibraryInfo : public ImmutablePass { 00676 virtual void anchor(); 00677 unsigned char AvailableArray[(LibFunc::NumLibFuncs+3)/4]; 00678 llvm::DenseMap<unsigned, std::string> CustomNames; 00679 static const char* StandardNames[LibFunc::NumLibFuncs]; 00680 00681 enum AvailabilityState { 00682 StandardName = 3, // (memset to all ones) 00683 CustomName = 1, 00684 Unavailable = 0 // (memset to all zeros) 00685 }; 00686 void setState(LibFunc::Func F, AvailabilityState State) { 00687 AvailableArray[F/4] &= ~(3 << 2*(F&3)); 00688 AvailableArray[F/4] |= State << 2*(F&3); 00689 } 00690 AvailabilityState getState(LibFunc::Func F) const { 00691 return static_cast<AvailabilityState>((AvailableArray[F/4] >> 2*(F&3)) & 3); 00692 } 00693 00694 public: 00695 static char ID; 00696 TargetLibraryInfo(); 00697 TargetLibraryInfo(const Triple &T); 00698 explicit TargetLibraryInfo(const TargetLibraryInfo &TLI); 00699 00700 /// getLibFunc - Search for a particular function name. If it is one of the 00701 /// known library functions, return true and set F to the corresponding value. 00702 bool getLibFunc(StringRef funcName, LibFunc::Func &F) const; 00703 00704 /// has - This function is used by optimizations that want to match on or form 00705 /// a given library function. 00706 bool has(LibFunc::Func F) const { 00707 return getState(F) != Unavailable; 00708 } 00709 00710 /// hasOptimizedCodeGen - Return true if the function is both available as 00711 /// a builtin and a candidate for optimized code generation. 00712 bool hasOptimizedCodeGen(LibFunc::Func F) const { 00713 if (getState(F) == Unavailable) 00714 return false; 00715 switch (F) { 00716 default: break; 00717 case LibFunc::copysign: case LibFunc::copysignf: case LibFunc::copysignl: 00718 case LibFunc::fabs: case LibFunc::fabsf: case LibFunc::fabsl: 00719 case LibFunc::sin: case LibFunc::sinf: case LibFunc::sinl: 00720 case LibFunc::cos: case LibFunc::cosf: case LibFunc::cosl: 00721 case LibFunc::sqrt: case LibFunc::sqrtf: case LibFunc::sqrtl: 00722 case LibFunc::sqrt_finite: case LibFunc::sqrtf_finite: 00723 case LibFunc::sqrtl_finite: 00724 case LibFunc::fmax: case LibFunc::fmaxf: case LibFunc::fmaxl: 00725 case LibFunc::fmin: case LibFunc::fminf: case LibFunc::fminl: 00726 case LibFunc::floor: case LibFunc::floorf: case LibFunc::floorl: 00727 case LibFunc::nearbyint: case LibFunc::nearbyintf: case LibFunc::nearbyintl: 00728 case LibFunc::ceil: case LibFunc::ceilf: case LibFunc::ceill: 00729 case LibFunc::rint: case LibFunc::rintf: case LibFunc::rintl: 00730 case LibFunc::round: case LibFunc::roundf: case LibFunc::roundl: 00731 case LibFunc::trunc: case LibFunc::truncf: case LibFunc::truncl: 00732 case LibFunc::log2: case LibFunc::log2f: case LibFunc::log2l: 00733 case LibFunc::exp2: case LibFunc::exp2f: case LibFunc::exp2l: 00734 case LibFunc::memcmp: case LibFunc::strcmp: case LibFunc::strcpy: 00735 case LibFunc::stpcpy: case LibFunc::strlen: case LibFunc::strnlen: 00736 case LibFunc::memchr: 00737 return true; 00738 } 00739 return false; 00740 } 00741 00742 StringRef getName(LibFunc::Func F) const { 00743 AvailabilityState State = getState(F); 00744 if (State == Unavailable) 00745 return StringRef(); 00746 if (State == StandardName) 00747 return StandardNames[F]; 00748 assert(State == CustomName); 00749 return CustomNames.find(F)->second; 00750 } 00751 00752 /// setUnavailable - this can be used by whatever sets up TargetLibraryInfo to 00753 /// ban use of specific library functions. 00754 void setUnavailable(LibFunc::Func F) { 00755 setState(F, Unavailable); 00756 } 00757 00758 void setAvailable(LibFunc::Func F) { 00759 setState(F, StandardName); 00760 } 00761 00762 void setAvailableWithName(LibFunc::Func F, StringRef Name) { 00763 if (StandardNames[F] != Name) { 00764 setState(F, CustomName); 00765 CustomNames[F] = Name; 00766 assert(CustomNames.find(F) != CustomNames.end()); 00767 } else { 00768 setState(F, StandardName); 00769 } 00770 } 00771 00772 /// disableAllFunctions - This disables all builtins, which is used for 00773 /// options like -fno-builtin. 00774 void disableAllFunctions(); 00775 }; 00776 00777 } // end namespace llvm 00778 00779 #endif