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
, 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() {
39 declare
<VisibilityDeclaration
>(Visibility::Public
);
40 declare
<ExtraClassDeclaration
>(extraClassDeclaration
.str(),
41 extraClassDefinition
);