MCPcopy Create free account
hub / github.com/python/cpython / get_instruction_size_for_uop

Function get_instruction_size_for_uop

Tools/cases_generator/analyzer.py:1285–1311  ·  view source on GitHub ↗

Return the size of the instruction that contains the given uop or `None` if the uop does not contains the `INSTRUCTION_SIZE` macro. If there is more than one instruction that contains the uop, ensure that they all have the same size.

(instructions: dict[str, Instruction], uop: Uop)

Source from the content-addressed store, hash-verified

1283
1284
1285def get_instruction_size_for_uop(instructions: dict[str, Instruction], uop: Uop) -> int | None:
1286 """Return the size of the instruction that contains the given uop or
1287 `None` if the uop does not contains the `INSTRUCTION_SIZE` macro.
1288
1289 If there is more than one instruction that contains the uop,
1290 ensure that they all have the same size.
1291 """
1292 for tkn in uop.body.tokens():
1293 if tkn.text == "INSTRUCTION_SIZE":
1294 break
1295 else:
1296 return None
1297
1298 size = None
1299 for inst in instructions.values():
1300 if uop in inst.parts:
1301 if size is None:
1302 size = inst.size
1303 if size != inst.size:
1304 raise analysis_error(
1305 "All instructions containing a uop with the `INSTRUCTION_SIZE` macro "
1306 f"must have the same size: {size} != {inst.size}",
1307 tkn
1308 )
1309 if size is None:
1310 raise analysis_error(f"No instruction containing the uop '{uop.name}' was found", tkn)
1311 return size
1312
1313
1314def analyze_forest(forest: list[parser.AstNode]) -> Analysis:

Callers 1

analyze_forestFunction · 0.85

Calls 3

analysis_errorFunction · 0.85
tokensMethod · 0.45
valuesMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…