(
filenames: list[str], analysis: Analysis, outfile: TextIO, distinct_namespace: bool
)
| 23 | |
| 24 | |
| 25 | def generate_uop_ids( |
| 26 | filenames: list[str], analysis: Analysis, outfile: TextIO, distinct_namespace: bool |
| 27 | ) -> None: |
| 28 | write_header(__file__, filenames, outfile) |
| 29 | out = CWriter(outfile, 0, False) |
| 30 | with out.header_guard("Py_CORE_UOP_IDS_H"): |
| 31 | next_id = 1 if distinct_namespace else 300 |
| 32 | # These two are first by convention |
| 33 | out.emit(f"#define _EXIT_TRACE {next_id}\n") |
| 34 | next_id += 1 |
| 35 | out.emit(f"#define _SET_IP {next_id}\n") |
| 36 | next_id += 1 |
| 37 | PRE_DEFINED = {"_EXIT_TRACE", "_SET_IP"} |
| 38 | |
| 39 | uops = [(uop.name, uop) for uop in analysis.uops.values()] |
| 40 | # Sort so that _BASE comes immediately before _BASE_0, etc. |
| 41 | for name, uop in sorted(uops): |
| 42 | if name in PRE_DEFINED or uop.is_super() or uop.properties.tier == 1: |
| 43 | continue |
| 44 | if uop.implicitly_created and not distinct_namespace and not uop.replicated: |
| 45 | out.emit(f"#define {name} {name[1:]}\n") |
| 46 | else: |
| 47 | out.emit(f"#define {name} {next_id}\n") |
| 48 | next_id += 1 |
| 49 | |
| 50 | out.emit(f"#define MAX_UOP_ID {next_id-1}\n") |
| 51 | for name, uop in sorted(uops): |
| 52 | if uop.properties.tier == 1: |
| 53 | continue |
| 54 | if uop.properties.records_value: |
| 55 | continue |
| 56 | for inputs, outputs, _ in sorted(get_uop_cache_depths(uop)): |
| 57 | out.emit(f"#define {name}_r{inputs}{outputs} {next_id}\n") |
| 58 | next_id += 1 |
| 59 | out.emit(f"#define MAX_UOP_REGS_ID {next_id-1}\n") |
| 60 | |
| 61 | |
| 62 | arg_parser = argparse.ArgumentParser( |
no test coverage detected
searching dependent graphs…