Skip to content

Commit 3ae7a5d

Browse files
committed
Simplify code
1 parent a10d4ee commit 3ae7a5d

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

Tools/cases_generator/analyzer.py

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1081,18 +1081,17 @@ def add_instruction(name: str) -> None:
10811081
return instmap, len(no_arg), min_instrumented
10821082

10831083

1084-
def is_instruction_size_macro(token: lexer.Token) -> bool:
1085-
return token.text == "INSTRUCTION_SIZE"
1086-
1087-
10881084
def get_instruction_size_for_uop(instructions: dict[str, Instruction], uop: Uop) -> int | None:
10891085
"""Return the size of the instruction that contains the given uop or
10901086
`None` if the uop does not contains the `INSTRUCTION_SIZE` macro.
10911087
10921088
If there is more than one instruction that contains the uop,
10931089
ensure that they all have the same size.
10941090
"""
1095-
if not (token := next((t for t in uop.body if is_instruction_size_macro(t)), None)):
1091+
for tkn in uop.body:
1092+
if tkn.text == "INSTRUCTION_SIZE":
1093+
break
1094+
else:
10961095
return None
10971096

10981097
size = None
@@ -1104,10 +1103,10 @@ def get_instruction_size_for_uop(instructions: dict[str, Instruction], uop: Uop)
11041103
raise analysis_error(
11051104
"All instructions containing a uop with the `INSTRUCTION_SIZE` macro "
11061105
f"must have the same size: {size} != {inst.size}",
1107-
token
1106+
tkn
11081107
)
11091108
if size is None:
1110-
raise analysis_error(f"No instruction containing the uop '{uop.name}' was found", token)
1109+
raise analysis_error(f"No instruction containing the uop '{uop.name}' was found", tkn)
11111110
return size
11121111

11131112

0 commit comments

Comments
 (0)