Skip to content

Commit e75bc5c

Browse files
committed
Revert "Separate the Registration from Loading dialects in the Context"
This reverts commit d14cf45. The build is broken with GCC-5.
1 parent c996d49 commit e75bc5c

File tree

95 files changed

+239
-761
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

95 files changed

+239
-761
lines changed

mlir/examples/standalone/standalone-opt/standalone-opt.cpp

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -24,16 +24,9 @@
2424
int main(int argc, char **argv) {
2525
mlir::registerAllDialects();
2626
mlir::registerAllPasses();
27-
// TODO: Register standalone passes here.
2827

29-
mlir::DialectRegistry registry;
30-
registry.insert<mlir::standalone::StandaloneDialect>();
31-
registry.insert<mlir::StandardOpsDialect>();
32-
// Add the following to include *all* MLIR Core dialects, or selectively
33-
// include what you need like above. You only need to register dialects that
34-
// will be *parsed* by the tool, not the one generated
35-
// registerAllDialects(registry);
28+
mlir::registerDialect<mlir::standalone::StandaloneDialect>();
29+
// TODO: Register standalone passes here.
3630

37-
return failed(
38-
mlir::MlirOptMain(argc, argv, "Standalone optimizer driver\n", registry));
31+
return failed(mlir::MlirOptMain(argc, argv, "Standalone optimizer driver\n"));
3932
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
// RUN: standalone-opt --show-dialects | FileCheck %s
2-
// CHECK: Available Dialects:
2+
// CHECK: Registered Dialects:
33
// CHECK: standalone

mlir/examples/toy/Ch2/toyc.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,9 +68,10 @@ std::unique_ptr<toy::ModuleAST> parseInputFile(llvm::StringRef filename) {
6868
}
6969

7070
int dumpMLIR() {
71-
mlir::MLIRContext context(/*loadAllDialects=*/false);
72-
// Load our Dialect in this MLIR Context.
73-
context.getOrLoadDialect<mlir::toy::ToyDialect>();
71+
// Register our Dialect with MLIR.
72+
mlir::registerDialect<mlir::toy::ToyDialect>();
73+
74+
mlir::MLIRContext context;
7475

7576
// Handle '.toy' input to the compiler.
7677
if (inputType != InputType::MLIR &&

mlir/examples/toy/Ch3/toyc.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -102,10 +102,10 @@ int loadMLIR(llvm::SourceMgr &sourceMgr, mlir::MLIRContext &context,
102102
}
103103

104104
int dumpMLIR() {
105-
mlir::MLIRContext context(/*loadAllDialects=*/false);
106-
// Load our Dialect in this MLIR Context.
107-
context.getOrLoadDialect<mlir::toy::ToyDialect>();
105+
// Register our Dialect with MLIR.
106+
mlir::registerDialect<mlir::toy::ToyDialect>();
108107

108+
mlir::MLIRContext context;
109109
mlir::OwningModuleRef module;
110110
llvm::SourceMgr sourceMgr;
111111
mlir::SourceMgrDiagnosticHandler sourceMgrHandler(sourceMgr, &context);

mlir/examples/toy/Ch4/toyc.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -103,10 +103,10 @@ int loadMLIR(llvm::SourceMgr &sourceMgr, mlir::MLIRContext &context,
103103
}
104104

105105
int dumpMLIR() {
106-
mlir::MLIRContext context(/*loadAllDialects=*/false);
107-
// Load our Dialect in this MLIR Context.
108-
context.getOrLoadDialect<mlir::toy::ToyDialect>();
106+
// Register our Dialect with MLIR.
107+
mlir::registerDialect<mlir::toy::ToyDialect>();
109108

109+
mlir::MLIRContext context;
110110
mlir::OwningModuleRef module;
111111
llvm::SourceMgr sourceMgr;
112112
mlir::SourceMgrDiagnosticHandler sourceMgrHandler(sourceMgr, &context);

mlir/examples/toy/Ch5/mlir/LowerToAffineLoops.cpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -256,9 +256,6 @@ struct TransposeOpLowering : public ConversionPattern {
256256
namespace {
257257
struct ToyToAffineLoweringPass
258258
: public PassWrapper<ToyToAffineLoweringPass, FunctionPass> {
259-
void getDependentDialects(DialectRegistry &registry) const override {
260-
registry.insert<AffineDialect, StandardOpsDialect>();
261-
}
262259
void runOnFunction() final;
263260
};
264261
} // end anonymous namespace.

mlir/examples/toy/Ch5/toyc.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -106,10 +106,10 @@ int loadMLIR(llvm::SourceMgr &sourceMgr, mlir::MLIRContext &context,
106106
}
107107

108108
int dumpMLIR() {
109-
mlir::MLIRContext context(/*loadAllDialects=*/false);
110-
// Load our Dialect in this MLIR Context.
111-
context.getOrLoadDialect<mlir::toy::ToyDialect>();
109+
// Register our Dialect with MLIR.
110+
mlir::registerDialect<mlir::toy::ToyDialect>();
112111

112+
mlir::MLIRContext context;
113113
mlir::OwningModuleRef module;
114114
llvm::SourceMgr sourceMgr;
115115
mlir::SourceMgrDiagnosticHandler sourceMgrHandler(sourceMgr, &context);

mlir/examples/toy/Ch6/mlir/LowerToAffineLoops.cpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -255,9 +255,6 @@ struct TransposeOpLowering : public ConversionPattern {
255255
namespace {
256256
struct ToyToAffineLoweringPass
257257
: public PassWrapper<ToyToAffineLoweringPass, FunctionPass> {
258-
void getDependentDialects(DialectRegistry &registry) const override {
259-
registry.insert<AffineDialect, StandardOpsDialect>();
260-
}
261258
void runOnFunction() final;
262259
};
263260
} // end anonymous namespace.

mlir/examples/toy/Ch6/mlir/LowerToLLVM.cpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -159,9 +159,6 @@ class PrintOpLowering : public ConversionPattern {
159159
namespace {
160160
struct ToyToLLVMLoweringPass
161161
: public PassWrapper<ToyToLLVMLoweringPass, OperationPass<ModuleOp>> {
162-
void getDependentDialects(DialectRegistry &registry) const override {
163-
registry.insert<LLVM::LLVMDialect, scf::SCFDialect>();
164-
}
165162
void runOnOperation() final;
166163
};
167164
} // end anonymous namespace

mlir/examples/toy/Ch6/toyc.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -255,10 +255,10 @@ int main(int argc, char **argv) {
255255

256256
// If we aren't dumping the AST, then we are compiling with/to MLIR.
257257

258-
mlir::MLIRContext context(/*loadAllDialects=*/false);
259-
// Load our Dialect in this MLIR Context.
260-
context.getOrLoadDialect<mlir::toy::ToyDialect>();
258+
// Register our Dialect with MLIR.
259+
mlir::registerDialect<mlir::toy::ToyDialect>();
261260

261+
mlir::MLIRContext context;
262262
mlir::OwningModuleRef module;
263263
if (int error = loadAndProcessMLIR(context, module))
264264
return error;

0 commit comments

Comments
 (0)