(
filenames: list[str], analysis: Analysis, outfile: TextIO, lines: bool
)
| 248 | ) |
| 249 | |
| 250 | def generate_tier2( |
| 251 | filenames: list[str], analysis: Analysis, outfile: TextIO, lines: bool |
| 252 | ) -> None: |
| 253 | write_header(__file__, filenames, outfile) |
| 254 | outfile.write( |
| 255 | """ |
| 256 | #ifdef TIER_ONE |
| 257 | #error "This file is for Tier 2 only" |
| 258 | #endif |
| 259 | #define TIER_TWO 2 |
| 260 | """ |
| 261 | ) |
| 262 | out = CWriter(outfile, 2, lines) |
| 263 | out.emit("\n") |
| 264 | |
| 265 | for name, uop in analysis.uops.items(): |
| 266 | if uop.properties.tier == 1: |
| 267 | continue |
| 268 | if uop.is_super(): |
| 269 | continue |
| 270 | if uop.properties.records_value: |
| 271 | continue |
| 272 | why_not_viable = uop.why_not_viable() |
| 273 | if why_not_viable is not None: |
| 274 | out.emit( |
| 275 | f"/* {uop.name} is not a viable micro-op for tier 2 because it {why_not_viable} */\n\n" |
| 276 | ) |
| 277 | continue |
| 278 | for inputs, outputs, exit_depth in get_uop_cache_depths(uop): |
| 279 | emitter = Tier2Emitter(out, analysis.labels, exit_depth) |
| 280 | out.emit(f"case {uop.name}_r{inputs}{outputs}: {{\n") |
| 281 | out.emit(f"CHECK_CURRENT_CACHED_VALUES({inputs});\n") |
| 282 | out.emit("assert(WITHIN_STACK_BOUNDS_IGNORING_CACHE());\n") |
| 283 | declare_variables(uop, out) |
| 284 | stack = Stack() |
| 285 | stack.push_cache([f"_tos_cache{i}" for i in range(inputs)], out) |
| 286 | stack._print(out) |
| 287 | reachable, stack = write_uop(uop, emitter, stack, outputs) |
| 288 | out.start_line() |
| 289 | if reachable: |
| 290 | out.emit("assert(WITHIN_STACK_BOUNDS_IGNORING_CACHE());\n") |
| 291 | if not uop.properties.always_exits: |
| 292 | out.emit("break;\n") |
| 293 | out.start_line() |
| 294 | out.emit("}") |
| 295 | out.emit("\n\n") |
| 296 | out.emit("\n") |
| 297 | outfile.write("#undef TIER_TWO\n") |
| 298 | |
| 299 | |
| 300 | arg_parser = argparse.ArgumentParser( |
no test coverage detected
searching dependent graphs…