[NFC] Add libcxx python reformat SHA to .git-blame-ignore-revs
[llvm-project.git] / mlir / tools / mlir-tblgen / OpClass.cpp
blob698569c790e934d7f83b941517a09f4b99d63de3
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 //===----------------------------------------------------------------------===//
9 #include "OpClass.h"
11 using namespace mlir;
12 using namespace mlir::tblgen;
14 //===----------------------------------------------------------------------===//
15 // OpClass definitions
16 //===----------------------------------------------------------------------===//
18 OpClass::OpClass(StringRef name, StringRef extraClassDeclaration,
19 std::string extraClassDefinition)
20 : Class(name.str()), extraClassDeclaration(extraClassDeclaration),
21 extraClassDefinition(std::move(extraClassDefinition)),
22 parent(addParent("::mlir::Op")) {
23 parent.addTemplateParam(getClassName().str());
24 declare<VisibilityDeclaration>(Visibility::Public);
25 /// Inherit functions from Op.
26 declare<UsingDeclaration>("Op::Op");
27 declare<UsingDeclaration>("Op::print");
28 /// Type alias for the adaptor class.
29 declare<UsingDeclaration>("Adaptor", className + "Adaptor");
30 declare<UsingDeclaration>("GenericAdaptor",
31 className + "GenericAdaptor<RangeT>")
32 ->addTemplateParam("RangeT");
33 declare<UsingDeclaration>(
34 "FoldAdaptor", "GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>");
37 void OpClass::finalize() {
38 Class::finalize();
39 declare<VisibilityDeclaration>(Visibility::Public);
40 declare<ExtraClassDeclaration>(extraClassDeclaration.str(),
41 extraClassDefinition);