mirror of
https://github.com/python/cpython.git
synced 2025-09-26 10:19:53 +00:00
GH-98831: Auto-generate PREDICTED() macro calls (#99102)
Co-authored-by: Brandt Bucher <brandtbucher@gmail.com>
This commit is contained in:
parent
e99380cc39
commit
c885623e9f
2 changed files with 7 additions and 16 deletions
|
@ -6,6 +6,7 @@
|
|||
|
||||
import argparse
|
||||
import io
|
||||
import re
|
||||
import sys
|
||||
|
||||
import parser
|
||||
|
@ -61,12 +62,18 @@ def always_exits(block: parser.Block) -> bool:
|
|||
|
||||
|
||||
def write_cases(f: io.TextIOBase, instrs: list[InstDef]):
|
||||
predictions = set()
|
||||
for inst in instrs:
|
||||
for target in re.findall(r"(?:PREDICT|GO_TO_INSTRUCTION)\((\w+)\)", inst.block.text):
|
||||
predictions.add(target)
|
||||
indent = " "
|
||||
f.write("// This file is generated by Tools/scripts/generate_cases.py\n")
|
||||
f.write("// Do not edit!\n")
|
||||
for instr in instrs:
|
||||
assert isinstance(instr, InstDef)
|
||||
f.write(f"\n{indent}TARGET({instr.name}) {{\n")
|
||||
if instr.name in predictions:
|
||||
f.write(f"{indent} PREDICTED({instr.name});\n")
|
||||
# input = ", ".join(instr.inputs)
|
||||
# output = ", ".join(instr.outputs)
|
||||
# f.write(f"{indent} // {input} -- {output}\n")
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue