Skip to content

Commit

Permalink
Remove some code repetition
Browse files Browse the repository at this point in the history
  • Loading branch information
tomasr8 committed Oct 28, 2024
1 parent 772f803 commit a718cfb
Showing 1 changed file with 1 addition and 3 deletions.
4 changes: 1 addition & 3 deletions Tools/cases_generator/analyzer.py
Original file line number Diff line number Diff line change
Expand Up @@ -1092,7 +1092,7 @@ def get_instruction_size_for_uop(instructions: dict[str, Instruction], uop: Uop)
If there is more than one instruction that contains the uop,
ensure that they all have the same size.
"""
if not any(is_instruction_size_macro(token) for token in uop.body):
if not (token := next((t for t in uop.body if is_instruction_size_macro(t)), None)):
return None

size = None
Expand All @@ -1101,14 +1101,12 @@ def get_instruction_size_for_uop(instructions: dict[str, Instruction], uop: Uop)
if size is None:
size = inst.size
if size != inst.size:
token = next(t for t in uop.body if is_instruction_size_macro(t))
raise analysis_error(
"All instructions containing a uop with the `INSTRUCTION_SIZE` macro "
f"must have the same size: {size} != {inst.size}",
token
)
if size is None:
token = next(t for t in uop.body if is_instruction_size_macro(t))
raise analysis_error(f"No instruction containing the uop '{uop.name}' was found", token)
return size

Expand Down

0 comments on commit a718cfb

Please sign in to comment.