@@ -3540,43 +3540,57 @@ load_borrow
3540
3540
%1 = load_borrow %0 : $*T
3541
3541
// $T must be a loadable type
3542
3542
3543
- Loads the value ``%1 `` from the memory location ``%0 ``. The `` load_borrow ``
3543
+ Loads the value ``%1 `` from the memory location ``%0 ``. The `load_borrow `_
3544
3544
instruction creates a borrowed scope in which a read-only borrow value ``%1 ``
3545
3545
can be used to read the value stored in ``%0 ``. The end of scope is delimited
3546
- by an `` end_borrow `` instruction. All `` load_borrow `` instructions must be
3547
- paired with exactly one `` end_borrow `` instruction along any path through the
3548
- program. Until `` end_borrow `` , it is illegal to invalidate or store to ``%0 ``.
3546
+ by an `end_borrow `_ instruction. All `load_borrow `_ instructions must be
3547
+ paired with exactly one `end_borrow `_ instruction along any path through the
3548
+ program. Until `end_borrow `_ , it is illegal to invalidate or store to ``%0 ``.
3549
3549
3550
3550
begin_borrow
3551
3551
````````````
3552
3552
3553
- TODO
3553
+ ::
3554
+
3555
+ sil-instruction ::= 'begin_borrow' sil-operand
3556
+
3557
+ %1 = begin_borrow %0 : $T
3558
+
3559
+ Given a value ``%0 `` with `Owned `_ or `Guaranteed `_ ownership, produces a new
3560
+ same typed value with `Guaranteed `_ ownership: ``%1 ``. ``%1 `` is guaranteed to
3561
+ have a lifetime ending use (e.x.: `end_borrow `_) along all paths that do not end
3562
+ in `Dead End Blocks `_. This `begin_borrow `_ and the lifetime ending uses of
3563
+ ``%1 `` are considered to be liveness requiring uses of ``%0 `` and as such in the
3564
+ region in between this borrow and its lifetime ending use, ``%0 `` must be
3565
+ live. This makes sense semantically since ``%1 `` is modeling a new value with a
3566
+ dependent lifetime on ``%0 ``.
3567
+
3568
+ This instruction is only valid in functions in Ownership SSA form.
3554
3569
3555
3570
end_borrow
3556
3571
``````````
3557
3572
3558
3573
::
3559
3574
3560
- sil-instruction ::= 'end_borrow' sil-value 'from' sil-value : sil-type, sil-type
3575
+ sil-instruction ::= 'end_borrow' sil-operand
3561
3576
3562
- end_borrow %1 from %0 : $T, $T
3563
- end_borrow %1 from %0 : $T, $*T
3564
- end_borrow %1 from %0 : $*T, $T
3565
- end_borrow %1 from %0 : $*T, $*T
3566
- // We allow for end_borrow to be specified in between values and addresses
3567
- // all of the same type T.
3577
+ // somewhere earlier
3578
+ // %1 = begin_borrow %0
3579
+ end_borrow %1 : $T
3568
3580
3569
- Ends the scope for which the SILValue ``%1 `` is borrowed from the SILValue
3570
- ``%0 ``. Must be paired with at most 1 borrowing instruction (like
3571
- `` load_borrow `` ) along any path through the program. In the region in between
3572
- the borrow instruction and the `` end_borrow ``, the original SILValue can not be
3573
- modified. This means that:
3581
+ Ends the scope for which the ` Guaranteed `_ ownership possessing SILValue ``%1 ``
3582
+ is borrowed from the SILValue ``%0 ``. Must be paired with at most 1 borrowing
3583
+ instruction (like ` load_borrow `_, ` begin_borrow `_ ) along any path through the
3584
+ program. In the region in between the borrow instruction and the `end_borrow `_,
3585
+ the original SILValue can not be modified. This means that:
3574
3586
3575
3587
1. If ``%0 `` is an address, ``%0 `` can not be written to.
3576
3588
2. If ``%0 `` is a non-trivial value, ``%0 `` can not be destroyed.
3577
3589
3578
3590
We require that ``%1 `` and ``%0 `` have the same type ignoring SILValueCategory.
3579
3591
3592
+ This instruction is only valid in functions in Ownership SSA form.
3593
+
3580
3594
assign
3581
3595
``````
3582
3596
::
@@ -3592,12 +3606,12 @@ The type of %1 is ``*T`` and the type of ``%0`` is ``T``, which must be a
3592
3606
loadable type. This will overwrite the memory at ``%1 `` and destroy the value
3593
3607
currently held there.
3594
3608
3595
- The purpose of the `` assign `` instruction is to simplify the
3609
+ The purpose of the `assign `_ instruction is to simplify the
3596
3610
definitive initialization analysis on loadable variables by removing
3597
3611
what would otherwise appear to be a load and use of the current value.
3598
3612
It is produced by SILGen, which cannot know which assignments are
3599
3613
meant to be initializations. If it is deemed to be an initialization,
3600
- it can be replaced with a `` store `` ; otherwise, it must be replaced
3614
+ it can be replaced with a `store `_ ; otherwise, it must be replaced
3601
3615
with a sequence that also correctly destroys the current value.
3602
3616
3603
3617
This instruction is only valid in Raw SIL and is rewritten as appropriate
@@ -3615,7 +3629,7 @@ assign_by_wrapper
3615
3629
// $F must be a function type, taking $S as a single argument (or multiple arguments in case of a tuple) and returning $T
3616
3630
// $G must be a function type, taking $S as a single argument (or multiple arguments in case of a tuple) and without a return value
3617
3631
3618
- Similar to the `` assign `` instruction, but the assignment is done via a
3632
+ Similar to the `assign `_ instruction, but the assignment is done via a
3619
3633
delegate.
3620
3634
3621
3635
In case of an initialization, the function ``%2 `` is called with ``%0 `` as
0 commit comments