-
Notifications
You must be signed in to change notification settings - Fork 10.4k
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
Split off ArgumentShuffleExpr from TupleShuffleExpr #23458
Split off ArgumentShuffleExpr from TupleShuffleExpr #23458
Conversation
Right now we use TupleShuffleExpr for two completely different things: - Tuple conversions, where elements can be re-ordered and labels can be introduced/eliminated - Complex argument lists, involving default arguments or varargs The first case does not allow default arguments or varargs, and the second case does not allow re-ordering or introduction/elimination of labels. Furthermore, the first case has a representation limitation that prevents us from expressing tuple conversions that change the type of tuple elements. For all these reasons, it is better if we use two separate Expr kinds for these purposes. For now, just make an identical copy of TupleShuffleExpr and call it ArgumentShuffleExpr. In CSApply, use ArgumentShuffleExpr when forming the arguments to a call, and keep using TupleShuffleExpr for tuple conversions. Each usage of TupleShuffleExpr has been audited to see if it should instead look at ArgumentShuffleExpr. In sequent commits I plan on redesigning TupleShuffleExpr to correctly represent all tuple conversions without any unnecessary baggage. Longer term, we actually want to change the representation of CallExpr to directly store an argument list; then instead of a single child expression that must be a ParenExpr, TupleExpr or ArgumentShuffleExpr, all CallExprs will have a uniform representation and ArgumentShuffleExpr will go away altogether. This should reduce memory usage and radically simplify parts of SILGen.
Before extending TupleShuffleExpr to represent all tuple conversions allowed by the constraint solver, remove the parts of TupleShuffleExpr that are no longer needed; this is support for default arguments, varargs, and scalar-to-tuple and tuple-to-scalar conversions.
548613e
to
428c709
Compare
@swift-ci Please smoke test |
@swift-ci Please test source compatibility |
@xedin This may interest you as well. |
printRec(E->getSubExpr()); | ||
PrintWithColorRAII(OS, ParenthesisColor) << ')'; | ||
} | ||
void visitArgumentShuffleExpr(ArgumentShuffleExpr *E) { | ||
printCommon(E, "tuple_shuffle_expr"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did you mean to also update this to argument_shuffle_expr
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch. I grepped for TupleShuffleExpr but forgot to check other spellings. I'll fix this in a follow-up PR.
Right now we use TupleShuffleExpr for two completely different things:
introduced/eliminated
The first case does not allow default arguments or varargs, and the
second case does not allow re-ordering or introduction/elimination
of labels. Furthermore, the first case has a representation limitation
that prevents us from expressing tuple conversions that change the
type of tuple elements.
For all these reasons, it is better if we use two separate Expr kinds
for these purposes.
In sequent commits I plan on redesigning TupleShuffleExpr to correctly
represent all tuple conversions without any unnecessary baggage.
Longer term, we actually want to change the representation of CallExpr
to directly store an argument list; then instead of a single child
expression that must be a ParenExpr, TupleExpr or ArgumentShuffleExpr,
all CallExprs will have a uniform representation and ArgumentShuffleExpr
will go away altogether. This should reduce memory usage and radically
simplify parts of SILGen.
(Progress on rdar://12340004, https://bugs.swift.org/browse/SR-2672.)