dataflow
AbstractAssemblyDataflow
Bases: DataFlowAnalysis
Assembly-specific base for dataflow analyses.
Source code in src/finch/finch_assembly/dataflow.py
106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 | |
get_lattice_value(state, stmt)
abstractmethod
Return list of (var_instance_name, lattice_value) pairs for a stmt/expr.
Source code in src/finch/finch_assembly/dataflow.py
121 122 123 124 | |
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
109 110 111 112 113 114 115 116 117 118 119 | |
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
127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 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 293 294 295 296 297 298 299 | |
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
142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 | |
direction()
Copy propagation is a forward analysis.
Source code in src/finch/finch_assembly/dataflow.py
138 139 140 | |
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
167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 | |
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
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 | |
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
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 | |
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
60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 | |
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
31 32 33 34 35 36 37 38 39 40 41 42 43 44 | |
assembly_dataflow_run(node, analysis_cls, apply)
Run a full dataflow pass (preprocess -> analyze -> apply -> postprocess).
Source code in src/finch/finch_assembly/dataflow.py
47 48 49 50 51 52 53 54 55 56 57 | |