Commit Graph

15 Commits

Author SHA1 Message Date
Dmitri Gribenko
8c3fbc51a4 stdlib: rename Optional and IUO intrinsics 2016-02-22 18:16:37 -08:00
John McCall
e249fd680e Destructure result types in SIL function types.
Similarly to how we've always handled parameter types, we
now recursively expand tuples in result types and separately
determine a result convention for each result.

The most important code-generation change here is that
indirect results are now returned separately from each
other and from any direct results.  It is generally far
better, when receiving an indirect result, to receive it
as an independent result; the caller is much more likely
to be able to directly receive the result in the address
they want to initialize, rather than having to receive it
in temporary memory and then copy parts of it into the
target.

The most important conceptual change here that clients and
producers of SIL must be aware of is the new distinction
between a SILFunctionType's *parameters* and its *argument
list*.  The former is just the formal parameters, derived
purely from the parameter types of the original function;
indirect results are no longer in this list.  The latter
includes the indirect result arguments; as always, all
the indirect results strictly precede the parameters.
Apply instructions and entry block arguments follow the
argument list, not the parameter list.

A relatively minor change is that there can now be multiple
direct results, each with its own result convention.
This is a minor change because I've chosen to leave
return instructions as taking a single operand and
apply instructions as producing a single result; when
the type describes multiple results, they are implicitly
bound up in a tuple.  It might make sense to split these
up and allow e.g. return instructions to take a list
of operands; however, it's not clear what to do on the
caller side, and this would be a major change that can
be separated out from this already over-large patch.

Unsurprisingly, the most invasive changes here are in
SILGen; this requires substantial reworking of both call
emission and reabstraction.  It also proved important
to switch several SILGen operations over to work with
RValue instead of ManagedValue, since otherwise they
would be forced to spuriously "implode" buffers.
2016-02-18 01:26:28 -08:00
Erik Eckstein
506ab9809f SIL: remove getTyp() from SILValue 2016-01-25 15:00:49 -08:00
Slava Pestov
9aba84417a Re-apply "SILGen: Move even more abstraction patterns over to interface types, NFC"
Now with a fix for a crash with rvalue references to local functions
that had generic types in their signature.

This reverts commit 31b97bcc15.
2016-01-22 11:35:02 -08:00
Mark Lacey
31b97bcc15 Revert "SILGen: Move even more abstraction patterns over to interface types, NFC"
This reverts commit 0188258a87 because we
now assert when compiling a performance test.
2016-01-21 21:52:48 -08:00
Slava Pestov
0188258a87 SILGen: Move even more abstraction patterns over to interface types, NFC
This eliminates several usages of constantInfo.{FormalType,LoweredType}
and PolymorphicFunctionType.
2016-01-21 18:47:11 -08:00
Erik Eckstein
b7ea3b9bb2 [SIL] Let alloc_existential_box return a single value.
And use the new project_existential_box to get to the address value.
SILGen now generates a project_existential_box for each alloc_existential_box.
And IRGen re-uses the address value from the alloc_existential_box if the operand of project_existential_box is an alloc_existential_box.
This lets the generated code be the same as before.
2016-01-20 11:27:06 -08:00
Slava Pestov
086cfc284b SILGen: Small cleanups, NFC 2016-01-18 20:34:30 -08:00
John McCall
5112864dad Remove the archetype from Substitution.
This eliminates some minor overheads, but mostly it eliminates
a lot of conceptual complexity due to the overhead basically
appearing outside of its context.
2016-01-08 15:27:13 -08:00
John McCall
2df6880617 Introduce ProtocolConformanceRef. NFC.
The main idea here is that we really, really want to be
able to recover the protocol requirement of a conformance
reference even if it's abstract due to the conforming type
being abstract (e.g. an archetype).  I've made the conversion
from ProtocolConformance* explicit to discourage casual
contamination of the Ref with a null value.

As part of this change, always make conformance arrays in
Substitutions fully parallel to the requirements, as opposed
to occasionally being empty when the conformances are abstract.

As another part of this, I've tried to proactively fix
prospective bugs with partially-concrete conformances, which I
believe can happen with concretely-bound archetypes.

In addition to just giving us stronger invariants, this is
progress towards the removal of the archetype from Substitution.
2016-01-08 00:19:59 -08:00
Zach Panzarino
e3a4147ac9 Update copyright date 2015-12-31 23:28:40 +00:00
Slava Pestov
9025cf881d SILGen: Add comments describing call decomposition in more detail, NFC 2015-12-05 01:37:55 -08:00
Slava Pestov
1b55becf76 SILGen: Fix issues with one-element tuples in thunks
Take apart exploded one-element tuples and be more careful with
passing around tuple abstraction patterns.

Also, now we can  remove the inputSubstType parameter from
emitOrigToSubstValue() and emitSubstToOrigValue(), making the
signatures of these functions nice and simple once again.

Fixes <rdar://problem/19506347> and <rdar://problem/22502450>.
2015-11-06 13:51:15 -08:00
Chris Lattner
f148776c40 fix a warning about newline at end of file
Swift SVN r31580
2015-08-30 05:34:51 +00:00
Slava Pestov
0af82e6345 SILGen: Move optional and existential conversions to SILGenConvert.cpp, NFC
This is a better place for code shared between expression emission
and thunks.

Swift SVN r31544
2015-08-27 21:53:49 +00:00