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)
| 1283 | |
| 1284 | |
| 1285 | def 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 | |
| 1314 | def analyze_forest(forest: list[parser.AstNode]) -> Analysis: |
no test coverage detected
searching dependent graphs…