diff options
author | Irit Katriel <1055913+iritkatriel@users.noreply.github.com> | 2023-08-01 20:05:48 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-08-01 20:05:48 (GMT) |
commit | 2bd04d423404e5ea862c858f62af76feade4d831 (patch) | |
tree | f60ed68a6779a6bb8119d7351ee2cc1ba5c0eca3 /Tools/build | |
parent | 6ef8f8ca88b925685c6af83a9f0a899e565e1e33 (diff) | |
download | cpython-2bd04d423404e5ea862c858f62af76feade4d831.zip cpython-2bd04d423404e5ea862c858f62af76feade4d831.tar.gz cpython-2bd04d423404e5ea862c858f62af76feade4d831.tar.bz2 |
gh-105481: combine regen-opcode-targets with regen-opcode to avoid calculating the specialized opcodes in two places (#107540)
Diffstat (limited to 'Tools/build')
-rw-r--r-- | Tools/build/generate_opcode_h.py | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/Tools/build/generate_opcode_h.py b/Tools/build/generate_opcode_h.py index 2259dad..16b028d 100644 --- a/Tools/build/generate_opcode_h.py +++ b/Tools/build/generate_opcode_h.py @@ -64,6 +64,7 @@ def get_python_module_dict(filename): def main(opcode_py, _opcode_metadata_py='Lib/_opcode_metadata.py', outfile='Include/opcode.h', + opcode_targets_h='Python/opcode_targets.h', internaloutfile='Include/internal/pycore_opcode.h'): _opcode_metadata = get_python_module_dict(_opcode_metadata_py) @@ -161,9 +162,18 @@ def main(opcode_py, fobj.write(footer) iobj.write(internal_footer) + with open(opcode_targets_h, "w") as f: + targets = ["_unknown_opcode"] * 256 + for op, name in enumerate(opname_including_specialized): + if op < 256 and not name.startswith("<"): + targets[op] = f"TARGET_{name}" + + f.write("static void *opcode_targets[256] = {\n") + f.write(",\n".join([f" &&{s}" for s in targets])) + f.write("\n};\n") print(f"{outfile} regenerated from {opcode_py}") if __name__ == '__main__': - main(sys.argv[1], sys.argv[2], sys.argv[3], sys.argv[4]) + main(sys.argv[1], sys.argv[2], sys.argv[3], sys.argv[4], sys.argv[5]) |