MLIR 24.0.0git
MlirOptMain.cpp File Reference
#include "mlir/Tools/mlir-opt/MlirOptMain.h"
#include "mlir/Bytecode/BytecodeImplementation.h"
#include "mlir/Bytecode/BytecodeWriter.h"
#include "mlir/Debug/CLOptionsSetup.h"
#include "mlir/Debug/Counter.h"
#include "mlir/Dialect/IRDL/IR/IRDL.h"
#include "mlir/Dialect/IRDL/IRDLLoading.h"
#include "mlir/IR/AsmState.h"
#include "mlir/IR/Attributes.h"
#include "mlir/IR/BuiltinOps.h"
#include "mlir/IR/Diagnostics.h"
#include "mlir/IR/Location.h"
#include "mlir/IR/MLIRContext.h"
#include "mlir/IR/Remarks.h"
#include "mlir/Parser/Parser.h"
#include "mlir/Pass/PassManager.h"
#include "mlir/Pass/PassRegistry.h"
#include "mlir/Remark/RemarkStreamer.h"
#include "mlir/Support/FileUtilities.h"
#include "mlir/Support/Timing.h"
#include "mlir/Support/ToolUtilities.h"
#include "mlir/Tools/ParseUtilities.h"
#include "mlir/Tools/Plugins/DialectPlugin.h"
#include "mlir/Tools/Plugins/PassPlugin.h"
#include "llvm/ADT/ScopeExit.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/ADT/StringSet.h"
#include "llvm/Remarks/RemarkFormat.h"
#include "llvm/Support/CommandLine.h"
#include "llvm/Support/Debug.h"
#include "llvm/Support/InitLLVM.h"
#include "llvm/Support/LogicalResult.h"
#include "llvm/Support/ManagedStatic.h"
#include "llvm/Support/Process.h"
#include "llvm/Support/Regex.h"
#include "llvm/Support/SourceMgr.h"
#include "llvm/Support/ThreadPool.h"
#include "llvm/Support/ToolOutputFile.h"

Go to the source code of this file.

Functions

LogicalResult loadIRDLDialects (StringRef irdlFile, MLIRContext &ctx)
static LogicalResult doVerifyRoundTrip (Operation *op, const MlirOptMainConfig &config, bool useBytecode)
static LogicalResult doVerifyRoundTrip (Operation *op, const MlirOptMainConfig &config)
static LogicalResult performActions (raw_ostream &os, const std::shared_ptr< llvm::SourceMgr > &sourceMgr, MLIRContext *context, const MlirOptMainConfig &config)
 Perform the actions on the input file indicated by the command line flags within the specified context.
static LogicalResult processBuffer (raw_ostream &os, std::unique_ptr< MemoryBuffer > ownedBuffer, llvm::MemoryBufferRef sourceBuffer, const MlirOptMainConfig &config, DialectRegistry &registry, SourceMgrDiagnosticVerifierHandler *verifyHandler, llvm::ThreadPoolInterface *threadPool)
 Parses the memory buffer.
static LogicalResult printRegisteredDialects (DialectRegistry &registry)
static LogicalResult printRegisteredPassesAndReturn ()

Variables

ManagedStatic< MlirOptMainConfigCLOptions > clOptionsConfig

Function Documentation

◆ doVerifyRoundTrip() [1/2]

LogicalResult doVerifyRoundTrip ( Operation * op,
const MlirOptMainConfig & config )
static

Definition at line 499 of file MlirOptMain.cpp.

References doVerifyRoundTrip(), and success().

◆ doVerifyRoundTrip() [2/2]

◆ loadIRDLDialects()

◆ performActions()

LogicalResult performActions ( raw_ostream & os,
const std::shared_ptr< llvm::SourceMgr > & sourceMgr,
MLIRContext * context,
const MlirOptMainConfig & config )
static

Perform the actions on the input file indicated by the command line flags within the specified context.

