Skip to content

Commit 772f803

Browse files
committed
Simplify code
1 parent 8138a06 commit 772f803

File tree

1 file changed

+6
-8
lines changed

1 file changed

+6
-8
lines changed

Tools/cases_generator/analyzer.py

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1085,16 +1085,16 @@ def is_instruction_size_macro(token: lexer.Token) -> bool:
10851085
return token.kind == "IDENTIFIER" and token.text == "INSTRUCTION_SIZE"
10861086

10871087

1088-
def contains_instruction_size_macro(uop: Uop) -> bool:
1089-
return any(is_instruction_size_macro(token) for token in uop.body)
1090-
1091-
1092-
def get_instruction_size_for_uop(instructions: dict[str, Instruction], uop: Uop) -> int:
1093-
"""Return the size of the instruction that contains the given uop.
1088+
def get_instruction_size_for_uop(instructions: dict[str, Instruction], uop: Uop) -> int | None:
1089+
"""Return the size of the instruction that contains the given uop or
1090+
`None` if the uop does not contains the `INSTRUCTION_SIZE` macro.
10941091
10951092
If there is more than one instruction that contains the uop,
10961093
ensure that they all have the same size.
10971094
"""
1095+
if not any(is_instruction_size_macro(token) for token in uop.body):
1096+
return None
1097+
10981098
size = None
10991099
for inst in instructions.values():
11001100
if uop in inst.parts:
@@ -1157,8 +1157,6 @@ def analyze_forest(forest: list[parser.AstNode]) -> Analysis:
11571157
if target.text in instructions:
11581158
instructions[target.text].is_target = True
11591159
for uop in uops.values():
1160-
if not contains_instruction_size_macro(uop):
1161-
continue
11621160
uop.instruction_size = get_instruction_size_for_uop(instructions, uop)
11631161
# Special case BINARY_OP_INPLACE_ADD_UNICODE
11641162
# BINARY_OP_INPLACE_ADD_UNICODE is not a normal family member,

0 commit comments

Comments
 (0)