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 this header because it cannot be practically forward
22// declared, and are effectively language features.
23#include "llvm/Support/Casting.h"
24#include <vector>
25
26// Workaround for clang-5 (PR41549)
27#if defined(__clang_major__)
28#if __clang_major__ <= 5
29#include "llvm/ADT/DenseMapInfo.h"
30#include "llvm/ADT/SmallVector.h"
31#endif
32#endif
33
34// Forward declarations.
35namespace llvm {
36// String types
37template <unsigned N>
38class SmallString;
39class StringRef;
40class StringLiteral;
41class Twine;
42
43// Containers.
44template <typename T>
45class ArrayRef;
46class BitVector;
47namespace detail {
48template <typename KeyT, typename ValueT>
49struct DenseMapPair;
50} // namespace detail
51template <typename KeyT, typename ValueT, typename KeyInfoT, typename BucketT>
52class DenseMap;
53template <typename T, typename Enable>
54struct DenseMapInfo;
55template <typename ValueT, typename ValueInfoT>
56class DenseSet;
57class MallocAllocator;
58template <typename T>
59class MutableArrayRef;
60template <typename... PT>
61class PointerUnion;
62template <typename T, typename Vector, typename Set, unsigned N>
63class SetVector;
64template <typename T, unsigned N>
65class SmallPtrSet;
66template <typename T>
67class SmallPtrSetImpl;
68template <typename T, unsigned N>
69class SmallVector;
70template <typename T>
71class SmallVectorImpl;
72template <typename AllocatorTy>
73class StringSet;
74template <typename T, typename R>
75class StringSwitch;
76template <typename T>
77class TinyPtrVector;
78template <typename T, typename ResultT>
79class TypeSwitch;
80
81// Other common classes.
82class APInt;
83class APSInt;
84class APFloat;
85template <typename Fn>
86class function_ref;
87template <typename IteratorT>
88class iterator_range;
89class raw_ostream;
90class SMLoc;
91class SMRange;
92} // namespace llvm
93
94namespace mlir {
95// Casting operators.
96using llvm::cast;
97using llvm::cast_if_present;
98using llvm::cast_or_null;
99using llvm::dyn_cast;
100using llvm::dyn_cast_if_present;
101using llvm::dyn_cast_or_null;
102using llvm::isa;
103using llvm::isa_and_nonnull;
104using llvm::isa_and_present;
105
106// String types
107using llvm::SmallString;
108using llvm::StringLiteral;
109using llvm::StringRef;
110using llvm::Twine;
111
112// Container Related types
113//
114// Containers.
115using llvm::ArrayRef;
116using llvm::BitVector;
117template <typename T, typename Enable = void>
118using DenseMapInfo = llvm::DenseMapInfo<T, Enable>;
119template <typename KeyT, typename ValueT,
120 typename KeyInfoT = DenseMapInfo<KeyT>,
121 typename BucketT = llvm::detail::DenseMapPair<KeyT, ValueT>>
122using DenseMap = llvm::DenseMap<KeyT, ValueT, KeyInfoT, BucketT>;
123template <typename ValueT, typename ValueInfoT = DenseMapInfo<ValueT>>
124using DenseSet = llvm::DenseSet<ValueT, ValueInfoT>;
125template <typename T, typename Vector = llvm::SmallVector<T, 0>,
126 typename Set = DenseSet<T>, unsigned N = 0>
127using SetVector = llvm::SetVector<T, Vector, Set, N>;
128template <typename AllocatorTy = llvm::MallocAllocator>
129using StringSet = llvm::StringSet<AllocatorTy>;
130using llvm::MutableArrayRef;
131using llvm::PointerUnion;
132using llvm::SmallPtrSet;
133using llvm::SmallPtrSetImpl;
134using llvm::SmallVector;
135using llvm::SmallVectorImpl;
136template <typename T, typename R = T>
137using StringSwitch = llvm::StringSwitch<T, R>;
138using llvm::TinyPtrVector;
139template <typename T, typename ResultT = void>
140using TypeSwitch = llvm::TypeSwitch<T, ResultT>;
141
142// Other common classes.
143using llvm::APFloat;
144using llvm::APInt;
145using llvm::APSInt;
146template <typename Fn>
147using function_ref = llvm::function_ref<Fn>;
148using llvm::iterator_range;
149using llvm::raw_ostream;
150using llvm::SMLoc;
151using llvm::SMRange;
152} // namespace mlir
153
154#endif // MLIR_SUPPORT_LLVM_H
155

source code of mlir/include/mlir/Support/LLVM.h