MLIR  15.0.0git
Type.h
Go to the documentation of this file.
1 //===- Type.h - Type class --------------------------------------*- 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 // Type wrapper to simplify using TableGen Record defining a MLIR Type.
10 //
11 //===----------------------------------------------------------------------===//
12 
13 #ifndef MLIR_TABLEGEN_TYPE_H_
14 #define MLIR_TABLEGEN_TYPE_H_
15 
16 #include "mlir/Support/LLVM.h"
18 #include "mlir/TableGen/Dialect.h"
19 
20 namespace llvm {
21 class DefInit;
22 class Record;
23 } // namespace llvm
24 
25 namespace mlir {
26 namespace tblgen {
27 
28 // Wrapper class with helper methods for accessing Type constraints defined in
29 // TableGen.
30 class TypeConstraint : public Constraint {
31 public:
32  using Constraint::Constraint;
33 
34  TypeConstraint(const llvm::DefInit *record);
35 
36  static bool classof(const Constraint *c) { return c->getKind() == CK_Type; }
37 
38  // Returns true if this is an optional type constraint.
39  bool isOptional() const;
40 
41  // Returns true if this is a variadic type constraint.
42  bool isVariadic() const;
43 
44  // Returns true if this is a nested variadic type constraint.
45  bool isVariadicOfVariadic() const;
46 
47  // Return the segment size attribute used if this is a variadic of variadic
48  // constraint. Asserts isVariadicOfVariadic() is true.
49  StringRef getVariadicOfVariadicSegmentSizeAttr() const;
50 
51  // Returns true if this is a variable length type constraint. This is either
52  // variadic or optional.
53  bool isVariableLength() const { return isOptional() || isVariadic(); }
54 
55  // Returns the builder call for this constraint if this is a buildable type,
56  // returns None otherwise.
57  Optional<StringRef> getBuilderCall() const;
58 
59  // Return the C++ class name for this type (which may just be ::mlir::Type).
60  std::string getCPPClassName() const;
61 };
62 
63 // Wrapper class with helper methods for accessing Types defined in TableGen.
64 class Type : public TypeConstraint {
65 public:
66  explicit Type(const llvm::Record *record);
67 
68  // Returns the dialect for the type if defined.
69  Dialect getDialect() const;
70 };
71 
72 } // namespace tblgen
73 } // namespace mlir
74 
75 #endif // MLIR_TABLEGEN_TYPE_H_
TODO: Remove this file when SCCP and integer range analysis have been ported to the new framework...
The OpAsmOpInterface, see OpAsmInterface.td for more details.
Definition: CallGraph.h:221
static bool classof(const Constraint *c)
Definition: Type.h:36
Kind getKind() const
Definition: Constraint.h:72
bool isVariableLength() const
Definition: Type.h:53