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

Function write_uop

Tools/cases_generator/tier1_generator.py:71–116  ·  view source on GitHub ↗
(
    uop: Part,
    emitter: Emitter,
    offset: int,
    stack: Stack,
    inst: Instruction,
    braces: bool,
)

Source from the content-addressed store, hash-verified

69
70
71def write_uop(
72 uop: Part,
73 emitter: Emitter,
74 offset: int,
75 stack: Stack,
76 inst: Instruction,
77 braces: bool,
78) -> tuple[bool, int, Stack]:
79 # out.emit(stack.as_comment() + "\n")
80 if isinstance(uop, Skip):
81 entries = "entries" if uop.size > 1 else "entry"
82 emitter.emit(f"/* Skip {uop.size} cache {entries} */\n")
83 return True, (offset + uop.size), stack
84 if isinstance(uop, Flush):
85 emitter.emit(f"// flush\n")
86 stack.flush(emitter.out)
87 return True, offset, stack
88 locals: dict[str, Local] = {}
89 emitter.out.start_line()
90 if braces:
91 emitter.out.emit(f"// {uop.name}\n")
92 emitter.emit("{\n")
93 stack._print(emitter.out)
94 storage = Storage.for_uop(stack, uop, emitter.out)
95
96 for cache in uop.caches:
97 if cache.name != "unused":
98 if cache.size == 4:
99 type = "PyObject *"
100 reader = "read_obj"
101 else:
102 type = f"uint{cache.size*16}_t "
103 reader = f"read_u{cache.size*16}"
104 emitter.emit(
105 f"{type}{cache.name} = {reader}(&this_instr[{offset}].cache);\n"
106 )
107 if inst.family is None:
108 emitter.emit(f"(void){cache.name};\n")
109 offset += cache.size
110
111 reachable, storage = emitter.emit_tokens(uop, storage, inst, False)
112 if braces:
113 emitter.out.start_line()
114 emitter.emit("}\n")
115 # emitter.emit(stack.as_comment() + "\n")
116 return reachable, offset, storage.stack
117
118
119def uses_this(inst: Instruction) -> bool:

Callers 2

generate_tier1_casesFunction · 0.70

Calls 6

start_lineMethod · 0.80
for_uopMethod · 0.80
emit_tokensMethod · 0.80
emitMethod · 0.45
flushMethod · 0.45
_printMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…