Commit Graph

127 Commits

Author SHA1 Message Date
Chris Lattner
7cd0f1739a A big part of handling address-only types is making sure that various
emission routines use the SGFContext passed in.  To help with this and
to help the handshake, add a new "isInContext()" representation to 
ManagedValue.  This makes the code producing and consuming these more
explicit.  NFC.


Swift SVN r12783
2014-01-22 21:31:44 +00:00
Chris Lattner
90e1b572f0 split the ManagedValue class out to its own .h/.cpp files.
Swift SVN r12702
2014-01-22 05:42:34 +00:00
John McCall
817e80bde5 Implicit conversions for UncheckedOptional.
rdar://15189000
rdar://15189009

Swift SVN r12260
2014-01-13 23:15:03 +00:00
Chris Lattner
5c5c7829da Rework SILGen of address-only let declarations. Previously, we would just drop them
into heap boxes like var decls.  Now we drop them into stack temporaries like rvalues.

No semantic change goes with this.



Swift SVN r11939
2014-01-06 19:42:50 +00:00
Chris Lattner
1ca2722e83 introduce ManagedValue::forLValue(x) as a helper function for
making LValue ManagedValues, and switch SILGenLValue to use
this form of managed value consistently for lvalues, instead of
using unmanaged values in some cases.  NFC. 


Swift SVN r11878
2014-01-04 00:45:05 +00:00
Chris Lattner
be58684653 further detangle @inout and @lvalue types, making the code more specific
and simpler.


Swift SVN r11801
2014-01-01 21:35:31 +00:00
Chris Lattner
2aab668817 Change two places that can only see @inout types, not @lvalue types.
Swift SVN r11733
2013-12-30 06:57:13 +00:00
Chris Lattner
9ae289de46 Drive the semantic wedge harder into lvalues. Now, instead of having one LValueType
with qualifiers on it, we have two distinct types:
 - LValueType(T) aka @lvalue T, which is used for mutable values on the LHS of an
   assignment in the typechecker.
 - InOutType(T) aka @inout T, which is used for @inout arguments, and the implicit
   @inout self argument of mutable methods on value types.  This type is also used
   at the SIL level for address types.

While I detangled a number of cases that were checking for LValueType (without checking
qualifiers) and only meant @inout or @lvalue, there is more to be done here.  Notably,
getRValueType() still strips @inout, which is totally and unbearably wrong.



Swift SVN r11727
2013-12-29 22:23:11 +00:00
Chris Lattner
5faf530cf2 implement restructuring assignment of let decls, repurposing the existing
implosion logic.  This resolves rdar://15716277


Swift SVN r11679
2013-12-27 22:30:28 +00:00
Chris Lattner
90284eca72 reimplement cleanup processing for 'let' VarDecls. Previously, we would
emit the cleanup for the initializing expression when the expression was
complete, instead of at the end of the let decl scope (releasing things 
too early).

This fixes rdar://15689514, thanks to DaveA for the great testcase.


Swift SVN r11516
2013-12-20 18:50:03 +00:00
Chris Lattner
1788421e5d Change SILGen to lower and bind non-address-only 'let' variables
as values, without a box at all.  This generalizes some of the
previous hacks I had for silgen'ing 'self' as a value instead of
a box, and capturing them with CaptureKind::Constant.




Swift SVN r11360
2013-12-16 20:36:16 +00:00
Adrian Prantl
2acb71831e SILArgument: Make Decls mandatory for function arguments.
Swift SVN r11099
2013-12-10 23:30:23 +00:00
John McCall
20e58dcf93 Change the type of function values in SIL to SILFunctionType.
Perform major abstraction remappings in SILGen.  Introduce
thunking functions as necessary to map between abstraction
patterns.

Swift SVN r10562
2013-11-19 22:55:09 +00:00
John McCall
08171453da Make it a bit easier to propogate expressions around instead
of having to lower to an RValue.

This is valuable because we can often emit an expression to a
desired abstraction level more efficiently than just emitting
it to minimal abstraction and then generalizing.

Swift SVN r10455
2013-11-14 05:25:06 +00:00
Adrian Prantl
9ad9548388 Debug info: Update the inout testcase and emit debug information for
unboxed [inout] arguments.

Swift SVN r9187
2013-10-11 01:00:46 +00:00
Joe Groff
3d4c1251f1 Rename 'byref' attribute to 'inout'.
Swift SVN r8661
2013-09-25 20:56:52 +00:00
Joe Groff
7c3e1e1dd1 SILGen: Emit semantic-to-storage conversions in implicit struct ctors.
If a struct has [unowned] fields and an implicit elementwise constructor, then the constructor receives a strong reference argument corresponding to the unowned field, and we have to introduce that conversion as part of the construction.

Swift SVN r8207
2013-09-13 20:39:03 +00:00
Anna Zaks
32e14dc63b [SIL] Add another missing location (for BBArguments).
Swift SVN r8084
2013-09-10 22:52:41 +00:00
Anna Zaks
369a948248 [SIL] Minor auto-generated SILLocation API rename/refactor.
Swift SVN r8018
2013-09-06 23:57:27 +00:00
John McCall
b9dea7f458 Remove the emitSemantic* methods from TypeLowering and
move the corresponding functionality into SILGen.

I've switched around 'assign' so that it's no longer a
semantic assignment --- that is, so that it expects a properly
lowered value as its operand, not an r-value of the semantic
type.  This actually simplifies quite a lot of code and removes
some ugly special-casing from MemoryPromotion.

Swift SVN r7942
2013-09-05 06:44:50 +00:00
John McCall
215ffa5381 Make SILGenFunction methods for stores as well.
Swift SVN r7941
2013-09-05 06:44:48 +00:00
Anna Zaks
422ab63a38 [SIL] Add proper location when copying a ManagedValue.
Swift SVN r7925
2013-09-05 00:01:54 +00:00
Anna Zaks
115a15830b [SIL] Replace empty locations with valid locations in tuple exploding/encoding and pattern gen code.
Tuple exploding happens during RValue construction, so changed the constructor and addElement() method to take the location parameter. The imploding happens on RValue::forwardAsSingleValue and RValue::getAsSingleValue(). Make sure the right SIL locations are passed to all of these

Also, added some missing locations in pattern matching code.

Swift SVN r7916
2013-09-04 21:57:52 +00:00
Anna Zaks
2ea48d3d52 [SIL] Assign SIL location info for tuple initialization code.
Swift SVN r7915
2013-09-04 21:57:50 +00:00
Chris Lattner
803f5dc551 Rearrange the careful dance that is Initialization finalization.
We had a weird (and problematic for me) situation before where
tuple initializations would not recursively finalize their tuple
elements when they were finalized.  Making them do so runs afoul
of the poorly named Initialization::getSubInitializations(x,y,z)
method, which had nothing to do with the
Initialization::getSubInitializations() method.  Rename the former
to "getSubInitializationsForTuple" to make it more clear what is
going on, and make it handle the finalization of the SingleElement
initialization when it explodes it.

No functionality change, this unblocks some cases definite init was
tripping over.



Swift SVN r7600
2013-08-26 23:01:48 +00:00
John McCall
581cac8d83 Don't carry a type on an Initialization; just pass it down
where needed.

Removes a few more non-Sema uses of getTypeOfReference.

Swift SVN r7412
2013-08-21 18:44:59 +00:00
Stephen Lin
8d90466523 Reorganize SIL source tree: move lib/SIL/SILGen -> lib/SILGen, move lib/SIL/Passes -> lib/SILPasses, add lib/SILPasses/Utils
Swift SVN r7246
2013-08-14 23:47:29 +00:00