Package jminusminus
Class NInterval
java.lang.Object
jminusminus.NInterval
- All Implemented Interfaces:
- Comparable<NInterval>
Represents a lifetime interval, recording the interval of LIR code for which the corresponding
 virtual register contains a useful value.
- 
Field SummaryFieldsModifier and TypeFieldDescriptionChildren of this interval.intOffset.From offset.Parent of this interval.The NPhyicalRegister assigned to this interval.All live ranges for this virtual registerbooleanWhether or not to spill.All use positions (in LIR) and their types for this virtual registerintThe virtual register id corresponding to the index in the array list of NIntervals used by register allocation
- 
Constructor SummaryConstructorsConstructorDescriptionNInterval(int vRegId, NControlFlowGraph cfg) Constructs an NInterval object.NInterval(int virtualRegID, NControlFlowGraph cfg, ArrayList<NRange> childRanges, NInterval parent) This second constructor is used in instantiating children of a split interval.
- 
Method SummaryModifier and TypeMethodDescriptionvoidaddOrExtendNRange(NRange newNRange) Adds a new range to the existing ranges.voidaddUsePosition(Integer index, InstructionType type) Registers a use (read or write).childAt(int idx) Returns the child interval at the given instruction index.Returns the child of this interval which is live or ends before the given basic block's end.Returns the child of this interval which is live or starts after the given basic block's start.intReturns a comparison of this interval with other.intReturns the basic block in which this interval's end position falls.booleanReturns true if this interval is the same as other, and false otherwise.intReturns the start position for the first range.intReturns the first use position in this interval.booleanisChild()Returns true if this is a child interval, and false otherwise.booleanisLiveAt(int atIndex) Returns true if this virtual register is alive at a given index, and false otherwise.booleanisParent()Returns true if this is a parent interval, and false otherwise.intReturns the stop position for the last range.voidnewFirstRangeStart(int newStart) Sets the start value of the very first range.intnextIntersection(NInterval otherInterval) Returns the very first position where an intersection with another interval occurs.intnextUsageOverlapping(NInterval currInterval) Returns the next use position of this interval after the first range start of the foreign interval.voidspill()Assigns an offset to this interval (if one hasn't been already assigned).splitAt(int idx) Splits the current interval at the given index.intReturns the basic block in which this interval's start position falls.voidWrites the interval information to STDOUT.
- 
Field Details- 
vRegIdpublic int vRegIdThe virtual register id corresponding to the index in the array list of NIntervals used by register allocation
- 
rangesAll live ranges for this virtual register
- 
usePositionsAll use positions (in LIR) and their types for this virtual register
- 
pRegisterThe NPhyicalRegister assigned to this interval. If an interval ends up needing more than one physical register it is split.
- 
spillpublic boolean spillWhether or not to spill.
- 
offsetFromFrom offset.
- 
offsetpublic int offsetOffset.
- 
parentParent of this interval.
- 
childrenChildren of this interval.
 
- 
- 
Constructor Details- 
NIntervalConstructs an NInterval object.- Parameters:
- vRegId- program counter.
- cfg- the control flow graph.
 
- 
NIntervalpublic NInterval(int virtualRegID, NControlFlowGraph cfg, ArrayList<NRange> childRanges, NInterval parent) This second constructor is used in instantiating children of a split interval.- Parameters:
- virtualRegID- program counter.
- cfg- The control flow graph.
- childRanges- The instruction ranges for this child.
- parent- The parent interval.
 
 
- 
- 
Method Details- 
addOrExtendNRangeAdds a new range to the existing ranges. If the range overlaps then the old start position will be given the new start range position.- Parameters:
- newNRange- the NRange to add
 
- 
nextIntersectionReturns the very first position where an intersection with another interval occurs.- Parameters:
- otherInterval- the interval to compare against for intersection.
- Returns:
- the position where the intersection begins.
 
- 
nextUsageOverlappingReturns the next use position of this interval after the first range start of the foreign interval. If there is no such use, then the first use position is returned to preserve data flow (in case of loops).- Parameters:
- currInterval- the interval with starting point after which we want to find the next usage of this one.
- Returns:
- the next use position.
 
- 
firstUsagepublic int firstUsage()Returns the first use position in this interval.- Returns:
- the first use position in this interval.
 
- 
newFirstRangeStartpublic void newFirstRangeStart(int newStart) Sets the start value of the very first range. Note: There will always be at least one range before this method is used by the NRegisterAllocator.buildIntervals() method.- Parameters:
- newStart- the value to which the first range's start will be set.
 
- 
addUsePositionRegisters a use (read or write).- Parameters:
- index- the site of the use.
- type- the instruction type.
 
- 
isLiveAtpublic boolean isLiveAt(int atIndex) Returns true if this virtual register is alive at a given index, and false otherwise.- Parameters:
- atIndex- the index at which to see if this register is live.
- Returns:
- true if this virtual register is alive at a given index, and false otherwise.
 
- 
writeToStdOutWrites the interval information to STDOUT.- Parameters:
- p- for pretty printing with indentation.
 
- 
firstNRangeStartpublic int firstNRangeStart()Returns the start position for the first range.- Returns:
- the start position for the first range.
 
- 
lastNRangeStoppublic int lastNRangeStop()Returns the stop position for the last range.- Returns:
- the stop position for the last range.
 
- 
compareToReturns a comparison of this interval with other.- Specified by:
- compareToin interface- Comparable<NInterval>
- Parameters:
- other- interval to compare to.
- Returns:
- a comparison of this interval with other.
 
- 
equalsReturns true if this interval is the same as other, and false otherwise.- Parameters:
- other- the interval we are comparing with.
- Returns:
- true if this interval is the same as other, and false otherwise.
 
- 
splitAtSplits the current interval at the given index. Responsible for splitting a range if the index falls on one, moving remaining ranges over to child, and moving appropriate usePositions over to the child.- Parameters:
- idx- the index at which this interval is to be split
- Returns:
- the child interval which is to be sorted onto unhandled. If there was no child created in the case of a pruning this interval is returned.
 
- 
childAtReturns the child interval at the given instruction index.- Parameters:
- idx- the instruction index.
- Returns:
- the child interval at the given instruction index.
 
- 
childAtOrEndingBeforeReturns the child of this interval which is live or ends before the given basic block's end.- Parameters:
- b- the basic block.
- Returns:
- the child of this interval which ends at or nearest (before) this basic block's end (last lir instruction index).
 
- 
childAtOrStartingAfterReturns the child of this interval which is live or starts after the given basic block's start.- Parameters:
- b- the basic block.
- Returns:
- the child of this interval which starts at or nearest (after) this basic block's start (fist lir instruction index).
 
- 
startsAtBlockpublic int startsAtBlock()Returns the basic block in which this interval's start position falls.- Returns:
- the basic block in which this interval's start position falls.
 
- 
endsAtBlockpublic int endsAtBlock()Returns the basic block in which this interval's end position falls.- Returns:
- the basic block in which this interval's end position falls.
 
- 
spillpublic void spill()Assigns an offset to this interval (if one hasn't been already assigned). Assigns that same offset to any (newly created) children.
- 
isChildpublic boolean isChild()Returns true if this is a child interval, and false otherwise.- Returns:
- true if this is a child interval, and false otherwise.
 
- 
isParentpublic boolean isParent()Returns true if this is a parent interval, and false otherwise.- Returns:
- true if this is a parent interval, and false otherwise.
 
 
-