• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 //===- LLVM.h - Import and forward declare core LLVM types ------*- C++ -*-===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 //
9 // This file forward declares and imports various common LLVM datatypes that
10 // MLIR wants to use unqualified.
11 //
12 // Note that most of these are forward declared and then imported into the MLIR
13 // namespace with using decls, rather than being #included.  This is because we
14 // want clients to explicitly #include the files they need.
15 //
16 //===----------------------------------------------------------------------===//
17 
18 #ifndef MLIR_SUPPORT_LLVM_H
19 #define MLIR_SUPPORT_LLVM_H
20 
21 // We include these two headers because they cannot be practically forward
22 // declared, and are effectively language features.
23 #include "llvm/ADT/None.h"
24 #include "llvm/Support/Casting.h"
25 
26 // Forward declarations.
27 namespace llvm {
28 // String types
29 template <unsigned N>
30 class SmallString;
31 class StringRef;
32 class StringLiteral;
33 class Twine;
34 
35 // Containers.
36 template <typename T> class ArrayRef;
37 namespace detail {
38 template <typename KeyT, typename ValueT> struct DenseMapPair;
39 } // namespace detail
40 template <typename KeyT, typename ValueT, typename KeyInfoT, typename BucketT>
41 class DenseMap;
42 template <typename T>
43 struct DenseMapInfo;
44 template <typename ValueT, typename ValueInfoT>
45 class DenseSet;
46 class MallocAllocator;
47 template <typename T>
48 class MutableArrayRef;
49 template <typename T>
50 class Optional;
51 template <typename... PT>
52 class PointerUnion;
53 template <typename T, unsigned N>
54 class SmallPtrSet;
55 template <typename T>
56 class SmallPtrSetImpl;
57 template <typename T, unsigned N>
58 class SmallVector;
59 template <typename T>
60 class SmallVectorImpl;
61 template <typename AllocatorTy>
62 class StringSet;
63 template <typename T, typename R>
64 class StringSwitch;
65 template <typename T>
66 class TinyPtrVector;
67 template <typename T, typename ResultT>
68 class TypeSwitch;
69 
70 // Other common classes.
71 class APInt;
72 class APFloat;
73 template <typename Fn>
74 class function_ref;
75 template <typename IteratorT>
76 class iterator_range;
77 class raw_ostream;
78 } // end namespace llvm
79 
80 namespace mlir {
81 // Casting operators.
82 using llvm::cast;
83 using llvm::cast_or_null;
84 using llvm::dyn_cast;
85 using llvm::dyn_cast_or_null;
86 using llvm::isa;
87 using llvm::isa_and_nonnull;
88 
89 // String types
90 using llvm::SmallString;
91 using llvm::StringLiteral;
92 using llvm::StringRef;
93 using llvm::Twine;
94 
95 // Container Related types
96 //
97 // Containers.
98 using llvm::ArrayRef;
99 using llvm::DenseMapInfo;
100 template <typename KeyT, typename ValueT,
101           typename KeyInfoT = DenseMapInfo<KeyT>,
102           typename BucketT = llvm::detail::DenseMapPair<KeyT, ValueT>>
103 using DenseMap = llvm::DenseMap<KeyT, ValueT, KeyInfoT, BucketT>;
104 template <typename ValueT, typename ValueInfoT = DenseMapInfo<ValueT>>
105 using DenseSet = llvm::DenseSet<ValueT, ValueInfoT>;
106 template <typename AllocatorTy = llvm::MallocAllocator>
107 using StringSet = llvm::StringSet<AllocatorTy>;
108 using llvm::MutableArrayRef;
109 using llvm::None;
110 using llvm::Optional;
111 using llvm::PointerUnion;
112 using llvm::SmallPtrSet;
113 using llvm::SmallPtrSetImpl;
114 using llvm::SmallVector;
115 using llvm::SmallVectorImpl;
116 template <typename T, typename R = T>
117 using StringSwitch = llvm::StringSwitch<T, R>;
118 using llvm::TinyPtrVector;
119 template <typename T, typename ResultT = void>
120 using TypeSwitch = llvm::TypeSwitch<T, ResultT>;
121 
122 // Other common classes.
123 using llvm::APFloat;
124 using llvm::APInt;
125 template <typename Fn>
126 using function_ref = llvm::function_ref<Fn>;
127 using llvm::iterator_range;
128 using llvm::raw_ostream;
129 } // namespace mlir
130 
131 #endif // MLIR_SUPPORT_LLVM_H
132