[Mlir-commits] [mlir] 0dc66b7 - [MLIR] Change call sites from deprecated `parseSourceFile()` to `parseSourceFile<ModuleOp>()`.

Christian Sigg llvmlistbot at llvm.org
Sun Mar 6 21:49:53 PST 2022


Author: Christian Sigg
Date: 2022-03-07T06:49:38+01:00
New Revision: 0dc66b76fe4c33843755ade391b85ffda0742aeb

URL: https://github.com/llvm/llvm-project/commit/0dc66b76fe4c33843755ade391b85ffda0742aeb
DIFF: https://github.com/llvm/llvm-project/commit/0dc66b76fe4c33843755ade391b85ffda0742aeb.diff

LOG: [MLIR] Change call sites from deprecated `parseSourceFile()` to `parseSourceFile<ModuleOp>()`.

Mark `parseSourceFile()` deprecated. The functions will be removed two weeks after landing this change.

Reviewed By: rriddle

Differential Revision: https://reviews.llvm.org/D121075

Added: 
    

Modified: 
    mlir/examples/toy/Ch2/toyc.cpp
    mlir/examples/toy/Ch3/toyc.cpp
    mlir/examples/toy/Ch4/toyc.cpp
    mlir/examples/toy/Ch5/toyc.cpp
    mlir/examples/toy/Ch6/toyc.cpp
    mlir/examples/toy/Ch7/toyc.cpp
    mlir/include/mlir/Parser.h
    mlir/lib/ExecutionEngine/JitRunner.cpp
    mlir/lib/Support/MlirOptMain.cpp
    mlir/lib/Tools/mlir-reduce/MlirReduceMain.cpp
    mlir/lib/Translation/Translation.cpp

Removed: 
    


