]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - include/llvm/Target/TargetLibraryInfo.h
Vendor import of llvm trunk r130700:
[FreeBSD/FreeBSD.git] / include / llvm / Target / TargetLibraryInfo.h
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/Pass.h"
14
15 namespace llvm {
16   class Triple;
17
18   namespace LibFunc {
19     enum Func {
20       /// void *memset(void *b, int c, size_t len);
21       memset,
22       
23       // void *memcpy(void *s1, const void *s2, size_t n);
24       memcpy,
25       
26       // void *memmove(void *s1, const void *s2, size_t n);
27       memmove,
28       
29       /// void memset_pattern16(void *b, const void *pattern16, size_t len);
30       memset_pattern16,
31       
32       /// int iprintf(const char *format, ...);
33       iprintf,
34       
35       /// int siprintf(char *str, const char *format, ...);
36       siprintf,
37       
38       /// int fiprintf(FILE *stream, const char *format, ...);
39       fiprintf,
40       
41       NumLibFuncs
42     };
43   }
44
45 /// TargetLibraryInfo - This immutable pass captures information about what
46 /// library functions are available for the current target, and allows a
47 /// frontend to disable optimizations through -fno-builtin etc.
48 class TargetLibraryInfo : public ImmutablePass {
49   unsigned char AvailableArray[(LibFunc::NumLibFuncs+7)/8];
50 public:
51   static char ID;
52   TargetLibraryInfo();
53   TargetLibraryInfo(const Triple &T);
54   
55   /// has - This function is used by optimizations that want to match on or form
56   /// a given library function.
57   bool has(LibFunc::Func F) const {
58     return (AvailableArray[F/8] & (1 << (F&7))) != 0;
59   }
60
61   /// setUnavailable - this can be used by whatever sets up TargetLibraryInfo to
62   /// ban use of specific library functions.
63   void setUnavailable(LibFunc::Func F) {
64     AvailableArray[F/8] &= ~(1 << (F&7));
65   }
66
67   void setAvailable(LibFunc::Func F) {
68     AvailableArray[F/8] |= 1 << (F&7);
69   }
70   
71   /// disableAllFunctions - This disables all builtins, which is used for
72   /// options like -fno-builtin.
73   void disableAllFunctions();
74 };
75
76 } // end namespace llvm
77
78 #endif