My Project
Dialect.h
Go to the documentation of this file.
1 //
2 // Part of the MLIR Project, under the Apache License v2.0 with LLVM Exceptions.
3 // See https://llvm.org/LICENSE.txt for license information.
4 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
5 //
6 //===----------------------------------------------------------------------===//
7 //
8 // Dialect wrapper to simplify using TableGen Record defining a MLIR dialect.
9 //
10 //===----------------------------------------------------------------------===//
11 
12 #ifndef MLIR_TABLEGEN_DIALECT_H_
13 #define MLIR_TABLEGEN_DIALECT_H_
14 
15 #include "mlir/Support/LLVM.h"
16 
17 namespace llvm {
18 class Record;
19 } // end namespace llvm
20 
21 namespace mlir {
22 namespace tblgen {
23 // Wrapper class that contains a MLIR dialect's information defined in TableGen
24 // and provides helper methods for accessing them.
25 class Dialect {
26 public:
27  explicit Dialect(const llvm::Record *def) : def(def) {}
28 
29  // Returns the name of this dialect.
30  StringRef getName() const;
31 
32  // Returns the C++ namespaces that ops of this dialect should be placed into.
33  StringRef getCppNamespace() const;
34 
35  // Returns the summary description of the dialect. Returns empty string if
36  // none.
37  StringRef getSummary() const;
38 
39  // Returns the description of the dialect. Returns empty string if none.
40  StringRef getDescription() const;
41 
42  // Returns whether two dialects are equal by checking the equality of the
43  // underlying record.
44  bool operator==(const Dialect &other) const;
45 
46  // Compares two dialects by comparing the names of the dialects.
47  bool operator<(const Dialect &other) const;
48 
49  // Returns whether the dialect is defined.
50  operator bool() const { return def != nullptr; }
51 
52 private:
53  const llvm::Record *def;
54 };
55 } // end namespace tblgen
56 } // end namespace mlir
57 
58 #endif // MLIR_TABLEGEN_DIALECT_H_
Definition: InferTypeOpInterface.cpp:20
Definition: PassRegistry.cpp:413
Definition: Dialect.h:25
bool operator==(IntInfty lhs, IntInfty rhs)
Definition: SDBM.h:90
bool operator<(IntInfty lhs, IntInfty rhs)
Definition: SDBM.h:82
Dialect(const llvm::Record *def)
Definition: Dialect.h:27