aboutsummaryrefslogtreecommitdiffstats
path: root/standalone-opt
diff options
context:
space:
mode:
authorYann Herklotz <git@yannherklotz.com>2021-09-28 14:50:44 +0100
committerYann Herklotz <git@yannherklotz.com>2021-09-28 14:50:44 +0100
commita08f79d3e01c92859e6b33f602b2be2bb8c52e61 (patch)
treeaa6fe94ea8b3ad841dbda0e354a88f8291d6973d /standalone-opt
downloadgsa-mlir-a08f79d3e01c92859e6b33f602b2be2bb8c52e61.tar.gz
gsa-mlir-a08f79d3e01c92859e6b33f602b2be2bb8c52e61.zip
Add initial files
Diffstat (limited to 'standalone-opt')
-rw-r--r--standalone-opt/CMakeLists.txt14
-rw-r--r--standalone-opt/standalone-opt.cpp38
2 files changed, 52 insertions, 0 deletions
diff --git a/standalone-opt/CMakeLists.txt b/standalone-opt/CMakeLists.txt
new file mode 100644
index 0000000..06bbb47
--- /dev/null
+++ b/standalone-opt/CMakeLists.txt
@@ -0,0 +1,14 @@
+get_property(dialect_libs GLOBAL PROPERTY MLIR_DIALECT_LIBS)
+get_property(conversion_libs GLOBAL PROPERTY MLIR_CONVERSION_LIBS)
+set(LIBS
+ ${dialect_libs}
+ ${conversion_libs}
+ MLIROptLib
+ MLIRStandalone
+ )
+add_llvm_executable(standalone-opt standalone-opt.cpp)
+
+llvm_update_compile_flags(standalone-opt)
+target_link_libraries(standalone-opt PRIVATE ${LIBS})
+
+mlir_check_all_link_libraries(standalone-opt)
diff --git a/standalone-opt/standalone-opt.cpp b/standalone-opt/standalone-opt.cpp
new file mode 100644
index 0000000..97a996a
--- /dev/null
+++ b/standalone-opt/standalone-opt.cpp
@@ -0,0 +1,38 @@
+//===- standalone-opt.cpp ---------------------------------------*- C++ -*-===//
+//
+// This file is licensed under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#include "mlir/IR/Dialect.h"
+#include "mlir/IR/MLIRContext.h"
+#include "mlir/InitAllDialects.h"
+#include "mlir/InitAllPasses.h"
+#include "mlir/Pass/Pass.h"
+#include "mlir/Pass/PassManager.h"
+#include "mlir/Support/FileUtilities.h"
+#include "mlir/Support/MlirOptMain.h"
+#include "llvm/Support/CommandLine.h"
+#include "llvm/Support/InitLLVM.h"
+#include "llvm/Support/SourceMgr.h"
+#include "llvm/Support/ToolOutputFile.h"
+
+#include "Standalone/StandaloneDialect.h"
+
+int main(int argc, char **argv) {
+ mlir::registerAllPasses();
+ // TODO: Register standalone passes here.
+
+ mlir::DialectRegistry registry;
+ registry.insert<mlir::standalone::StandaloneDialect>();
+ registry.insert<mlir::StandardOpsDialect>();
+ // Add the following to include *all* MLIR Core dialects, or selectively
+ // include what you need like above. You only need to register dialects that
+ // will be *parsed* by the tool, not the one generated
+ // registerAllDialects(registry);
+
+ return mlir::asMainReturnCode(
+ mlir::MlirOptMain(argc, argv, "Standalone optimizer driver\n", registry));
+}