
`InitAll***` functions are used by `opt`-style tools to init all MLIR dialects/passes/extensions. Currently they are implemeted as inline functions and include essentially the entire MLIR header tree. Each file which includes this header (~10 currently) takes 10+ sec and multiple GB of ram to compile (tested with clang-19), which limits amount of parallel compiler jobs which can be run. Also, flang just includes this file into one of its headers. Move the actual registration code to the static library, so it's compiled only once. Discourse thread https://discourse.llvm.org/t/rfc-moving-initall-implementation-into-static-library/87559
36 lines
1.4 KiB
C++
36 lines
1.4 KiB
C++
//===- 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/Dialect/Arith/IR/Arith.h"
|
|
#include "mlir/Dialect/Func/IR/FuncOps.h"
|
|
#include "mlir/IR/MLIRContext.h"
|
|
#include "mlir/InitAllDialects.h"
|
|
#include "mlir/InitAllPasses.h"
|
|
#include "mlir/Support/FileUtilities.h"
|
|
#include "mlir/Tools/mlir-opt/MlirOptMain.h"
|
|
|
|
#include "Standalone/StandaloneDialect.h"
|
|
#include "Standalone/StandalonePasses.h"
|
|
|
|
int main(int argc, char **argv) {
|
|
mlir::registerAllPasses();
|
|
mlir::standalone::registerPasses();
|
|
// TODO: Register standalone passes here.
|
|
|
|
mlir::DialectRegistry registry;
|
|
registry.insert<mlir::standalone::StandaloneDialect,
|
|
mlir::arith::ArithDialect, mlir::func::FuncDialect>();
|
|
// 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));
|
|
}
|