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