Path: blob/main/contrib/llvm-project/clang/lib/CIR/Lowering/CIRPasses.cpp
213799 views
//===----------------------------------------------------------------------===//1//2// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.3// See https://llvm.org/LICENSE.txt for license information.4// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception5//6//===----------------------------------------------------------------------===//7//8// This file implements machinery for any CIR <-> CIR passes used by clang.9//10//===----------------------------------------------------------------------===//1112// #include "clang/AST/ASTContext.h"13#include "mlir/IR/BuiltinOps.h"14#include "mlir/Pass/PassManager.h"15#include "clang/CIR/Dialect/Passes.h"16#include "llvm/Support/TimeProfiler.h"1718namespace cir {19mlir::LogicalResult runCIRToCIRPasses(mlir::ModuleOp theModule,20mlir::MLIRContext &mlirContext,21clang::ASTContext &astContext,22bool enableVerifier,23bool enableCIRSimplify) {2425llvm::TimeTraceScope scope("CIR To CIR Passes");2627mlir::PassManager pm(&mlirContext);28pm.addPass(mlir::createCIRCanonicalizePass());2930if (enableCIRSimplify)31pm.addPass(mlir::createCIRSimplifyPass());3233pm.addPass(mlir::createLoweringPreparePass());3435pm.enableVerifier(enableVerifier);36(void)mlir::applyPassManagerCLOptions(pm);37return pm.run(theModule);38}3940} // namespace cir4142namespace mlir {4344void populateCIRPreLoweringPasses(OpPassManager &pm) {45pm.addPass(createHoistAllocasPass());46pm.addPass(createCIRFlattenCFGPass());47}4849} // namespace mlir505152