mirror of
https://github.com/python/cpython.git
synced 2025-08-31 05:58:33 +00:00
gh-119689: generate stack effect metadata for pseudo instructions (#119691)
This commit is contained in:
parent
7ca74a760a
commit
c1e9647107
10 changed files with 112 additions and 73 deletions
|
@ -10,6 +10,7 @@ import sys
|
|||
from analyzer import (
|
||||
Analysis,
|
||||
Instruction,
|
||||
PseudoInstruction,
|
||||
analyze_files,
|
||||
Skip,
|
||||
Uop,
|
||||
|
@ -94,12 +95,18 @@ def emit_stack_effect_function(
|
|||
def generate_stack_effect_functions(analysis: Analysis, out: CWriter) -> None:
|
||||
popped_data: list[tuple[str, str]] = []
|
||||
pushed_data: list[tuple[str, str]] = []
|
||||
for inst in analysis.instructions.values():
|
||||
def add(inst: Instruction | PseudoInstruction) -> None:
|
||||
stack = get_stack_effect(inst)
|
||||
popped = (-stack.base_offset).to_c()
|
||||
pushed = (stack.top_offset - stack.base_offset).to_c()
|
||||
popped_data.append((inst.name, popped))
|
||||
pushed_data.append((inst.name, pushed))
|
||||
|
||||
for inst in analysis.instructions.values():
|
||||
add(inst)
|
||||
for pseudo in analysis.pseudos.values():
|
||||
add(pseudo)
|
||||
|
||||
emit_stack_effect_function(out, "popped", sorted(popped_data))
|
||||
emit_stack_effect_function(out, "pushed", sorted(pushed_data))
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue