15
15
// - `AccessPath`: a pair of an `AccessBase` and `SmallProjectionPath` with the
16
16
// the path describing the specific address (in terms of projections) of the
17
17
// access.
18
- // - `AccessStoragePath`: identifies the reference (or a value which contains a
19
- // reference) an address originates from.
18
+ // - Access storage path (which is of type `ProjectedValue`): identifies the
19
+ // reference (or a value which contains a reference ) an address originates from.
20
20
//
21
21
// The snippet below shows the relationship between the access concepts.
22
22
// ```
23
- // %ref = struct_extract %value, #f1 AccessStoragePath
23
+ // %ref = struct_extract %value, #f1 access storage path
24
24
// %base = ref_element_addr %ref, #f2 AccessBase AccessPath |
25
25
// %scope = begin_access %base AccessScope | |
26
26
// %t = tuple_element_addr %scope, 0 | |
@@ -253,22 +253,6 @@ struct AccessPath : CustomStringConvertible {
253
253
}
254
254
}
255
255
256
- /// An `AccessStoragePath` is the reference (or a value which contains a reference)
257
- /// an address originates from.
258
- /// In the following example the `storage` is `contains_ref` with `path` `"s0.c0.s0"`
259
- /// ```
260
- /// %ref = struct_extract %contains_ref : $S, #S.l
261
- /// %base = ref_element_addr %ref : $List, #List.x
262
- /// %addr = struct_element_addr %base : $X, #X.e
263
- /// store %v to [trivial] %addr : $*Int
264
- /// ```
265
- struct AccessStoragePath {
266
- let storage : Value
267
-
268
- /// Only valid paths are: `"<sequence of value projections>.<one reference projection>.<sequence of address projections>"`
269
- let path : SmallProjectionPath
270
- }
271
-
272
256
private func canBeOperandOfIndexAddr( _ value: Value ) -> Bool {
273
257
switch value {
274
258
case is IndexAddrInst , is RefTailAddrInst , is PointerToAddressInst :
@@ -506,10 +490,19 @@ extension Value {
506
490
}
507
491
}
508
492
509
- /// A ValueUseDef walker that identifies which values a reference of an access path might
510
- /// originate from.
493
+ /// A ValueUseDef walker that that visits access storage paths of an address.
494
+ ///
495
+ /// An access storage path is the reference (or a value which contains a reference)
496
+ /// an address originates from.
497
+ /// In the following example the `storage` is `contains_ref` with `path` `"s0.c0.s0"`
498
+ /// ```
499
+ /// %ref = struct_extract %contains_ref : $S, #S.l
500
+ /// %base = ref_element_addr %ref : $List, #List.x
501
+ /// %addr = struct_element_addr %base : $X, #X.e
502
+ /// store %v to [trivial] %addr : $*Int
503
+ /// ```
511
504
protocol AccessStoragePathWalker : ValueUseDefWalker where Path == SmallProjectionPath {
512
- mutating func visit( access : AccessStoragePath )
505
+ mutating func visit( accessStoragePath : ProjectedValue )
513
506
}
514
507
515
508
extension AccessStoragePathWalker {
@@ -534,7 +527,7 @@ extension AccessStoragePathWalker {
534
527
}
535
528
536
529
mutating func rootDef( value: Value , path: SmallProjectionPath ) -> WalkResult {
537
- visit ( access : AccessStoragePath ( storage : value, path : path) )
530
+ visit ( accessStoragePath : value. at ( path) )
538
531
return . continueWalk
539
532
}
540
533
}
0 commit comments