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

Bytecode interpreter generator should support composing instructions from parts. #101369

Closed
markshannon opened this issue Jan 27, 2023 · 3 comments · Fixed by #101399
Closed

Bytecode interpreter generator should support composing instructions from parts. #101369

markshannon opened this issue Jan 27, 2023 · 3 comments · Fixed by #101399
Assignees
Labels
type-feature A feature request or enhancement

Comments

@markshannon
Copy link
Member

markshannon commented Jan 27, 2023

I.e. this should work as expected.

inst(BINARY_OP_ADD_FLOAT) = _BINARY_OP_ADD_FLOAT_CHECK + _BINARY_OP_ADD_FLOAT_ACTION;

The suggested solution of using macro doesn't work.
I get the error:

./Python/bytecodes.c:171: Unknown instruction 'BINARY_OP_ADD_FLOAT' referenced in family 'binary_op'
./Python/bytecodes.c:171: Family 'binary_op' has unknown members: {'BINARY_OP_ADD_FLOAT'}

Linked PRs

@gvanrossum
Copy link
Member

gvanrossum commented Jan 28, 2023

Looks like I left some technical debt in macro handling. :-(

  • check_families() needs to look for family members in macros
  • map_families() needs store family back-links in macro parts
  • Those two need to run after super and macro analysis
  • macro prelude generation needs to avoid emitting duplicate declarations when input and output variable names overlap (this was a dumb oversight)
  • add tests

@markshannon
Copy link
Member Author

I would "macro" to go. Instructions defined by composing ops are instructions just as much as those defined by a blob of C code.
inst(FOO_AND_BAR) = FOO + BAR;
Could you add

  • Rename macro as inst, as they are instructions.

to the end of your list?

@gvanrossum
Copy link
Member

We’ve talked about that before, it would get a red squiggle in VS Code. Other than that it’s doable. @brandtbucher ?

gvanrossum added a commit that referenced this issue Jan 30, 2023
Also check for instructions straddling families (this includes macro parts).
mdboom pushed a commit to mdboom/cpython that referenced this issue Jan 31, 2023
Also check for instructions straddling families (this includes macro parts).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type-feature A feature request or enhancement
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants