TargetLibraryInfo.h revision 3649824bec09768cbdee7aa7cfbbcdd865373626
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
15namespace 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 memset_pattern16(void *b, const void *pattern16, size_t len);
27      memset_pattern16,
28
29      /// int iprintf(const char *format, ...);
30      iprintf,
31
32      NumLibFuncs
33    };
34  }
35
36/// TargetLibraryInfo - This immutable pass captures information about what
37/// library functions are available for the current target, and allows a
38/// frontend to disable optimizations through -fno-builtin etc.
39class TargetLibraryInfo : public ImmutablePass {
40  unsigned char AvailableArray[(LibFunc::NumLibFuncs+7)/8];
41public:
42  static char ID;
43  TargetLibraryInfo();
44  TargetLibraryInfo(const Triple &T);
45
46  /// has - This function is used by optimizations that want to match on or form
47  /// a given library function.
48  bool has(LibFunc::Func F) const {
49    return (AvailableArray[F/8] & (1 << (F&7))) != 0;
50  }
51
52  /// setUnavailable - this can be used by whatever sets up TargetLibraryInfo to
53  /// ban use of specific library functions.
54  void setUnavailable(LibFunc::Func F) {
55    AvailableArray[F/8] &= ~(1 << (F&7));
56  }
57
58  void setAvailable(LibFunc::Func F) {
59    AvailableArray[F/8] |= 1 << (F&7);
60  }
61
62  /// disableAllFunctions - This disables all builtins, which is used for
63  /// options like -fno-builtin.
64  void disableAllFunctions();
65};
66
67} // end namespace llvm
68
69#endif
70