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

[draft] Register machine - Add tmps in frame and compiler. Add RETURN_VALUE_R. #101208

Closed
wants to merge 5 commits into from

Conversation

iritkatriel
Copy link
Member

@iritkatriel iritkatriel commented Jan 21, 2023

  • add tmps to the frame, between the fast locals and the stack.
  • add plumbing in the compiler for a 1-arg reg machine, with RETURN_VALUE_R that uses a tmp register.

#define SAME_REGISTER(R1, R2) (((R1).type == (R2).type) && ((R1).value == (R2).value))

typedef struct instr_opargs_ {
oparg_t arg1;
Copy link
Member Author

Choose a reason for hiding this comment

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

Once we have variable-length instructions, arg2, arg3 should be added here. Then search this file for arg1 and update all those places to work with the other args as well.

@@ -144,7 +144,8 @@ GETITEM(PyObject *v, Py_ssize_t i) {
#define NEXTOPARG() do { \
_Py_CODEUNIT word = *next_instr; \
opcode = _Py_OPCODE(word); \
oparg1 = oparg = _Py_OPARG(word); \
oparg = _Py_OPARG(word); \
oparg1 = oparg; \
Copy link
Member

Choose a reason for hiding this comment

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

I'm not excited about having two variables. In my own 'long-insts' branch I just count oparg, oparg2, oparg3, ...

Copy link
Member Author

Choose a reason for hiding this comment

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

I think the generator currently emits REG(oparg1). We could change that.

Copy link
Member Author

Choose a reason for hiding this comment

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

Or we could "#define oparg1 oparg".

Copy link
Member

Choose a reason for hiding this comment

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

I prefer modifying the generator over the macro. REG(oparg1) only occurs once in the generator, explicitly, so it's very easy to change (in fact in ly 'long-instrs' I already changed it.)

Copy link
Member

Choose a reason for hiding this comment

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

You can even cherry-pick 8d06d1b from that branch.

@iritkatriel iritkatriel deleted the add_tmps branch April 3, 2023 17:47
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.

3 participants