Skip to content
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

GH-111485: Separate out parsing, analysis and code-gen phases #112299

Merged
merged 42 commits into from
Dec 7, 2023

Conversation

markshannon
Copy link
Member

@markshannon markshannon commented Nov 21, 2023

@gvanrossum gvanrossum changed the title Seperate out parsing, analysis and code-gen phases Separate out parsing, analysis and code-gen phases Nov 21, 2023
Copy link
Member

@gvanrossum gvanrossum left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's more of a rewrite (or everything besides the parser and lexer) than a refactor. :-) It does feel cleaner, so I support forging ahead here.

General: I'd like it to use argparse, have correct type annotations everywhere, and be formatted using Black.

I'd like to understand why _PUSH_FRAME and the macros using it are now considered not to have an output stack effect (or one less, for the macros). Given that the generated output is unchanged for these, I am assuming that you're no longer checking that all the members of a family have the same stack effect?

One concern I have with creating separate top-level command-line utilities is that in my experience, the bulk of the processing time is in the parser -- which means that if you have five utilities to generate each of the five output files, you end up waiting five times as long for make regen-cases or its equivalent. This should be easy to address given your architecture. Please don't forget to update README.md.

I didn't try to understand your stack.py carefully, but it deserves a lot of scrutiny. In the past fixes there usually were obvious when the generated code was different -- but you've moved things around in the output just enough (even taking the case-sorting out of the equation) that it's hard to review everything without glazing over.

Tools/cases_generator/tier1_generator.py Outdated Show resolved Hide resolved
Tools/cases_generator/tier1_generator.py Outdated Show resolved Hide resolved
Tools/cases_generator/cwriter.py Outdated Show resolved Hide resolved
Tools/cases_generator/tier1_generator.py Outdated Show resolved Hide resolved
Tools/cases_generator/lexer.py Outdated Show resolved Hide resolved
Tools/cases_generator/cwriter.py Outdated Show resolved Hide resolved
Tools/cases_generator/cwriter.py Outdated Show resolved Hide resolved
Tools/cases_generator/cwriter.py Outdated Show resolved Hide resolved
Tools/cases_generator/analyzer.py Show resolved Hide resolved
Tools/cases_generator/analyzer.py Show resolved Hide resolved
@markshannon markshannon changed the title Separate out parsing, analysis and code-gen phases GH-111485: Separate out parsing, analysis and code-gen phases Nov 22, 2023
@markshannon markshannon marked this pull request as ready for review December 1, 2023 11:32
Tools/cases_generator/analyzer.py Show resolved Hide resolved
Tools/cases_generator/parser.py Outdated Show resolved Hide resolved
Tools/cases_generator/analyzer.py Show resolved Hide resolved
Tools/cases_generator/analyzer.py Show resolved Hide resolved
Tools/cases_generator/analyzer.py Outdated Show resolved Hide resolved
Tools/cases_generator/analyzer.py Outdated Show resolved Hide resolved
Tools/cases_generator/analyzer.py Outdated Show resolved Hide resolved
return self._size


Part = Uop | Skip
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Skip is "unused cache entry", but here it's used as a uop?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Where is Part used as a Uop?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

uops: list[Part] in line 133

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is a list of parts, and used as such. I'll change the name.

Tools/cases_generator/stack.py Show resolved Hide resolved
Copy link
Member

@AlexWaygood AlexWaygood left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some optional suggestions:

Comment on lines +14 to +15
allow_redefinition = True
implicit_reexport = True
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggestion: move these lines of the config file above the # ...And be strict: comment on line 9, since they don't relate to increasing the strictness of mypy

from typing import Optional


@dataclass
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would be tempted to do this, for readability. I agree with Guido's opinion that it's hard to read when instances of this class are constructed using positional arguments

Suggested change
@dataclass
@dataclass(kw_only=True)

Tools/cases_generator/analyzer.py Outdated Show resolved Hide resolved
Tools/cases_generator/tier1_generator.py Show resolved Hide resolved
@markshannon markshannon merged commit b449415 into python:main Dec 7, 2023
35 checks passed
aisk pushed a commit to aisk/cpython that referenced this pull request Feb 11, 2024
@markshannon markshannon deleted the refactor-code-gen branch August 6, 2024 10:18
Glyphack pushed a commit to Glyphack/cpython that referenced this pull request Sep 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants