10000 GH-131498: Another refactoring of the code generator by markshannon · Pull Request #131827 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

GH-131498: Another refactoring of the code generator #131827

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 18 commits into from
Mar 31, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Don't declare unused variables and update test
  • Loading branch information
markshannon committed Mar 30, 2025
commit e38eab42851acac94dfd9f33c74181ae8bdd07bf
10 changes: 6 additions & 4 deletions Lib/test/test_generated_cases.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,13 +68,15 @@ def test_effect_sizes(self):
StackItem("b", None, "oparg*4"),
StackItem("c", None, "1"),
]
stack.pop(z)
stack.pop(y)
stack.pop(x)
null = CWriter.null()
stack.pop(z, null)
stack.pop(y, null)
stack.pop(x, null)
for out in outputs:
stack.push(Local.undefined(out))
self.assertEqual(stack.base_offset.to_c(), "-1 - oparg - oparg*2")
self.assertEqual(stack.top_offset.to_c(), "1 - oparg - oparg*2 + oparg*4")
self.assertEqual(stack.physical_sp.to_c(), "0")
self.assertEqual(stack.logical_sp.to_c(), "1 - oparg - oparg*2 + oparg*4")


class TestGeneratedCases(unittest.TestCase):
Expand Down
10 changes: 5 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.

4 changes: 2 additions & 2 deletions Tools/cases_generator/tier1_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,11 @@ def declare_variables(inst: Instruction, out: CWriter) -> None:
if not isinstance(part, Uop):
continue
for var in part.stack.inputs:
if var.name not in seen:
if var.used and var.name not in seen:
seen.add(var.name)
declare_variable(var, out)
for var in part.stack.outputs:
if var.name not in seen:
if var.used and var.name not in seen:
seen.add(var.name)
declare_variable(var, out)

Expand Down
Loading
0