2929// ```
3030//===----------------------------------------------------------------------===//
3131
32- import SIL
33-
3432/// AccessBase describes the base address of a memory access (e.g. of a `load` or `store``).
3533/// The "base address" is defined as the address which is obtained from the access address by
3634/// looking through all address projections.
@@ -48,7 +46,7 @@ import SIL
4846/// ```
4947///
5048/// The base address is never inside an access scope.
51- enum AccessBase : CustomStringConvertible , Hashable {
49+ public enum AccessBase : CustomStringConvertible , Hashable {
5250
5351 /// The address of a boxed variable, i.e. a field of an `alloc_box`.
5452 case box( ProjectBoxInst )
@@ -78,7 +76,7 @@ enum AccessBase : CustomStringConvertible, Hashable {
7876 /// This should be a very rare situation.
7977 case unidentified
8078
81- init ( baseAddress: Value ) {
79+ public init ( baseAddress: Value ) {
8280 switch baseAddress {
8381 case let rea as RefElementAddrInst : self = . class( rea)
8482 case let rta as RefTailAddrInst : self = . tail( rta)
@@ -97,7 +95,7 @@ enum AccessBase : CustomStringConvertible, Hashable {
9795 }
9896 }
9997
100- var description : String {
98+ public var description : String {
10199 switch self {
102100 case . unidentified: return " ? "
103101 case . box( let pbi) : return " box - \( pbi) "
@@ -112,7 +110,7 @@ enum AccessBase : CustomStringConvertible, Hashable {
112110 }
113111
114112 /// True, if this is an access to a class instance.
115- var isObjectAccess : Bool {
113+ public var isObjectAccess : Bool {
116114 switch self {
117115 case . class, . tail:
118116 return true
@@ -122,7 +120,7 @@ enum AccessBase : CustomStringConvertible, Hashable {
122120 }
123121
124122 /// The reference value if this is an access to a referenced objecct (class, box, tail).
125- var reference : Value ? {
123+ public var reference : Value ? {
126124 switch self {
127125 case . box( let pbi) : return pbi. box
128126 case . class( let rea) : return rea. instance
@@ -141,7 +139,7 @@ enum AccessBase : CustomStringConvertible, Hashable {
141139 ///
142140 /// This is not true for scoped storage such as alloc_stack and @in arguments.
143141 ///
144- var hasLocalOwnershipLifetime : Bool {
142+ public var hasLocalOwnershipLifetime : Bool {
145143 if let reference = reference {
146144 // Conservatively assume that everything which is a ref-counted object is within an ownership scope.
147145 // TODO: we could e.g. exclude guaranteed function arguments.
@@ -151,7 +149,7 @@ enum AccessBase : CustomStringConvertible, Hashable {
151149 }
152150
153151 /// True, if the baseAddress is of an immutable property or global variable
154- var isLet : Bool {
152+ public var isLet : Bool {
155153 switch self {
156154 case . class( let rea) : return rea. fieldIsLet
157155 case . global( let g) : return g. isLet
@@ -161,7 +159,7 @@ enum AccessBase : CustomStringConvertible, Hashable {
161159 }
162160
163161 /// True, if the address is immediately produced by an allocation in its function.
164- var isLocal : Bool {
162+ public var isLocal : Bool {
165163 switch self {
166164 case . box( let pbi) : return pbi. box is AllocBoxInst
167165 case . class( let rea) : return rea. instance is AllocRefInstBase
@@ -173,7 +171,7 @@ enum AccessBase : CustomStringConvertible, Hashable {
173171 }
174172
175173 /// True, if the kind of storage of the access is known (e.g. a class property, or global variable).
176- var hasKnownStorageKind : Bool {
174+ public var hasKnownStorageKind : Bool {
177175 switch self {
178176 case . box, . class, . tail, . stack, . global:
179177 return true
@@ -187,7 +185,7 @@ enum AccessBase : CustomStringConvertible, Hashable {
187185 /// `isEqual` abstracts away the projection instructions that are included as part of the AccessBase:
188186 /// multiple `project_box` and `ref_element_addr` instructions are equivalent bases as long as they
189187 /// refer to the same variable or class property.
190- func isEqual( to other: AccessBase ) -> Bool {
188+ public func isEqual( to other: AccessBase ) -> Bool {
191189 switch ( self , other) {
192190 case ( . box( let pb1) , . box( let pb2) ) :
193191 return pb1. box. referenceRoot == pb2. box. referenceRoot
@@ -213,8 +211,8 @@ enum AccessBase : CustomStringConvertible, Hashable {
213211 }
214212
215213 /// Returns `true` if the two access bases do not alias.
216- func isDistinct( from other: AccessBase ) -> Bool {
217-
214+ public func isDistinct( from other: AccessBase ) -> Bool {
215+
218216 func isDifferentAllocation( _ lhs: Value , _ rhs: Value ) -> Bool {
219217 switch ( lhs, rhs) {
220218 case ( is Allocation , is Allocation ) :
@@ -273,21 +271,21 @@ enum AccessBase : CustomStringConvertible, Hashable {
273271
274272/// An `AccessPath` is a pair of a `base: AccessBase` and a `projectionPath: Path`
275273/// which denotes the offset of the access from the base in terms of projections.
276- struct AccessPath : CustomStringConvertible {
277- let base : AccessBase
274+ public struct AccessPath : CustomStringConvertible {
275+ public let base : AccessBase
278276
279277 /// address projections only
280- let projectionPath : SmallProjectionPath
278+ public let projectionPath : SmallProjectionPath
281279
282- static func unidentified( ) -> AccessPath {
280+ public static func unidentified( ) -> AccessPath {
283281 return AccessPath ( base: . unidentified, projectionPath: SmallProjectionPath ( ) )
284282 }
285283
286- var description : String {
284+ public var description : String {
287285 " \( projectionPath) : \( base) "
288286 }
289287
290- func isDistinct( from other: AccessPath ) -> Bool {
288+ public func isDistinct( from other: AccessPath ) -> Bool {
291289 if base. isDistinct ( from: other. base) {
292290 // We can already derived from the bases that there is no alias.
293291 // No need to look at the projection paths.
@@ -308,11 +306,11 @@ struct AccessPath : CustomStringConvertible {
308306 /// Note that this access _contains_ `other` if `other` has a _larger_ projection path than this acccess.
309307 /// For example:
310308 /// `%value.s0` contains `%value.s0.s1`
311- func isEqualOrContains( _ other: AccessPath ) -> Bool {
309+ public func isEqualOrContains( _ other: AccessPath ) -> Bool {
312310 return getProjection ( to: other) != nil
313311 }
314312
315- var materializableProjectionPath : SmallProjectionPath ? {
313+ public var materializableProjectionPath : SmallProjectionPath ? {
316314 if projectionPath. isMaterializable {
317315 return projectionPath
318316 }
@@ -325,7 +323,7 @@ struct AccessPath : CustomStringConvertible {
325323 /// `%value.s0`.getProjection(to: `%value.s0.s1`)
326324 /// yields
327325 /// `s1`
328- func getProjection( to other: AccessPath ) -> SmallProjectionPath ? {
326+ public func getProjection( to other: AccessPath ) -> SmallProjectionPath ? {
329327 if !base. isEqual ( to: other. base) {
330328 return nil
331329 }
@@ -339,7 +337,7 @@ struct AccessPath : CustomStringConvertible {
339337 }
340338
341339 /// Like `getProjection`, but also requires that the resulting projection path is materializable.
342- func getMaterializableProjection( to other: AccessPath ) -> SmallProjectionPath ? {
340+ public func getMaterializableProjection( to other: AccessPath ) -> SmallProjectionPath ? {
343341 if let projectionPath = getProjection ( to: other) ,
344342 projectionPath. isMaterializable {
345343 return projectionPath
@@ -364,7 +362,7 @@ private func canBeOperandOfIndexAddr(_ value: Value) -> Bool {
364362/// %ptr = address_to_pointer %orig_addr
365363/// %addr = pointer_to_address %ptr
366364/// ```
367- extension PointerToAddressInst {
365+ private extension PointerToAddressInst {
368366 var originatingAddress : Value ? {
369367
370368 struct Walker : ValueUseDefWalker {
@@ -426,7 +424,7 @@ extension PointerToAddressInst {
426424/// %l3 = load %a3 : $*Int64
427425/// end_access %a3 : $*Int64
428426/// ```
429- enum EnclosingScope {
427+ public enum EnclosingScope {
430428 case scope( BeginAccessInst )
431429 case base( AccessBase )
432430}
@@ -512,30 +510,30 @@ extension Value {
512510 // go through phi-arguments, the AccessPathWalker will allocate memnory in its cache.
513511
514512 /// Computes the access base of this address value.
515- var accessBase : AccessBase { accessPath. base }
513+ public var accessBase : AccessBase { accessPath. base }
516514
517515 /// Computes the access path of this address value.
518- var accessPath : AccessPath {
516+ public var accessPath : AccessPath {
519517 var walker = AccessPathWalker ( )
520518 walker. walk ( startAt: self )
521519 return walker. result
522520 }
523521
524- func getAccessPath( fromInitialPath: SmallProjectionPath ) -> AccessPath {
522+ public func getAccessPath( fromInitialPath: SmallProjectionPath ) -> AccessPath {
525523 var walker = AccessPathWalker ( )
526524 walker. walk ( startAt: self , initialPath: fromInitialPath)
527525 return walker. result
528526 }
529527
530528 /// Computes the access path of this address value and also returns the scope.
531- var accessPathWithScope : ( AccessPath , scope: BeginAccessInst ? ) {
529+ public var accessPathWithScope : ( AccessPath , scope: BeginAccessInst ? ) {
532530 var walker = AccessPathWalker ( )
533531 walker. walk ( startAt: self )
534532 return ( walker. result, walker. foundBeginAccess)
535533 }
536534
537535 /// Computes the enclosing access scope of this address value.
538- var enclosingAccessScope : EnclosingScope {
536+ public var enclosingAccessScope : EnclosingScope {
539537 var walker = AccessPathWalker ( )
540538 walker. walk ( startAt: self )
541539 if let ba = walker. foundBeginAccess {
@@ -545,7 +543,7 @@ extension Value {
545543 }
546544
547545 /// The root definition of a reference, obtained by skipping casts, etc.
548- var referenceRoot : Value {
546+ public var referenceRoot : Value {
549547 var value : Value = self
550548 while true {
551549 switch value {
@@ -583,7 +581,7 @@ extension ValueUseDefWalker where Path == SmallProjectionPath {
583581 /// the `visit` function for all storage roots with a the corresponding path.
584582 /// Returns true on success.
585583 /// Returns false if not all storage roots could be identified or if `accessPath` has not a "reference" base.
586- mutating func visitAccessStorageRoots( of accessPath: AccessPath ) -> Bool {
584+ public mutating func visitAccessStorageRoots( of accessPath: AccessPath ) -> Bool {
587585 walkUpCache. clear ( )
588586 let path = accessPath. projectionPath
589587 switch accessPath. base {
0 commit comments