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