Skip to content

[mypyc] Support var arg in CallC, replace new_dict_op #8948

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

Merged
merged 12 commits into from
Jun 9, 2020
Merged

[mypyc] Support var arg in CallC, replace new_dict_op #8948

merged 12 commits into from
Jun 9, 2020

Conversation

TH3CHARLie
Copy link
Collaborator

@TH3CHARLie TH3CHARLie commented Jun 4, 2020

related mypyc/mypyc#709 mypyc/mypyc#734

Summary:

  • introduce variable arguments in CallC
  • replace old new_dict_op(which relies on a specialized emit callback) with two CallC ops: dict_new_op and dict_build_op, which handles create an empty dict and a dict from k-v pairs.
  • fix related IR tests, especially separate the testDel case into three subcases which test list, dict and attributes respectively.

@TH3CHARLie
Copy link
Collaborator Author

TH3CHARLie commented Jun 4, 2020

The current codegen for CallC

def visit_call_c(self, op: CallC) -> None:
dest = self.get_dest_assign(op)
args = ', '.join(self.reg(arg) for arg in op.args)
self.emitter.emit_line("{}{}({});".format(dest, op.function_name, args))

Seeing this, I start to think, does the newly introduced var_arg_idx really necessary? Since we join the args anyway(and there's no difference for fixed/var args), if we handle all the semantics properly before make a CallC(mainly via xxx.call_c), then maybe the var_arg_idx is unnecessary.

Updates: so far in the C code generation scheme, it is indeed unnecessary, but we'd keep it for further backends.

@TH3CHARLie TH3CHARLie marked this pull request as draft June 5, 2020 04:31
@TH3CHARLie TH3CHARLie marked this pull request as ready for review June 5, 2020 23:26
@TH3CHARLie TH3CHARLie changed the title [WIP][mypyc]Support var arg in CallC, transfrom new_dict_op [mypyc] Support var arg in CallC, transfrom new_dict_op Jun 5, 2020
@TH3CHARLie TH3CHARLie changed the title [mypyc] Support var arg in CallC, transfrom new_dict_op [mypyc] Support var arg in CallC, replace new_dict_op Jun 5, 2020
Copy link
Collaborator

@JukkaL JukkaL left a comment

Choose a reason for hiding this comment

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

Looks great! Left a bunch of minor comments, mostly suggestions about additional comments/docstrings.

This a compelling use case for the new IR. Getting rid of callbacks used for primitives makes things a lot cleaner.

@TH3CHARLie TH3CHARLie requested a review from JukkaL June 8, 2020 12:45
Copy link
Collaborator

@JukkaL JukkaL left a comment

Choose a reason for hiding this comment

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

Thanks for the updates!

@JukkaL JukkaL merged commit 793cf18 into python:master Jun 9, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy