Skip to content

Commit

Permalink
Minor code adjustments
Browse files Browse the repository at this point in the history
  • Loading branch information
mscuttari committed Nov 27, 2024
1 parent 1ebfa02 commit 6b271a4
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,11 @@

#include "mlir/Pass/Pass.h"

namespace mlir::bmodelica
{
namespace mlir::bmodelica {
#define GEN_PASS_DECL_VARIABLESPRUNINGPASS
#include "marco/Dialect/BaseModelica/Transforms/Passes.h.inc"

std::unique_ptr<mlir::Pass> createVariablesPruningPass();
}
} // namespace mlir::bmodelica

#endif // MARCO_DIALECT_BASEMODELICA_TRANSFORMS_VARIABLESPRUNING_H
Original file line number Diff line number Diff line change
Expand Up @@ -114,8 +114,9 @@ namespace llvm {
// that are defined inside LLVM itself. This way we don't have to implement
// them from scratch.
template <typename VertexProperty, typename EdgeProperty>
struct GraphTraits<const marco::modeling::internal::dependency ::
SingleEntryWeaklyConnectedDigraph<VertexProperty, EdgeProperty> *> {
struct GraphTraits<
const marco::modeling::internal::dependency ::
SingleEntryWeaklyConnectedDigraph<VertexProperty, EdgeProperty> *> {
// The LLVM traits require the class specified as Graph to be copyable.
// We use its address to overcome this limitation.
using Graph = const marco::modeling::internal::dependency ::
Expand Down
20 changes: 3 additions & 17 deletions lib/Dialect/BaseModelica/Transforms/VariablesPruning.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class VariablesPruningPass
collectUsedVariables(llvm::DenseSet<VariableOp> &usedVariables,
mlir::SymbolTableCollection &symbolTableCollection,
ModelOp modelOp,
const llvm::DenseSet<VariableOp>& outputVariables,
const llvm::DenseSet<VariableOp> &outputVariables,
llvm::ArrayRef<MatchedEquationInstanceOp> equations);

mlir::LogicalResult
Expand Down Expand Up @@ -149,20 +149,6 @@ mlir::LogicalResult VariablesPruningPass::processModelOp(ModelOp modelOp) {
// Collect the used variables.
llvm::DenseSet<VariableOp> usedVariables;

/*
if (mlir::failed(collectUsedVariables(usedVariables, symbolTableCollection,
modelOp, outputVariables,
initialEquations))) {
return mlir::failure();
}
if (mlir::failed(collectUsedVariables(usedVariables, symbolTableCollection,
modelOp, outputVariables,
dynamicEquations))) {
return mlir::failure();
}
*/

if (mlir::failed(collectUsedVariables(usedVariables, symbolTableCollection,
modelOp, outputVariables,
allEquations))) {
Expand Down Expand Up @@ -245,7 +231,7 @@ void walkDerivativeVariables(
mlir::LogicalResult VariablesPruningPass::collectUsedVariables(
llvm::DenseSet<VariableOp> &usedVariables,
mlir::SymbolTableCollection &symbolTableCollection, ModelOp modelOp,
const llvm::DenseSet<VariableOp>& outputVariables,
const llvm::DenseSet<VariableOp> &outputVariables,
llvm::ArrayRef<MatchedEquationInstanceOp> equations) {
// Create the dependency graph.
using DependencyGraph = marco::modeling::ArrayEquationsDependencyGraph<
Expand Down Expand Up @@ -351,7 +337,7 @@ mlir::LogicalResult VariablesPruningPass::collectUsedVariables(
auto writingEquations =
graph.getWritesMap().equal_range(variablesMap[variableName]);

for (const auto& writeInfo : llvm::make_range(writingEquations)) {
for (const auto &writeInfo : llvm::make_range(writingEquations)) {
baseGraph->addEdge(baseGraph->getEntryNode(),
writeInfo.second.getEquation());
}
Expand Down

0 comments on commit 6b271a4

Please sign in to comment.