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

[MooreToCore] Add nested moore.conditional support #8125

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
3 changes: 3 additions & 0 deletions lib/Conversion/MooreToCore/MooreToCore.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1346,6 +1346,9 @@ struct ConditionalOpConversion : public OpConversionPattern<ConditionalOp> {
!memOp.hasEffect<MemoryEffects::Free>())
return WalkResult::advance();

if (operation->hasTrait<OpTrait::HasRecursiveMemoryEffects>())
return WalkResult::advance();
Comment on lines +1349 to +1350
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice one!


return WalkResult::interrupt();
});
return !result.wasInterrupted();
Expand Down
25 changes: 25 additions & 0 deletions test/Conversion/MooreToCore/basic.mlir
Original file line number Diff line number Diff line change
Expand Up @@ -982,6 +982,31 @@ moore.module @StringConstant() {
}
}

// CHECK-LABEL: func.func @RecurciveConditional
func.func @RecurciveConditional(%arg0 : !moore.l1, %arg1 : !moore.l1) {
// CHECK: [[C_2:%.+]] = hw.constant -2 : i2
// CHECK: [[C_1:%.+]] = hw.constant 1 : i2
// CHECK: [[C_0:%.+]] = hw.constant 0 : i2
%c_2 = moore.constant -2 : l2
%c_1 = moore.constant 1 : l2
%c_0 = moore.constant 0 : l2

// CHECK: [[MUX0:%.+]] = comb.mux %arg1, [[C_0]], [[C_1]] : i2
// CHECK: [[MUX1:%.+]] = comb.mux %arg0, [[MUX0]], [[C_2]] : i2
%0 = moore.conditional %arg0 : l1 -> l2 {
%1 = moore.conditional %arg1 : l1 -> l2 {
moore.yield %c_0 : l2
} {
moore.yield %c_1 : l2
}
moore.yield %1 : l2
} {
moore.yield %c_2 : l2
}

return
}

// CHECK-LABEL: func.func @Conversions
func.func @Conversions(%arg0: !moore.i16, %arg1: !moore.l16) {
// CHECK: [[TMP:%.+]] = comb.extract %arg0 from 0 : (i16) -> i8
Expand Down