graph/cfa: add cfa package for control flow analysis algorithms
Created by: mewmew
This PR is a work in progress. DO NOT MERGE.
It is based on the initial discussions in https://github.com/gonum/gonum/issues/796 and the intention is to arrive at an API that control flow analysis algorithms can unify around. Specifically, we define the notion of a cfa.Graph
, a control flow graph rooted at an entry node.
This PR also adds the initial API scaffolding for finding the unique set of intervals in a control flow graph.
Follow-up PRs (or extensions to this PR) will move other control flow analysis algorithms to the cfa
package, and update their API to make use of the cfa.Graph
interface. Specifically, this relates to the path.DominatorTree
API.
-func Dominators(root graph.Node, g graph.Directed) DominatorTree
+func Dominators(g Graph) DominatorTree
Please take a look.