1 //===- OpClass.cpp - Implementation of an Op Class ------------------------===//
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
7 //===----------------------------------------------------------------------===//
12 using namespace mlir::tblgen
;
14 //===----------------------------------------------------------------------===//
15 // OpClass definitions
16 //===----------------------------------------------------------------------===//
18 OpClass::OpClass(StringRef name
, std::string extraClassDeclaration
,
19 std::string extraClassDefinition
)
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() {
40 declare
<VisibilityDeclaration
>(Visibility::Public
);
41 declare
<ExtraClassDeclaration
>(extraClassDeclaration
, extraClassDefinition
);