Enzyme main
Loading...
Searching...
No Matches
Dialect.cpp
Go to the documentation of this file.
1//===- EnzymeDialect.cpp - Enzyme dialect -----------------------*- C++ -*-===//
2//
3// This file is licensed 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 "Dialect.h"
10#include "Ops.h"
11#include "mlir/IR/DialectImplementation.h"
12
13#include "mlir/Dialect/Affine/IR/AffineOps.h"
14#include "mlir/Dialect/MemRef/IR/MemRef.h"
15#include "mlir/IR/Builders.h"
16#include "mlir/Transforms/InliningUtils.h"
17#include "llvm/ADT/TypeSwitch.h"
18
19#include "Dialect/EnzymeEnums.cpp.inc"
20#include "Dialect/EnzymeOpsDialect.cpp.inc"
21
22#define GET_OP_CLASSES
23#include "Dialect/EnzymeOps.cpp.inc"
24#define GET_TYPEDEF_CLASSES
25#include "Dialect/EnzymeOpsTypes.cpp.inc"
26// #include "Dialect/EnzymeTypes.cpp.inc"
27
28using namespace mlir;
29using namespace mlir::enzyme;
30
31//===----------------------------------------------------------------------===//
32// Enzyme dialect.
33//===----------------------------------------------------------------------===//
34
35namespace {
36struct EnzymeDialectInlinerInterface : public DialectInlinerInterface {
37 using DialectInlinerInterface::DialectInlinerInterface;
38
39 bool isLegalToInline(Operation * /*call*/, Operation * /*callable*/,
40 bool /*wouldBeCloned*/) const final {
41 return true;
42 }
43
44 bool isLegalToInline(Region * /*dest*/, Region * /*src*/,
45 bool /*wouldBeCloned*/,
46 IRMapping & /*valueMapping*/) const final {
47 return true;
48 }
49
50 bool isLegalToInline(Operation * /*op*/, Region * /*dest*/,
51 bool /*wouldBeCloned*/,
52 IRMapping & /*valueMapping*/) const final {
53 return true;
54 }
55};
56} // namespace
57
58void EnzymeDialect::initialize() {
59 addInterfaces<EnzymeDialectInlinerInterface>();
60 addOperations<
61#define GET_OP_LIST
62#include "Dialect/EnzymeOps.cpp.inc"
63 >();
64 addAttributes<
65#define GET_ATTRDEF_LIST
66#include "Dialect/EnzymeAttributes.cpp.inc"
67 >();
68 addTypes<
69#define GET_TYPEDEF_LIST
70#include "Dialect/EnzymeOpsTypes.cpp.inc"
71 >();
72}
73
74#define GET_ATTRDEF_CLASSES
75#include "Dialect/EnzymeAttributes.cpp.inc"