diff --git a/lib/Dialect/BaseModelica/Transforms/CallCSE.cpp b/lib/Dialect/BaseModelica/Transforms/CallCSE.cpp index d211602c6..4ee46d7e1 100644 --- a/lib/Dialect/BaseModelica/Transforms/CallCSE.cpp +++ b/lib/Dialect/BaseModelica/Transforms/CallCSE.cpp @@ -149,19 +149,19 @@ void CallCSEPass::emitCse(llvm::SmallVectorImpl &equivalenceGroup, for (auto result : llvm::enumerate(representative.getResults())) { rewriter.setInsertionPointToStart(modelOp.getBody()); // Emit cse variable - VariableOp cseVariable = rewriter.create( + auto cseVariable = rewriter.create( loc, "_cse", VariableType::wrap(result.value().getType())); symbolTable.insert(cseVariable); cseVariables.push_back(cseVariable); // Emit driver equation rewriter.setInsertionPoint(dynamicOp); - EquationTemplateOp equationTemplateOp = + auto equationTemplateOp = rewriter.create(loc); rewriter.setInsertionPointToStart(equationTemplateOp.createBody(0)); - EquationSideOp lhsOp = rewriter.create( + auto lhsOp = rewriter.create( loc, rewriter.create(loc, cseVariable)->getResults()); - EquationSideOp rhsOp = rewriter.create( + auto rhsOp = rewriter.create( loc, cloneDefUseChain(representative, rewriter)->getResult(result.index())); rewriter.create(loc, lhsOp, rhsOp); @@ -177,7 +177,7 @@ void CallCSEPass::emitCse(llvm::SmallVectorImpl &equivalenceGroup, rewriter.setInsertionPoint(callOp); llvm::SmallVector results; - for (auto &cseVariable : cseVariables) { + for (VariableOp cseVariable : cseVariables) { results.push_back( rewriter.create(loc, cseVariable).getResult()); } @@ -206,7 +206,7 @@ mlir::LogicalResult CallCSEPass::processModelOp(ModelOp modelOp) { DynamicOp dynamicOp = rewriter.create(rewriter.getUnknownLoc()); rewriter.createBlock(&dynamicOp.getRegion()); - for (auto &equivalenceGroup : callEquivalenceGroups) { + for (llvm::SmallVector &equivalenceGroup : callEquivalenceGroups) { // Only emit CSEs that will lead to an equivalent, or lower amount of calls if (equivalenceGroup.size() >= equivalenceGroup.front().getNumResults()) { emitCse(equivalenceGroup, modelOp, dynamicOp, symbolTable, rewriter); diff --git a/test/Dialect/BaseModelica/Transforms/CallCSE/basic-cse.mlir b/test/Dialect/BaseModelica/Transforms/CallCSE/basic-cse.mlir index 72dae1be1..b6b7fe826 100644 --- a/test/Dialect/BaseModelica/Transforms/CallCSE/basic-cse.mlir +++ b/test/Dialect/BaseModelica/Transforms/CallCSE/basic-cse.mlir @@ -55,17 +55,15 @@ module @Test { bmodelica.equation_instance %t1 : !bmodelica.equation } - // CHECK: %[[TEMPLATE:.*]] = bmodelica.equation_template inductions = [] { + // CHECK: %[[TEMPLATE:.*]] = bmodelica.equation_template inductions = [] // CHECK-NEXT: %[[RES2:.*]] = bmodelica.variable_get @[[CSE]] // CHECK-NEXT: %[[LHS2:.*]] = bmodelica.equation_side %[[RES2]] // CHECK-NEXT: %[[RES3:.*]] = bmodelica.constant 1 // CHECK-NEXT: %[[RES4:.*]] = bmodelica.call @foo(%[[RES3]]) // CHECK-NEXT: %[[RHS:.*]] = bmodelica.equation_side %[[RES4]] // CHECK-NEXT: bmodelica.equation_sides %[[LHS2]], %[[RHS]] - // CHECK-NEXT: } - // CHECK-NEXT: bmodelica.dynamic { + // CHECK: bmodelica.dynamic // CHECK-NEXT: bmodelica.equation_instance %[[TEMPLATE]] - // CHECK-NEXT: } } } \ No newline at end of file diff --git a/test/Dialect/BaseModelica/Transforms/CallCSE/complex-expression.mlir b/test/Dialect/BaseModelica/Transforms/CallCSE/complex-expression.mlir index 590e6d310..b1d9a7df1 100644 --- a/test/Dialect/BaseModelica/Transforms/CallCSE/complex-expression.mlir +++ b/test/Dialect/BaseModelica/Transforms/CallCSE/complex-expression.mlir @@ -65,7 +65,7 @@ module @Test { bmodelica.equation_instance %t1 : !bmodelica.equation } - // CHECK: %[[TEMPLATE:.*]] = bmodelica.equation_template inductions = [] { + // CHECK: %[[TEMPLATE:.*]] = bmodelica.equation_template inductions = [] // CHECK-NEXT: %[[RES2:.*]] = bmodelica.variable_get @[[CSE]] // CHECK-NEXT: %[[LHS2:.*]] = bmodelica.equation_side %[[RES2]] // CHECK-DAG: %[[C1:.*]] = bmodelica.constant 1 @@ -77,9 +77,8 @@ module @Test { // CHECK-NEXT: %[[RES4:.*]] = bmodelica.call @foo(%[[POW]]) // CHECK-NEXT: %[[RHS:.*]] = bmodelica.equation_side %[[RES4]] // CHECK-NEXT: bmodelica.equation_sides %[[LHS2]], %[[RHS]] - // CHECK-NEXT: } - // CHECK-NEXT: bmodelica.dynamic { + // CHECK: bmodelica.dynamic // CHECK-NEXT: bmodelica.equation_instance %[[TEMPLATE]] } } \ No newline at end of file diff --git a/test/Dialect/BaseModelica/Transforms/CallCSE/multiple-calls.mlir b/test/Dialect/BaseModelica/Transforms/CallCSE/multiple-calls.mlir index 853a81123..ebbb84f0f 100644 --- a/test/Dialect/BaseModelica/Transforms/CallCSE/multiple-calls.mlir +++ b/test/Dialect/BaseModelica/Transforms/CallCSE/multiple-calls.mlir @@ -12,7 +12,7 @@ module @Test { } } - // CHECK: bmodelica.model + // CHECK-LABEL: @M bmodelica.model @M { // CHECK-NEXT: bmodelica.variable @[[CSE1:.*]] : !bmodelica.variable // CHECK-NEXT: bmodelica.variable @[[CSE0:.*]] : !bmodelica.variable @@ -92,7 +92,7 @@ module @Test { bmodelica.equation_instance %t2 : !bmodelica.equation } - // CHECK: %[[T0:.*]] = bmodelica.equation_template inductions = [] { + // CHECK: %[[T0:.*]] = bmodelica.equation_template inductions = [] // CHECK-NEXT: %[[RES0:.*]] = bmodelica.variable_get @[[CSE0]] // CHECK-NEXT: %[[LHS:.*]] = bmodelica.equation_side %[[RES0]] // CHECK-DAG: %[[RES1:.*]] = bmodelica.constant 1 @@ -101,9 +101,8 @@ module @Test { // CHECK-NEXT: %[[RES4:.*]] = bmodelica.call @foo(%[[RES3]]) // CHECK-NEXT: %[[RHS:.*]] = bmodelica.equation_side %[[RES4]] // CHECK-NEXT: bmodelica.equation_sides %[[LHS]], %[[RHS]] - // CHECK-NEXT: } - // CHECK: %[[T1:.*]] = bmodelica.equation_template inductions = [] { + // CHECK: %[[T1:.*]] = bmodelica.equation_template inductions = [] // CHECK-NEXT: %[[RES0:.*]] = bmodelica.variable_get @[[CSE1]] // CHECK-NEXT: %[[LHS:.*]] = bmodelica.equation_side %[[RES0]] // CHECK-DAG: %[[RES1:.*]] = bmodelica.constant 2 @@ -112,11 +111,9 @@ module @Test { // CHECK-NEXT: %[[RES4:.*]] = bmodelica.call @foo(%[[RES3]]) // CHECK-NEXT: %[[RHS:.*]] = bmodelica.equation_side %[[RES4]] // CHECK-NEXT: bmodelica.equation_sides %[[LHS]], %[[RHS]] - // CHECK-NEXT: } - // CHECK: bmodelica.dynamic { + // CHECK: bmodelica.dynamic // CHECK-DAG: bmodelica.equation_instance %[[T0]] // CHECK-DAG: bmodelica.equation_instance %[[T1]] - // CHECK-NEXT: } } } diff --git a/test/Dialect/BaseModelica/Transforms/CallCSE/multiple-return-values.mlir b/test/Dialect/BaseModelica/Transforms/CallCSE/multiple-return-values.mlir index a49f3e914..73ba8ede8 100644 --- a/test/Dialect/BaseModelica/Transforms/CallCSE/multiple-return-values.mlir +++ b/test/Dialect/BaseModelica/Transforms/CallCSE/multiple-return-values.mlir @@ -59,27 +59,24 @@ module @Test { bmodelica.equation_instance %t1 : !bmodelica.equation } - // CHECK: %[[TEMPLATE1:.*]] = bmodelica.equation_template inductions = [] { + // CHECK: %[[TEMPLATE1:.*]] = bmodelica.equation_template inductions = [] // CHECK-NEXT: %[[RES2:.*]] = bmodelica.variable_get @[[CSE0]] // CHECK-NEXT: %[[LHS2:.*]] = bmodelica.equation_side %[[RES2]] // CHECK-NEXT: %[[RES3:.*]] = bmodelica.constant 1 // CHECK-NEXT: %[[RES4:.*]]:2 = bmodelica.call @foo(%[[RES3]]) // CHECK-NEXT: %[[RHS0:.*]] = bmodelica.equation_side %[[RES4]]#0 // CHECK-NEXT: bmodelica.equation_sides %[[LHS2]], %[[RHS0]] - // CHECK-NEXT: } - // CHECK-NEXT: %[[TEMPLATE2:.*]] = bmodelica.equation_template inductions = [] { + // CHECK: %[[TEMPLATE2:.*]] = bmodelica.equation_template inductions = [] // CHECK-NEXT: %[[RES2:.*]] = bmodelica.variable_get @[[CSE1]] // CHECK-NEXT: %[[LHS2:.*]] = bmodelica.equation_side %[[RES2]] // CHECK-NEXT: %[[RES3:.*]] = bmodelica.constant 1 // CHECK-NEXT: %[[RES4:.*]]:2 = bmodelica.call @foo(%[[RES3]]) // CHECK-NEXT: %[[RHS0:.*]] = bmodelica.equation_side %[[RES4]]#1 // CHECK-NEXT: bmodelica.equation_sides %[[LHS2]], %[[RHS0]] - // CHECK-NEXT: } - // CHECK-NEXT: bmodelica.dynamic { + // CHECK: bmodelica.dynamic // CHECK-NEXT: bmodelica.equation_instance %[[TEMPLATE1]] // CHECK-NEXT: bmodelica.equation_instance %[[TEMPLATE2]] - // CHECK-NEXT: } } } diff --git a/test/Dialect/BaseModelica/Transforms/CallCSE/op-with-region.mlir b/test/Dialect/BaseModelica/Transforms/CallCSE/op-with-region.mlir index 9e101b06f..22fe9f528 100644 --- a/test/Dialect/BaseModelica/Transforms/CallCSE/op-with-region.mlir +++ b/test/Dialect/BaseModelica/Transforms/CallCSE/op-with-region.mlir @@ -79,7 +79,7 @@ module @Test { bmodelica.equation_instance %t1 : !bmodelica.equation } - // CHECK: %[[TEMPLATE:.*]] = bmodelica.equation_template inductions = [] { + // CHECK: %[[TEMPLATE:.*]] = bmodelica.equation_template inductions = [] // CHECK-NEXT: %[[RES:.*]] = bmodelica.variable_get @[[CSE]] // CHECK-NEXT: %[[LHS:.*]] = bmodelica.equation_side %[[RES]] // CHECK-DAG: %[[c:.*]] = bmodelica.constant 2 @@ -94,10 +94,8 @@ module @Test { // CHECK: %[[RES1:.*]] = bmodelica.call @foo(%[[red]]) // CHECK-NEXT: %[[RHS:.*]] = bmodelica.equation_side %[[RES1]] // CHECK-NEXT: bmodelica.equation_sides %[[LHS]], %[[RHS]] - // CHECK-NEXT: } - // CHECK: bmodelica.dynamic { + // CHECK: bmodelica.dynamic // CHECK-NEXT: bmodelica.equation_instance %[[TEMPLATE]] - // CHECK-NEXT: } } }