FrameReification
struct FrameReification
Tracks cross-region values that must be reified in a function frame and provides the metadata required to rewrite their uses.
A “region”, in this context, is a set of instructions (maybe from different blocks). For
example, the instructions from the beginning of a simple projection to the yield form a region
(the ramp), and the instructions from the yield to the end of the projection form another
region (the slide).
If one instruction from the slide of the projection uses the value of an instruction from the ramp, the value must be reified in a frame that is passed from the ramp to the slide. The frame reification is the process of detecting which values need to be reified into a frame and performing the appropriate transformations, such as creating the frame storage and replacing the relevant instructions to access the frame.
We say that an instruction is “frame-backed” if its value is stored in the frame.
-
Reification metadata for instructions that must become frame-backed.
Declaration
Swift
fileprivate var instructionMetadata: [InstructionID : InstructionReification] -
Populates
instructionMetadatawith the instructions inregionfromfthat have to be frame-backed, excludingignored.After this call,
instructionMetadatacontains all instructions fromregionthat are used outsideregion, and all the instructions outside ofregionthat are used by instructions inregion.Declaration
Swift
public mutating func collectCrossRegionInstructions( in f: Function, from region: some Sequence<InstructionID>, ignoring predicate: (InstructionID) -> Bool = { (_) in false } ) -
Returns
trueiff the instructioni, which is inf, is used outside the regionr.Declaration
Swift
private static func isUsedOutsideRegion( _ i: InstructionID, in f: Function, region r: Set<InstructionID> ) -> Bool -
Returns the instructions outside
rthat define the operands ofiinf.Declaration
Swift
private static func operands( of i: InstructionID, outsideRegion r: Set<InstructionID>, in f: Function ) -> [InstructionID]
View on GitHub