1 //===- LLVM.h - Import and forward declare core LLVM types ------*- C++ -*-===//
2 //
3 // Part of the MLIR 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 // Containers.
29 class StringRef;
30 class StringLiteral;
31 class Twine;
32 template <typename T> class SmallPtrSetImpl;
33 template <typename T, unsigned N> class SmallPtrSet;
34 template <typename T> class SmallVectorImpl;
35 template <typename T, unsigned N> class SmallVector;
36 template <unsigned N> class SmallString;
37 template <typename T> class ArrayRef;
38 template <typename T> class MutableArrayRef;
39 template <typename T> class TinyPtrVector;
40 template <typename T> class Optional;
41 template <typename... PT> class PointerUnion;
42 namespace detail {
43 template <typename KeyT, typename ValueT> struct DenseMapPair;
44 }
45 template <typename T> struct DenseMapInfo;
46 template <typename ValueT, typename ValueInfoT> class DenseSet;
47 template <typename KeyT, typename ValueT, typename KeyInfoT, typename BucketT>
48 class DenseMap;
49 template <typename Fn> class function_ref;
50 template <typename IteratorT> class iterator_range;
51 
52 // Other common classes.
53 class raw_ostream;
54 class APInt;
55 class APFloat;
56 } // end namespace llvm
57 
58 namespace mlir {
59 // Casting operators.
60 using llvm::cast;
61 using llvm::cast_or_null;
62 using llvm::dyn_cast;
63 using llvm::dyn_cast_or_null;
64 using llvm::isa;
65 using llvm::isa_and_nonnull;
66 
67 // Containers.
68 using llvm::ArrayRef;
69 using llvm::DenseMapInfo;
70 template <typename KeyT, typename ValueT,
71           typename KeyInfoT = DenseMapInfo<KeyT>,
72           typename BucketT = llvm::detail::DenseMapPair<KeyT, ValueT>>
73 using DenseMap = llvm::DenseMap<KeyT, ValueT, KeyInfoT, BucketT>;
74 template <typename ValueT, typename ValueInfoT = DenseMapInfo<ValueT>>
75 using DenseSet = llvm::DenseSet<ValueT, ValueInfoT>;
76 template <typename Fn> using function_ref = llvm::function_ref<Fn>;
77 using llvm::iterator_range;
78 using llvm::MutableArrayRef;
79 using llvm::None;
80 using llvm::Optional;
81 using llvm::PointerUnion;
82 using llvm::SmallPtrSet;
83 using llvm::SmallPtrSetImpl;
84 using llvm::SmallString;
85 using llvm::SmallVector;
86 using llvm::SmallVectorImpl;
87 using llvm::StringLiteral;
88 using llvm::StringRef;
89 using llvm::TinyPtrVector;
90 using llvm::Twine;
91 
92 // Other common classes.
93 using llvm::APFloat;
94 using llvm::APInt;
95 using llvm::raw_ostream;
96 } // namespace mlir
97 
98 #endif // MLIR_SUPPORT_LLVM_H
99