-
Notifications
You must be signed in to change notification settings - Fork 603
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
Add support for control flow lowering in the VM to emitc target #5208
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
3007c21
Sort descriptors as expected by the native module
simon-camp e831d66
Simplify comparison functions
simon-camp fa3a1cf
Support control flow ops in the vm to emitc path
simon-camp 35ea5b8
Enable comparison ops
simon-camp 18f685c
Fix dependency
simon-camp a9f17ff
Add lit test for control flow conversion
simon-camp 7459c8f
Fix comment
simon-camp File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
// RUN: iree-translate -iree-vm-ir-to-c-module -iree-vm-c-module-optimize=false %s | IreeFileCheck %s | ||
|
||
vm.module @control_flow_module { | ||
vm.func @control_flow_test(%a: i32, %cond: i32) -> i32 { | ||
vm.cond_br %cond, ^bb1, ^bb2 | ||
^bb1: | ||
vm.br ^bb3(%a: i32) | ||
^bb2: | ||
%b = vm.add.i32 %a, %a : i32 | ||
vm.br ^bb3(%b: i32) | ||
^bb3(%c: i32): | ||
vm.br ^bb4(%c, %a : i32, i32) | ||
^bb4(%d : i32, %e : i32): | ||
%0 = vm.add.i32 %d, %e : i32 | ||
vm.return %0 : i32 | ||
} | ||
} | ||
// CHECK: iree_status_t control_flow_module_control_flow_test_impl(int32_t [[A:[^ ]*]], int32_t [[COND:[^ ]*]], int32_t *[[RESULT:[^ ]*]], control_flow_module_state_t* [[STATE:[^ ]*]]) { | ||
// CHECK-NEXT: int32_t [[B:[^ ]*]]; | ||
// CHECK-NEXT: int32_t [[V0:[^ ]*]]; | ||
// CHECK-NEXT: int32_t [[C:[^ ]*]]; | ||
// CHECK-NEXT: int32_t [[D:[^ ]*]]; | ||
// CHECK-NEXT: int32_t [[E:[^ ]*]]; | ||
// CHECK-NEXT: [[BB0:[^ ]*]]: | ||
// CHECK-NEXT: if ([[COND]]) { | ||
// CHECK-NEXT: goto [[BB1:[^ ]*]]; | ||
// CHECK-NEXT: } else { | ||
// CHECK-NEXT: goto [[BB2:[^ ]*]]; | ||
// CHECK-NEXT: } | ||
// CHECK-NEXT: [[BB1]]: | ||
// CHECK-NEXT: [[C]] = [[A]]; | ||
// CHECK-NEXT: goto [[BB3:[^ ]*]]; | ||
// CHECK-NEXT: [[BB2]]: | ||
// CHECK-NEXT: [[B]] = vm_add_i32([[A]], [[A]]); | ||
// CHECK-NEXT: [[C]] = [[B]]; | ||
// CHECK-NEXT: goto [[BB3]]; | ||
// CHECK-NEXT: [[BB3]]: | ||
// CHECK-NEXT: [[D]] = [[C]]; | ||
// CHECK-NEXT: [[E]] = [[A]]; | ||
// CHECK-NEXT: goto [[BB4:[^ ]*]]; | ||
// CHECK-NEXT: [[BB4]]: | ||
// CHECK-NEXT: [[V0]] = vm_add_i32([[D]], [[E]]); | ||
// CHECK-NEXT: *[[RESULT]] = [[V0]]; | ||
// CHECK-NEXT: return iree_ok_status(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
are there any lit tests that could be added for these? it'd help demonstrate what's happening and be good examples of the conversion
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We have those for the
mlir::BranchOp
and themlir::CondBranchOp
(https://github.com/iml130/mlir-emitc/blob/main/test/Target/control_flow.mlir), so we can also add similar lit tests to IREE.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've added the test (and fixed all broken tests in the directory :D)