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