1 //===-- TargetLibraryInfo.cpp - Runtime library information ----------------==//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // This file implements the TargetLibraryInfo class.
12 //===----------------------------------------------------------------------===//
14 #include "llvm/Target/TargetLibraryInfo.h"
15 #include "llvm/ADT/Triple.h"
18 // Register the default implementation.
19 INITIALIZE_PASS(TargetLibraryInfo, "targetlibinfo",
20 "Target Library Information", false, true)
21 char TargetLibraryInfo::ID = 0;
23 /// initialize - Initialize the set of available library functions based on the
24 /// specified target triple. This should be carefully written so that a missing
25 /// target triple gets a sane set of defaults.
26 static void initialize(TargetLibraryInfo &TLI, const Triple &T) {
27 initializeTargetLibraryInfoPass(*PassRegistry::getPassRegistry());
30 // memset_pattern16 is only available on iOS 3.0 and Mac OS/X 10.5 and later.
32 if (T.isMacOSXVersionLT(10, 5))
33 TLI.setUnavailable(LibFunc::memset_pattern16);
34 } else if (T.getOS() == Triple::IOS) {
35 if (T.isOSVersionLT(3, 0))
36 TLI.setUnavailable(LibFunc::memset_pattern16);
38 TLI.setUnavailable(LibFunc::memset_pattern16);
41 // iprintf and friends are only available on XCore and TCE.
42 if (T.getArch() != Triple::xcore && T.getArch() != Triple::tce) {
43 TLI.setUnavailable(LibFunc::iprintf);
44 TLI.setUnavailable(LibFunc::siprintf);
45 TLI.setUnavailable(LibFunc::fiprintf);
50 TargetLibraryInfo::TargetLibraryInfo() : ImmutablePass(ID) {
51 // Default to everything being available.
52 memset(AvailableArray, -1, sizeof(AvailableArray));
54 initialize(*this, Triple());
57 TargetLibraryInfo::TargetLibraryInfo(const Triple &T) : ImmutablePass(ID) {
58 // Default to everything being available.
59 memset(AvailableArray, -1, sizeof(AvailableArray));
64 TargetLibraryInfo::TargetLibraryInfo(const TargetLibraryInfo &TLI)
66 memcpy(AvailableArray, TLI.AvailableArray, sizeof(AvailableArray));
70 /// disableAllFunctions - This disables all builtins, which is used for options
71 /// like -fno-builtin.
72 void TargetLibraryInfo::disableAllFunctions() {
73 memset(AvailableArray, 0, sizeof(AvailableArray));