Dataflow
oqd_compiler_infrastructure.dataflow
¶
GraphProtocol
¶
Bases: Protocol[NodeType]
Any object passed to ForwardDataflowAnalysis.analyze must provide this interface.
The protocol is intentionally minimal so it can adapt to Control Flow Graphs (CFGs),
dependency graphs, custom IR graphs, etc.
Source code in oqd-compiler-infrastructure/src/oqd_compiler_infrastructure/dataflow.py
DataflowResult
dataclass
¶
Bases: Generic[NodeType, StateType]
The result of a dataflow analysis.
Source code in oqd-compiler-infrastructure/src/oqd_compiler_infrastructure/dataflow.py
DataflowAnalysis
¶
Bases: ABC, Generic[NodeType, StateType]
Base class that defines what every dataflow analysis must implement.
Source code in oqd-compiler-infrastructure/src/oqd_compiler_infrastructure/dataflow.py
ForwardDataflowAnalysis
¶
Bases: DataflowAnalysis[NodeType, StateType], Generic[NodeType, StateType]
Forward dataflow analysis framework. This class implements the fixed point loop.
Source code in oqd-compiler-infrastructure/src/oqd_compiler_infrastructure/dataflow.py
analyze(graph: GraphProtocol[NodeType]) -> DataflowResult[NodeType, StateType]
¶
Runs the worklist algorithm and returns the result of the dataflow analysis.
Steps:
- Initializes in/out states with bottom().
- Puts all nodes in a worklist.
- Recomputes each node from predecessor outputs.
- If a node output changes, schedules its successors again.
- Returns final states and iteration count.