Commit Graph

218 Commits

Author SHA1 Message Date
Joe Shajrawi
1e521c453b Add support for Init Existentials for opaque value types 2017-02-20 16:40:02 -08:00
Michael Gottesman
26a266b15e [silgen] Cleanup emitPreconditionOptionalHasValue and its uses so that they use proper ownership.
The big change here is that this routine will not emit switch_enum as a +1 value
and create a proper owned argument with cleanup.

rdar://29791263
2017-02-19 22:19:47 -08:00
Michael Gottesman
be50b2a624 [silgen] Add new ownership APIs for enum extraction to SILGenBuilder.
rdar://29791263
2017-02-19 20:43:43 -08:00
Michael Gottesman
dd5120e9f0 [silgen] Create a closure API called bufferForExprResult based on getBufferForExpr/manageBufferForExpr but managing the ownership for the user.
There are many cases where getBufferForExpr and manageBufferForExpr occur right
next to each other. The closure based API expresses this pattern in a more
convenient manner where the user can express his/her intent with one action
instead of two. In these cases, the split is messy and not necessary.
2017-02-19 11:15:01 -08:00
Michael Gottesman
825765a047 [silgen] Change createFormalAccessCopyAddr to take take/init parameters.
Previously, I just refactored one use of this API resulting in these two
parameters being hard coded. In truth these should never be hard coded.
2017-02-19 10:56:23 -08:00
Michael Gottesman
5717eeba67 [silgen] Create a ManagedValue::formalAccessCopy(SILGenFunction &, SILLocation).
This is the same as the current ManagedValue::copy(...) convenience API except
that the cleanups are formal evaluation scoped.

rdar://29791263
2017-02-19 08:03:33 -08:00
Michael Gottesman
0ae6c25238 [silgen] Make SILGenBuilder::createCopyValue a drop in replacement for SILGenFunction::emitManagedRetain.
The only difference is that the copy value API takes a ManagedValue. Hopefully
once we eliminate direct manipulation of SILValue in SILGen, we can get rid of
the emitManagedRetain API in SILGen.

rdar://29791263
2017-02-19 07:58:03 -08:00
Michael Gottesman
d051583378 [semantic-sil] When emitting a base for an accessor use a load_borrow when appropriate.
This builds on 92bf345. I am very pleased that a couple of the cases I needed to
update, a retain/release was eliminated on the base.

rdar://29791263
2017-02-18 00:55:36 -08:00
Michael Gottesman
64ad05bfed [gardening] Standardize variable capitalization in SILGenBuilder to match the rest of SILGen. NFC. 2017-02-17 19:47:43 -08:00
Michael Gottesman
5f226ffc59 [silgen] Perform borrow + tuple_extract + copy for SILGenPoly.
Another case of needing a destructure operation.

rdar://29791263
2017-02-08 16:20:02 -08:00
Michael Gottesman
d153f36e48 [silgen] Handle forwarding of direct tuple args using a borrow + extract + copy triple
Once we have a destructure operation this will not be necessary.

rdar://29791263
2017-02-08 16:00:23 -08:00
swift-ci
bfa3cece06 Merge pull request #7310 from gottesmm/alloc_tail_fix 2017-02-07 15:34:56 -08:00
Michael Gottesman
03b8375d83 [silgen] When emitting BuiltinAllocWithTailElems, be sure to create a cleanup.
This is actually a NFC change since we forward the cleanup in most cases and the
forwarding behavior is tested already by SILGen. But what this /does/ do is
prevent us from creating a ManagedValue that is "owned" but does not have a
cleanup.

rdar://29791263
2017-02-07 12:25:58 -08:00
Slava Pestov
3519e0cd25 AST: Introduce new SubstitutionList type to replace ArrayRef<Substitution>
SubstitutionList is going to be a more compact representation of
a SubstitutionMap, suitable for inline allocation inside another
object.

For now, it's just a typedef for ArrayRef<Substitution>.
2017-02-06 21:36:33 -08:00
Michael Gottesman
9bcbe8c299 [silgen] Add a new API called SILGenBuilder::createOwnedPHIArgument.
This new API creates a new PHI argument in the current insertion block of the
SILBuilder with @owned ownership, creates a new ManagedValue with cleanup and
returns that ManagedValue. This eliminates one case where often times in SILGen
people use SILBuilder APIs on SILGenBuilder and then manage their own ownership
instead of gliding lightly on top of pure ManagedValue APIs.

rdar://29791263
2017-02-04 13:40:26 -08:00
Michael Gottesman
77c1dfcb3a [semantic-sil] Use borrow semantics when emitting a struct_extract sequence.
rdar://29791263
2017-01-26 16:46:42 -08:00
Michael Gottesman
0331400f60 [silgen] Store the relevant SILGenFunction instead of the SILGenModule in SILGenBuilder
We already always associate a SILGenBuilder with one function, just like
SILBuilder, so there really is no reason not to store the SILGenFunction. The
reason why I want to do so here though is that I want access to the ManagedValue
APIs on SILGenFunction so I can begin to add Ownership endowed entry points on
SILBuilder that traffic only in ManagedValue instead of SILValue.

rdar://29791263
2017-01-19 13:40:55 -08:00
Michael Gottesman
1dbabed576 [silgen] Extract SILGenBuilder into its own header/cpp file.
NFC.
2017-01-18 16:46:14 -08:00