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

Function write_uop

Tools/cases_generator/tier2_generator.py:210–240  ·  view source on GitHub ↗
(uop: Uop, emitter: Tier2Emitter, stack: Stack, cached_items: int = 0)

Source from the content-addressed store, hash-verified

208
209
210def write_uop(uop: Uop, emitter: Tier2Emitter, stack: Stack, cached_items: int = 0) -> tuple[bool, Stack]:
211 locals: dict[str, Local] = {}
212 zero_regs = is_large(uop) or uop.properties.escapes
213 try:
214 emitter.out.start_line()
215 if uop.properties.oparg:
216 emitter.emit("oparg = CURRENT_OPARG();\n")
217 assert uop.properties.const_oparg < 0
218 elif uop.properties.const_oparg >= 0:
219 emitter.emit(f"oparg = {uop.properties.const_oparg};\n")
220 emitter.emit(f"assert(oparg == CURRENT_OPARG());\n")
221 storage = Storage.for_uop(stack, uop, emitter.out)
222 idx = 0
223 for cache in uop.caches:
224 if cache.name != "unused":
225 bits = cache.size*16
226 if cache.size == 4:
227 type = cast = "PyObject *"
228 else:
229 type = f"uint{bits}_t "
230 cast = f"uint{bits}_t"
231 emitter.emit(f"{type}{cache.name} = ({cast})CURRENT_OPERAND{idx}_{bits}();\n")
232 idx += 1
233 reachable, storage = emitter.emit_tokens(uop, storage, None, False)
234 if reachable:
235 storage.stack._print(emitter.out)
236 emitter.cache_items(storage.stack, cached_items, zero_regs)
237 storage.flush(emitter.out)
238 return reachable, storage.stack
239 except StackError as ex:
240 raise analysis_error(ex.args[0], uop.body.open) from None
241
242SKIPS = ("_EXTENDED_ARG",)
243

Callers 1

generate_tier2Function · 0.70

Calls 9

is_largeFunction · 0.90
analysis_errorFunction · 0.90
start_lineMethod · 0.80
for_uopMethod · 0.80
emit_tokensMethod · 0.80
cache_itemsMethod · 0.80
emitMethod · 0.45
_printMethod · 0.45
flushMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…