Conversation
|
I am currently working on implementing a dominance tree data structure that closely mirrors with the one defined in LLVM: https://github.com/llvm/llvm-project/blob/main/llvm/include/llvm/Support/GenericDomTree.h |
85e953d to
156344b
Compare
| deriving Inhabited, Repr, DecidableEq, Hashable | ||
|
|
||
| structure DomTreeNode where | ||
| -- The block in question |
There was a problem hiding this comment.
You can use /-- -/ to write doc comments.
| let parentNode := (parent.get! ctx) | ||
|
|
||
| if (child.getSibling! ctx).isSome then | ||
| panic! "cannot add child that already has siblings" |
There was a problem hiding this comment.
Would it be better to return none. @math-fehr do you have an opinion?
Veir/IR/Dominance.lean
Outdated
| panic! "parent's last child is not the same as the last sibling" | ||
|
|
||
| -- Special case: child being removed is first child in sibling list | ||
| if parentFirst == child then |
There was a problem hiding this comment.
Usually, it's more canonical to use = instead of == in Lean
There was a problem hiding this comment.
Done. What are some of the benefits of giving if ... then ... else ... a Prop instead of a Bool?
ineol
left a comment
There was a problem hiding this comment.
Thank you!
Maybe we should consider splitting the dominance tree off of the PR to keep it manageable?
I definitely will. I also intend on cleaning up all of these commits because they're a mess. I've been under the weather lately - I was planning on splitting up the PR a couple days ago. I'll get to it soon. Also, thanks for the comments. This'll help me write better Lean code :) |
I just split my work into two PRs. This one now only contains the Dominance Tree. #264 contains the Dataflow Analysis Framework now. |
The following draft implements a dominance tree. The dominance tree currently uses the Cooper-Harvey-Kennedy algorithm.