[Mlir-commits] [mlir] 6b7d211 - [mlir][NFC] Move MlirOptMain to the Tools/ directory

River Riddle llvmlistbot at llvm.org
Mon Mar 7 01:06:16 PST 2022


Author: River Riddle
Date: 2022-03-07T01:05:38-08:00
New Revision: 6b7d211a1b80957619a0ca81f4d2b832bf7e593b

URL: https://github.com/llvm/llvm-project/commit/6b7d211a1b80957619a0ca81f4d2b832bf7e593b
DIFF: https://github.com/llvm/llvm-project/commit/6b7d211a1b80957619a0ca81f4d2b832bf7e593b.diff

LOG: [mlir][NFC] Move MlirOptMain to the Tools/ directory

MlirOptMain is currently awkwardly shoved into mlir/Support. This commit
moves it to the Tools/ directory, which is intended for libraries used to
implement tools.

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

Added: 
    mlir/include/mlir/Tools/mlir-opt/MlirOptMain.h
    mlir/lib/Tools/mlir-opt/CMakeLists.txt
    mlir/lib/Tools/mlir-opt/MlirOptMain.cpp

Modified: 
    flang/tools/fir-opt/fir-opt.cpp
    mlir/examples/standalone/standalone-opt/standalone-opt.cpp
    mlir/lib/Support/CMakeLists.txt
    mlir/lib/Tools/CMakeLists.txt
    mlir/tools/mlir-opt/mlir-opt.cpp

Removed: 
    mlir/include/mlir/Support/MlirOptMain.h
    mlir/lib/Support/MlirOptMain.cpp


################################################################################
diff  --git a/flang/tools/fir-opt/fir-opt.cpp b/flang/tools/fir-opt/fir-opt.cpp
index 2a0fb7d99b005..dc3a0a4b84764 100644
--- a/flang/tools/fir-opt/fir-opt.cpp
+++ b/flang/tools/fir-opt/fir-opt.cpp
@@ -11,7 +11,7 @@
 //
 //===----------------------------------------------------------------------===//
 
-#include "mlir/Support/MlirOptMain.h"
+#include "mlir/Tools/mlir-opt/MlirOptMain.h"
 #include "flang/Optimizer/CodeGen/CodeGen.h"
 #include "flang/Optimizer/Support/InitFIR.h"
 #include "flang/Optimizer/Transforms/Passes.h"

diff  --git a/mlir/examples/standalone/standalone-opt/standalone-opt.cpp b/mlir/examples/standalone/standalone-opt/standalone-opt.cpp
index 5a1354d4648ef..e84628f57c5b8 100644
--- a/mlir/examples/standalone/standalone-opt/standalone-opt.cpp
+++ b/mlir/examples/standalone/standalone-opt/standalone-opt.cpp
@@ -14,7 +14,7 @@
 #include "mlir/Pass/Pass.h"
 #include "mlir/Pass/PassManager.h"
 #include "mlir/Support/FileUtilities.h"
-#include "mlir/Support/MlirOptMain.h"
+#include "mlir/Tools/mlir-opt/MlirOptMain.h"
 #include "llvm/Support/CommandLine.h"
 #include "llvm/Support/InitLLVM.h"
 #include "llvm/Support/SourceMgr.h"

diff  --git a/mlir/include/mlir/Support/MlirOptMain.h b/mlir/include/mlir/Tools/mlir-opt/MlirOptMain.h
similarity index 97%
rename from mlir/include/mlir/Support/MlirOptMain.h
rename to mlir/include/mlir/Tools/mlir-opt/MlirOptMain.h
index 666d83a614a5a..7446455503ce1 100644
--- a/mlir/include/mlir/Support/MlirOptMain.h
+++ b/mlir/include/mlir/Tools/mlir-opt/MlirOptMain.h
@@ -10,8 +10,8 @@
 //
 //===----------------------------------------------------------------------===//
 
-#ifndef MLIR_SUPPORT_MLIROPTMAIN_H
-#define MLIR_SUPPORT_MLIROPTMAIN_H
+#ifndef MLIR_TOOLS_MLIROPT_MLIROPTMAIN_H
+#define MLIR_TOOLS_MLIROPT_MLIROPTMAIN_H
 
 #include "mlir/Support/LogicalResult.h"
 #include "llvm/ADT/StringRef.h"
@@ -95,4 +95,4 @@ inline int asMainReturnCode(LogicalResult r) {
 
 } // namespace mlir
 
