Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Increase compilation pipeline controllability #40

Merged
merged 4 commits into from
Oct 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 26 additions & 27 deletions include/public/marco/Frontend/CodegenOptions.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,35 +6,34 @@
#include <string>
#include <vector>

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<std::string> features;
};
}
std::string cpu = "generic";
std::vector<std::string> features;
};
} // namespace marco::frontend

#endif // MARCO_FRONTEND_CODEGENOPTIONS_H
2 changes: 2 additions & 0 deletions lib/Frontend/CompilerInvocation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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;
}
Expand Down
16 changes: 13 additions & 3 deletions lib/Frontend/FrontendActions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -824,17 +824,27 @@ 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());

// 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(
Expand Down