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