8000 gh-105481: split opcode_ids.h out of opcode.h so that it can be generated separately by iritkatriel · Pull Request #107866 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

gh-105481: split opcode_ids.h out of opcode.h so that it can be generated separately #107866

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 6 commits into from
Aug 11, 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
rename variables
  • Loading branch information
iritkatriel committed Aug 11, 2023
commit 88370dfd300e23a065c629d5159572d335032b3f
14 changes: 7 additions & 7 deletions Tools/build/generate_opcode_h.py
830D
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
SCRIPT_NAME = "Tools/build/generate_opcode_h.py"
PYTHON_OPCODE = "Lib/opcode.py"

header = f"""
opcode_h_header = f"""
// Auto-generated by {SCRIPT_NAME} from {PYTHON_OPCODE}

#ifndef Py_OPCODE_H
Expand All @@ -19,7 +19,7 @@
/* Instruction opcodes for compiled code */
""".lstrip()

footer = """
opcode_h_footer = """

#ifdef __cplusplus
}
Expand Down Expand Up @@ -63,7 +63,7 @@ def get_python_module_dict(filename):

def main(opcode_py,
_opcode_metadata_py='Lib/_opcode_metadata.py',
outfile='Include/opcode.h',
opcode_h='Include/opcode.h',
opcode_targets_h='Python/opcode_targets.h',
internaloutfile='Include/internal/pycore_opcode.h'):

Expand Down Expand Up @@ -91,8 +91,8 @@ def main(opcode_py,
opname_including_specialized[next_op] = name
used[next_op] = True

with open(outfile, 'w') as fobj:
fobj.write(header)
with open(opcode_h, 'w') as fobj:
fobj.write(opcode_h_header)

for name in opname:
if name in opmap:
Expand All @@ -110,7 +110,7 @@ def main(opcode_py,
for i, (op, _) in enumerate(opcode["_nb_ops"]):
fobj.write(DEFINE.format(op, i))

fobj.write(footer)
fobj.write(opcode_h_footer)

with open(internaloutfile, 'w') as iobj:
iobj.write(internal_header)
Expand Down Expand Up @@ -167,7 +167,7 @@ def main(opcode_py,
f.write(",\n".join([f" &&{s}" for s in targets]))
f.write("\n};\n")

print(f"{outfile} regenerated from {opcode_py}")
print(f"{opcode_h} regenerated from {opcode_py}")


if __name__ == '__main__':
Expand Down
0