From b4726e6e59c79c8b8c4a61275caff75e907da67c Mon Sep 17 00:00:00 2001 From: "A. Unique TensorFlower" Date: Wed, 19 Aug 2020 17:17:34 -0700 Subject: [PATCH] Integrate LLVM at llvm/llvm-project@f9dc2b707935 Updates LLVM usage to match [f9dc2b707935](https://github.com/llvm/llvm-project/commit/f9dc2b707935) PiperOrigin-RevId: 327538369 --- build_tools/llvm_version.txt | 2 +- tools/mlir-hlo-opt/mlir-hlo-opt.cpp | 102 ++-------------------------- 2 files changed, 5 insertions(+), 99 deletions(-) diff --git a/build_tools/llvm_version.txt b/build_tools/llvm_version.txt index 4c70951..3970ba8 100644 --- a/build_tools/llvm_version.txt +++ b/build_tools/llvm_version.txt @@ -1,2 +1,2 @@ -e75bc5c791e0e8dbe79f7453e55af9e8d03c9cc0 +f9dc2b7079350d0fed3bb3775f496b90483c9e42 diff --git a/tools/mlir-hlo-opt/mlir-hlo-opt.cpp b/tools/mlir-hlo-opt/mlir-hlo-opt.cpp index c071e2c..f82c5cc 100644 --- a/tools/mlir-hlo-opt/mlir-hlo-opt.cpp +++ b/tools/mlir-hlo-opt/mlir-hlo-opt.cpp @@ -13,112 +13,18 @@ See the License for the specific language governing permissions and limitations under the License. ==============================================================================*/ -#include "llvm/Support/CommandLine.h" -#include "llvm/Support/InitLLVM.h" -#include "llvm/Support/SourceMgr.h" -#include "llvm/Support/ToolOutputFile.h" #include "mlir-hlo/Dialect/mhlo/IR/register.h" #include "mlir-hlo/Dialect/mhlo/transforms/register_passes.h" -#include "mlir/IR/AsmState.h" -#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" -// NOLINTNEXTLINE -static llvm::cl::opt inputFilename(llvm::cl::Positional, - llvm::cl::desc(""), - llvm::cl::init("-")); - -// NOLINTNEXTLINE -static llvm::cl::opt outputFilename( - "o", llvm::cl::desc("Output filename"), llvm::cl::value_desc("filename"), - llvm::cl::init("-")); - -// NOLINTNEXTLINE -static llvm::cl::opt splitInputFile( - "split-input-file", - llvm::cl::desc("Split the input file into pieces and process each " - "chunk independently"), - llvm::cl::init(false)); - -// NOLINTNEXTLINE -static llvm::cl::opt verifyDiagnostics( - "verify-diagnostics", - llvm::cl::desc("Check that emitted diagnostics match " - "expected-* lines on the corresponding line"), - llvm::cl::init(false)); - -// NOLINTNEXTLINE -static llvm::cl::opt verifyPasses( - "verify-each", - llvm::cl::desc("Run the verifier after each transformation pass"), - llvm::cl::init(true)); - -// NOLINTNEXTLINE -static llvm::cl::opt allowUnregisteredDialects( - "allow-unregistered-dialect", - llvm::cl::desc("Allow operation with no registered dialects"), - llvm::cl::init(false)); - -// NOLINTNEXTLINE -static llvm::cl::opt showDialects( - "show-dialects", llvm::cl::desc("Print the list of registered dialects"), - llvm::cl::init(false)); - int main(int argc, char **argv) { - mlir::registerAllDialects(); + mlir::DialectRegistry registry; + mlir::registerAllDialects(registry); mlir::registerAllPasses(); - - mlir::mhlo::registerAllDialects(); mlir::mhlo::registerAllMhloPasses(); mlir::lmhlo::registerAllLmhloPasses(); - - llvm::InitLLVM y(argc, argv); - - // Register any pass manager command line options. - mlir::registerAsmPrinterCLOptions(); - mlir::registerMLIRContextCLOptions(); - mlir::registerPassManagerCLOptions(); - mlir::PassPipelineCLParser passPipeline("", "Compiler passes to run"); - - // Parse pass names in main to ensure static initialization completed. - llvm::cl::ParseCommandLineOptions(argc, argv, - "MLIR modular optimizer driver\n"); - - if (showDialects) { - mlir::MLIRContext context; - llvm::outs() << "Registered Dialects:\n"; - for (mlir::Dialect *dialect : context.getRegisteredDialects()) { - llvm::outs() << dialect->getNamespace() << "\n"; - } - return 0; - } - - // Set up the input file. - std::string errorMessage; - auto file = mlir::openInputFile(inputFilename, &errorMessage); - if (!file) { - llvm::errs() << errorMessage << "\n"; - return 1; - } - - auto output = mlir::openOutputFile(outputFilename, &errorMessage); - if (!output) { - llvm::errs() << errorMessage << "\n"; - exit(1); - } - - if (failed(MlirOptMain(output->os(), std::move(file), passPipeline, - splitInputFile, verifyDiagnostics, verifyPasses, - allowUnregisteredDialects))) { - return 1; - } - // Keep the output file if the invocation of MlirOptMain was successful. - output->keep(); - return 0; + return failed( + mlir::MlirOptMain(argc, argv, "MLIR HLO pass driver\n", registry)); }