mirror of
https://github.com/python/cpython.git
synced 2025-08-31 05:58:33 +00:00
GH-111485: Factor out tier 2 code generation from the rest of the interpreter code generator (GH-112968)
This commit is contained in:
parent
c454e934d3
commit
0c55f27060
14 changed files with 1391 additions and 974 deletions
|
@ -24,8 +24,11 @@ from typing import TextIO
|
|||
DEFAULT_OUTPUT = ROOT / "Include/internal/pycore_uop_ids.h"
|
||||
|
||||
|
||||
OMIT = {"_CACHE", "_RESERVED", "_EXTENDED_ARG"}
|
||||
|
||||
|
||||
def generate_uop_ids(
|
||||
filenames: str, analysis: Analysis, outfile: TextIO, distinct_namespace: bool
|
||||
filenames: list[str], analysis: Analysis, outfile: TextIO, distinct_namespace: bool
|
||||
) -> None:
|
||||
write_header(__file__, filenames, outfile)
|
||||
out = CWriter(outfile, 0, False)
|
||||
|
@ -45,11 +48,15 @@ extern "C" {
|
|||
next_id += 1
|
||||
out.emit(f"#define _SET_IP {next_id}\n")
|
||||
next_id += 1
|
||||
PRE_DEFINED = {"_EXIT_TRACE", "_SET_IP", "_CACHE", "_RESERVED", "_EXTENDED_ARG"}
|
||||
PRE_DEFINED = {"_EXIT_TRACE", "_SET_IP"}
|
||||
|
||||
for uop in analysis.uops.values():
|
||||
if uop.name in PRE_DEFINED:
|
||||
continue
|
||||
# TODO: We should omit all tier-1 only uops, but
|
||||
# generate_cases.py still generates code for those.
|
||||
if uop.name in OMIT:
|
||||
continue
|
||||
if uop.implicitly_created and not distinct_namespace:
|
||||
out.emit(f"#define {uop.name} {uop.name[1:]}\n")
|
||||
else:
|
||||
|
@ -85,7 +92,7 @@ arg_parser.add_argument(
|
|||
if __name__ == "__main__":
|
||||
args = arg_parser.parse_args()
|
||||
if len(args.input) == 0:
|
||||
args.input.append(DEFAULT_INPUT.as_posix())
|
||||
args.input.append(DEFAULT_INPUT)
|
||||
data = analyze_files(args.input)
|
||||
with open(args.output, "w") as outfile:
|
||||
generate_uop_ids(args.input, data, outfile, args.namespace)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue