FLANG

FIRDialect.h
1 //===-- Optimizer/Dialect/FIRDialect.h -- FIR dialect -----------*- C++ -*-===//
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 #ifndef OPTIMIZER_DIALECT_FIRDIALECT_H
10 #define OPTIMIZER_DIALECT_FIRDIALECT_H
11
12 #include "mlir/IR/Dialect.h"
13 #include "mlir/InitAllDialects.h"
14 #include "mlir/InitAllPasses.h"
15
16 namespace fir {
17
19 class FIROpsDialect final : public mlir::Dialect {
20 public:
21 explicit FIROpsDialect(mlir::MLIRContext *ctx);
22 virtual ~FIROpsDialect();
23
24 static llvm::StringRef getDialectNamespace() { return "fir"; }
25
26 mlir::Type parseType(mlir::DialectAsmParser &parser) const override;
27 void printType(mlir::Type ty, mlir::DialectAsmPrinter &p) const override;
28
29 mlir::Attribute parseAttribute(mlir::DialectAsmParser &parser,
30 mlir::Type type) const override;
31 void printAttribute(mlir::Attribute attr,
32 mlir::DialectAsmPrinter &p) const override;
33 };
34
36 inline void registerFIR() {
37 // we want to register exactly once
38 [[maybe_unused]] static bool init_once = [] {
39 mlir::registerDialect<mlir::AffineDialect>();
40 mlir::registerDialect<mlir::LLVM::LLVMDialect>();
41 mlir::registerDialect<mlir::omp::OpenMPDialect>();
42 mlir::registerDialect<mlir::scf::SCFDialect>();
43 mlir::registerDialect<mlir::StandardOpsDialect>();
44 mlir::registerDialect<mlir::vector::VectorDialect>();
45 mlir::registerDialect<FIROpsDialect>();
46 return true;
47 }();
48 }
49
52 inline void registerGeneralPasses() {
53 mlir::createCanonicalizerPass();
54 mlir::createCSEPass();
55 mlir::createSuperVectorizePass({});
56 mlir::createLoopUnrollPass();
57 mlir::createLoopUnrollAndJamPass();
58 mlir::createSimplifyAffineStructuresPass();
59 mlir::createLoopFusionPass();
60 mlir::createLoopInvariantCodeMotionPass();
61 mlir::createAffineLoopInvariantCodeMotionPass();
62 mlir::createPipelineDataTransferPass();
63 mlir::createLowerAffinePass();
64 mlir::createLoopTilingPass(0);
65 mlir::createLoopCoalescingPass();
66 mlir::createAffineDataCopyGenerationPass(0, 0);
67 mlir::createMemRefDataFlowOptPass();
68 mlir::createStripDebugInfoPass();
69 mlir::createPrintOpStatsPass();
70 mlir::createInlinerPass();
71 mlir::createSymbolDCEPass();
72 mlir::createLocationSnapshotPass({});
73 }
74
75 inline void registerFIRPasses() { registerGeneralPasses(); }
76
77 } // namespace fir
78
79 #endif // OPTIMIZER_DIALECT_FIRDIALECT_H
fir::FIROpsDialect
FIR dialect.
Definition: FIRDialect.h:19