MLIR 24.0.0git
MLProgramDialect.cpp
Go to the documentation of this file.
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
11
12using namespace mlir;
13using namespace mlir::ml_program;
14
15//===----------------------------------------------------------------------===//
16/// Tablegen Definitions
17//===----------------------------------------------------------------------===//
18
19#include "mlir/Dialect/MLProgram/IR/MLProgramOpsDialect.cpp.inc"
20#define GET_ATTRDEF_CLASSES
21#include "mlir/Dialect/MLProgram/IR/MLProgramAttributes.cpp.inc"
22#define GET_TYPEDEF_CLASSES
23#include "mlir/Dialect/MLProgram/IR/MLProgramTypes.cpp.inc"
24
25namespace {
26
27struct MLProgramInlinerInterface : public DialectInlinerInterface {
28 using DialectInlinerInterface::DialectInlinerInterface;
29
30 bool isLegalToInline(Operation *, Region *, bool,
31 IRMapping &) const override {
32 // We have no specific opinion on whether ops defined in this dialect should
33 // be inlined.
34 return true;
35 }
36};
37
38struct MLProgramOpAsmDialectInterface : public OpAsmDialectInterface {
39 using OpAsmDialectInterface::OpAsmDialectInterface;
40};
41} // namespace
42
43void ml_program::MLProgramDialect::initialize() {
44#define GET_ATTRDEF_LIST
45 addAttributes<
46#include "mlir/Dialect/MLProgram/IR/MLProgramAttributes.cpp.inc"
47 >();
48
49#define GET_TYPEDEF_LIST
50 addTypes<
51#include "mlir/Dialect/MLProgram/IR/MLProgramTypes.cpp.inc"
52 >();
53
54 addOperations<
55#define GET_OP_LIST
56#include "mlir/Dialect/MLProgram/IR/MLProgramOps.cpp.inc"
57 >();
58
59 addInterfaces<MLProgramInlinerInterface, MLProgramOpAsmDialectInterface>();
60}
static bool isLegalToInline(InlinerInterface &interface, Region *src, Region *insertRegion, bool shouldCloneInlinedRegion, IRMapping &valueMapping)
Utility to check that all of the operations within 'src' can be inlined.
This is a utility class for mapping one set of IR entities to another.
Definition IRMapping.h:26
Operation is the basic unit of execution within MLIR.
Definition Operation.h:87
This class contains a list of basic blocks and a link to the parent operation it is attached to.
Definition Region.h:26
Include the generated interface declarations.