This typically parses the main source file, runs zero or more optimization passes, then prints the output.

Definition at line 513 of file MlirOptMain.cpp.

References mlir::PassReproducerOptions::apply(), mlir::applyDefaultTimingManagerCLOptions(), mlir::applyPassManagerCLOptions(), mlir::PassReproducerOptions::attachResourceParser(), mlir::MlirOptMainConfig::bytecodeDialectVersionsToEmit(), mlir::MlirOptMainConfig::bytecodeProducerToEmit(), mlir::MlirOptMainConfig::bytecodeVersionToEmit(), createPolicy(), mlir::MLIRContext::disableMultithreading(), doVerifyRoundTrip(), mlir::emitError(), mlir::MLIRContext::enableMultithreading(), mlir::remark::enableOptimizationRemarks(), mlir::remark::enableOptimizationRemarksWithLLVMStreamer(), mlir::get(), mlir::OwningOpRef< OpTy >::get(), mlir::MLIRContext::getOrLoadDialect(), mlir::MLIRContext::getRemarkEngine(), mlir::MlirOptMainConfig::getRemarkFormat(), mlir::MlirOptMainConfig::getRemarkPolicy(), mlir::MlirOptMainConfig::getRemarksAllFilter(), mlir::MlirOptMainConfig::getRemarksAnalyseFilter(), mlir::MlirOptMainConfig::getRemarksFailedFilter(), mlir::MlirOptMainConfig::getRemarksMissedFilter(), mlir::MlirOptMainConfig::getRemarksOutputFile(), mlir::MlirOptMainConfig::getRemarksPassedFilter(), mlir::MlirOptMainConfig::getReproducerFilename(), mlir::TimingManager::getRootScope(), if(), mlir::OpPassManager::Implicit, mlir::MLIRContext::isMultithreadingEnabled(), mlir::makeReproducer(), mlir::TimingScope::nest(), nullptr, mlir::parseSourceFileForTool(), mlir::REMARK_FORMAT_BITSTREAM, mlir::REMARK_FORMAT_STDOUT, mlir::REMARK_FORMAT_YAML, mlir::REMARK_POLICY_ALL, mlir::REMARK_POLICY_FINAL, mlir::BytecodeWriterConfig::setDesiredBytecodeVersion(), mlir::MlirOptMainConfig::setupPassPipeline(), mlir::MlirOptMainConfig::shouldEmitBytecode(), mlir::MlirOptMainConfig::shouldRunReproducer(), mlir::MlirOptMainConfig::shouldUseExplicitModule(), mlir::MlirOptMainConfig::shouldVerifyOnParsing(), mlir::MlirOptMainConfig::shouldVerifyPasses(), mlir::MlirOptMainConfig::shouldVerifyRoundtrip(), and mlir::TimingScope::stop().

◆ printRegisteredDialects()

LogicalResult printRegisteredDialects ( DialectRegistry & registry)
static

Definition at line 778 of file MlirOptMain.cpp.

◆ printRegisteredPassesAndReturn()

LogicalResult printRegisteredPassesAndReturn ( )
static

Definition at line 785 of file MlirOptMain.cpp.

◆ processBuffer()

LogicalResult processBuffer ( raw_ostream & os,
std::unique_ptr< MemoryBuffer > ownedBuffer,
llvm::MemoryBufferRef sourceBuffer,
const MlirOptMainConfig & config,
DialectRegistry & registry,
SourceMgrDiagnosticVerifierHandler * verifyHandler,
llvm::ThreadPoolInterface * threadPool )
static

Parses the memory buffer.

If successfully, run a series of passes against it and print the result.

Definition at line 684 of file MlirOptMain.cpp.

Referenced by mlirTranslateMainImpl().

Variable Documentation

◆ clOptionsConfig

ManagedStatic<MlirOptMainConfigCLOptions> clOptionsConfig

Definition at line 358 of file MlirOptMain.cpp.