################################################################################
diff  --git a/mlir/examples/toy/Ch2/toyc.cpp b/mlir/examples/toy/Ch2/toyc.cpp
index 5f817dbdff3e2..b03505c35e02f 100644
--- a/mlir/examples/toy/Ch2/toyc.cpp
+++ b/mlir/examples/toy/Ch2/toyc.cpp
@@ -98,7 +98,7 @@ int dumpMLIR() {
   llvm::SourceMgr sourceMgr;
   sourceMgr.AddNewSourceBuffer(std::move(*fileOrErr), llvm::SMLoc());
   mlir::OwningOpRef<mlir::ModuleOp> module =
-      mlir::parseSourceFile(sourceMgr, &context);
+      mlir::parseSourceFile<mlir::ModuleOp>(sourceMgr, &context);
   if (!module) {
     llvm::errs() << "Error can't load file " << inputFilename << "\n";
     return 3;

diff  --git a/mlir/examples/toy/Ch3/toyc.cpp b/mlir/examples/toy/Ch3/toyc.cpp
index 4437e4cdac60e..57787cd81e0de 100644
--- a/mlir/examples/toy/Ch3/toyc.cpp
+++ b/mlir/examples/toy/Ch3/toyc.cpp
@@ -93,7 +93,7 @@ int loadMLIR(llvm::SourceMgr &sourceMgr, mlir::MLIRContext &context,
 
   // Parse the input mlir.
   sourceMgr.AddNewSourceBuffer(std::move(*fileOrErr), llvm::SMLoc());
-  module = mlir::parseSourceFile(sourceMgr, &context);
+  module = mlir::parseSourceFile<mlir::ModuleOp>(sourceMgr, &context);
   if (!module) {
     llvm::errs() << "Error can't load file " << inputFilename << "\n";
     return 3;

diff  --git a/mlir/examples/toy/Ch4/toyc.cpp b/mlir/examples/toy/Ch4/toyc.cpp
index f8c3fda432250..b0c6f11c4a7eb 100644
--- a/mlir/examples/toy/Ch4/toyc.cpp
+++ b/mlir/examples/toy/Ch4/toyc.cpp
@@ -94,7 +94,7 @@ int loadMLIR(llvm::SourceMgr &sourceMgr, mlir::MLIRContext &context,
 
   // Parse the input mlir.
   sourceMgr.AddNewSourceBuffer(std::move(*fileOrErr), llvm::SMLoc());
-  module = mlir::parseSourceFile(sourceMgr, &context);
+  module = mlir::parseSourceFile<mlir::ModuleOp>(sourceMgr, &context);
   if (!module) {
     llvm::errs() << "Error can't load file " << inputFilename << "\n";
     return 3;

diff  --git a/mlir/examples/toy/Ch5/toyc.cpp b/mlir/examples/toy/Ch5/toyc.cpp
index 76fc00fbf463f..dffc657c14463 100644
--- a/mlir/examples/toy/Ch5/toyc.cpp
+++ b/mlir/examples/toy/Ch5/toyc.cpp
@@ -98,7 +98,7 @@ int loadMLIR(llvm::SourceMgr &sourceMgr, mlir::MLIRContext &context,
 
   // Parse the input mlir.
   sourceMgr.AddNewSourceBuffer(std::move(*fileOrErr), llvm::SMLoc());
-  module = mlir::parseSourceFile(sourceMgr, &context);
+  module = mlir::parseSourceFile<mlir::ModuleOp>(sourceMgr, &context);
   if (!module) {
     llvm::errs() << "Error can't load file " << inputFilename << "\n";
     return 3;

diff  --git a/mlir/examples/toy/Ch6/toyc.cpp b/mlir/examples/toy/Ch6/toyc.cpp
index 659104032ecc1..062ca7ca8d802 100644
--- a/mlir/examples/toy/Ch6/toyc.cpp
+++ b/mlir/examples/toy/Ch6/toyc.cpp
@@ -119,7 +119,7 @@ int loadMLIR(mlir::MLIRContext &context,
   // Parse the input mlir.
   llvm::SourceMgr sourceMgr;
   sourceMgr.AddNewSourceBuffer(std::move(*fileOrErr), llvm::SMLoc());
-  module = mlir::parseSourceFile(sourceMgr, &context);
+  module = mlir::parseSourceFile<mlir::ModuleOp>(sourceMgr, &context);
   if (!module) {
     llvm::errs() << "Error can't load file " << inputFilename << "\n";
     return 3;

diff  --git a/mlir/examples/toy/Ch7/toyc.cpp b/mlir/examples/toy/Ch7/toyc.cpp
index 2b976ba97a9e0..d208a0fe779c4 100644
--- a/mlir/examples/toy/Ch7/toyc.cpp
+++ b/mlir/examples/toy/Ch7/toyc.cpp
@@ -119,7 +119,7 @@ int loadMLIR(mlir::MLIRContext &context,
   // Parse the input mlir.
   llvm::SourceMgr sourceMgr;
   sourceMgr.AddNewSourceBuffer(std::move(*fileOrErr), llvm::SMLoc());
-  module = mlir::parseSourceFile(sourceMgr, &context);
+  module = mlir::parseSourceFile<mlir::ModuleOp>(sourceMgr, &context);
   if (!module) {
     llvm::errs() << "Error can't load file " << inputFilename << "\n";
     return 3;

diff  --git a/mlir/include/mlir/Parser.h b/mlir/include/mlir/Parser.h
index 9bf55fee3d1be..48244123478f8 100644
--- a/mlir/include/mlir/Parser.h
+++ b/mlir/include/mlir/Parser.h
@@ -206,21 +206,21 @@ inline OwningOpRef<ContainerOpT> parseSourceString(llvm::StringRef sourceStr,
 
 /// TODO: These methods are deprecated in favor of the above template versions.
 /// They should be removed when usages have been updated.
-inline OwningOpRef<ModuleOp> parseSourceFile(const llvm::SourceMgr &sourceMgr,
-                                             MLIRContext *context) {
+[[deprecated("use parseSourceFile<ModuleOp>")]] inline OwningOpRef<ModuleOp>
+parseSourceFile(const llvm::SourceMgr &sourceMgr, MLIRContext *context) {
   return parseSourceFile<ModuleOp>(sourceMgr, context);
 }
-inline OwningOpRef<ModuleOp> parseSourceFile(llvm::StringRef filename,
-                                             MLIRContext *context) {
+[[deprecated("use parseSourceFile<ModuleOp>")]] inline OwningOpRef<ModuleOp>
+parseSourceFile(llvm::StringRef filename, MLIRContext *context) {
   return parseSourceFile<ModuleOp>(filename, context);
 }
-inline OwningOpRef<ModuleOp> parseSourceFile(llvm::StringRef filename,
-                                             llvm::SourceMgr &sourceMgr,
-                                             MLIRContext *context) {
+[[deprecated("use parseSourceFile<ModuleOp>")]] inline OwningOpRef<ModuleOp>
+parseSourceFile(llvm::StringRef filename, llvm::SourceMgr &sourceMgr,
+                MLIRContext *context) {
   return parseSourceFile<ModuleOp>(filename, sourceMgr, context);
 }
-inline OwningOpRef<ModuleOp> parseSourceString(llvm::StringRef moduleStr,
-                                               MLIRContext *context) {
+[[deprecated("use parseSourceFile<ModuleOp>")]] inline OwningOpRef<ModuleOp>
+parseSourceString(llvm::StringRef moduleStr, MLIRContext *context) {
   return parseSourceString<ModuleOp>(moduleStr, context);
 }
 

diff  --git a/mlir/lib/ExecutionEngine/JitRunner.cpp b/mlir/lib/ExecutionEngine/JitRunner.cpp
index 79468fc6d63de..cbe31be964883 100644
--- a/mlir/lib/ExecutionEngine/JitRunner.cpp
+++ b/mlir/lib/ExecutionEngine/JitRunner.cpp
@@ -122,7 +122,7 @@ static OwningOpRef<ModuleOp> parseMLIRInput(StringRef inputFilename,
 
   llvm::SourceMgr sourceMgr;
   sourceMgr.AddNewSourceBuffer(std::move(file), SMLoc());
-  return OwningOpRef<ModuleOp>(parseSourceFile(sourceMgr, context));
+  return parseSourceFile<ModuleOp>(sourceMgr, context);
 }
 
 static inline Error makeStringError(const Twine &message) {

diff  --git a/mlir/lib/Support/MlirOptMain.cpp b/mlir/lib/Support/MlirOptMain.cpp
index b567097a9e0cb..11114cd22573b 100644
--- a/mlir/lib/Support/MlirOptMain.cpp
+++ b/mlir/lib/Support/MlirOptMain.cpp
@@ -59,7 +59,7 @@ static LogicalResult performActions(raw_ostream &os, bool verifyDiagnostics,
 
   // Parse the input file and reset the context threading state.
   TimingScope parserTiming = timing.nest("Parser");
-  OwningOpRef<ModuleOp> module(parseSourceFile(sourceMgr, context));
+  OwningOpRef<ModuleOp> module(parseSourceFile<ModuleOp>(sourceMgr, context));
   context->enableMultithreading(wasThreadingEnabled);
   if (!module)
     return failure();

diff  --git a/mlir/lib/Tools/mlir-reduce/MlirReduceMain.cpp b/mlir/lib/Tools/mlir-reduce/MlirReduceMain.cpp
index 53e29f5284022..56de3366021dd 100644
--- a/mlir/lib/Tools/mlir-reduce/MlirReduceMain.cpp
+++ b/mlir/lib/Tools/mlir-reduce/MlirReduceMain.cpp
@@ -31,7 +31,7 @@ using namespace mlir;
 static LogicalResult loadModule(MLIRContext &context,
                                 OwningOpRef<ModuleOp> &module,
                                 StringRef inputFilename) {
-  module = parseSourceFile(inputFilename, &context);
+  module = parseSourceFile<ModuleOp>(inputFilename, &context);
   if (!module)
     return failure();
 

diff  --git a/mlir/lib/Translation/Translation.cpp b/mlir/lib/Translation/Translation.cpp
index 6da62f68f55a0..fae87d34d3e8e 100644
--- a/mlir/lib/Translation/Translation.cpp
+++ b/mlir/lib/Translation/Translation.cpp
@@ -101,7 +101,7 @@ TranslateFromMLIRRegistration::TranslateFromMLIRRegistration(
     DialectRegistry registry;
     dialectRegistration(registry);
     context->appendDialectRegistry(registry);
-    auto module = OwningOpRef<ModuleOp>(parseSourceFile(sourceMgr, context));
+    auto module = parseSourceFile<ModuleOp>(sourceMgr, context);
     if (!module || failed(verify(*module)))
       return failure();
     return function(module.get(), output);


        


More information about the Mlir-commits mailing list