| 1 | //===- MLProgramDialect.cpp - MLProgram dialect implementation ------------===// |
| 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 "mlir/Dialect/MLProgram/IR/MLProgram.h" |
| 10 | #include "mlir/IR/DialectImplementation.h" |
| 11 | #include "mlir/Transforms/InliningUtils.h" |
| 12 | #include "llvm/ADT/TypeSwitch.h" |
| 13 | |
| 14 | using namespace mlir; |
| 15 | using namespace mlir::ml_program; |
| 16 | |
| 17 | //===----------------------------------------------------------------------===// |
| 18 | /// Tablegen Definitions |
| 19 | //===----------------------------------------------------------------------===// |
| 20 | |
| 21 | #include "mlir/Dialect/MLProgram/IR/MLProgramOpsDialect.cpp.inc" |
| 22 | #define GET_ATTRDEF_CLASSES |
| 23 | #include "mlir/Dialect/MLProgram/IR/MLProgramAttributes.cpp.inc" |
| 24 | #define GET_TYPEDEF_CLASSES |
| 25 | #include "mlir/Dialect/MLProgram/IR/MLProgramTypes.cpp.inc" |
| 26 | |
| 27 | namespace { |
| 28 | |
| 29 | struct MLProgramInlinerInterface : public DialectInlinerInterface { |
| 30 | using DialectInlinerInterface::DialectInlinerInterface; |
| 31 | |
| 32 | bool isLegalToInline(Operation *, Region *, bool, |
| 33 | IRMapping &) const override { |
| 34 | // We have no specific opinion on whether ops defined in this dialect should |
| 35 | // be inlined. |
| 36 | return true; |
| 37 | } |
| 38 | }; |
| 39 | |
| 40 | struct MLProgramOpAsmDialectInterface : public OpAsmDialectInterface { |
| 41 | using OpAsmDialectInterface::OpAsmDialectInterface; |
| 42 | }; |
| 43 | } // namespace |
| 44 | |
| 45 | void ml_program::MLProgramDialect::initialize() { |
| 46 | #define GET_ATTRDEF_LIST |
| 47 | addAttributes< |
| 48 | #include "mlir/Dialect/MLProgram/IR/MLProgramAttributes.cpp.inc" |
| 49 | >(); |
| 50 | |
| 51 | #define GET_TYPEDEF_LIST |
| 52 | addTypes< |
| 53 | #include "mlir/Dialect/MLProgram/IR/MLProgramTypes.cpp.inc" |
| 54 | >(); |
| 55 | |
| 56 | addOperations< |
| 57 | #define GET_OP_LIST |
| 58 | #include "mlir/Dialect/MLProgram/IR/MLProgramOps.cpp.inc" |
| 59 | >(); |
| 60 | |
| 61 | addInterfaces<MLProgramInlinerInterface, MLProgramOpAsmDialectInterface>(); |
| 62 | } |
| 63 | |