clang 23.0.0git
CIRPasses.cpp
Go to the documentation of this file.
1//===----------------------------------------------------------------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8//
9// This file implements machinery for any CIR <-> CIR passes used by clang.
10//
11//===----------------------------------------------------------------------===//
12
13// #include "clang/AST/ASTContext.h"
14#include "mlir/IR/BuiltinOps.h"
15#include "mlir/Pass/PassManager.h"
17#include "llvm/Support/TimeProfiler.h"
18
19namespace cir {
20mlir::LogicalResult
21runCIRToCIRPasses(mlir::ModuleOp theModule, mlir::MLIRContext &mlirContext,
22 clang::ASTContext &astContext, bool enableVerifier,
23 bool enableIdiomRecognizer, bool enableCIRSimplify) {
24
25 llvm::TimeTraceScope scope("CIR To CIR Passes");
26
27 mlir::PassManager pm(&mlirContext);
29
30 if (enableCIRSimplify)
31 pm.addPass(mlir::createCIRSimplifyPass());
32
33 if (enableIdiomRecognizer)
34 pm.addPass(mlir::createIdiomRecognizerPass(&astContext));
35
38 pm.addPass(mlir::createLoweringPreparePass(&astContext));
39
40 pm.enableVerifier(enableVerifier);
41 (void)mlir::applyPassManagerCLOptions(pm);
42 return pm.run(theModule);
43}
44
45} // namespace cir
46
47namespace mlir {
48
49void populateCIRPreLoweringPasses(OpPassManager &pm) {
50 pm.addPass(createHoistAllocasPass());
51 pm.addPass(createCIRFlattenCFGPass());
52 pm.addPass(createCIREHABILoweringPass());
53 pm.addPass(createGotoSolverPass());
54}
55
56} // namespace mlir
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
Definition ASTContext.h:226
mlir::LogicalResult runCIRToCIRPasses(mlir::ModuleOp theModule, mlir::MLIRContext &mlirCtx, clang::ASTContext &astCtx, bool enableVerifier, bool enableIdiomRecognizer, bool enableCIRSimplify)
Definition CIRPasses.cpp:21
std::unique_ptr< Pass > createCIREHABILoweringPass()
std::unique_ptr< Pass > createCIRCanonicalizePass()
std::unique_ptr< Pass > createCIRFlattenCFGPass()
std::unique_ptr< Pass > createIdiomRecognizerPass()
void populateCIRPreLoweringPasses(mlir::OpPassManager &pm)
std::unique_ptr< Pass > createTargetLoweringPass()
std::unique_ptr< Pass > createGotoSolverPass()
std::unique_ptr< Pass > createLoweringPreparePass()
std::unique_ptr< Pass > createCIRSimplifyPass()
std::unique_ptr< Pass > createCXXABILoweringPass()
std::unique_ptr< Pass > createHoistAllocasPass()