[Infra] Fix version-check workflow (#100090)
[llvm-project.git] / mlir / tools / mlir-tblgen / OpClass.h
blob20b96baf868c77b143ad8f8074c514c071e61ba6
1 //===- OpClass.h - Implementation of an Op Class --------------------------===//
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 //===----------------------------------------------------------------------===//
9 #ifndef MLIR_TOOLS_MLIRTBLGEN_OPCLASS_H_
10 #define MLIR_TOOLS_MLIRTBLGEN_OPCLASS_H_
12 #include "mlir/TableGen/Class.h"
14 namespace mlir {
15 namespace tblgen {
17 /// Class for holding an op for C++ code emission. The class is specialized to
18 /// add Op-specific declarations to the class.
19 class OpClass : public Class {
20 public:
21 /// Create an operation class with extra class declarations, whose default
22 /// visibility is public. Also declares at the top of the class:
23 ///
24 /// - inheritance of constructors from `Op`
25 /// - inheritance of `print`
26 /// - a type alias for the associated adaptor class
27 ///
28 OpClass(StringRef name, std::string extraClassDeclaration,
29 std::string extraClassDefinition);
31 /// Add an op trait.
32 void addTrait(Twine trait) { parent.addTemplateParam(trait.str()); }
34 /// The operation class is finalized by calling `Class::finalize` to delcare
35 /// all pending private and public methods (ops don't have custom constructors
36 /// or fields). Then, the extra class declarations are appended to the end of
37 /// the class declaration.
38 void finalize() override;
40 private:
41 /// Hand-written extra class declarations.
42 std::string extraClassDeclaration;
43 /// Hand-written extra class definitions.
44 std::string extraClassDefinition;
45 /// The parent class, which also contains the traits to be inherited.
46 ParentClass &parent;
49 } // namespace tblgen
50 } // namespace mlir
52 #endif // MLIR_TOOLS_MLIRTBLGEN_OPCLASS_H_