mirror of
https://github.com/python/cpython.git
synced 2025-11-01 06:01:29 +00:00
gh-105481: do not auto-generate pycore_intrinsics.h (#106913)
This commit is contained in:
parent
214a25dd81
commit
9c81fc2dbe
11 changed files with 174 additions and 91 deletions
|
|
@ -50,18 +50,6 @@
|
|||
#endif // !Py_INTERNAL_OPCODE_H
|
||||
"""
|
||||
|
||||
intrinsic_header = f"""
|
||||
// Auto-generated by {SCRIPT_NAME} from {PYTHON_OPCODE}
|
||||
|
||||
""".lstrip()
|
||||
|
||||
intrinsic_footer = """
|
||||
typedef PyObject *(*instrinsic_func1)(PyThreadState* tstate, PyObject *value);
|
||||
typedef PyObject *(*instrinsic_func2)(PyThreadState* tstate, PyObject *value1, PyObject *value2);
|
||||
extern const instrinsic_func1 _PyIntrinsics_UnaryFunctions[];
|
||||
extern const instrinsic_func2 _PyIntrinsics_BinaryFunctions[];
|
||||
"""
|
||||
|
||||
DEFINE = "#define {:<38} {:>3}\n"
|
||||
|
||||
UINT32_MASK = (1<<32)-1
|
||||
|
|
@ -76,8 +64,7 @@ def get_python_module_dict(filename):
|
|||
def main(opcode_py,
|
||||
_opcode_metadata_py='Lib/_opcode_metadata.py',
|
||||
outfile='Include/opcode.h',
|
||||
internaloutfile='Include/internal/pycore_opcode.h',
|
||||
intrinsicoutfile='Include/internal/pycore_intrinsics.h'):
|
||||
internaloutfile='Include/internal/pycore_opcode.h'):
|
||||
|
||||
_opcode_metadata = get_python_module_dict(_opcode_metadata_py)
|
||||
|
||||
|
|
@ -107,11 +94,9 @@ def main(opcode_py,
|
|||
opname_including_specialized[next_op] = name
|
||||
used[next_op] = True
|
||||
|
||||
with open(outfile, 'w') as fobj, open(internaloutfile, 'w') as iobj, open(
|
||||
intrinsicoutfile, "w") as nobj:
|
||||
with open(outfile, 'w') as fobj, open(internaloutfile, 'w') as iobj:
|
||||
fobj.write(header)
|
||||
iobj.write(internal_header)
|
||||
nobj.write(intrinsic_header)
|
||||
|
||||
for name in opname:
|
||||
if name in opmap:
|
||||
|
|
@ -157,22 +142,6 @@ def main(opcode_py,
|
|||
for i, (op, _) in enumerate(opcode["_nb_ops"]):
|
||||
fobj.write(DEFINE.format(op, i))
|
||||
|
||||
nobj.write("/* Unary Functions: */")
|
||||
nobj.write("\n")
|
||||
for i, op in enumerate(opcode["_intrinsic_1_descs"]):
|
||||
nobj.write(DEFINE.format(op, i))
|
||||
nobj.write("\n")
|
||||
nobj.write(DEFINE.format("MAX_INTRINSIC_1", i))
|
||||
|
||||
nobj.write("\n\n")
|
||||
nobj.write("/* Binary Functions: */\n")
|
||||
for i, op in enumerate(opcode["_intrinsic_2_descs"]):
|
||||
nobj.write(DEFINE.format(op, i))
|
||||
nobj.write("\n")
|
||||
nobj.write(DEFINE.format("MAX_INTRINSIC_2", i))
|
||||
|
||||
nobj.write(intrinsic_footer)
|
||||
|
||||
fobj.write("\n")
|
||||
fobj.write("/* Defined in Lib/opcode.py */\n")
|
||||
fobj.write(f"#define ENABLE_SPECIALIZATION {int(ENABLE_SPECIALIZATION)}")
|
||||
|
|
@ -203,4 +172,4 @@ def main(opcode_py,
|
|||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main(sys.argv[1], sys.argv[2], sys.argv[3], sys.argv[4], sys.argv[5])
|
||||
main(sys.argv[1], sys.argv[2], sys.argv[3], sys.argv[4])
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue