|
16 | 16 | #include "flang/Optimizer/CodeGen/CodeGen.h"
|
17 | 17 | #include "flang/Optimizer/HLFIR/Passes.h"
|
18 | 18 | #include "flang/Optimizer/Transforms/Passes.h"
|
19 |
| -#include "llvm/Frontend/Debug/Options.h" |
20 | 19 | #include "llvm/Passes/OptimizationLevel.h"
|
21 | 20 | #include "llvm/Support/CommandLine.h"
|
22 | 21 |
|
@@ -184,29 +183,28 @@ inline void addExternalNameConversionPass(
|
184 | 183 | /// incremental conversion of FIR.
|
185 | 184 | ///
|
186 | 185 | /// \param pm - MLIR pass manager that will hold the pipeline definition
|
187 |
| -inline void createDefaultFIROptimizerPassPipeline(mlir::PassManager &pm, |
188 |
| - llvm::OptimizationLevel optLevel = defaultOptLevel, |
189 |
| - bool stackArrays = false, bool loopVersioning = false) { |
| 186 | +inline void createDefaultFIROptimizerPassPipeline( |
| 187 | + mlir::PassManager &pm, const MLIRToLLVMPassPipelineConfig &pc) { |
190 | 188 | // simplify the IR
|
191 | 189 | mlir::GreedyRewriteConfig config;
|
192 | 190 | config.enableRegionSimplification = false;
|
193 | 191 | pm.addPass(mlir::createCSEPass());
|
194 |
| - fir::addAVC(pm, optLevel); |
| 192 | + fir::addAVC(pm, pc.OptLevel); |
195 | 193 | pm.addNestedPass<mlir::func::FuncOp>(fir::createCharacterConversionPass());
|
196 | 194 | pm.addPass(mlir::createCanonicalizerPass(config));
|
197 | 195 | pm.addPass(fir::createSimplifyRegionLitePass());
|
198 |
| - if (optLevel.isOptimizingForSpeed()) { |
| 196 | + if (pc.OptLevel.isOptimizingForSpeed()) { |
199 | 197 | // These passes may increase code size.
|
200 | 198 | pm.addPass(fir::createSimplifyIntrinsicsPass());
|
201 | 199 | pm.addPass(fir::createAlgebraicSimplificationPass(config));
|
202 | 200 | }
|
203 | 201 |
|
204 |
| - if (loopVersioning) |
| 202 | + if (pc.LoopVersioning) |
205 | 203 | pm.addPass(fir::createLoopVersioningPass());
|
206 | 204 |
|
207 | 205 | pm.addPass(mlir::createCSEPass());
|
208 | 206 |
|
209 |
| - if (stackArrays) |
| 207 | + if (pc.StackArrays) |
210 | 208 | pm.addPass(fir::createStackArraysPass());
|
211 | 209 | else
|
212 | 210 | fir::addMemoryAllocationOpt(pm);
|
@@ -291,40 +289,33 @@ inline void createDebugPasses(
|
291 | 289 | }
|
292 | 290 | }
|
293 | 291 |
|
294 |
| -inline void createDefaultFIRCodeGenPassPipeline(mlir::PassManager &pm, |
295 |
| - llvm::OptimizationLevel optLevel = defaultOptLevel, |
296 |
| - bool underscoring = true, |
297 |
| - llvm::codegenoptions::DebugInfoKind debugInfo = NoDebugInfo) { |
| 292 | +inline void createDefaultFIRCodeGenPassPipeline( |
| 293 | + mlir::PassManager &pm, MLIRToLLVMPassPipelineConfig config) { |
298 | 294 | fir::addBoxedProcedurePass(pm);
|
299 | 295 | pm.addNestedPass<mlir::func::FuncOp>(
|
300 | 296 | fir::createAbstractResultOnFuncOptPass());
|
301 | 297 | pm.addNestedPass<fir::GlobalOp>(fir::createAbstractResultOnGlobalOptPass());
|
302 | 298 | fir::addCodeGenRewritePass(pm);
|
303 | 299 | fir::addTargetRewritePass(pm);
|
304 |
| - fir::addExternalNameConversionPass(pm, underscoring); |
305 |
| - fir::createDebugPasses(pm, debugInfo); |
306 |
| - fir::addFIRToLLVMPass(pm, optLevel); |
| 300 | + fir::addExternalNameConversionPass(pm, config.Underscoring); |
| 301 | + fir::createDebugPasses(pm, config.DebugInfo); |
| 302 | + fir::addFIRToLLVMPass(pm, config.OptLevel); |
307 | 303 | }
|
308 | 304 |
|
309 | 305 | /// Create a pass pipeline for lowering from MLIR to LLVM IR
|
310 | 306 | ///
|
311 | 307 | /// \param pm - MLIR pass manager that will hold the pipeline definition
|
312 | 308 | /// \param optLevel - optimization level used for creating FIR optimization
|
313 | 309 | /// passes pipeline
|
314 |
| -inline void createMLIRToLLVMPassPipeline(mlir::PassManager &pm, |
315 |
| - llvm::OptimizationLevel optLevel = defaultOptLevel, |
316 |
| - bool stackArrays = false, bool underscoring = true, |
317 |
| - bool loopVersioning = false, |
318 |
| - llvm::codegenoptions::DebugInfoKind debugInfo = NoDebugInfo) { |
319 |
| - fir::createHLFIRToFIRPassPipeline(pm, optLevel); |
| 310 | +inline void createMLIRToLLVMPassPipeline( |
| 311 | + mlir::PassManager &pm, const MLIRToLLVMPassPipelineConfig &config) { |
| 312 | + fir::createHLFIRToFIRPassPipeline(pm, config.OptLevel); |
320 | 313 |
|
321 | 314 | // Add default optimizer pass pipeline.
|
322 |
| - fir::createDefaultFIROptimizerPassPipeline( |
323 |
| - pm, optLevel, stackArrays, loopVersioning); |
| 315 | + fir::createDefaultFIROptimizerPassPipeline(pm, config); |
324 | 316 |
|
325 | 317 | // Add codegen pass pipeline.
|
326 |
| - fir::createDefaultFIRCodeGenPassPipeline( |
327 |
| - pm, optLevel, underscoring, debugInfo); |
| 318 | + fir::createDefaultFIRCodeGenPassPipeline(pm, config); |
328 | 319 | }
|
329 | 320 | #undef FLANG_EXCLUDE_CODEGEN
|
330 | 321 | #endif
|
|
0 commit comments