File tree Expand file tree Collapse file tree 2 files changed +15
-17
lines changed
include/flang/Optimizer/Dialect Expand file tree Collapse file tree 2 files changed +15
-17
lines changed Original file line number Diff line number Diff line change @@ -32,19 +32,17 @@ class FIROpsDialect final : public mlir::Dialect {
32
32
mlir::DialectAsmPrinter &p) const override ;
33
33
};
34
34
35
- // / Register the dialect with MLIR
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
- }();
35
+ // / Register the dialect with the provided registry.
36
+ inline void registerFIRDialects (mlir::DialectRegistry ®istry) {
37
+ // clang-format off
38
+ registry.insert <mlir::AffineDialect,
39
+ mlir::LLVM::LLVMDialect,
40
+ mlir::omp::OpenMPDialect,
41
+ mlir::scf::SCFDialect,
42
+ mlir::StandardOpsDialect,
43
+ mlir::vector::VectorDialect,
44
+ FIROpsDialect>();
45
+ // clang-format on
48
46
}
49
47
50
48
// / Register the standard passes we use. This comes from registerAllPasses(),
Original file line number Diff line number Diff line change @@ -60,8 +60,9 @@ static int compileFIR() {
60
60
// load the file into a module
61
61
SourceMgr sourceMgr;
62
62
sourceMgr.AddNewSourceBuffer (std::move (*fileOrErr), SMLoc ());
63
- auto context = std::make_unique<mlir::MLIRContext>();
64
- auto owningRef = mlir::parseSourceFile (sourceMgr, context.get ());
63
+ mlir::MLIRContext context;
64
+ fir::registerFIRDialects (context.getDialectRegistry ());
65
+ auto owningRef = mlir::parseSourceFile (sourceMgr, &context);
65
66
66
67
if (!owningRef) {
67
68
errs () << " Error can't load file " << inputFilename << ' \n ' ;
@@ -76,7 +77,7 @@ static int compileFIR() {
76
77
ToolOutputFile out (outputFilename, ec, sys::fs::OF_None);
77
78
78
79
// run passes
79
- mlir::PassManager pm{context. get () };
80
+ mlir::PassManager pm{& context};
80
81
mlir::applyPassManagerCLOptions (pm);
81
82
if (emitFir) {
82
83
// parse the input and pretty-print it back out
@@ -103,7 +104,6 @@ static int compileFIR() {
103
104
}
104
105
105
106
int main (int argc, char **argv) {
106
- fir::registerFIR ();
107
107
fir::registerFIRPasses ();
108
108
[[maybe_unused]] InitLLVM y (argc, argv);
109
109
mlir::registerPassManagerCLOptions ();
You can’t perform that action at this time.
0 commit comments