8000 gh-106581: Support multiple uops pushing new values by gvanrossum · Pull Request #108895 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

gh-106581: Support multiple uops pushing new values #108895

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 3 commits into from
Sep 5, 2023
Merged
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
Refactor to use write_all_pokes() in two places
  • Loading branch information
gvanrossum committed Sep 4, 2023
commit ab56dba6163aa584c584582dec52f55e0669a486
34 changes: 23 additions & 11 deletions Tools/cases_generator/stacking.py
Original file line number Diff line number Diff line change
Expand Up @@ -428,8 +428,8 @@ def write_components(
if mgr.instr.name in ("_PUSH_FRAME", "_POP_FRAME"):
# Adjust stack to min_offset (input effects materialized)
out.stack_adjust(mgr.min_offset.deep, mgr.min_offset.high)
# Use clone() since adjust_inverse() mutates final_offset
mgr.adjust_inverse(mgr.final_offset.clone())
assert mgr is managers[-1]
write_all_pokes(mgr.final_offset, managers, out)

if mgr.instr.name == "SAVE_CURRENT_IP":
next_instr_is_set = True
Expand All @@ -445,19 +445,31 @@ def write_components(
if mgr is managers[-1] and not next_instr_is_set:
# TODO: Explain why this adjustment is needed.
out.stack_adjust(mgr.final_offset.deep, mgr.final_offset.high)
# Use clone() since adjust_inverse() mutates final_offset
mgr.adjust_inverse(mgr.final_offset.clone())

for poke in mgr.pokes:
if not poke.effect.size and poke.effect.name not in mgr.instr.unmoved_names:
out.assign(
poke.as_stack_effect(),
poke.effect,
)
write_all_pokes(mgr.final_offset, managers, out)

return next_instr_is_set


def write_all_pokes(
offset: StackOffset, managers: list[EffectManager], out: Formatter
) -> None:
# Clone offset since adjust_inverse() mutates final_offset
offset = offset.clone()
# Emit all remaining pushes (pokes)
for m in managers:
m.adjust_inverse(offset)
write_pokes(m, out)


def write_pokes(mgr: EffectManager, out: Formatter) -> None:
for poke in mgr.pokes:
if not poke.effect.size and poke.effect.name not in mgr.instr.unmoved_names:
out.assign(
poke.as_stack_effect(),
poke.effect,
)


def write_single_instr_for_abstract_interp(instr: Instruction, out: Formatter) -> None:
try:
_write_components_for_abstract_interp(
Expand Down
0