@@ -868,7 +868,9 @@ class LLVM_LIBRARY_VISIBILITY SILGenFunction
868
868
// / \param subs - Used to get subscript function type and to substitute generic args.
869
869
// / \param argList - The argument list of the subscript.
870
870
SmallVector<ManagedValue, 4 >
871
- emitKeyPathSubscriptOperands (SubscriptDecl *subscript, SubstitutionMap subs,
871
+ emitKeyPathSubscriptOperands (SILLocation loc,
872
+ SubscriptDecl *subscript,
873
+ SubstitutionMap subs,
872
874
ArgumentList *argList);
873
875
874
876
// / Convert a block to a native function with a thunk.
@@ -1139,6 +1141,11 @@ class LLVM_LIBRARY_VISIBILITY SILGenFunction
1139
1141
bool hasDynamicLifetime = false ,
1140
1142
bool isLexical = false );
1141
1143
1144
+ // / Emits a temporary allocation for a pack that will be deallocated
1145
+ // / automatically at the end of the current scope. Returns the address
1146
+ // / of the allocation.
1147
+ SILValue emitTemporaryPackAllocation (SILLocation loc, SILType packTy);
1148
+
1142
1149
// / Prepares a buffer to receive the result of an expression, either using the
1143
1150
// / 'emit into' initialization buffer if available, or allocating a temporary
1144
1151
// / allocation if not.
@@ -1537,7 +1544,8 @@ class LLVM_LIBRARY_VISIBILITY SILGenFunction
1537
1544
SubstitutionMap subs,
1538
1545
bool alreadyConverted);
1539
1546
1540
- PreparedArguments prepareSubscriptIndices (SubscriptDecl *subscript,
1547
+ PreparedArguments prepareSubscriptIndices (SILLocation loc,
1548
+ SubscriptDecl *subscript,
1541
1549
SubstitutionMap subs,
1542
1550
AccessStrategy strategy,
1543
1551
ArgumentList *argList);
@@ -2346,10 +2354,24 @@ class LLVM_LIBRARY_VISIBILITY SILGenFunction
2346
2354
2347
2355
// / Enter a cleanup to deallocate a stack variable.
2348
2356
CleanupHandle enterDeallocStackCleanup (SILValue address);
2357
+
2358
+ // / Enter a cleanup to deallocate a pack.
2359
+ CleanupHandle enterDeallocPackCleanup (SILValue address);
2349
2360
2350
2361
// / Enter a cleanup to emit a ReleaseValue/DestroyAddr of the specified value.
2351
2362
CleanupHandle enterDestroyCleanup (SILValue valueOrAddr);
2352
2363
2364
+ // / Enter a cleanup to destroy all of the values in the given pack.
2365
+ CleanupHandle enterDestroyPackCleanup (SILValue addr,
2366
+ CanPackType formalPackType);
2367
+
2368
+ // / Enter a cleanup to destroy the preceding values in a pack-expansion
2369
+ // / component of a pack.
2370
+ CleanupHandle enterPartialDestroyPackCleanup (SILValue addr,
2371
+ CanPackType formalPackType,
2372
+ unsigned componentIndex,
2373
+ SILValue limitWithinComponent);
2374
+
2353
2375
// / Return an owned managed value for \p value that is cleaned up using an end_lifetime instruction.
2354
2376
// /
2355
2377
// / The end_lifetime cleanup is not placed into the ManagedValue itself and
@@ -2452,6 +2474,65 @@ class LLVM_LIBRARY_VISIBILITY SILGenFunction
2452
2474
SILDeclRef getAccessorDeclRef (AccessorDecl *accessor) {
2453
2475
return SGM.getAccessorDeclRef (accessor, F.getResilienceExpansion ());
2454
2476
}
2477
+
2478
+ // / Emit a dynamic loop over a single pack-expansion component of a pack.
2479
+ // /
2480
+ // / \param formalPackType - a pack type with the right shape for the
2481
+ // / overall pack being iterated over
2482
+ // / \param componentIndex - the index of the pack expansion component
2483
+ // / within the formal pack type
2484
+ // / \param limitWithinComponent - the number of elements in a prefix of
2485
+ // / the expansion component to dynamically visit; if null, all elements
2486
+ // / will be visited
2487
+ // / \param openedElementEnv - a set of opened element archetypes to bind
2488
+ // / within the loop; can be null to bind no elements
2489
+ // / \param reverse - if true, iterate the elements in reverse order,
2490
+ // / starting at index limitWithinComponent - 1
2491
+ // / \param emitBody - a function that will be called to emit the body of
2492
+ // / the loop. It's okay if this has paths that exit the body of the loop,
2493
+ // / but it should leave the insertion point set at the end. Will be
2494
+ // / called within a cleanups scope. The first parameter is the current
2495
+ // / index within the expansion component, a value of type Builtin.Word.
2496
+ // / The second parameter is that index as a pack indexing instruction
2497
+ // / that indexes into packs with the shape of the pack expasion.
2498
+ // / The third parameter is the current pack index within the overall
2499
+ // / pack, a pack indexing instruction that indexes into packs with the
2500
+ // / shape of formalPackType.
2501
+ void emitDynamicPackLoop (SILLocation loc,
2502
+ CanPackType formalPackType,
2503
+ unsigned componentIndex,
2504
+ SILValue limitWithinComponent,
2505
+ GenericEnvironment *openedElementEnv,
2506
+ bool reverse,
2507
+ llvm::function_ref<void (SILValue indexWithinComponent,
2508
+ SILValue packExpansionIndex,
2509
+ SILValue packIndex)> emitBody);
2510
+
2511
+ // / Emit a loop which destroys a prefix of a pack expansion component
2512
+ // / of a pack value.
2513
+ // /
2514
+ // / \param packAddr - the address of the overall pack value
2515
+ // / \param formalPackType - a pack type with the same shape as the
2516
+ // / overall pack value
2517
+ // / \param componentIndex - the index of the pack expansion component
2518
+ // / within the formal pack type
2519
+ // / \param limitWithinComponent - the number of elements in a prefix of
2520
+ // / the expansion component to destroy; if null, all elements in the
2521
+ // / component will be destroyed
2522
+ void emitPartialDestroyPack (SILLocation loc,
2523
+ SILValue packAddr,
2524
+ CanPackType formalPackType,
2525
+ unsigned componentIndex,
2526
+ SILValue limitWithinComponent);
2527
+
2528
+ // / Emit a loop which destroys all the elements of a pack value.
2529
+ // /
2530
+ // / \param packAddr - the address of the overall pack value
2531
+ // / \param formalPackType - a pack type with the same shape as the
2532
+ // / overall pack value
2533
+ void emitDestroyPack (SILLocation loc,
2534
+ SILValue packAddr,
2535
+ CanPackType formalPackType);
2455
2536
};
2456
2537
2457
2538
0 commit comments