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
11using namespace mlir;
12using namespace mlir::tblgen;
13
14//===----------------------------------------------------------------------===//
15// OpClass definitions
16//===----------------------------------------------------------------------===//
17
18OpClass::OpClass(StringRef name, std::string extraClassDeclaration,
19 std::string extraClassDefinition)
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
38void OpClass::finalize() {
39 Class::finalize();
40 declare<VisibilityDeclaration>(args: Visibility::Public);
41 declare<ExtraClassDeclaration>(args&: extraClassDeclaration, args&: extraClassDefinition);
42}
43

source code of mlir/tools/mlir-tblgen/OpClass.cpp