Skip to content

Commit

Permalink
RLSRA: strengthen invariants of (collected) register live intervals
Browse files Browse the repository at this point in the history
This strengthen invariant checking before proceeding to actual
allocation, namely:

 * checks that each virtual register is at least once defined
   (assigned) and
 * checks that each virtual register is used only after it is defined
   or not used at all.
  • Loading branch information
janvrany committed Aug 16, 2024
1 parent 9fa36d9 commit 6402474
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
12 changes: 12 additions & 0 deletions src/Tinyrossa/TRRegisterLiveInterval.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,18 @@ TRRegisterLiveInterval >> firstDef [
^ nil
]

{ #category : #accessing }
TRRegisterLiveInterval >> firstUse [
"Return the first use position for this interval."

uses do: [:encodedPosition |
(self encodesUsePosition: encodedPosition) ifTrue: [
^ self decodePosition: encodedPosition
].
].
^ nil
]

{ #category : #initialization }
TRRegisterLiveInterval >> initializeWithRegister: aTRVirtualRegister [
self assert: aTRVirtualRegister isTRVirtualRegister.
Expand Down
4 changes: 3 additions & 1 deletion src/Tinyrossa/TRReverseLinearScanRegisterAllocator.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,9 @@ TRReverseLinearScanRegisterAllocator >> allocateRegisters [
].
].
intervals do: [:interval |
self assert: interval start < interval stop.
self assert: interval start <= interval stop.
self assert: interval firstDef notNil description: 'virtual register not defined (assigned)'.
self assert:(interval firstUse isNil or:[interval firstDef < interval firstUse]) description: 'virtual register used before defined (assigned)'.
].

"Create todo (work) list. The list is sorted by interval's end position (#stop).
Expand Down

0 comments on commit 6402474

Please sign in to comment.