-#endif // MLIR_SUPPORT_MLIROPTMAIN_H
+#endif // MLIR_TOOLS_MLIROPT_MLIROPTMAIN_H

diff  --git a/mlir/lib/Support/CMakeLists.txt b/mlir/lib/Support/CMakeLists.txt
index 9e5d039c2f1a6..aae02573c020f 100644
--- a/mlir/lib/Support/CMakeLists.txt
+++ b/mlir/lib/Support/CMakeLists.txt
@@ -3,7 +3,6 @@ set(LLVM_OPTIONAL_SOURCES
   FileUtilities.cpp
   IndentedOstream.cpp
   InterfaceSupport.cpp
-  MlirOptMain.cpp
   StorageUniquer.cpp
   Timing.cpp
   ToolUtilities.cpp
@@ -24,18 +23,6 @@ add_mlir_library(MLIRSupport
   LINK_LIBS PUBLIC
   ${LLVM_PTHREAD_LIB})
 
-add_mlir_library(MLIROptLib
-  MlirOptMain.cpp
-
-  ADDITIONAL_HEADER_DIRS
-  ${MLIR_MAIN_INCLUDE_DIR}/mlir/Support
-
-  LINK_LIBS PUBLIC
-  MLIRPass
-  MLIRParser
-  MLIRSupport
-  )
-
 # This doesn't use add_mlir_library as it is used in mlir-tblgen and else
 # mlir-tblgen ends up depending on mlir-generic-headers.
 add_llvm_library(MLIRSupportIndentedOstream

diff  --git a/mlir/lib/Tools/CMakeLists.txt b/mlir/lib/Tools/CMakeLists.txt
index cf598f7c1f029..88c2b25bce288 100644
--- a/mlir/lib/Tools/CMakeLists.txt
+++ b/mlir/lib/Tools/CMakeLists.txt
@@ -1,3 +1,4 @@
 add_subdirectory(mlir-lsp-server)
+add_subdirectory(mlir-opt)
 add_subdirectory(mlir-reduce)
 add_subdirectory(PDLL)

diff  --git a/mlir/lib/Tools/mlir-opt/CMakeLists.txt b/mlir/lib/Tools/mlir-opt/CMakeLists.txt
new file mode 100644
index 0000000000000..318eb0a383fd0
--- /dev/null
+++ b/mlir/lib/Tools/mlir-opt/CMakeLists.txt
@@ -0,0 +1,11 @@
+add_mlir_library(MLIROptLib
+  MlirOptMain.cpp
+
+  ADDITIONAL_HEADER_DIRS
+  ${MLIR_MAIN_INCLUDE_DIR}/mlir/Tools/mlir-opt
+
+  LINK_LIBS PUBLIC
+  MLIRPass
+  MLIRParser
+  MLIRSupport
+  )

diff  --git a/mlir/lib/Support/MlirOptMain.cpp b/mlir/lib/Tools/mlir-opt/MlirOptMain.cpp
similarity index 99%
rename from mlir/lib/Support/MlirOptMain.cpp
rename to mlir/lib/Tools/mlir-opt/MlirOptMain.cpp
index 1926edcc695b8..ccfc1a5ad0039 100644
--- a/mlir/lib/Support/MlirOptMain.cpp
+++ b/mlir/lib/Tools/mlir-opt/MlirOptMain.cpp
@@ -11,7 +11,7 @@
 //
 //===----------------------------------------------------------------------===//
 
-#include "mlir/Support/MlirOptMain.h"
+#include "mlir/Tools/mlir-opt/MlirOptMain.h"
 #include "mlir/IR/AsmState.h"
 #include "mlir/IR/Attributes.h"
 #include "mlir/IR/BuiltinOps.h"

diff  --git a/mlir/tools/mlir-opt/mlir-opt.cpp b/mlir/tools/mlir-opt/mlir-opt.cpp
index 2bb690bede084..7336980583bb2 100644
--- a/mlir/tools/mlir-opt/mlir-opt.cpp
+++ b/mlir/tools/mlir-opt/mlir-opt.cpp
@@ -18,7 +18,7 @@
 #include "mlir/Pass/Pass.h"
 #include "mlir/Pass/PassManager.h"
 #include "mlir/Support/FileUtilities.h"
-#include "mlir/Support/MlirOptMain.h"
+#include "mlir/Tools/mlir-opt/MlirOptMain.h"
 #include "llvm/Support/CommandLine.h"
 #include "llvm/Support/InitLLVM.h"
 #include "llvm/Support/SourceMgr.h"


        


More information about the Mlir-commits mailing list