-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[mlir][python] bind block predecessors and successors #145116
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||
---|---|---|---|---|
|
@@ -1059,6 +1059,26 @@ void mlirBlockPrint(MlirBlock block, MlirStringCallback callback, | |||
unwrap(block)->print(stream); | ||||
} | ||||
|
||||
intptr_t mlirBlockGetNumSuccessors(MlirBlock block) { | ||||
return static_cast<intptr_t>(unwrap(block)->getNumSuccessors()); | ||||
} | ||||
|
||||
MlirBlock mlirBlockGetSuccessor(MlirBlock block, intptr_t pos) { | ||||
return wrap(unwrap(block)->getSuccessor(static_cast<unsigned>(pos))); | ||||
} | ||||
|
||||
intptr_t mlirBlockGetNumPredecessors(MlirBlock block) { | ||||
Block *b = unwrap(block); | ||||
return static_cast<intptr_t>(std::distance(b->pred_begin(), b->pred_end())); | ||||
} | ||||
|
||||
MlirBlock mlirBlockGetPredecessor(MlirBlock block, intptr_t pos) { | ||||
Block *b = unwrap(block); | ||||
Block::pred_iterator it = b->pred_begin(); | ||||
std::advance(it, pos); | ||||
return wrap(*it); | ||||
Comment on lines
+1077
to
+1079
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'd rather avoid iterating over the use-def list every time... This goes through block's use-def chain, maybe there is a way to expose a There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Don't think so
Compare with |
||||
} | ||||
|
||||
//===----------------------------------------------------------------------===// | ||||
// Value API. | ||||
//===----------------------------------------------------------------------===// | ||||
|
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.
Let's have tests for the C API as well