ARM NEON two-operand aliases for VPADD.
[oota-llvm.git] / lib / Target / TargetLibraryInfo.cpp
1 //===-- TargetLibraryInfo.cpp - Runtime library information ----------------==//
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 // This file implements the TargetLibraryInfo class.
11 //
12 //===----------------------------------------------------------------------===//
13
14 #include "llvm/Target/TargetLibraryInfo.h"
15 #include "llvm/ADT/Triple.h"
16 using namespace llvm;
17
18 // Register the default implementation.
19 INITIALIZE_PASS(TargetLibraryInfo, "targetlibinfo",
20                 "Target Library Information", false, true)
21 char TargetLibraryInfo::ID = 0;
22
23 const char* TargetLibraryInfo::StandardNames[LibFunc::NumLibFuncs] =
24   {
25     "acos",
26     "acosl",
27     "acosf",
28     "asin",
29     "asinl",
30     "asinf",
31     "atan",
32     "atanl",
33     "atanf",
34     "atan2",
35     "atan2l",
36     "atan2f",
37     "ceil",
38     "ceill",
39     "ceilf",
40     "copysign",
41     "copysignf",
42     "copysignl",
43     "cos",
44     "cosl",
45     "cosf",
46     "cosh",
47     "coshl",
48     "coshf",
49     "exp",
50     "expl",
51     "expf",
52     "exp2",
53     "exp2l",
54     "exp2f",
55     "expm1",
56     "expm1l",
57     "expl1f",
58     "fabs",
59     "fabsl",
60     "fabsf",
61     "floor",
62     "floorl",
63     "floorf",
64     "fiprintf",
65     "fmod",
66     "fmodl",
67     "fmodf",
68     "fputs",
69     "fwrite",
70     "iprintf",
71     "log",
72     "logl",
73     "logf",
74     "log2",
75     "log2l",
76     "log2f",
77     "log10",
78     "log10l",
79     "log10f",
80     "log1p",
81     "log1pl",
82     "log1pf",
83     "memcpy",
84     "memmove",
85     "memset",
86     "memset_pattern16",
87     "nearbyint",
88     "nearbyintf",
89     "nearbyintl",
90     "pow",
91     "powf",
92     "powl",
93     "rint",
94     "rintf",
95     "rintl",
96     "sin",
97     "sinl",
98     "sinf",
99     "sinh",
100     "sinhl",
101     "sinhf",
102     "siprintf",
103     "sqrt",
104     "sqrtl",
105     "sqrtf",
106     "tan",
107     "tanl",
108     "tanf",
109     "tanh",
110     "tanhl",
111     "tanhf",
112     "trunc",
113     "truncf",
114     "truncl"
115   };
116
117 /// initialize - Initialize the set of available library functions based on the
118 /// specified target triple.  This should be carefully written so that a missing
119 /// target triple gets a sane set of defaults.
120 static void initialize(TargetLibraryInfo &TLI, const Triple &T) {
121   initializeTargetLibraryInfoPass(*PassRegistry::getPassRegistry());
122
123   
124   // memset_pattern16 is only available on iOS 3.0 and Mac OS/X 10.5 and later.
125   if (T.isMacOSX()) {
126     if (T.isMacOSXVersionLT(10, 5))
127       TLI.setUnavailable(LibFunc::memset_pattern16);
128   } else if (T.getOS() == Triple::IOS) {
129     if (T.isOSVersionLT(3, 0))
130       TLI.setUnavailable(LibFunc::memset_pattern16);
131   } else {
132     TLI.setUnavailable(LibFunc::memset_pattern16);
133   }
134
135   if (T.isMacOSX() && T.getArch() == Triple::x86 &&
136       !T.isMacOSXVersionLT(10, 7)) {
137     // x86-32 OSX has a scheme where fwrite and fputs (and some other functions
138     // we don't care about) have two versions; on recent OSX, the one we want
139     // has a $UNIX2003 suffix. The two implementations are identical except
140     // for the return value in some edge cases.  However, we don't want to
141     // generate code that depends on the old symbols.
142     TLI.setAvailableWithName(LibFunc::fwrite, "fwrite$UNIX2003");
143     TLI.setAvailableWithName(LibFunc::fputs, "fputs$UNIX2003");
144   }
145
146   // iprintf and friends are only available on XCore and TCE.
147   if (T.getArch() != Triple::xcore && T.getArch() != Triple::tce) {
148     TLI.setUnavailable(LibFunc::iprintf);
149     TLI.setUnavailable(LibFunc::siprintf);
150     TLI.setUnavailable(LibFunc::fiprintf);
151   }
152 }
153
154
155 TargetLibraryInfo::TargetLibraryInfo() : ImmutablePass(ID) {
156   // Default to everything being available.
157   memset(AvailableArray, -1, sizeof(AvailableArray));
158
159   initialize(*this, Triple());
160 }
161
162 TargetLibraryInfo::TargetLibraryInfo(const Triple &T) : ImmutablePass(ID) {
163   // Default to everything being available.
164   memset(AvailableArray, -1, sizeof(AvailableArray));
165   
166   initialize(*this, T);
167 }
168
169 TargetLibraryInfo::TargetLibraryInfo(const TargetLibraryInfo &TLI)
170   : ImmutablePass(ID) {
171   memcpy(AvailableArray, TLI.AvailableArray, sizeof(AvailableArray));
172   CustomNames = TLI.CustomNames;
173 }
174
175
176 /// disableAllFunctions - This disables all builtins, which is used for options
177 /// like -fno-builtin.
178 void TargetLibraryInfo::disableAllFunctions() {
179   memset(AvailableArray, 0, sizeof(AvailableArray));
180 }