dataflow
AbstractAssemblyDataflow
¶
Bases: DataFlowAnalysis
Assembly-specific base for dataflow analyses.
Source code in src/finch/finch_assembly/dataflow.py
get_lattice_value(state, stmt)
abstractmethod
¶
Return list of (var_instance_name, lattice_value) pairs for a stmt/expr.
statement_states()
¶
yield each numbered statement of the reached blocks with the state flowing into its transfer (before it for forward, after it for backward).
Source code in src/finch/finch_assembly/dataflow.py
stmt_str(stmt, state)
¶
Annotate a statement with lattice values.
Delegates expression traversal and collection of (name,value) pairs to
get_lattice_value which now returns the annotation list directly.
Source code in src/finch/finch_assembly/dataflow.py
AssemblyCopyPropagation
¶
Bases: AbstractAssemblyDataflow
Copy propagation for FinchAssembly.
Lattice:
- defs: mapping { var_name: sid | None } describing a unique reaching
definition id for each variable (None means "not uniquely defined").
- copies: mapping { dst_var: (src_var, src_def_id) } describing a direct
copy dst_var = src_var that is valid only if src_var still has the
same unique reaching definition src_def_id.
Source code in src/finch/finch_assembly/dataflow.py
142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 | |
collect_copy_replacements()
¶
Collect per-statement copy replacements.
Returns:
| Name | Type | Description |
|---|---|---|
dict |
dict[tuple[int, str], str]
|
Mapping |
Source code in src/finch/finch_assembly/dataflow.py
direction()
¶
get_lattice_value(state, stmt)
¶
Collect lattice annotations for variables used in a stmt or expr.
Source code in src/finch/finch_assembly/dataflow.py
join(state_1, state_2)
¶
Meet operator for must copy-propagation.
- defs join: keep a def id only if both agree, else None.
- copies join: keep a copy only if both agree exactly, and it remains consistent with the joined defs.
Source code in src/finch/finch_assembly/dataflow.py
transfer(stmts, state)
¶
Transfer function over a sequence of statements.
Applies copy-propagation effects of each statement in order, returning the updated lattice mapping. Only copies of variables are recorded; any existing mappings that point to a variable being reassigned are invalidated first.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
stmts
|
Iterable[Any]
|
Iterable of Assembly statements in a basic block. |
required |
state
|
dict
|
Incoming lattice mapping. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
dict |
dict
|
The outgoing lattice mapping after processing |
Source code in src/finch/finch_assembly/dataflow.py
assembly_copy_propagation(node)
¶
Apply copy-propagation to a FinchAssembly node. Args: node: Root FinchAssembly node to optimize. Returns: AssemblyNode: The optimized FinchAssembly node.
Source code in src/finch/finch_assembly/dataflow.py
assembly_dataflow_analyze(node, analysis_cls)
¶
Run preprocessing + CFG build + analysis for a dataflow pass.
Returns:
| Type | Description |
|---|---|
tuple[AnalysisT, AssemblyNode]
|
(analysis_ctx, preprocessed_node) |
Source code in src/finch/finch_assembly/dataflow.py
assembly_dataflow_run(node, analysis_cls, apply)
¶
Run a full dataflow pass (preprocess -> analyze -> apply -> postprocess).