1218885Sdim//===-- llvm/Target/TargetLibraryInfo.h - Library information ---*- C++ -*-===//
2218885Sdim//
3218885Sdim//                     The LLVM Compiler Infrastructure
4218885Sdim//
5218885Sdim// This file is distributed under the University of Illinois Open Source
6218885Sdim// License. See LICENSE.TXT for details.
7218885Sdim//
8218885Sdim//===----------------------------------------------------------------------===//
9218885Sdim
10218885Sdim#ifndef LLVM_TARGET_TARGETLIBRARYINFO_H
11218885Sdim#define LLVM_TARGET_TARGETLIBRARYINFO_H
12218885Sdim
13249423Sdim#include "llvm/ADT/DenseMap.h"
14218885Sdim#include "llvm/Pass.h"
15218885Sdim
16218885Sdimnamespace llvm {
17218885Sdim  class Triple;
18218885Sdim
19218885Sdim  namespace LibFunc {
20218885Sdim    enum Func {
21249423Sdim      /// int _IO_getc(_IO_FILE * __fp);
22249423Sdim      under_IO_getc,
23249423Sdim      /// int _IO_putc(int __c, _IO_FILE * __fp);
24249423Sdim      under_IO_putc,
25243830Sdim      /// void operator delete[](void*);
26243830Sdim      ZdaPv,
27263508Sdim      /// void operator delete[](void*, nothrow);
28263508Sdim      ZdaPvRKSt9nothrow_t,
29243830Sdim      /// void operator delete(void*);
30243830Sdim      ZdlPv,
31263508Sdim      /// void operator delete(void*, nothrow);
32263508Sdim      ZdlPvRKSt9nothrow_t,
33243830Sdim      /// void *new[](unsigned int);
34243830Sdim      Znaj,
35243830Sdim      /// void *new[](unsigned int, nothrow);
36243830Sdim      ZnajRKSt9nothrow_t,
37243830Sdim      /// void *new[](unsigned long);
38243830Sdim      Znam,
39243830Sdim      /// void *new[](unsigned long, nothrow);
40243830Sdim      ZnamRKSt9nothrow_t,
41243830Sdim      /// void *new(unsigned int);
42243830Sdim      Znwj,
43243830Sdim      /// void *new(unsigned int, nothrow);
44243830Sdim      ZnwjRKSt9nothrow_t,
45243830Sdim      /// void *new(unsigned long);
46243830Sdim      Znwm,
47243830Sdim      /// void *new(unsigned long, nothrow);
48243830Sdim      ZnwmRKSt9nothrow_t,
49263508Sdim      /// double __cospi(double x);
50263508Sdim      cospi,
51263508Sdim      /// float __cospif(float x);
52263508Sdim      cospif,
53239462Sdim      /// int __cxa_atexit(void (*f)(void *), void *p, void *d);
54239462Sdim      cxa_atexit,
55239462Sdim      /// void __cxa_guard_abort(guard_t *guard);
56239462Sdim      /// guard_t is int64_t in Itanium ABI or int32_t on ARM eabi.
57239462Sdim      cxa_guard_abort,
58239462Sdim      /// int __cxa_guard_acquire(guard_t *guard);
59239462Sdim      cxa_guard_acquire,
60239462Sdim      /// void __cxa_guard_release(guard_t *guard);
61239462Sdim      cxa_guard_release,
62249423Sdim      /// int __isoc99_scanf (const char *format, ...)
63249423Sdim      dunder_isoc99_scanf,
64249423Sdim      /// int __isoc99_sscanf(const char *s, const char *format, ...)
65249423Sdim      dunder_isoc99_sscanf,
66239462Sdim      /// void *__memcpy_chk(void *s1, const void *s2, size_t n, size_t s1size);
67239462Sdim      memcpy_chk,
68263508Sdim      /// double __sincospi_stret(double x);
69263508Sdim      sincospi_stret,
70263508Sdim      /// float __sincospi_stretf(float x);
71263508Sdim      sincospi_stretf,
72263508Sdim      /// double __sinpi(double x);
73263508Sdim      sinpi,
74263508Sdim      /// float __sinpif(float x);
75263508Sdim      sinpif,
76263508Sdim      /// double __sqrt_finite(double x);
77263508Sdim      sqrt_finite,
78263508Sdim      /// float __sqrt_finite(float x);
79263508Sdim      sqrtf_finite,
80263508Sdim      /// long double __sqrt_finite(long double x);
81263508Sdim      sqrtl_finite,
82249423Sdim      /// char * __strdup(const char *s);
83249423Sdim      dunder_strdup,
84249423Sdim      /// char *__strndup(const char *s, size_t n);
85249423Sdim      dunder_strndup,
86249423Sdim      /// char * __strtok_r(char *s, const char *delim, char **save_ptr);
87249423Sdim      dunder_strtok_r,
88249423Sdim      /// int abs(int j);
89249423Sdim      abs,
90249423Sdim      /// int access(const char *path, int amode);
91249423Sdim      access,
92234353Sdim      /// double acos(double x);
93234353Sdim      acos,
94239462Sdim      /// float acosf(float x);
95239462Sdim      acosf,
96243830Sdim      /// double acosh(double x);
97243830Sdim      acosh,
98243830Sdim      /// float acoshf(float x);
99243830Sdim      acoshf,
100243830Sdim      /// long double acoshl(long double x);
101243830Sdim      acoshl,
102234353Sdim      /// long double acosl(long double x);
103234353Sdim      acosl,
104234353Sdim      /// double asin(double x);
105234353Sdim      asin,
106239462Sdim      /// float asinf(float x);
107239462Sdim      asinf,
108243830Sdim      /// double asinh(double x);
109243830Sdim      asinh,
110243830Sdim      /// float asinhf(float x);
111243830Sdim      asinhf,
112243830Sdim      /// long double asinhl(long double x);
113243830Sdim      asinhl,
114234353Sdim      /// long double asinl(long double x);
115234353Sdim      asinl,
116234353Sdim      /// double atan(double x);
117234353Sdim      atan,
118234353Sdim      /// double atan2(double y, double x);
119234353Sdim      atan2,
120239462Sdim      /// float atan2f(float y, float x);
121239462Sdim      atan2f,
122234353Sdim      /// long double atan2l(long double y, long double x);
123234353Sdim      atan2l,
124239462Sdim      /// float atanf(float x);
125239462Sdim      atanf,
126243830Sdim      /// double atanh(double x);
127243830Sdim      atanh,
128243830Sdim      /// float atanhf(float x);
129243830Sdim      atanhf,
130243830Sdim      /// long double atanhl(long double x);
131243830Sdim      atanhl,
132239462Sdim      /// long double atanl(long double x);
133239462Sdim      atanl,
134249423Sdim      /// double atof(const char *str);
135249423Sdim      atof,
136249423Sdim      /// int atoi(const char *str);
137249423Sdim      atoi,
138249423Sdim      /// long atol(const char *str);
139249423Sdim      atol,
140249423Sdim      /// long long atoll(const char *nptr);
141249423Sdim      atoll,
142249423Sdim      /// int bcmp(const void *s1, const void *s2, size_t n);
143249423Sdim      bcmp,
144249423Sdim      /// void bcopy(const void *s1, void *s2, size_t n);
145249423Sdim      bcopy,
146249423Sdim      /// void bzero(void *s, size_t n);
147249423Sdim      bzero,
148243830Sdim      /// void *calloc(size_t count, size_t size);
149243830Sdim      calloc,
150243830Sdim      /// double cbrt(double x);
151243830Sdim      cbrt,
152243830Sdim      /// float cbrtf(float x);
153243830Sdim      cbrtf,
154243830Sdim      /// long double cbrtl(long double x);
155243830Sdim      cbrtl,
156234353Sdim      /// double ceil(double x);
157234353Sdim      ceil,
158239462Sdim      /// float ceilf(float x);
159239462Sdim      ceilf,
160234353Sdim      /// long double ceill(long double x);
161234353Sdim      ceill,
162249423Sdim      /// int chmod(const char *path, mode_t mode);
163249423Sdim      chmod,
164249423Sdim      /// int chown(const char *path, uid_t owner, gid_t group);
165249423Sdim      chown,
166249423Sdim      /// void clearerr(FILE *stream);
167249423Sdim      clearerr,
168249423Sdim      /// int closedir(DIR *dirp);
169249423Sdim      closedir,
170234353Sdim      /// double copysign(double x, double y);
171234353Sdim      copysign,
172234353Sdim      /// float copysignf(float x, float y);
173234353Sdim      copysignf,
174234353Sdim      /// long double copysignl(long double x, long double y);
175234353Sdim      copysignl,
176234353Sdim      /// double cos(double x);
177234353Sdim      cos,
178234353Sdim      /// float cosf(float x);
179234353Sdim      cosf,
180234353Sdim      /// double cosh(double x);
181234353Sdim      cosh,
182239462Sdim      /// float coshf(float x);
183239462Sdim      coshf,
184234353Sdim      /// long double coshl(long double x);
185234353Sdim      coshl,
186239462Sdim      /// long double cosl(long double x);
187239462Sdim      cosl,
188249423Sdim      /// char *ctermid(char *s);
189249423Sdim      ctermid,
190234353Sdim      /// double exp(double x);
191234353Sdim      exp,
192243830Sdim      /// double exp10(double x);
193243830Sdim      exp10,
194243830Sdim      /// float exp10f(float x);
195243830Sdim      exp10f,
196243830Sdim      /// long double exp10l(long double x);
197243830Sdim      exp10l,
198234353Sdim      /// double exp2(double x);
199234353Sdim      exp2,
200239462Sdim      /// float exp2f(float x);
201239462Sdim      exp2f,
202234353Sdim      /// long double exp2l(long double x);
203234353Sdim      exp2l,
204239462Sdim      /// float expf(float x);
205239462Sdim      expf,
206239462Sdim      /// long double expl(long double x);
207239462Sdim      expl,
208234353Sdim      /// double expm1(double x);
209234353Sdim      expm1,
210239462Sdim      /// float expm1f(float x);
211239462Sdim      expm1f,
212234353Sdim      /// long double expm1l(long double x);
213234353Sdim      expm1l,
214234353Sdim      /// double fabs(double x);
215234353Sdim      fabs,
216239462Sdim      /// float fabsf(float x);
217239462Sdim      fabsf,
218234353Sdim      /// long double fabsl(long double x);
219234353Sdim      fabsl,
220249423Sdim      /// int fclose(FILE *stream);
221249423Sdim      fclose,
222249423Sdim      /// FILE *fdopen(int fildes, const char *mode);
223249423Sdim      fdopen,
224249423Sdim      /// int feof(FILE *stream);
225249423Sdim      feof,
226249423Sdim      /// int ferror(FILE *stream);
227249423Sdim      ferror,
228249423Sdim      /// int fflush(FILE *stream);
229249423Sdim      fflush,
230249423Sdim      /// int ffs(int i);
231249423Sdim      ffs,
232249423Sdim      /// int ffsl(long int i);
233249423Sdim      ffsl,
234249423Sdim      /// int ffsll(long long int i);
235249423Sdim      ffsll,
236249423Sdim      /// int fgetc(FILE *stream);
237249423Sdim      fgetc,
238249423Sdim      /// int fgetpos(FILE *stream, fpos_t *pos);
239249423Sdim      fgetpos,
240249423Sdim      /// char *fgets(char *s, int n, FILE *stream);
241249423Sdim      fgets,
242249423Sdim      /// int fileno(FILE *stream);
243249423Sdim      fileno,
244239462Sdim      /// int fiprintf(FILE *stream, const char *format, ...);
245239462Sdim      fiprintf,
246249423Sdim      /// void flockfile(FILE *file);
247249423Sdim      flockfile,
248234353Sdim      /// double floor(double x);
249234353Sdim      floor,
250239462Sdim      /// float floorf(float x);
251239462Sdim      floorf,
252234353Sdim      /// long double floorl(long double x);
253234353Sdim      floorl,
254234353Sdim      /// double fmod(double x, double y);
255234353Sdim      fmod,
256239462Sdim      /// float fmodf(float x, float y);
257239462Sdim      fmodf,
258234353Sdim      /// long double fmodl(long double x, long double y);
259234353Sdim      fmodl,
260249423Sdim      /// FILE *fopen(const char *filename, const char *mode);
261249423Sdim      fopen,
262249423Sdim      /// FILE *fopen64(const char *filename, const char *opentype)
263249423Sdim      fopen64,
264249423Sdim      /// int fprintf(FILE *stream, const char *format, ...);
265249423Sdim      fprintf,
266239462Sdim      /// int fputc(int c, FILE *stream);
267239462Sdim      fputc,
268234353Sdim      /// int fputs(const char *s, FILE *stream);
269234353Sdim      fputs,
270249423Sdim      /// size_t fread(void *ptr, size_t size, size_t nitems, FILE *stream);
271249423Sdim      fread,
272243830Sdim      /// void free(void *ptr);
273243830Sdim      free,
274249423Sdim      /// double frexp(double num, int *exp);
275249423Sdim      frexp,
276249423Sdim      /// float frexpf(float num, int *exp);
277249423Sdim      frexpf,
278249423Sdim      /// long double frexpl(long double num, int *exp);
279249423Sdim      frexpl,
280249423Sdim      /// int fscanf(FILE *stream, const char *format, ... );
281249423Sdim      fscanf,
282249423Sdim      /// int fseek(FILE *stream, long offset, int whence);
283249423Sdim      fseek,
284249423Sdim      /// int fseeko(FILE *stream, off_t offset, int whence);
285249423Sdim      fseeko,
286249423Sdim      /// int fseeko64(FILE *stream, off64_t offset, int whence)
287249423Sdim      fseeko64,
288249423Sdim      /// int fsetpos(FILE *stream, const fpos_t *pos);
289249423Sdim      fsetpos,
290249423Sdim      /// int fstat(int fildes, struct stat *buf);
291249423Sdim      fstat,
292249423Sdim      /// int fstat64(int filedes, struct stat64 *buf)
293249423Sdim      fstat64,
294249423Sdim      /// int fstatvfs(int fildes, struct statvfs *buf);
295249423Sdim      fstatvfs,
296249423Sdim      /// int fstatvfs64(int fildes, struct statvfs64 *buf);
297249423Sdim      fstatvfs64,
298249423Sdim      /// long ftell(FILE *stream);
299249423Sdim      ftell,
300249423Sdim      /// off_t ftello(FILE *stream);
301249423Sdim      ftello,
302249423Sdim      /// off64_t ftello64(FILE *stream)
303249423Sdim      ftello64,
304249423Sdim      /// int ftrylockfile(FILE *file);
305249423Sdim      ftrylockfile,
306249423Sdim      /// void funlockfile(FILE *file);
307249423Sdim      funlockfile,
308234353Sdim      /// size_t fwrite(const void *ptr, size_t size, size_t nitems,
309234353Sdim      /// FILE *stream);
310234353Sdim      fwrite,
311249423Sdim      /// int getc(FILE *stream);
312249423Sdim      getc,
313249423Sdim      /// int getc_unlocked(FILE *stream);
314249423Sdim      getc_unlocked,
315249423Sdim      /// int getchar(void);
316249423Sdim      getchar,
317249423Sdim      /// char *getenv(const char *name);
318249423Sdim      getenv,
319249423Sdim      /// int getitimer(int which, struct itimerval *value);
320249423Sdim      getitimer,
321249423Sdim      /// int getlogin_r(char *name, size_t namesize);
322249423Sdim      getlogin_r,
323249423Sdim      /// struct passwd *getpwnam(const char *name);
324249423Sdim      getpwnam,
325249423Sdim      /// char *gets(char *s);
326249423Sdim      gets,
327263508Sdim      /// int gettimeofday(struct timeval *tp, void *tzp);
328263508Sdim      gettimeofday,
329249423Sdim      /// uint32_t htonl(uint32_t hostlong);
330249423Sdim      htonl,
331249423Sdim      /// uint16_t htons(uint16_t hostshort);
332249423Sdim      htons,
333234353Sdim      /// int iprintf(const char *format, ...);
334234353Sdim      iprintf,
335249423Sdim      /// int isascii(int c);
336249423Sdim      isascii,
337249423Sdim      /// int isdigit(int c);
338249423Sdim      isdigit,
339249423Sdim      /// long int labs(long int j);
340249423Sdim      labs,
341249423Sdim      /// int lchown(const char *path, uid_t owner, gid_t group);
342249423Sdim      lchown,
343249423Sdim      /// long long int llabs(long long int j);
344249423Sdim      llabs,
345234353Sdim      /// double log(double x);
346234353Sdim      log,
347234353Sdim      /// double log10(double x);
348234353Sdim      log10,
349239462Sdim      /// float log10f(float x);
350239462Sdim      log10f,
351234353Sdim      /// long double log10l(long double x);
352234353Sdim      log10l,
353234353Sdim      /// double log1p(double x);
354234353Sdim      log1p,
355239462Sdim      /// float log1pf(float x);
356239462Sdim      log1pf,
357234353Sdim      /// long double log1pl(long double x);
358234353Sdim      log1pl,
359239462Sdim      /// double log2(double x);
360239462Sdim      log2,
361239462Sdim      /// float log2f(float x);
362239462Sdim      log2f,
363239462Sdim      /// double long double log2l(long double x);
364239462Sdim      log2l,
365243830Sdim      /// double logb(double x);
366243830Sdim      logb,
367243830Sdim      /// float logbf(float x);
368243830Sdim      logbf,
369243830Sdim      /// long double logbl(long double x);
370243830Sdim      logbl,
371239462Sdim      /// float logf(float x);
372239462Sdim      logf,
373239462Sdim      /// long double logl(long double x);
374239462Sdim      logl,
375249423Sdim      /// int lstat(const char *path, struct stat *buf);
376249423Sdim      lstat,
377249423Sdim      /// int lstat64(const char *path, struct stat64 *buf);
378249423Sdim      lstat64,
379243830Sdim      /// void *malloc(size_t size);
380243830Sdim      malloc,
381249423Sdim      /// void *memalign(size_t boundary, size_t size);
382249423Sdim      memalign,
383249423Sdim      /// void *memccpy(void *s1, const void *s2, int c, size_t n);
384249423Sdim      memccpy,
385239462Sdim      /// void *memchr(const void *s, int c, size_t n);
386239462Sdim      memchr,
387239462Sdim      /// int memcmp(const void *s1, const void *s2, size_t n);
388239462Sdim      memcmp,
389234353Sdim      /// void *memcpy(void *s1, const void *s2, size_t n);
390234353Sdim      memcpy,
391234353Sdim      /// void *memmove(void *s1, const void *s2, size_t n);
392234353Sdim      memmove,
393249423Sdim      // void *memrchr(const void *s, int c, size_t n);
394249423Sdim      memrchr,
395218885Sdim      /// void *memset(void *b, int c, size_t len);
396218885Sdim      memset,
397218885Sdim      /// void memset_pattern16(void *b, const void *pattern16, size_t len);
398218885Sdim      memset_pattern16,
399249423Sdim      /// int mkdir(const char *path, mode_t mode);
400249423Sdim      mkdir,
401249423Sdim      /// time_t mktime(struct tm *timeptr);
402249423Sdim      mktime,
403249423Sdim      /// double modf(double x, double *iptr);
404249423Sdim      modf,
405249423Sdim      /// float modff(float, float *iptr);
406249423Sdim      modff,
407249423Sdim      /// long double modfl(long double value, long double *iptr);
408249423Sdim      modfl,
409234353Sdim      /// double nearbyint(double x);
410234353Sdim      nearbyint,
411234353Sdim      /// float nearbyintf(float x);
412234353Sdim      nearbyintf,
413234353Sdim      /// long double nearbyintl(long double x);
414234353Sdim      nearbyintl,
415249423Sdim      /// uint32_t ntohl(uint32_t netlong);
416249423Sdim      ntohl,
417249423Sdim      /// uint16_t ntohs(uint16_t netshort);
418249423Sdim      ntohs,
419249423Sdim      /// int open(const char *path, int oflag, ... );
420249423Sdim      open,
421249423Sdim      /// int open64(const char *filename, int flags[, mode_t mode])
422249423Sdim      open64,
423249423Sdim      /// DIR *opendir(const char *dirname);
424249423Sdim      opendir,
425249423Sdim      /// int pclose(FILE *stream);
426249423Sdim      pclose,
427249423Sdim      /// void perror(const char *s);
428249423Sdim      perror,
429249423Sdim      /// FILE *popen(const char *command, const char *mode);
430249423Sdim      popen,
431243830Sdim      /// int posix_memalign(void **memptr, size_t alignment, size_t size);
432243830Sdim      posix_memalign,
433234353Sdim      /// double pow(double x, double y);
434234353Sdim      pow,
435234353Sdim      /// float powf(float x, float y);
436234353Sdim      powf,
437234353Sdim      /// long double powl(long double x, long double y);
438234353Sdim      powl,
439249423Sdim      /// ssize_t pread(int fildes, void *buf, size_t nbyte, off_t offset);
440249423Sdim      pread,
441249423Sdim      /// int printf(const char *format, ...);
442249423Sdim      printf,
443249423Sdim      /// int putc(int c, FILE *stream);
444249423Sdim      putc,
445239462Sdim      /// int putchar(int c);
446239462Sdim      putchar,
447239462Sdim      /// int puts(const char *s);
448239462Sdim      puts,
449249423Sdim      /// ssize_t pwrite(int fildes, const void *buf, size_t nbyte,
450249423Sdim      ///                off_t offset);
451249423Sdim      pwrite,
452249423Sdim      /// void qsort(void *base, size_t nel, size_t width,
453249423Sdim      ///            int (*compar)(const void *, const void *));
454249423Sdim      qsort,
455249423Sdim      /// ssize_t read(int fildes, void *buf, size_t nbyte);
456249423Sdim      read,
457249423Sdim      /// ssize_t readlink(const char *path, char *buf, size_t bufsize);
458249423Sdim      readlink,
459243830Sdim      /// void *realloc(void *ptr, size_t size);
460243830Sdim      realloc,
461243830Sdim      /// void *reallocf(void *ptr, size_t size);
462243830Sdim      reallocf,
463249423Sdim      /// char *realpath(const char *file_name, char *resolved_name);
464249423Sdim      realpath,
465249423Sdim      /// int remove(const char *path);
466249423Sdim      remove,
467249423Sdim      /// int rename(const char *old, const char *new);
468249423Sdim      rename,
469249423Sdim      /// void rewind(FILE *stream);
470249423Sdim      rewind,
471234353Sdim      /// double rint(double x);
472234353Sdim      rint,
473234353Sdim      /// float rintf(float x);
474234353Sdim      rintf,
475234982Sdim      /// long double rintl(long double x);
476234353Sdim      rintl,
477249423Sdim      /// int rmdir(const char *path);
478249423Sdim      rmdir,
479234982Sdim      /// double round(double x);
480234982Sdim      round,
481234982Sdim      /// float roundf(float x);
482234982Sdim      roundf,
483234982Sdim      /// long double roundl(long double x);
484234982Sdim      roundl,
485249423Sdim      /// int scanf(const char *restrict format, ... );
486249423Sdim      scanf,
487249423Sdim      /// void setbuf(FILE *stream, char *buf);
488249423Sdim      setbuf,
489249423Sdim      /// int setitimer(int which, const struct itimerval *value,
490249423Sdim      ///               struct itimerval *ovalue);
491249423Sdim      setitimer,
492249423Sdim      /// int setvbuf(FILE *stream, char *buf, int type, size_t size);
493249423Sdim      setvbuf,
494234353Sdim      /// double sin(double x);
495234353Sdim      sin,
496234353Sdim      /// float sinf(float x);
497234353Sdim      sinf,
498234353Sdim      /// double sinh(double x);
499234353Sdim      sinh,
500239462Sdim      /// float sinhf(float x);
501239462Sdim      sinhf,
502234353Sdim      /// long double sinhl(long double x);
503234353Sdim      sinhl,
504239462Sdim      /// long double sinl(long double x);
505239462Sdim      sinl,
506221345Sdim      /// int siprintf(char *str, const char *format, ...);
507221345Sdim      siprintf,
508249423Sdim      /// int snprintf(char *s, size_t n, const char *format, ...);
509249423Sdim      snprintf,
510249423Sdim      /// int sprintf(char *str, const char *format, ...);
511249423Sdim      sprintf,
512234353Sdim      /// double sqrt(double x);
513234353Sdim      sqrt,
514239462Sdim      /// float sqrtf(float x);
515239462Sdim      sqrtf,
516234353Sdim      /// long double sqrtl(long double x);
517234353Sdim      sqrtl,
518249423Sdim      /// int sscanf(const char *s, const char *format, ... );
519249423Sdim      sscanf,
520249423Sdim      /// int stat(const char *path, struct stat *buf);
521249423Sdim      stat,
522249423Sdim      /// int stat64(const char *path, struct stat64 *buf);
523249423Sdim      stat64,
524249423Sdim      /// int statvfs(const char *path, struct statvfs *buf);
525249423Sdim      statvfs,
526249423Sdim      /// int statvfs64(const char *path, struct statvfs64 *buf)
527249423Sdim      statvfs64,
528243830Sdim      /// char *stpcpy(char *s1, const char *s2);
529243830Sdim      stpcpy,
530249423Sdim      /// char *stpncpy(char *s1, const char *s2, size_t n);
531249423Sdim      stpncpy,
532249423Sdim      /// int strcasecmp(const char *s1, const char *s2);
533249423Sdim      strcasecmp,
534239462Sdim      /// char *strcat(char *s1, const char *s2);
535239462Sdim      strcat,
536239462Sdim      /// char *strchr(const char *s, int c);
537239462Sdim      strchr,
538243830Sdim      /// int strcmp(const char *s1, const char *s2);
539243830Sdim      strcmp,
540249423Sdim      /// int strcoll(const char *s1, const char *s2);
541249423Sdim      strcoll,
542239462Sdim      /// char *strcpy(char *s1, const char *s2);
543239462Sdim      strcpy,
544243830Sdim      /// size_t strcspn(const char *s1, const char *s2);
545243830Sdim      strcspn,
546243830Sdim      /// char *strdup(const char *s1);
547243830Sdim      strdup,
548239462Sdim      /// size_t strlen(const char *s);
549239462Sdim      strlen,
550249423Sdim      /// int strncasecmp(const char *s1, const char *s2, size_t n);
551249423Sdim      strncasecmp,
552239462Sdim      /// char *strncat(char *s1, const char *s2, size_t n);
553239462Sdim      strncat,
554239462Sdim      /// int strncmp(const char *s1, const char *s2, size_t n);
555239462Sdim      strncmp,
556239462Sdim      /// char *strncpy(char *s1, const char *s2, size_t n);
557239462Sdim      strncpy,
558243830Sdim      /// char *strndup(const char *s1, size_t n);
559243830Sdim      strndup,
560239462Sdim      /// size_t strnlen(const char *s, size_t maxlen);
561239462Sdim      strnlen,
562243830Sdim      /// char *strpbrk(const char *s1, const char *s2);
563243830Sdim      strpbrk,
564243830Sdim      /// char *strrchr(const char *s, int c);
565243830Sdim      strrchr,
566243830Sdim      /// size_t strspn(const char *s1, const char *s2);
567243830Sdim      strspn,
568243830Sdim      /// char *strstr(const char *s1, const char *s2);
569243830Sdim      strstr,
570243830Sdim      /// double strtod(const char *nptr, char **endptr);
571243830Sdim      strtod,
572243830Sdim      /// float strtof(const char *nptr, char **endptr);
573243830Sdim      strtof,
574249423Sdim      // char *strtok(char *s1, const char *s2);
575249423Sdim      strtok,
576249423Sdim      // char *strtok_r(char *s, const char *sep, char **lasts);
577249423Sdim      strtok_r,
578243830Sdim      /// long int strtol(const char *nptr, char **endptr, int base);
579243830Sdim      strtol,
580243830Sdim      /// long double strtold(const char *nptr, char **endptr);
581243830Sdim      strtold,
582243830Sdim      /// long long int strtoll(const char *nptr, char **endptr, int base);
583243830Sdim      strtoll,
584243830Sdim      /// unsigned long int strtoul(const char *nptr, char **endptr, int base);
585243830Sdim      strtoul,
586243830Sdim      /// unsigned long long int strtoull(const char *nptr, char **endptr,
587243830Sdim      ///                                 int base);
588243830Sdim      strtoull,
589249423Sdim      /// size_t strxfrm(char *s1, const char *s2, size_t n);
590249423Sdim      strxfrm,
591249423Sdim      /// int system(const char *command);
592249423Sdim      system,
593234353Sdim      /// double tan(double x);
594234353Sdim      tan,
595234353Sdim      /// float tanf(float x);
596234353Sdim      tanf,
597234353Sdim      /// double tanh(double x);
598234353Sdim      tanh,
599239462Sdim      /// float tanhf(float x);
600239462Sdim      tanhf,
601234353Sdim      /// long double tanhl(long double x);
602234353Sdim      tanhl,
603239462Sdim      /// long double tanl(long double x);
604239462Sdim      tanl,
605249423Sdim      /// clock_t times(struct tms *buffer);
606249423Sdim      times,
607249423Sdim      /// FILE *tmpfile(void);
608249423Sdim      tmpfile,
609249423Sdim      /// FILE *tmpfile64(void)
610249423Sdim      tmpfile64,
611249423Sdim      /// int toascii(int c);
612249423Sdim      toascii,
613234353Sdim      /// double trunc(double x);
614234353Sdim      trunc,
615234353Sdim      /// float truncf(float x);
616234353Sdim      truncf,
617234353Sdim      /// long double truncl(long double x);
618234353Sdim      truncl,
619249423Sdim      /// int uname(struct utsname *name);
620249423Sdim      uname,
621249423Sdim      /// int ungetc(int c, FILE *stream);
622249423Sdim      ungetc,
623249423Sdim      /// int unlink(const char *path);
624249423Sdim      unlink,
625249423Sdim      /// int unsetenv(const char *name);
626249423Sdim      unsetenv,
627249423Sdim      /// int utime(const char *path, const struct utimbuf *times);
628249423Sdim      utime,
629249423Sdim      /// int utimes(const char *path, const struct timeval times[2]);
630249423Sdim      utimes,
631243830Sdim      /// void *valloc(size_t size);
632243830Sdim      valloc,
633249423Sdim      /// int vfprintf(FILE *stream, const char *format, va_list ap);
634249423Sdim      vfprintf,
635249423Sdim      /// int vfscanf(FILE *stream, const char *format, va_list arg);
636249423Sdim      vfscanf,
637249423Sdim      /// int vprintf(const char *restrict format, va_list ap);
638249423Sdim      vprintf,
639249423Sdim      /// int vscanf(const char *format, va_list arg);
640249423Sdim      vscanf,
641249423Sdim      /// int vsnprintf(char *s, size_t n, const char *format, va_list ap);
642249423Sdim      vsnprintf,
643249423Sdim      /// int vsprintf(char *s, const char *format, va_list ap);
644249423Sdim      vsprintf,
645249423Sdim      /// int vsscanf(const char *s, const char *format, va_list arg);
646249423Sdim      vsscanf,
647249423Sdim      /// ssize_t write(int fildes, const void *buf, size_t nbyte);
648249423Sdim      write,
649234353Sdim
650218885Sdim      NumLibFuncs
651218885Sdim    };
652218885Sdim  }
653218885Sdim
654218885Sdim/// TargetLibraryInfo - This immutable pass captures information about what
655218885Sdim/// library functions are available for the current target, and allows a
656218885Sdim/// frontend to disable optimizations through -fno-builtin etc.
657218885Sdimclass TargetLibraryInfo : public ImmutablePass {
658234353Sdim  virtual void anchor();
659234353Sdim  unsigned char AvailableArray[(LibFunc::NumLibFuncs+3)/4];
660234353Sdim  llvm::DenseMap<unsigned, std::string> CustomNames;
661234353Sdim  static const char* StandardNames[LibFunc::NumLibFuncs];
662234353Sdim
663234353Sdim  enum AvailabilityState {
664234353Sdim    StandardName = 3, // (memset to all ones)
665234353Sdim    CustomName = 1,
666234353Sdim    Unavailable = 0  // (memset to all zeros)
667234353Sdim  };
668234353Sdim  void setState(LibFunc::Func F, AvailabilityState State) {
669234353Sdim    AvailableArray[F/4] &= ~(3 << 2*(F&3));
670234353Sdim    AvailableArray[F/4] |= State << 2*(F&3);
671234353Sdim  }
672234353Sdim  AvailabilityState getState(LibFunc::Func F) const {
673234353Sdim    return static_cast<AvailabilityState>((AvailableArray[F/4] >> 2*(F&3)) & 3);
674234353Sdim  }
675234353Sdim
676218885Sdimpublic:
677218885Sdim  static char ID;
678218885Sdim  TargetLibraryInfo();
679218885Sdim  TargetLibraryInfo(const Triple &T);
680223017Sdim  explicit TargetLibraryInfo(const TargetLibraryInfo &TLI);
681218885Sdim
682239462Sdim  /// getLibFunc - Search for a particular function name.  If it is one of the
683239462Sdim  /// known library functions, return true and set F to the corresponding value.
684239462Sdim  bool getLibFunc(StringRef funcName, LibFunc::Func &F) const;
685239462Sdim
686218885Sdim  /// has - This function is used by optimizations that want to match on or form
687218885Sdim  /// a given library function.
688218885Sdim  bool has(LibFunc::Func F) const {
689234353Sdim    return getState(F) != Unavailable;
690218885Sdim  }
691218885Sdim
692239462Sdim  /// hasOptimizedCodeGen - Return true if the function is both available as
693239462Sdim  /// a builtin and a candidate for optimized code generation.
694239462Sdim  bool hasOptimizedCodeGen(LibFunc::Func F) const {
695239462Sdim    if (getState(F) == Unavailable)
696239462Sdim      return false;
697239462Sdim    switch (F) {
698239462Sdim    default: break;
699239462Sdim    case LibFunc::copysign:  case LibFunc::copysignf:  case LibFunc::copysignl:
700239462Sdim    case LibFunc::fabs:      case LibFunc::fabsf:      case LibFunc::fabsl:
701239462Sdim    case LibFunc::sin:       case LibFunc::sinf:       case LibFunc::sinl:
702239462Sdim    case LibFunc::cos:       case LibFunc::cosf:       case LibFunc::cosl:
703239462Sdim    case LibFunc::sqrt:      case LibFunc::sqrtf:      case LibFunc::sqrtl:
704263508Sdim    case LibFunc::sqrt_finite: case LibFunc::sqrtf_finite:
705263508Sdim                                                  case LibFunc::sqrtl_finite:
706239462Sdim    case LibFunc::floor:     case LibFunc::floorf:     case LibFunc::floorl:
707239462Sdim    case LibFunc::nearbyint: case LibFunc::nearbyintf: case LibFunc::nearbyintl:
708239462Sdim    case LibFunc::ceil:      case LibFunc::ceilf:      case LibFunc::ceill:
709239462Sdim    case LibFunc::rint:      case LibFunc::rintf:      case LibFunc::rintl:
710263508Sdim    case LibFunc::round:     case LibFunc::roundf:     case LibFunc::roundl:
711239462Sdim    case LibFunc::trunc:     case LibFunc::truncf:     case LibFunc::truncl:
712239462Sdim    case LibFunc::log2:      case LibFunc::log2f:      case LibFunc::log2l:
713239462Sdim    case LibFunc::exp2:      case LibFunc::exp2f:      case LibFunc::exp2l:
714263508Sdim    case LibFunc::memcmp:    case LibFunc::strcmp:     case LibFunc::strcpy:
715263508Sdim    case LibFunc::stpcpy:    case LibFunc::strlen:     case LibFunc::strnlen:
716263508Sdim    case LibFunc::memchr:
717239462Sdim      return true;
718239462Sdim    }
719239462Sdim    return false;
720239462Sdim  }
721239462Sdim
722234353Sdim  StringRef getName(LibFunc::Func F) const {
723234353Sdim    AvailabilityState State = getState(F);
724234353Sdim    if (State == Unavailable)
725234353Sdim      return StringRef();
726234353Sdim    if (State == StandardName)
727234353Sdim      return StandardNames[F];
728234353Sdim    assert(State == CustomName);
729234353Sdim    return CustomNames.find(F)->second;
730234353Sdim  }
731234353Sdim
732218885Sdim  /// setUnavailable - this can be used by whatever sets up TargetLibraryInfo to
733218885Sdim  /// ban use of specific library functions.
734218885Sdim  void setUnavailable(LibFunc::Func F) {
735234353Sdim    setState(F, Unavailable);
736218885Sdim  }
737218885Sdim
738218885Sdim  void setAvailable(LibFunc::Func F) {
739234353Sdim    setState(F, StandardName);
740218885Sdim  }
741234353Sdim
742234353Sdim  void setAvailableWithName(LibFunc::Func F, StringRef Name) {
743234353Sdim    if (StandardNames[F] != Name) {
744234353Sdim      setState(F, CustomName);
745234353Sdim      CustomNames[F] = Name;
746234353Sdim      assert(CustomNames.find(F) != CustomNames.end());
747234353Sdim    } else {
748234353Sdim      setState(F, StandardName);
749234353Sdim    }
750234353Sdim  }
751234353Sdim
752218885Sdim  /// disableAllFunctions - This disables all builtins, which is used for
753218885Sdim  /// options like -fno-builtin.
754218885Sdim  void disableAllFunctions();
755218885Sdim};
756218885Sdim
757218885Sdim} // end namespace llvm
758218885Sdim
759218885Sdim#endif
760