@@ -4363,11 +4363,22 @@ bind_memory
4363
4363
Binds memory at ``Builtin.RawPointer `` value ``%0 `` to type ``$T `` with enough
4364
4364
capacity to hold ``%1 `` values. See SE-0107: UnsafeRawPointer.
4365
4365
4366
- Produces a opaque token representing the previous memory state. For
4367
- memory binding semantics, this state includes the type that the memory
4368
- was previously bound to. The token cannot, however, be used to
4369
- retrieve a metatype. It's value is only meaningful to the Swift
4370
- runtime for typed pointer verification.
4366
+ Produces a opaque token representing the previous memory state for
4367
+ memory binding semantics. This abstract state includes the type that
4368
+ the memory was previously bound to along with the size of the affected
4369
+ memory region, which can be derived from ``%1 ``. The token cannot, for
4370
+ example, be used to retrieve a metatype. It only serves a purpose when
4371
+ used by ``rebind_memory ``, which has no static type information. The
4372
+ token dynamically passes type information from the first bind_memory
4373
+ into a chain of rebind_memory operations.
4374
+
4375
+ Example::
4376
+
4377
+ %_ = bind_memory %0 : $Builtin.RawPointer, %numT : $Builtin.Word to $T // holds type 'T'
4378
+ %token0 = bind_memory %0 : $Builtin.RawPointer, %numU : $Builtin.Word to $U // holds type 'U'
4379
+ %token1 = rebind_memory %0 : $Builtin.RawPointer, %token0 : $Builtin.Word // holds type 'T'
4380
+ %token2 = rebind_memory %0 : $Builtin.RawPointer, %token1 : $Builtin.Word // holds type 'U'
4381
+
4371
4382
4372
4383
rebind_memory
4373
4384
`````````````
@@ -4386,8 +4397,8 @@ This instruction's semantics are identical to ``bind_memory``, except
4386
4397
that the types to which memory will be bound, and the extent of the
4387
4398
memory region is unknown at compile time. Instead, the bound-types are
4388
4399
represented by a token that was produced by a prior memory binding
4389
- operation. ``%in_token `` must be the result of bind_memory or
4390
- rebind_memory.
4400
+ operation. ``%in_token `` must be the result of `` bind_memory `` or
4401
+ `` rebind_memory `` .
4391
4402
4392
4403
begin_access
4393
4404
````````````
0 commit comments