Skip to content

Small fixes to code generator #106845

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jul 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions Include/internal/pycore_opcode_metadata.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 3 additions & 5 deletions Python/generated_cases.c.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 5 additions & 5 deletions Tools/cases_generator/generate_cases.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ def effect_size(effect: StackEffect) -> tuple[int, str]:
return 0, effect.size
elif effect.cond:
if effect.cond in ("0", "1"):
return 0, effect.cond
return int(effect.cond), ""
return 0, f"{maybe_parenthesize(effect.cond)} ? 1 : 0"
else:
return 1, ""
Expand Down Expand Up @@ -841,9 +841,9 @@ def map_families(self) -> None:
def check_families(self) -> None:
"""Check each family:

- Must have at least 2 members
- All members must be known instructions
- All members must have the same cache, input and output effects
- Must have at least 2 members (including head)
- Head and all members must be known instructions
- Head and all members must have the same cache, input and output effects
"""
for family in self.families.values():
if family.name not in self.macro_instrs and family.name not in self.instrs:
Expand All @@ -868,7 +868,7 @@ def check_families(self) -> None:
self.error(
f"Family {family.name!r} has inconsistent "
f"(cache, input, output) effects:\n"
f" {family.members[0]} = {expected_effects}; "
f" {family.name} = {expected_effects}; "
f"{member} = {member_effects}",
family,
)
Expand Down