diff options
author | Andy Kaylor <akaylor@nvidia.com> | 2025-03-19 09:42:03 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2025-03-19 09:42:03 -0700 |
commit | 39ce99589b05ddd43e5c8b7f89ab5bbfda40d2ce (patch) | |
tree | 80a08af9b0ed4208d379867d8fe012a2d3ffc86f /clang/lib/FrontendTool/ExecuteCompilerInvocation.cpp | |
parent | cd26dd55959c11c1cd0ea4fe1f07e0fa9cb7a72a (diff) | |
download | llvm-39ce99589b05ddd43e5c8b7f89ab5bbfda40d2ce.zip llvm-39ce99589b05ddd43e5c8b7f89ab5bbfda40d2ce.tar.gz llvm-39ce99589b05ddd43e5c8b7f89ab5bbfda40d2ce.tar.bz2 |
[CIR] Upstream cir-canonicalize pass (#131891)
This change introduces the cir-canonicalize pass. This is a simple
cir-to-cir transformation that eliminates empty scopes and redundant
branches. It will be expanded in future changes to simplify other
redundant instruction sequences.
MLIR verification and mlir-specific command-line option handling is also
introduced here.
Diffstat (limited to 'clang/lib/FrontendTool/ExecuteCompilerInvocation.cpp')
-rw-r--r-- | clang/lib/FrontendTool/ExecuteCompilerInvocation.cpp | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/clang/lib/FrontendTool/ExecuteCompilerInvocation.cpp b/clang/lib/FrontendTool/ExecuteCompilerInvocation.cpp index bb3bb0a..6fc587f 100644 --- a/clang/lib/FrontendTool/ExecuteCompilerInvocation.cpp +++ b/clang/lib/FrontendTool/ExecuteCompilerInvocation.cpp @@ -32,6 +32,10 @@ #include "llvm/Support/ErrorHandling.h" #if CLANG_ENABLE_CIR +#include "mlir/IR/AsmState.h" +#include "mlir/IR/MLIRContext.h" +#include "mlir/Pass/PassManager.h" +#include "clang/CIR/Dialect/Passes.h" #include "clang/CIR/FrontendAction/CIRGenAction.h" #endif @@ -270,6 +274,22 @@ bool ExecuteCompilerInvocation(CompilerInstance *Clang) { } #endif +#if CLANG_ENABLE_CIR + if (!Clang->getFrontendOpts().MLIRArgs.empty()) { + mlir::registerCIRPasses(); + mlir::registerMLIRContextCLOptions(); + mlir::registerPassManagerCLOptions(); + mlir::registerAsmPrinterCLOptions(); + unsigned NumArgs = Clang->getFrontendOpts().MLIRArgs.size(); + auto Args = std::make_unique<const char *[]>(NumArgs + 2); + Args[0] = "clang (MLIR option parsing)"; + for (unsigned i = 0; i != NumArgs; ++i) + Args[i + 1] = Clang->getFrontendOpts().MLIRArgs[i].c_str(); + Args[NumArgs + 1] = nullptr; + llvm::cl::ParseCommandLineOptions(NumArgs + 1, Args.get()); + } +#endif + // If there were errors in processing arguments, don't do anything else. if (Clang->getDiagnostics().hasErrorOccurred()) return false; |