@@ -697,6 +697,14 @@ private import DefUse
697
697
* potentially very sparse.
698
698
*/
699
699
module DefUse {
700
+ bindingset [ index, block]
701
+ pragma [ inline_late]
702
+ private int getNonChiOffset ( int index , OldBlock block ) { result = 2 * index }
703
+
704
+ bindingset [ index, block]
705
+ pragma [ inline_late]
706
+ private int getChiOffset ( int index , OldBlock block ) { result = getNonChiOffset ( index , block ) + 1 }
707
+
700
708
/**
701
709
* Gets the `Instruction` for the definition at offset `defOffset` in block `defBlock`.
702
710
*/
@@ -709,7 +717,7 @@ module DefUse {
709
717
oldOffset >= 0
710
718
|
711
719
// An odd offset corresponds to the `Chi` instruction.
712
- defOffset = oldOffset * 2 + 1 and
720
+ defOffset = getChiOffset ( oldOffset , defBlock ) and
713
721
result = getChi ( oldInstr ) and
714
722
(
715
723
defLocation = Alias:: getResultMemoryLocation ( oldInstr ) or
@@ -718,7 +726,7 @@ module DefUse {
718
726
actualDefLocation = defLocation .getVirtualVariable ( )
719
727
or
720
728
// An even offset corresponds to the original instruction.
721
- defOffset = oldOffset * 2 and
729
+ defOffset = getNonChiOffset ( oldOffset , defBlock ) and
722
730
result = getNewInstruction ( oldInstr ) and
723
731
(
724
732
defLocation = Alias:: getResultMemoryLocation ( oldInstr ) or
@@ -871,8 +879,8 @@ module DefUse {
871
879
block .getInstruction ( index ) = def and
872
880
overlap = Alias:: getOverlap ( defLocation , useLocation ) and
873
881
if overlap instanceof MayPartiallyOverlap
874
- then offset = ( index * 2 ) + 1 // The use will be connected to the definition on the `Chi` instruction.
875
- else offset = index * 2 // The use will be connected to the definition on the original instruction.
882
+ then offset = getChiOffset ( index , block ) // The use will be connected to the definition on the `Chi` instruction.
883
+ else offset = getNonChiOffset ( index , block ) // The use will be connected to the definition on the original instruction.
876
884
)
877
885
}
878
886
@@ -933,10 +941,11 @@ module DefUse {
933
941
block .getInstruction ( index ) = use and
934
942
(
935
943
// A direct use of the location.
936
- useLocation = Alias:: getOperandMemoryLocation ( use .getAnOperand ( ) ) and offset = index * 2
944
+ useLocation = Alias:: getOperandMemoryLocation ( use .getAnOperand ( ) ) and
945
+ offset = getNonChiOffset ( index , block )
937
946
or
938
947
// A `Chi` instruction will include a use of the virtual variable.
939
- hasChiNode ( useLocation , use ) and offset = ( index * 2 ) + 1
948
+ hasChiNode ( useLocation , use ) and offset = getChiOffset ( index , block )
940
949
)
941
950
)
942
951
}
0 commit comments