clang 22.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 runCIRToCIRPasses(mlir::ModuleOp theModule,
21 mlir::MLIRContext &mlirContext,
22 clang::ASTContext &astContext,
23 bool enableVerifier,
24 bool enableCIRSimplify) {
25
26 llvm::TimeTraceScope scope("CIR To CIR Passes");
27
28 mlir::PassManager pm(&mlirContext);
30
31 if (enableCIRSimplify)
32 pm.addPass(mlir::createCIRSimplifyPass());
33
34 pm.addPass(mlir::createLoweringPreparePass(&astContext));
35
36 pm.enableVerifier(enableVerifier);
37 (void)mlir::applyPassManagerCLOptions(pm);
38 return pm.run(theModule);
39}
40
41} // namespace cir
42
43namespace mlir {
44
45void populateCIRPreLoweringPasses(OpPassManager &pm) {
46 pm.addPass(createHoistAllocasPass());
47 pm.addPass(createCIRFlattenCFGPass());
48 pm.addPass(createGotoSolverPass());
49}
50
51} // namespace mlir
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
Definition: ASTContext.h:188
Definition: ABIArgInfo.h:22
mlir::LogicalResult runCIRToCIRPasses(mlir::ModuleOp theModule, mlir::MLIRContext &mlirCtx, clang::ASTContext &astCtx, bool enableVerifier, bool enableCIRSimplify)
Definition: CIRPasses.cpp:20
std::unique_ptr< Pass > createCIRCanonicalizePass()
std::unique_ptr< Pass > createCIRFlattenCFGPass()
Definition: FlattenCFG.cpp:565
void populateCIRPreLoweringPasses(mlir::OpPassManager &pm)
std::unique_ptr< Pass > createGotoSolverPass()
Definition: GotoSolver.cpp:55
std::unique_ptr< Pass > createLoweringPreparePass()
std::unique_ptr< Pass > createCIRSimplifyPass()
std::unique_ptr< Pass > createHoistAllocasPass()