diff --git a/include/public/marco/Frontend/CodegenOptions.h b/include/public/marco/Frontend/CodegenOptions.h index 610f31c67..f7ea91d7b 100644 --- a/include/public/marco/Frontend/CodegenOptions.h +++ b/include/public/marco/Frontend/CodegenOptions.h @@ -6,35 +6,34 @@ #include #include -namespace marco::frontend -{ - /// Code generation operations. - /// The default values are for compiling without optimizations. - /// The class extends the language options for C / C++ to enable the - /// integration with clang's diagnostics infrastructure. - struct CodegenOptions : public clang::CodeGenOptions - { - llvm::OptimizationLevel optLevel = llvm::OptimizationLevel::O0; +namespace marco::frontend { +/// Code generation options. +/// The default values are for compiling without optimizations. +/// The class extends the language options for C / C++ to enable the +/// integration with clang's diagnostics infrastructure. +struct CodegenOptions : public clang::CodeGenOptions { + llvm::OptimizationLevel optLevel = llvm::OptimizationLevel::O0; - bool debug = true; - bool assertions = true; - bool inlining = false; - bool outputArraysPromotion = false; - bool heapToStackPromotion = false; - bool readOnlyVariablesPropagation = false; - bool variablesToParametersPromotion = false; - bool cse = false; - bool equationsRuntimeScheduling = false; - bool omp = false; - bool loopFusion = false; - bool loopCoalescing = false; - bool loopTiling = false; + bool debug = true; + bool assertions = true; + bool inlining = false; + bool outputArraysPromotion = false; + bool heapToStackPromotion = false; + bool readOnlyVariablesPropagation = false; + bool variablesToParametersPromotion = false; + bool cse = false; + bool equationsRuntimeScheduling = false; + bool omp = false; + bool singleValuedInductionElimination = false; + bool loopFusion = false; + bool loopCoalescing = false; + bool loopTiling = false; - unsigned int bitWidth = 64; + unsigned int bitWidth = 64; - std::string cpu = "generic"; - std::vector features; - }; -} + std::string cpu = "generic"; + std::vector features; +}; +} // namespace marco::frontend #endif // MARCO_FRONTEND_CODEGENOPTIONS_H diff --git a/lib/Frontend/CompilerInvocation.cpp b/lib/Frontend/CompilerInvocation.cpp index 1a8caa124..5f329779d 100644 --- a/lib/Frontend/CompilerInvocation.cpp +++ b/lib/Frontend/CompilerInvocation.cpp @@ -508,6 +508,7 @@ static void parseCodegenArgs(marco::frontend::CodegenOptions &options, if (options.optLevel.getSpeedupLevel() > 0) { options.debug = false; options.assertions = false; + options.singleValuedInductionElimination = true; } if (options.optLevel.getSpeedupLevel() > 1) { @@ -525,6 +526,7 @@ static void parseCodegenArgs(marco::frontend::CodegenOptions &options, if (options.optLevel.getSizeLevel() > 0) { options.debug = false; options.cse = true; + options.singleValuedInductionElimination = true; options.loopFusion = true; options.loopCoalescing = true; } diff --git a/lib/Frontend/FrontendActions.cpp b/lib/Frontend/FrontendActions.cpp index c8444a179..6e1d03383 100644 --- a/lib/Frontend/FrontendActions.cpp +++ b/lib/Frontend/FrontendActions.cpp @@ -824,9 +824,16 @@ void CodeGenAction::buildMLIRLoweringPipeline(mlir::PassManager &pm) { pm.addPass(mlir::createCanonicalizerPass()); pm.addPass(mlir::bmodelica::createMatchingPass()); pm.addPass(mlir::bmodelica::createEquationAccessSplitPass()); - pm.addPass(mlir::bmodelica::createSingleValuedInductionEliminationPass()); + + if (ci.getCodeGenOptions().singleValuedInductionElimination) { + pm.addPass(mlir::bmodelica::createSingleValuedInductionEliminationPass()); + } + pm.addPass(mlir::bmodelica::createSCCDetectionPass()); - pm.addPass(mlir::bmodelica::createVariablesPromotionPass()); + + if (ci.getCodeGenOptions().variablesToParametersPromotion) { + pm.addPass(mlir::bmodelica::createVariablesPromotionPass()); + } // Try to solve the cycles by substitution. pm.addPass(mlir::bmodelica::createSCCSolvingBySubstitutionPass()); @@ -834,7 +841,10 @@ void CodeGenAction::buildMLIRLoweringPipeline(mlir::PassManager &pm) { // Simplify the possibly complex accesses introduced by equations // substitutions. pm.addPass(mlir::createCanonicalizerPass()); - pm.addPass(mlir::bmodelica::createSingleValuedInductionEliminationPass()); + + if (ci.getCodeGenOptions().singleValuedInductionElimination) { + pm.addPass(mlir::bmodelica::createSingleValuedInductionEliminationPass()); + } // Apply the selected solver. pm.addPass(