My Project
MLIRContext.h
Go to the documentation of this file.
1 //===- MLIRContext.h - MLIR Global Context Class ----------------*- 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 #ifndef MLIR_IR_MLIRCONTEXT_H
10 #define MLIR_IR_MLIRCONTEXT_H
11 
12 #include "mlir/Support/LLVM.h"
13 #include <functional>
14 #include <memory>
15 #include <vector>
16 
17 namespace mlir {
18 class AbstractOperation;
19 class DiagnosticEngine;
20 class Dialect;
21 class InFlightDiagnostic;
22 class Location;
23 class MLIRContextImpl;
24 class StorageUniquer;
25 
34 class MLIRContext {
35 public:
36  explicit MLIRContext();
37  ~MLIRContext();
38 
40  std::vector<Dialect *> getRegisteredDialects();
41 
44  Dialect *getRegisteredDialect(StringRef name);
45 
48  template <typename T> T *getRegisteredDialect() {
49  return static_cast<T *>(getRegisteredDialect(T::getDialectNamespace()));
50  }
51 
55  std::vector<AbstractOperation *> getRegisteredOperations();
56 
57  // This is effectively private given that only MLIRContext.cpp can see the
58  // MLIRContextImpl type.
59  MLIRContextImpl &getImpl() { return *impl; }
60 
63 
66 
70 
74 
75 private:
76  const std::unique_ptr<MLIRContextImpl> impl;
77 
78  MLIRContext(const MLIRContext &) = delete;
79  void operator=(const MLIRContext &) = delete;
80 };
81 } // end namespace mlir
82 
83 #endif // MLIR_IR_MLIRCONTEXT_H
Definition: InferTypeOpInterface.cpp:20
StorageUniquer & getAffineUniquer()
Returns the storage uniquer used for creating affine constructs.
Definition: MLIRContext.cpp:567
Definition: MLIRContext.cpp:149
DiagnosticEngine & getDiagEngine()
Returns the diagnostic engine for this context.
Definition: MLIRContext.cpp:295
StorageUniquer & getTypeUniquer()
Definition: MLIRContext.cpp:461
StorageUniquer & getAttributeUniquer()
Definition: MLIRContext.cpp:535
Definition: Dialect.h:39
std::vector< AbstractOperation * > getRegisteredOperations()
Definition: MLIRContext.cpp:353
MLIRContext()
Definition: MLIRContext.cpp:232
Definition: StorageUniquer.h:64
T * getRegisteredDialect()
Definition: MLIRContext.h:48
Definition: Diagnostics.h:399
std::vector< Dialect * > getRegisteredDialects()
Return information about all registered IR dialects.
Definition: MLIRContext.cpp:302
MLIRContextImpl & getImpl()
Definition: MLIRContext.h:59
Definition: MLIRContext.h:34
~MLIRContext()
Definition: MLIRContext.cpp:278