MCPcopy Index your code
hub / github.com/python/cpython / generate_uop_ids

Function generate_uop_ids

Tools/cases_generator/uop_id_generator.py:25–59  ·  view source on GitHub ↗
(
    filenames: list[str], analysis: Analysis, outfile: TextIO, distinct_namespace: bool
)

Source from the content-addressed store, hash-verified

23
24
25def 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
62arg_parser = argparse.ArgumentParser(

Callers 1

Calls 7

header_guardMethod · 0.95
emitMethod · 0.95
write_headerFunction · 0.90
CWriterClass · 0.90
get_uop_cache_depthsFunction · 0.90
valuesMethod · 0.45
is_superMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…