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