1 | //===- OpClass.cpp - 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 | //===----------------------------------------------------------------------===// |
8 | |
9 | #include "OpClass.h" |
10 | |
11 | using namespace mlir; |
12 | using namespace mlir::tblgen; |
13 | |
14 | //===----------------------------------------------------------------------===// |
15 | // OpClass definitions |
16 | //===----------------------------------------------------------------------===// |
17 | |
18 | OpClass::OpClass(StringRef name, std::string , |
19 | std::string ) |
20 | : Class(name.str()), |
21 | extraClassDeclaration(std::move(extraClassDeclaration)), |
22 | extraClassDefinition(std::move(extraClassDefinition)), |
23 | parent(addParent(parent: "::mlir::Op" )) { |
24 | parent.addTemplateParam(param: getClassName().str()); |
25 | declare<VisibilityDeclaration>(args: Visibility::Public); |
26 | /// Inherit functions from Op. |
27 | declare<UsingDeclaration>(args: "Op::Op" ); |
28 | declare<UsingDeclaration>(args: "Op::print" ); |
29 | /// Type alias for the adaptor class. |
30 | declare<UsingDeclaration>(args: "Adaptor" , args: className + "Adaptor" ); |
31 | declare<UsingDeclaration>(args: "GenericAdaptor" , |
32 | args: className + "GenericAdaptor<RangeT>" ) |
33 | ->addTemplateParam(param: "RangeT" ); |
34 | declare<UsingDeclaration>( |
35 | args: "FoldAdaptor" , args: "GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>" ); |
36 | } |
37 | |
38 | void OpClass::finalize() { |
39 | Class::finalize(); |
40 | declare<VisibilityDeclaration>(args: Visibility::Public); |
41 | declare<ExtraClassDeclaration>(args&: extraClassDeclaration, args&: extraClassDefinition); |
42 | } |
43 | |