aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/FrontendTool/ExecuteCompilerInvocation.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'clang/lib/FrontendTool/ExecuteCompilerInvocation.cpp')
-rw-r--r--clang/lib/FrontendTool/ExecuteCompilerInvocation.cpp20
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;