[Mlir-commits] [mlir] 2ef95ef - Revert "[mlirTranslateMain] Add a customization callback."
Chris Lattner
llvmlistbot at llvm.org
Mon Mar 14 22:04:50 PDT 2022
Author: Chris Lattner
Date: 2022-03-14T22:04:46-07:00
New Revision: 2ef95efb414e215490a222de05cafdffb8054758
URL: https://github.com/llvm/llvm-project/commit/2ef95efb414e215490a222de05cafdffb8054758
DIFF: https://github.com/llvm/llvm-project/commit/2ef95efb414e215490a222de05cafdffb8054758.diff
LOG: Revert "[mlirTranslateMain] Add a customization callback."
This reverts commit f18d6af7e972ed0e2215ad098b4c5f52ccb68b5f.
This patch is a more controversial than I expected, it is
better to revert while the discussion continues. xref this
thread:
https://discourse.llvm.org/t/doc-mlir-translate-mlir-opt/60751/
xref this phab patch: https://reviews.llvm.org/D120970
Differential Revision: https://reviews.llvm.org/D121668
Added:
Modified:
mlir/include/mlir/Tools/mlir-translate/MlirTranslateMain.h
mlir/lib/Tools/mlir-translate/MlirTranslateMain.cpp
Removed:
################################################################################
diff --git a/mlir/include/mlir/Tools/mlir-translate/MlirTranslateMain.h b/mlir/include/mlir/Tools/mlir-translate/MlirTranslateMain.h
index 71ff20413448f..47769873529e6 100644
--- a/mlir/include/mlir/Tools/mlir-translate/MlirTranslateMain.h
+++ b/mlir/include/mlir/Tools/mlir-translate/MlirTranslateMain.h
@@ -13,30 +13,16 @@
#ifndef MLIR_TOOLS_MLIRTRANSLATE_MLIRTRANSLATEMAIN_H
#define MLIR_TOOLS_MLIRTRANSLATE_MLIRTRANSLATEMAIN_H
-#include "mlir/IR/Dialect.h"
#include "mlir/Support/LogicalResult.h"
-#include "llvm/ADT/STLFunctionalExtras.h"
#include "llvm/ADT/StringRef.h"
namespace mlir {
-
/// Translate to/from an MLIR module from/to an external representation (e.g.
/// LLVM IR, SPIRV binary, ...). This is the entry point for the implementation
/// of tools like `mlir-translate`. The translation to perform is parsed from
/// the command line. The `toolName` argument is used for the header displayed
/// by `--help`.
-///
-/// Dialect translation typically registers the dialects produced or returned
-/// by the translation itself, but some translation testing tools may want
-/// additional dialects registered so the .mlir parser can read them. In this
-/// case, `extraDialects` may be specified with additional dialects to use.
-///
-/// The client may specify a "customization" function if they'd like, which
-/// is invoked when an MLIRContext is set up, allowing custom settings.
-LogicalResult
-mlirTranslateMain(int argc, char **argv, StringRef toolName,
- const DialectRegistry &extraDialects = DialectRegistry(),
- function_ref<void(MLIRContext &)> customization = {});
+LogicalResult mlirTranslateMain(int argc, char **argv, StringRef toolName);
} // namespace mlir
#endif // MLIR_TOOLS_MLIRTRANSLATE_MLIRTRANSLATEMAIN_H
diff --git a/mlir/lib/Tools/mlir-translate/MlirTranslateMain.cpp b/mlir/lib/Tools/mlir-translate/MlirTranslateMain.cpp
index 5c673c4e2d162..bce04e7959fe7 100644
--- a/mlir/lib/Tools/mlir-translate/MlirTranslateMain.cpp
+++ b/mlir/lib/Tools/mlir-translate/MlirTranslateMain.cpp
@@ -22,13 +22,11 @@
using namespace mlir;
//===----------------------------------------------------------------------===//
-// mlir-translate tool driver
+// Translation Parser
//===----------------------------------------------------------------------===//
-LogicalResult
-mlir::mlirTranslateMain(int argc, char **argv, llvm::StringRef toolName,
- const DialectRegistry &extraDialects,
- llvm::function_ref<void(MLIRContext &)> customization) {
+LogicalResult mlir::mlirTranslateMain(int argc, char **argv,
+ llvm::StringRef toolName) {
static llvm::cl::opt<std::string> inputFilename(
llvm::cl::Positional, llvm::cl::desc("<input file>"),
@@ -82,22 +80,8 @@ mlir::mlirTranslateMain(int argc, char **argv, llvm::StringRef toolName,
auto processBuffer = [&](std::unique_ptr<llvm::MemoryBuffer> ownedBuffer,
raw_ostream &os) {
MLIRContext context;
-
- // If the client wanted to register additional dialects, go ahead and add
- // them to our context.
- context.appendDialectRegistry(extraDialects);
-
- // If a customization callback was provided, apply it to the MLIRContext.
- // This could add dialects to the registry or change context defaults.
- if (customization)
- customization(context);
-
- // If command line flags were used to customize the context, apply their
- // settings.
- if (allowUnregisteredDialects.getNumOccurrences())
- context.allowUnregisteredDialects(allowUnregisteredDialects);
+ context.allowUnregisteredDialects(allowUnregisteredDialects);
context.printOpOnDiagnostic(!verifyDiagnostics);
-
llvm::SourceMgr sourceMgr;
sourceMgr.AddNewSourceBuffer(std::move(ownedBuffer), SMLoc());
More information about the Mlir-commits
mailing list