LLVM API Documentation

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