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 11 using namespace mlir; 12 using namespace mlir::tblgen; 13 14 //===----------------------------------------------------------------------===// 15 // OpClass definitions 16 //===----------------------------------------------------------------------===// 17 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 } 31 32 void OpClass::finalize() { 33 Class::finalize(); 34 declare<VisibilityDeclaration>(Visibility::Public); 35 declare<ExtraClassDeclaration>(extraClassDeclaration, extraClassDefinition); 36 } 37