gh-119689: generate stack effect metadata for pseudo instructions (#119691)

This commit is contained in:
Irit Katriel 2024-05-29 10:47:56 +01:00 committed by GitHub
parent 7ca74a760a
commit c1e9647107
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
10 changed files with 112 additions and 73 deletions

View file

@ -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))