[Infra] Fix version-check workflow (#100090)
[llvm-project.git] / mlir / tools / mlir-tblgen / OpClass.cpp
blob60fa1833ce625ef843f38373bcb00f08a4292e63
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, std::string extraClassDeclaration,
19 std::string extraClassDefinition)
20 : Class(name.str()),
21 extraClassDeclaration(std::move(extraClassDeclaration)),
22 extraClassDefinition(std::move(extraClassDefinition)),
23 parent(addParent("::mlir::Op")) {
24 parent.addTemplateParam(getClassName().str());
25 declare<VisibilityDeclaration>(Visibility::Public);
26 /// Inherit functions from Op.
27 declare<UsingDeclaration>("Op::Op");
28 declare<UsingDeclaration>("Op::print");
29 /// Type alias for the adaptor class.
30 declare<UsingDeclaration>("Adaptor", className + "Adaptor");
31 declare<UsingDeclaration>("GenericAdaptor",
32 className + "GenericAdaptor<RangeT>")
33 ->addTemplateParam("RangeT");
34 declare<UsingDeclaration>(
35 "FoldAdaptor", "GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>");
38 void OpClass::finalize() {
39 Class::finalize();
40 declare<VisibilityDeclaration>(Visibility::Public);
41 declare<ExtraClassDeclaration>(extraClassDeclaration, extraClassDefinition);