Mercurial > repos > hgweb.cgi > bootstrap
annotate genesis/baste/bastepass4.church @ 1029:819bffdbe3eb
thread source location information through from parser to AST to LIR
basic support for emitting line numbers in stack trace
author  John Leuner <jewel@subvertthedominantparadigm.net> 

date  Thu, 20 Jun 2013 11:27:00 +0200 
parents  2868fb888d1b 
children  d5dc991bfcc4 
rev  line source 

965
1bb246ef3934
do basic linear scan register allocation on locals (use scc numbers as live interval indicators)
John Leuner <jewel@subvertthedominantparadigm.net>
parents:
diff
changeset

1 class liveintervallistelement 
1bb246ef3934
do basic linear scan register allocation on locals (use scc numbers as live interval indicators)
John Leuner <jewel@subvertthedominantparadigm.net>
parents:
diff
changeset

2 withslots 
1bb246ef3934
do basic linear scan register allocation on locals (use scc numbers as live interval indicators)
John Leuner <jewel@subvertthedominantparadigm.net>
parents:
diff
changeset

3 local 
988
686b07d79691
add new LIR representation, implement Wimmers Linear Scan allocator
John Leuner <jewel@subvertthedominantparadigm.net>
parents:
985
diff
changeset

4 interval 
965
1bb246ef3934
do basic linear scan register allocation on locals (use scc numbers as live interval indicators)
John Leuner <jewel@subvertthedominantparadigm.net>
parents:
diff
changeset

5 prev 
1bb246ef3934
do basic linear scan register allocation on locals (use scc numbers as live interval indicators)
John Leuner <jewel@subvertthedominantparadigm.net>
parents:
diff
changeset

6 next 
1bb246ef3934
do basic linear scan register allocation on locals (use scc numbers as live interval indicators)
John Leuner <jewel@subvertthedominantparadigm.net>
parents:
diff
changeset

7 
1bb246ef3934
do basic linear scan register allocation on locals (use scc numbers as live interval indicators)
John Leuner <jewel@subvertthedominantparadigm.net>
parents:
diff
changeset

8 
1004
324463b1cac0
lots of messing around with fixed intervals for call arguments (sending and receiving)
John Leuner <jewel@subvertthedominantparadigm.net>
parents:
1001
diff
changeset

9 intervalstartsbefore? a b 
324463b1cac0
lots of messing around with fixed intervals for call arguments (sending and receiving)
John Leuner <jewel@subvertthedominantparadigm.net>
parents:
1001
diff
changeset

10 if (< a.ranges.start b.ranges.start) 
324463b1cac0
lots of messing around with fixed intervals for call arguments (sending and receiving)
John Leuner <jewel@subvertthedominantparadigm.net>
parents:
1001
diff
changeset

11 true 
324463b1cac0
lots of messing around with fixed intervals for call arguments (sending and receiving)
John Leuner <jewel@subvertthedominantparadigm.net>
parents:
1001
diff
changeset

12 else 
324463b1cac0
lots of messing around with fixed intervals for call arguments (sending and receiving)
John Leuner <jewel@subvertthedominantparadigm.net>
parents:
1001
diff
changeset

13 if (and (type? a 'lirfixedinterval) (type? b 'lirfixedinterval) (== a.ranges.start b.ranges.start)) 
324463b1cac0
lots of messing around with fixed intervals for call arguments (sending and receiving)
John Leuner <jewel@subvertthedominantparadigm.net>
parents:
1001
diff
changeset

14 < a.register b.register 
324463b1cac0
lots of messing around with fixed intervals for call arguments (sending and receiving)
John Leuner <jewel@subvertthedominantparadigm.net>
parents:
1001
diff
changeset

15 else 
324463b1cac0
lots of messing around with fixed intervals for call arguments (sending and receiving)
John Leuner <jewel@subvertthedominantparadigm.net>
parents:
1001
diff
changeset

16 nil 
324463b1cac0
lots of messing around with fixed intervals for call arguments (sending and receiving)
John Leuner <jewel@subvertthedominantparadigm.net>
parents:
1001
diff
changeset

17 
965
1bb246ef3934
do basic linear scan register allocation on locals (use scc numbers as live interval indicators)
John Leuner <jewel@subvertthedominantparadigm.net>
parents:
diff
changeset

18 class liveintervallist 
1bb246ef3934
do basic linear scan register allocation on locals (use scc numbers as live interval indicators)
John Leuner <jewel@subvertthedominantparadigm.net>
parents:
diff
changeset

19 withslots 
1bb246ef3934
do basic linear scan register allocation on locals (use scc numbers as live interval indicators)
John Leuner <jewel@subvertthedominantparadigm.net>
parents:
diff
changeset

20 first 
1bb246ef3934
do basic linear scan register allocation on locals (use scc numbers as live interval indicators)
John Leuner <jewel@subvertthedominantparadigm.net>
parents:
diff
changeset

21 last 
1bb246ef3934
do basic linear scan register allocation on locals (use scc numbers as live interval indicators)
John Leuner <jewel@subvertthedominantparadigm.net>
parents:
diff
changeset

22 insertafter existingli newli 
1bb246ef3934
do basic linear scan register allocation on locals (use scc numbers as live interval indicators)
John Leuner <jewel@subvertthedominantparadigm.net>
parents:
diff
changeset

23 if (eq? self.last existingli) 
1bb246ef3934
do basic linear scan register allocation on locals (use scc numbers as live interval indicators)
John Leuner <jewel@subvertthedominantparadigm.net>
parents:
diff
changeset

24 existingli.next = newli 
1bb246ef3934
do basic linear scan register allocation on locals (use scc numbers as live interval indicators)
John Leuner <jewel@subvertthedominantparadigm.net>
parents:
diff
changeset

25 newli.prev = existingli 
1bb246ef3934
do basic linear scan register allocation on locals (use scc numbers as live interval indicators)
John Leuner <jewel@subvertthedominantparadigm.net>
parents:
diff
changeset

26 newli.next = nil 
1bb246ef3934
do basic linear scan register allocation on locals (use scc numbers as live interval indicators)
John Leuner <jewel@subvertthedominantparadigm.net>
parents:
diff
changeset

27 self.last = newli 
1bb246ef3934
do basic linear scan register allocation on locals (use scc numbers as live interval indicators)
John Leuner <jewel@subvertthedominantparadigm.net>
parents:
diff
changeset

28 else 
1bb246ef3934
do basic linear scan register allocation on locals (use scc numbers as live interval indicators)
John Leuner <jewel@subvertthedominantparadigm.net>
parents:
diff
changeset

29 newli.next = existingli.next 
1bb246ef3934
do basic linear scan register allocation on locals (use scc numbers as live interval indicators)
John Leuner <jewel@subvertthedominantparadigm.net>
parents:
diff
changeset

30 existingli.next = newli 
1bb246ef3934
do basic linear scan register allocation on locals (use scc numbers as live interval indicators)
John Leuner <jewel@subvertthedominantparadigm.net>
parents:
diff
changeset

31 newli.prev = existingli 
1bb246ef3934
do basic linear scan register allocation on locals (use scc numbers as live interval indicators)
John Leuner <jewel@subvertthedominantparadigm.net>
parents:
diff
changeset

32 newli.next.prev = newli 
1bb246ef3934
do basic linear scan register allocation on locals (use scc numbers as live interval indicators)
John Leuner <jewel@subvertthedominantparadigm.net>
parents:
diff
changeset

33 insertbefore existingli newli 
1bb246ef3934
do basic linear scan register allocation on locals (use scc numbers as live interval indicators)
John Leuner <jewel@subvertthedominantparadigm.net>
parents:
diff
changeset

34 if (eq? self.first existingli) 
1bb246ef3934
do basic linear scan register allocation on locals (use scc numbers as live interval indicators)
John Leuner <jewel@subvertthedominantparadigm.net>
parents:
diff
changeset

35 existingli.prev = newli 
1bb246ef3934
do basic linear scan register allocation on locals (use scc numbers as live interval indicators)
John Leuner <jewel@subvertthedominantparadigm.net>
parents:
diff
changeset

36 newli.next = existingli 
1bb246ef3934
do basic linear scan register allocation on locals (use scc numbers as live interval indicators)
John Leuner <jewel@subvertthedominantparadigm.net>
parents:
diff
changeset

37 newli.prev = nil 
1bb246ef3934
do basic linear scan register allocation on locals (use scc numbers as live interval indicators)
John Leuner <jewel@subvertthedominantparadigm.net>
parents:
diff
changeset

38 self.first = newli 
1bb246ef3934
do basic linear scan register allocation on locals (use scc numbers as live interval indicators)
John Leuner <jewel@subvertthedominantparadigm.net>
parents:
diff
changeset

39 else 
1bb246ef3934
do basic linear scan register allocation on locals (use scc numbers as live interval indicators)
John Leuner <jewel@subvertthedominantparadigm.net>
parents:
diff
changeset

40 newli.prev = existingli.prev 
1bb246ef3934
do basic linear scan register allocation on locals (use scc numbers as live interval indicators)
John Leuner <jewel@subvertthedominantparadigm.net>
parents:
diff
changeset

41 existingli.prev = newli 
1bb246ef3934
do basic linear scan register allocation on locals (use scc numbers as live interval indicators)
John Leuner <jewel@subvertthedominantparadigm.net>
parents:
diff
changeset

42 newli.next = existingli 
1bb246ef3934
do basic linear scan register allocation on locals (use scc numbers as live interval indicators)
John Leuner <jewel@subvertthedominantparadigm.net>
parents:
diff
changeset

43 newli.prev.next = newli 
1bb246ef3934
do basic linear scan register allocation on locals (use scc numbers as live interval indicators)
John Leuner <jewel@subvertthedominantparadigm.net>
parents:
diff
changeset

44 addincreasingstartpoint li 
1017
f4c03e96159f
add tailcall
John Leuner <jewel@subvertthedominantparadigm.net>
parents:
1015
diff
changeset

45 error "unused" li 
965
1bb246ef3934
do basic linear scan register allocation on locals (use scc numbers as live interval indicators)
John Leuner <jewel@subvertthedominantparadigm.net>
parents:
diff
changeset

46 if (null? self.first) 
1bb246ef3934
do basic linear scan register allocation on locals (use scc numbers as live interval indicators)
John Leuner <jewel@subvertthedominantparadigm.net>
parents:
diff
changeset

47 self.first = li 
1bb246ef3934
do basic linear scan register allocation on locals (use scc numbers as live interval indicators)
John Leuner <jewel@subvertthedominantparadigm.net>
parents:
diff
changeset

48 self.last = li 
1bb246ef3934
do basic linear scan register allocation on locals (use scc numbers as live interval indicators)
John Leuner <jewel@subvertthedominantparadigm.net>
parents:
diff
changeset

49 li.prev = nil 
1bb246ef3934
do basic linear scan register allocation on locals (use scc numbers as live interval indicators)
John Leuner <jewel@subvertthedominantparadigm.net>
parents:
diff
changeset

50 li.next = nil 
1bb246ef3934
do basic linear scan register allocation on locals (use scc numbers as live interval indicators)
John Leuner <jewel@subvertthedominantparadigm.net>
parents:
diff
changeset

51 else 
1bb246ef3934
do basic linear scan register allocation on locals (use scc numbers as live interval indicators)
John Leuner <jewel@subvertthedominantparadigm.net>
parents:
diff
changeset

52 iter = self.first 
1bb246ef3934
do basic linear scan register allocation on locals (use scc numbers as live interval indicators)
John Leuner <jewel@subvertthedominantparadigm.net>
parents:
diff
changeset

53 loop 
1bb246ef3934
do basic linear scan register allocation on locals (use scc numbers as live interval indicators)
John Leuner <jewel@subvertthedominantparadigm.net>
parents:
diff
changeset

54 while (and (< iter.local.intervalbegin li.local.intervalbegin) (not (null? iter.next))) 
1bb246ef3934
do basic linear scan register allocation on locals (use scc numbers as live interval indicators)
John Leuner <jewel@subvertthedominantparadigm.net>
parents:
diff
changeset

55 do 
1bb246ef3934
do basic linear scan register allocation on locals (use scc numbers as live interval indicators)
John Leuner <jewel@subvertthedominantparadigm.net>
parents:
diff
changeset

56 iter = iter.next 
1bb246ef3934
do basic linear scan register allocation on locals (use scc numbers as live interval indicators)
John Leuner <jewel@subvertthedominantparadigm.net>
parents:
diff
changeset

57 
1bb246ef3934
do basic linear scan register allocation on locals (use scc numbers as live interval indicators)
John Leuner <jewel@subvertthedominantparadigm.net>
parents:
diff
changeset

58 if (< iter.local.intervalbegin li.local.intervalbegin) 
1bb246ef3934
do basic linear scan register allocation on locals (use scc numbers as live interval indicators)
John Leuner <jewel@subvertthedominantparadigm.net>
parents:
diff
changeset

59 insertafter self iter li 
1bb246ef3934
do basic linear scan register allocation on locals (use scc numbers as live interval indicators)
John Leuner <jewel@subvertthedominantparadigm.net>
parents:
diff
changeset

60 else 
1bb246ef3934
do basic linear scan register allocation on locals (use scc numbers as live interval indicators)
John Leuner <jewel@subvertthedominantparadigm.net>
parents:
diff
changeset

61 insertbefore self iter li 
1bb246ef3934
do basic linear scan register allocation on locals (use scc numbers as live interval indicators)
John Leuner <jewel@subvertthedominantparadigm.net>
parents:
diff
changeset

62 1 
1015
36e7992480d0
emit code for scc based allocator
John Leuner <jewel@subvertthedominantparadigm.net>
parents:
1013
diff
changeset

63 addincreasingstartpointnew li 
36e7992480d0
emit code for scc based allocator
John Leuner <jewel@subvertthedominantparadigm.net>
parents:
1013
diff
changeset

64 if (null? self.first) 
36e7992480d0
emit code for scc based allocator
John Leuner <jewel@subvertthedominantparadigm.net>
parents:
1013
diff
changeset

65 self.first = li 
36e7992480d0
emit code for scc based allocator
John Leuner <jewel@subvertthedominantparadigm.net>
parents:
1013
diff
changeset

66 self.last = li 
36e7992480d0
emit code for scc based allocator
John Leuner <jewel@subvertthedominantparadigm.net>
parents:
1013
diff
changeset

67 li.prev = nil 
36e7992480d0
emit code for scc based allocator
John Leuner <jewel@subvertthedominantparadigm.net>
parents:
1013
diff
changeset

68 li.next = nil 
36e7992480d0
emit code for scc based allocator
John Leuner <jewel@subvertthedominantparadigm.net>
parents:
1013
diff
changeset

69 else 
36e7992480d0
emit code for scc based allocator
John Leuner <jewel@subvertthedominantparadigm.net>
parents:
1013
diff
changeset

70 iter = self.first 
36e7992480d0
emit code for scc based allocator
John Leuner <jewel@subvertthedominantparadigm.net>
parents:
1013
diff
changeset

71 loop 
36e7992480d0
emit code for scc based allocator
John Leuner <jewel@subvertthedominantparadigm.net>
parents:
1013
diff
changeset

72 while (and (< (start iter.interval) (start li.interval)) (not (null? iter.next))) 
36e7992480d0
emit code for scc based allocator
John Leuner <jewel@subvertthedominantparadigm.net>
parents:
1013
diff
changeset

73 do 
36e7992480d0
emit code for scc based allocator
John Leuner <jewel@subvertthedominantparadigm.net>
parents:
1013
diff
changeset

74 iter = iter.next 
36e7992480d0
emit code for scc based allocator
John Leuner <jewel@subvertthedominantparadigm.net>
parents:
1013
diff
changeset

75 
36e7992480d0
emit code for scc based allocator
John Leuner <jewel@subvertthedominantparadigm.net>
parents:
1013
diff
changeset

76 if (< (start iter.interval) (start li.interval)) 
36e7992480d0
emit code for scc based allocator
John Leuner <jewel@subvertthedominantparadigm.net>
parents:
1013
diff
changeset

77 insertafter self iter li 
36e7992480d0
emit code for scc based allocator
John Leuner <jewel@subvertthedominantparadigm.net>
parents:
1013
diff
changeset

78 else 
36e7992480d0
emit code for scc based allocator
John Leuner <jewel@subvertthedominantparadigm.net>
parents:
1013
diff
changeset

79 insertbefore self iter li 
36e7992480d0
emit code for scc based allocator
John Leuner <jewel@subvertthedominantparadigm.net>
parents:
1013
diff
changeset

80 1 
36e7992480d0
emit code for scc based allocator
John Leuner <jewel@subvertthedominantparadigm.net>
parents:
1013
diff
changeset

81 addincreasingendpointnew li 
36e7992480d0
emit code for scc based allocator
John Leuner <jewel@subvertthedominantparadigm.net>
parents:
1013
diff
changeset

82 if (null? self.first) 
36e7992480d0
emit code for scc based allocator
John Leuner <jewel@subvertthedominantparadigm.net>
parents:
1013
diff
changeset

83 self.first = li 
36e7992480d0
emit code for scc based allocator
John Leuner <jewel@subvertthedominantparadigm.net>
parents:
1013
diff
changeset

84 self.last = li 
36e7992480d0
emit code for scc based allocator
John Leuner <jewel@subvertthedominantparadigm.net>
parents:
1013
diff
changeset

85 li.prev = nil 
36e7992480d0
emit code for scc based allocator
John Leuner <jewel@subvertthedominantparadigm.net>
parents:
1013
diff
changeset

86 li.next = nil 
36e7992480d0
emit code for scc based allocator
John Leuner <jewel@subvertthedominantparadigm.net>
parents:
1013
diff
changeset

87 else 
36e7992480d0
emit code for scc based allocator
John Leuner <jewel@subvertthedominantparadigm.net>
parents:
1013
diff
changeset

88 iter = self.first 
36e7992480d0
emit code for scc based allocator
John Leuner <jewel@subvertthedominantparadigm.net>
parents:
1013
diff
changeset

89 loop 
36e7992480d0
emit code for scc based allocator
John Leuner <jewel@subvertthedominantparadigm.net>
parents:
1013
diff
changeset

90 while (and (< (end iter.interval) (end li.interval)) (not (null? iter.next))) 
36e7992480d0
emit code for scc based allocator
John Leuner <jewel@subvertthedominantparadigm.net>
parents:
1013
diff
changeset

91 do 
36e7992480d0
emit code for scc based allocator
John Leuner <jewel@subvertthedominantparadigm.net>
parents:
1013
diff
changeset

92 iter = iter.next 
36e7992480d0
emit code for scc based allocator
John Leuner <jewel@subvertthedominantparadigm.net>
parents:
1013
diff
changeset

93 
36e7992480d0
emit code for scc based allocator
John Leuner <jewel@subvertthedominantparadigm.net>
parents:
1013
diff
changeset

94 if (< (end iter.interval) (end li.interval)) 
36e7992480d0
emit code for scc based allocator
John Leuner <jewel@subvertthedominantparadigm.net>
parents:
1013
diff
changeset

95 insertafter self iter li 
36e7992480d0
emit code for scc based allocator
John Leuner <jewel@subvertthedominantparadigm.net>
parents:
1013
diff
changeset

96 else 
36e7992480d0
emit code for scc based allocator
John Leuner <jewel@subvertthedominantparadigm.net>
parents:
1013
diff
changeset

97 insertbefore self iter li 
36e7992480d0
emit code for scc based allocator
John Leuner <jewel@subvertthedominantparadigm.net>
parents:
1013
diff
changeset

98 1 
988
686b07d79691
add new LIR representation, implement Wimmers Linear Scan allocator
John Leuner <jewel@subvertthedominantparadigm.net>
parents:
985
diff
changeset

99 addlirincreasingstartpoint li 
686b07d79691
add new LIR representation, implement Wimmers Linear Scan allocator
John Leuner <jewel@subvertthedominantparadigm.net>
parents:
985
diff
changeset

100 if (null? self.first) 
686b07d79691
add new LIR representation, implement Wimmers Linear Scan allocator
John Leuner <jewel@subvertthedominantparadigm.net>
parents:
985
diff
changeset

101 self.first = li 
686b07d79691
add new LIR representation, implement Wimmers Linear Scan allocator
John Leuner <jewel@subvertthedominantparadigm.net>
parents:
985
diff
changeset

102 self.last = li 
686b07d79691
add new LIR representation, implement Wimmers Linear Scan allocator
John Leuner <jewel@subvertthedominantparadigm.net>
parents:
985
diff
changeset

103 li.prev = nil 
686b07d79691
add new LIR representation, implement Wimmers Linear Scan allocator
John Leuner <jewel@subvertthedominantparadigm.net>
parents:
985
diff
changeset

104 li.next = nil 
686b07d79691
add new LIR representation, implement Wimmers Linear Scan allocator
John Leuner <jewel@subvertthedominantparadigm.net>
parents:
985
diff
changeset

105 else 
686b07d79691
add new LIR representation, implement Wimmers Linear Scan allocator
John Leuner <jewel@subvertthedominantparadigm.net>
parents:
985
diff
changeset

106 iter = self.first 
686b07d79691
add new LIR representation, implement Wimmers Linear Scan allocator
John Leuner <jewel@subvertthedominantparadigm.net>
parents:
985
diff
changeset

107 loop 
1004
324463b1cac0
lots of messing around with fixed intervals for call arguments (sending and receiving)
John Leuner <jewel@subvertthedominantparadigm.net>
parents:
1001
diff
changeset

108 while (and (intervalstartsbefore? iter.interval li.interval) (not (null? iter.next))) 
988
686b07d79691
add new LIR representation, implement Wimmers Linear Scan allocator
John Leuner <jewel@subvertthedominantparadigm.net>
parents:
985
diff
changeset

109 do 
686b07d79691
add new LIR representation, implement Wimmers Linear Scan allocator
John Leuner <jewel@subvertthedominantparadigm.net>
parents:
985
diff
changeset

110 iter = iter.next 
686b07d79691
add new LIR representation, implement Wimmers Linear Scan allocator
John Leuner <jewel@subvertthedominantparadigm.net>
parents:
985
diff
changeset

111 
1004
324463b1cac0
lots of messing around with fixed intervals for call arguments (sending and receiving)
John Leuner <jewel@subvertthedominantparadigm.net>
parents:
1001
diff
changeset

112 if (intervalstartsbefore? iter.interval li.interval) 
988
686b07d79691
add new LIR representation, implement Wimmers Linear Scan allocator
John Leuner <jewel@subvertthedominantparadigm.net>
parents:
985
diff
changeset

113 insertafter self iter li 
686b07d79691
add new LIR representation, implement Wimmers Linear Scan allocator
John Leuner <jewel@subvertthedominantparadigm.net>
parents:
985
diff
changeset

114 else 
686b07d79691
add new LIR representation, implement Wimmers Linear Scan allocator
John Leuner <jewel@subvertthedominantparadigm.net>
parents:
985
diff
changeset

115 insertbefore self iter li 
686b07d79691
add new LIR representation, implement Wimmers Linear Scan allocator
John Leuner <jewel@subvertthedominantparadigm.net>
parents:
985
diff
changeset

116 1 
991
3c09511d9bf9
filter / keep
John Leuner <jewel@subvertthedominantparadigm.net>
parents:
988
diff
changeset

117 maplirlist proc 
3c09511d9bf9
filter / keep
John Leuner <jewel@subvertthedominantparadigm.net>
parents:
988
diff
changeset

118 iter = self.first 
3c09511d9bf9
filter / keep
John Leuner <jewel@subvertthedominantparadigm.net>
parents:
988
diff
changeset

119 loop 
3c09511d9bf9
filter / keep
John Leuner <jewel@subvertthedominantparadigm.net>
parents:
988
diff
changeset

120 while iter 
3c09511d9bf9
filter / keep
John Leuner <jewel@subvertthedominantparadigm.net>
parents:
988
diff
changeset

121 do 
3c09511d9bf9
filter / keep
John Leuner <jewel@subvertthedominantparadigm.net>
parents:
988
diff
changeset

122 apply proc iter.interval 
3c09511d9bf9
filter / keep
John Leuner <jewel@subvertthedominantparadigm.net>
parents:
988
diff
changeset

123 iter = iter.next 
3c09511d9bf9
filter / keep
John Leuner <jewel@subvertthedominantparadigm.net>
parents:
988
diff
changeset

124 
3c09511d9bf9
filter / keep
John Leuner <jewel@subvertthedominantparadigm.net>
parents:
988
diff
changeset

125 true 
965
1bb246ef3934
do basic linear scan register allocation on locals (use scc numbers as live interval indicators)
John Leuner <jewel@subvertthedominantparadigm.net>
parents:
diff
changeset

126 addincreasingendpoint li 
1bb246ef3934
do basic linear scan register allocation on locals (use scc numbers as live interval indicators)
John Leuner <jewel@subvertthedominantparadigm.net>
parents:
diff
changeset

127 if (null? self.first) 
1bb246ef3934
do basic linear scan register allocation on locals (use scc numbers as live interval indicators)
John Leuner <jewel@subvertthedominantparadigm.net>
parents:
diff
changeset

128 self.first = li 
1bb246ef3934
do basic linear scan register allocation on locals (use scc numbers as live interval indicators)
John Leuner <jewel@subvertthedominantparadigm.net>
parents:
diff
changeset

129 self.last = li 
1bb246ef3934
do basic linear scan register allocation on locals (use scc numbers as live interval indicators)
John Leuner <jewel@subvertthedominantparadigm.net>
parents:
diff
changeset

130 li.prev = nil 
1bb246ef3934
do basic linear scan register allocation on locals (use scc numbers as live interval indicators)
John Leuner <jewel@subvertthedominantparadigm.net>
parents:
diff
changeset

131 li.next = nil 
1bb246ef3934
do basic linear scan register allocation on locals (use scc numbers as live interval indicators)
John Leuner <jewel@subvertthedominantparadigm.net>
parents:
diff
changeset

132 else 
1bb246ef3934
do basic linear scan register allocation on locals (use scc numbers as live interval indicators)
John Leuner <jewel@subvertthedominantparadigm.net>
parents:
diff
changeset

133 iter = self.first 
1bb246ef3934
do basic linear scan register allocation on locals (use scc numbers as live interval indicators)
John Leuner <jewel@subvertthedominantparadigm.net>
parents:
diff
changeset

134 loop 
1bb246ef3934
do basic linear scan register allocation on locals (use scc numbers as live interval indicators)
John Leuner <jewel@subvertthedominantparadigm.net>
parents:
diff
changeset

135 while (and (< iter.local.intervalend li.local.intervalend) (not (null? iter.next))) 
1bb246ef3934
do basic linear scan register allocation on locals (use scc numbers as live interval indicators)
John Leuner <jewel@subvertthedominantparadigm.net>
parents:
diff
changeset

136 do 
1bb246ef3934
do basic linear scan register allocation on locals (use scc numbers as live interval indicators)
John Leuner <jewel@subvertthedominantparadigm.net>
parents:
diff
changeset

137 iter = iter.next 
1bb246ef3934
do basic linear scan register allocation on locals (use scc numbers as live interval indicators)
John Leuner <jewel@subvertthedominantparadigm.net>
parents:
diff
changeset

138 
1bb246ef3934
do basic linear scan register allocation on locals (use scc numbers as live interval indicators)
John Leuner <jewel@subvertthedominantparadigm.net>
parents:
diff
changeset

139 if (< iter.local.intervalend li.local.intervalend) 
1bb246ef3934
do basic linear scan register allocation on locals (use scc numbers as live interval indicators)
John Leuner <jewel@subvertthedominantparadigm.net>
parents:
diff
changeset

140 insertafter self iter li 
1bb246ef3934
do basic linear scan register allocation on locals (use scc numbers as live interval indicators)
John Leuner <jewel@subvertthedominantparadigm.net>
parents:
diff
changeset

141 else 
1bb246ef3934
do basic linear scan register allocation on locals (use scc numbers as live interval indicators)
John Leuner <jewel@subvertthedominantparadigm.net>
parents:
diff
changeset

142 insertbefore self iter li 
1bb246ef3934
do basic linear scan register allocation on locals (use scc numbers as live interval indicators)
John Leuner <jewel@subvertthedominantparadigm.net>
parents:
diff
changeset

143 1 
1bb246ef3934
do basic linear scan register allocation on locals (use scc numbers as live interval indicators)
John Leuner <jewel@subvertthedominantparadigm.net>
parents:
diff
changeset

144 removelistelement li 
1bb246ef3934
do basic linear scan register allocation on locals (use scc numbers as live interval indicators)
John Leuner <jewel@subvertthedominantparadigm.net>
parents:
diff
changeset

145 if li.prev 
1bb246ef3934
do basic linear scan register allocation on locals (use scc numbers as live interval indicators)
John Leuner <jewel@subvertthedominantparadigm.net>
parents:
diff
changeset

146 li.prev.next = li.next 
1bb246ef3934
do basic linear scan register allocation on locals (use scc numbers as live interval indicators)
John Leuner <jewel@subvertthedominantparadigm.net>
parents:
diff
changeset

147 if li.next 
1bb246ef3934
do basic linear scan register allocation on locals (use scc numbers as live interval indicators)
John Leuner <jewel@subvertthedominantparadigm.net>
parents:
diff
changeset

148 li.next.prev = li.prev 
1bb246ef3934
do basic linear scan register allocation on locals (use scc numbers as live interval indicators)
John Leuner <jewel@subvertthedominantparadigm.net>
parents:
diff
changeset

149 if (eq? self.first li) 
1bb246ef3934
do basic linear scan register allocation on locals (use scc numbers as live interval indicators)
John Leuner <jewel@subvertthedominantparadigm.net>
parents:
diff
changeset

150 self.first = li.next 
1bb246ef3934
do basic linear scan register allocation on locals (use scc numbers as live interval indicators)
John Leuner <jewel@subvertthedominantparadigm.net>
parents:
diff
changeset

151 if (eq? self.last li) 
1bb246ef3934
do basic linear scan register allocation on locals (use scc numbers as live interval indicators)
John Leuner <jewel@subvertthedominantparadigm.net>
parents:
diff
changeset

152 self.last = li.prev 
1bb246ef3934
do basic linear scan register allocation on locals (use scc numbers as live interval indicators)
John Leuner <jewel@subvertthedominantparadigm.net>
parents:
diff
changeset

153 li 
1bb246ef3934
do basic linear scan register allocation on locals (use scc numbers as live interval indicators)
John Leuner <jewel@subvertthedominantparadigm.net>
parents:
diff
changeset

154 
1bb246ef3934
do basic linear scan register allocation on locals (use scc numbers as live interval indicators)
John Leuner <jewel@subvertthedominantparadigm.net>
parents:
diff
changeset

155 
988
686b07d79691
add new LIR representation, implement Wimmers Linear Scan allocator
John Leuner <jewel@subvertthedominantparadigm.net>
parents:
985
diff
changeset

156 ; 
686b07d79691
add new LIR representation, implement Wimmers Linear Scan allocator
John Leuner <jewel@subvertthedominantparadigm.net>
parents:
985
diff
changeset

157 ; Allocate registers (LIR) 
686b07d79691
add new LIR representation, implement Wimmers Linear Scan allocator
John Leuner <jewel@subvertthedominantparadigm.net>
parents:
985
diff
changeset

158 
1004
324463b1cac0
lots of messing around with fixed intervals for call arguments (sending and receiving)
John Leuner <jewel@subvertthedominantparadigm.net>
parents:
1001
diff
changeset

159 extern NUMPHYSICALREGS 
999
8997dd2656d6
extend machine code pass to load and store to spill slots
John Leuner <jewel@subvertthedominantparadigm.net>
parents:
995
diff
changeset

160 
1025
5c8991b36582
integrate fixed intervals for call arguments
John Leuner <jewel@subvertthedominantparadigm.net>
parents:
1023
diff
changeset

161 ; we reserve a stack slot to spill r8, r9, r10 and r11 across calls since they are callee clobbered 
1015
36e7992480d0
emit code for scc based allocator
John Leuner <jewel@subvertthedominantparadigm.net>
parents:
1013
diff
changeset

162 
1025
5c8991b36582
integrate fixed intervals for call arguments
John Leuner <jewel@subvertthedominantparadigm.net>
parents:
1023
diff
changeset

163 global NUMRESERVEDSPILLSLOTS = 4 
1015
36e7992480d0
emit code for scc based allocator
John Leuner <jewel@subvertthedominantparadigm.net>
parents:
1013
diff
changeset

164 
36e7992480d0
emit code for scc based allocator
John Leuner <jewel@subvertthedominantparadigm.net>
parents:
1013
diff
changeset

165 ; 
36e7992480d0
emit code for scc based allocator
John Leuner <jewel@subvertthedominantparadigm.net>
parents:
1013
diff
changeset

166 ; SCC based register allocation 
36e7992480d0
emit code for scc based allocator
John Leuner <jewel@subvertthedominantparadigm.net>
parents:
1013
diff
changeset

167 
988
686b07d79691
add new LIR representation, implement Wimmers Linear Scan allocator
John Leuner <jewel@subvertthedominantparadigm.net>
parents:
985
diff
changeset

168 pass4lirallocateregisters methodcontexts 
1019
4d2a41144f33
add support for a try catch construct
John Leuner <jewel@subvertthedominantparadigm.net>
parents:
1018
diff
changeset

169 print "pass 4 register allocation " 
988
686b07d79691
add new LIR representation, implement Wimmers Linear Scan allocator
John Leuner <jewel@subvertthedominantparadigm.net>
parents:
985
diff
changeset

170 loop 
686b07d79691
add new LIR representation, implement Wimmers Linear Scan allocator
John Leuner <jewel@subvertthedominantparadigm.net>
parents:
985
diff
changeset

171 for m in methodcontexts 
686b07d79691
add new LIR representation, implement Wimmers Linear Scan allocator
John Leuner <jewel@subvertthedominantparadigm.net>
parents:
985
diff
changeset

172 do 
686b07d79691
add new LIR representation, implement Wimmers Linear Scan allocator
John Leuner <jewel@subvertthedominantparadigm.net>
parents:
985
diff
changeset

173 lirfunction = m.lirfunction 
1015
36e7992480d0
emit code for scc based allocator
John Leuner <jewel@subvertthedominantparadigm.net>
parents:
1013
diff
changeset

174 nextfixedreg = 1 
36e7992480d0
emit code for scc based allocator
John Leuner <jewel@subvertthedominantparadigm.net>
parents:
1013
diff
changeset

175 loop 
36e7992480d0
emit code for scc based allocator
John Leuner <jewel@subvertthedominantparadigm.net>
parents:
1013
diff
changeset

176 for vreg across lirfunction.fixedvregs 
36e7992480d0
emit code for scc based allocator
John Leuner <jewel@subvertthedominantparadigm.net>
parents:
1013
diff
changeset

177 do 
36e7992480d0
emit code for scc based allocator
John Leuner <jewel@subvertthedominantparadigm.net>
parents:
1013
diff
changeset

178 if (and vreg.firstinterval (not (lirunusedvreg? vreg))) 
36e7992480d0
emit code for scc based allocator
John Leuner <jewel@subvertthedominantparadigm.net>
parents:
1013
diff
changeset

179 vreg.firstinterval.register = nextfixedreg 
36e7992480d0
emit code for scc based allocator
John Leuner <jewel@subvertthedominantparadigm.net>
parents:
1013
diff
changeset

180 nextfixedreg = * nextfixedreg 2 
36e7992480d0
emit code for scc based allocator
John Leuner <jewel@subvertthedominantparadigm.net>
parents:
1013
diff
changeset

181 
1027
2868fb888d1b
flesh out test suite
John Leuner <jewel@subvertthedominantparadigm.net>
parents:
1025
diff
changeset

182 print "" 
2868fb888d1b
flesh out test suite
John Leuner <jewel@subvertthedominantparadigm.net>
parents:
1025
diff
changeset

183 print m.name 
2868fb888d1b
flesh out test suite
John Leuner <jewel@subvertthedominantparadigm.net>
parents:
1025
diff
changeset

184 print "" 
1015
36e7992480d0
emit code for scc based allocator
John Leuner <jewel@subvertthedominantparadigm.net>
parents:
1013
diff
changeset

185 print "before allocation " 
36e7992480d0
emit code for scc based allocator
John Leuner <jewel@subvertthedominantparadigm.net>
parents:
1013
diff
changeset

186 loop 
36e7992480d0
emit code for scc based allocator
John Leuner <jewel@subvertthedominantparadigm.net>
parents:
1013
diff
changeset

187 for vreg across lirfunction.vregs 
36e7992480d0
emit code for scc based allocator
John Leuner <jewel@subvertthedominantparadigm.net>
parents:
1013
diff
changeset

188 do 
36e7992480d0
emit code for scc based allocator
John Leuner <jewel@subvertthedominantparadigm.net>
parents:
1013
diff
changeset

189 out vreg 
36e7992480d0
emit code for scc based allocator
John Leuner <jewel@subvertthedominantparadigm.net>
parents:
1013
diff
changeset

190 out " (" 
1025
5c8991b36582
integrate fixed intervals for call arguments
John Leuner <jewel@subvertthedominantparadigm.net>
parents:
1023
diff
changeset

191 if (type? vreg.firstinterval 'lirfixedinterval) 
5c8991b36582
integrate fixed intervals for call arguments
John Leuner <jewel@subvertthedominantparadigm.net>
parents:
1023
diff
changeset

192 out "F " 
5c8991b36582
integrate fixed intervals for call arguments
John Leuner <jewel@subvertthedominantparadigm.net>
parents:
1023
diff
changeset

193 else 
5c8991b36582
integrate fixed intervals for call arguments
John Leuner <jewel@subvertthedominantparadigm.net>
parents:
1023
diff
changeset

194 out vreg.firstinterval.spillslotindex 
1015
36e7992480d0
emit code for scc based allocator
John Leuner <jewel@subvertthedominantparadigm.net>
parents:
1013
diff
changeset

195 out ") " 
36e7992480d0
emit code for scc based allocator
John Leuner <jewel@subvertthedominantparadigm.net>
parents:
1013
diff
changeset

196 print vreg.firstinterval.register 
36e7992480d0
emit code for scc based allocator
John Leuner <jewel@subvertthedominantparadigm.net>
parents:
1013
diff
changeset

197 
1027
2868fb888d1b
flesh out test suite
John Leuner <jewel@subvertthedominantparadigm.net>
parents:
1025
diff
changeset

198 allocateregistersscc lirfunction m.name 
1004
324463b1cac0
lots of messing around with fixed intervals for call arguments (sending and receiving)
John Leuner <jewel@subvertthedominantparadigm.net>
parents:
1001
diff
changeset

199 print "final register allocation " 
1015
36e7992480d0
emit code for scc based allocator
John Leuner <jewel@subvertthedominantparadigm.net>
parents:
1013
diff
changeset

200 loop 
36e7992480d0
emit code for scc based allocator
John Leuner <jewel@subvertthedominantparadigm.net>
parents:
1013
diff
changeset

201 for vreg across lirfunction.vregs 
36e7992480d0
emit code for scc based allocator
John Leuner <jewel@subvertthedominantparadigm.net>
parents:
1013
diff
changeset

202 do 
36e7992480d0
emit code for scc based allocator
John Leuner <jewel@subvertthedominantparadigm.net>
parents:
1013
diff
changeset

203 out vreg 
36e7992480d0
emit code for scc based allocator
John Leuner <jewel@subvertthedominantparadigm.net>
parents:
1013
diff
changeset

204 out " (" 
1025
5c8991b36582
integrate fixed intervals for call arguments
John Leuner <jewel@subvertthedominantparadigm.net>
parents:
1023
diff
changeset

205 if (type? vreg.firstinterval 'lirfixedinterval) 
5c8991b36582
integrate fixed intervals for call arguments
John Leuner <jewel@subvertthedominantparadigm.net>
parents:
1023
diff
changeset

206 out "F " 
5c8991b36582
integrate fixed intervals for call arguments
John Leuner <jewel@subvertthedominantparadigm.net>
parents:
1023
diff
changeset

207 else 
5c8991b36582
integrate fixed intervals for call arguments
John Leuner <jewel@subvertthedominantparadigm.net>
parents:
1023
diff
changeset

208 out vreg.firstinterval.spillslotindex 
1015
36e7992480d0
emit code for scc based allocator
John Leuner <jewel@subvertthedominantparadigm.net>
parents:
1013
diff
changeset

209 out ") " 
36e7992480d0
emit code for scc based allocator
John Leuner <jewel@subvertthedominantparadigm.net>
parents:
1013
diff
changeset

210 print vreg.firstinterval.register 
36e7992480d0
emit code for scc based allocator
John Leuner <jewel@subvertthedominantparadigm.net>
parents:
1013
diff
changeset

211 
988
686b07d79691
add new LIR representation, implement Wimmers Linear Scan allocator
John Leuner <jewel@subvertthedominantparadigm.net>
parents:
985
diff
changeset

212 
1019
4d2a41144f33
add support for a try catch construct
John Leuner <jewel@subvertthedominantparadigm.net>
parents:
1018
diff
changeset

213 
988
686b07d79691
add new LIR representation, implement Wimmers Linear Scan allocator
John Leuner <jewel@subvertthedominantparadigm.net>
parents:
985
diff
changeset

214 'done 
686b07d79691
add new LIR representation, implement Wimmers Linear Scan allocator
John Leuner <jewel@subvertthedominantparadigm.net>
parents:
985
diff
changeset

215 
686b07d79691
add new LIR representation, implement Wimmers Linear Scan allocator
John Leuner <jewel@subvertthedominantparadigm.net>
parents:
985
diff
changeset

216 
1027
2868fb888d1b
flesh out test suite
John Leuner <jewel@subvertthedominantparadigm.net>
parents:
1025
diff
changeset

217 allocateregistersscc lirfunction functionname 
1015
36e7992480d0
emit code for scc based allocator
John Leuner <jewel@subvertthedominantparadigm.net>
parents:
1013
diff
changeset

218 freeregs = new 'basteregisterset 
36e7992480d0
emit code for scc based allocator
John Leuner <jewel@subvertthedominantparadigm.net>
parents:
1013
diff
changeset

219 ; reserve the fixed regs 
988
686b07d79691
add new LIR representation, implement Wimmers Linear Scan allocator
John Leuner <jewel@subvertthedominantparadigm.net>
parents:
985
diff
changeset

220 loop 
1015
36e7992480d0
emit code for scc based allocator
John Leuner <jewel@subvertthedominantparadigm.net>
parents:
1013
diff
changeset

221 for vreg across lirfunction.fixedvregs 
988
686b07d79691
add new LIR representation, implement Wimmers Linear Scan allocator
John Leuner <jewel@subvertthedominantparadigm.net>
parents:
985
diff
changeset

222 do 
1015
36e7992480d0
emit code for scc based allocator
John Leuner <jewel@subvertthedominantparadigm.net>
parents:
1013
diff
changeset

223 if vreg.firstinterval.register 
36e7992480d0
emit code for scc based allocator
John Leuner <jewel@subvertthedominantparadigm.net>
parents:
1013
diff
changeset

224 allocatespecificregister freeregs vreg.firstinterval.register 
988
686b07d79691
add new LIR representation, implement Wimmers Linear Scan allocator
John Leuner <jewel@subvertthedominantparadigm.net>
parents:
985
diff
changeset

225 
1017
f4c03e96159f
add tailcall
John Leuner <jewel@subvertthedominantparadigm.net>
parents:
1015
diff
changeset

226 spillslotindex = NUMRESERVEDSPILLSLOTS 
1015
36e7992480d0
emit code for scc based allocator
John Leuner <jewel@subvertthedominantparadigm.net>
parents:
1013
diff
changeset

227 print "live intervals" 
36e7992480d0
emit code for scc based allocator
John Leuner <jewel@subvertthedominantparadigm.net>
parents:
1013
diff
changeset

228 ; collect intervals into the unhandled list 
36e7992480d0
emit code for scc based allocator
John Leuner <jewel@subvertthedominantparadigm.net>
parents:
1013
diff
changeset

229 live = new 'liveintervallist 
36e7992480d0
emit code for scc based allocator
John Leuner <jewel@subvertthedominantparadigm.net>
parents:
1013
diff
changeset

230 completed = new 'liveintervallist 
1017
f4c03e96159f
add tailcall
John Leuner <jewel@subvertthedominantparadigm.net>
parents:
1015
diff
changeset

231 ; print "live intervals" 
f4c03e96159f
add tailcall
John Leuner <jewel@subvertthedominantparadigm.net>
parents:
1015
diff
changeset

232 ; print lirfunction 
1015
36e7992480d0
emit code for scc based allocator
John Leuner <jewel@subvertthedominantparadigm.net>
parents:
1013
diff
changeset

233 loop 
36e7992480d0
emit code for scc based allocator
John Leuner <jewel@subvertthedominantparadigm.net>
parents:
1013
diff
changeset

234 for vreg across lirfunction.vregs 
36e7992480d0
emit code for scc based allocator
John Leuner <jewel@subvertthedominantparadigm.net>
parents:
1013
diff
changeset

235 do 
36e7992480d0
emit code for scc based allocator
John Leuner <jewel@subvertthedominantparadigm.net>
parents:
1013
diff
changeset

236 if (not (lirunusedvreg? vreg)) 
36e7992480d0
emit code for scc based allocator
John Leuner <jewel@subvertthedominantparadigm.net>
parents:
1013
diff
changeset

237 addincreasingstartpointnew live (new 'liveintervallistelement :interval vreg.firstinterval :local vreg) 
988
686b07d79691
add new LIR representation, implement Wimmers Linear Scan allocator
John Leuner <jewel@subvertthedominantparadigm.net>
parents:
985
diff
changeset

238 
1015
36e7992480d0
emit code for scc based allocator
John Leuner <jewel@subvertthedominantparadigm.net>
parents:
1013
diff
changeset

239 print "done live intervals" 
36e7992480d0
emit code for scc based allocator
John Leuner <jewel@subvertthedominantparadigm.net>
parents:
1013
diff
changeset

240 dumpintervals live 
36e7992480d0
emit code for scc based allocator
John Leuner <jewel@subvertthedominantparadigm.net>
parents:
1013
diff
changeset

241 active = new 'liveintervallist 
36e7992480d0
emit code for scc based allocator
John Leuner <jewel@subvertthedominantparadigm.net>
parents:
1013
diff
changeset

242 ; for each interval 
36e7992480d0
emit code for scc based allocator
John Leuner <jewel@subvertthedominantparadigm.net>
parents:
1013
diff
changeset

243 li = live.first 
988
686b07d79691
add new LIR representation, implement Wimmers Linear Scan allocator
John Leuner <jewel@subvertthedominantparadigm.net>
parents:
985
diff
changeset

244 loop 
1015
36e7992480d0
emit code for scc based allocator
John Leuner <jewel@subvertthedominantparadigm.net>
parents:
1013
diff
changeset

245 while li 
988
686b07d79691
add new LIR representation, implement Wimmers Linear Scan allocator
John Leuner <jewel@subvertthedominantparadigm.net>
parents:
985
diff
changeset

246 do 
1015
36e7992480d0
emit code for scc based allocator
John Leuner <jewel@subvertthedominantparadigm.net>
parents:
1013
diff
changeset

247 current = li.interval 
36e7992480d0
emit code for scc based allocator
John Leuner <jewel@subvertthedominantparadigm.net>
parents:
1013
diff
changeset

248 ; expire active intervals that end before current 
36e7992480d0
emit code for scc based allocator
John Leuner <jewel@subvertthedominantparadigm.net>
parents:
1013
diff
changeset

249 ai = active.first 
36e7992480d0
emit code for scc based allocator
John Leuner <jewel@subvertthedominantparadigm.net>
parents:
1013
diff
changeset

250 loop 
36e7992480d0
emit code for scc based allocator
John Leuner <jewel@subvertthedominantparadigm.net>
parents:
1013
diff
changeset

251 while ai 
36e7992480d0
emit code for scc based allocator
John Leuner <jewel@subvertthedominantparadigm.net>
parents:
1013
diff
changeset

252 do 
36e7992480d0
emit code for scc based allocator
John Leuner <jewel@subvertthedominantparadigm.net>
parents:
1013
diff
changeset

253 if (< (end ai.interval) (start current)) 
36e7992480d0
emit code for scc based allocator
John Leuner <jewel@subvertthedominantparadigm.net>
parents:
1013
diff
changeset

254 completedli = new 'liveintervallistelement :interval ai.interval :local ai.local 
36e7992480d0
emit code for scc based allocator
John Leuner <jewel@subvertthedominantparadigm.net>
parents:
1013
diff
changeset

255 removelistelement active ai 
36e7992480d0
emit code for scc based allocator
John Leuner <jewel@subvertthedominantparadigm.net>
parents:
1013
diff
changeset

256 addincreasingstartpointnew completed completedli 
36e7992480d0
emit code for scc based allocator
John Leuner <jewel@subvertthedominantparadigm.net>
parents:
1013
diff
changeset

257 freeregister freeregs ai.interval.register 
36e7992480d0
emit code for scc based allocator
John Leuner <jewel@subvertthedominantparadigm.net>
parents:
1013
diff
changeset

258 ai = ai.next 
1013
ac8bce46cb1e
experiment with spill handling in loops
John Leuner <jewel@subvertthedominantparadigm.net>
parents:
1011
diff
changeset

259 
1025
5c8991b36582
integrate fixed intervals for call arguments
John Leuner <jewel@subvertthedominantparadigm.net>
parents:
1023
diff
changeset

260 if (and (not current.vreg.mustspill?) (empty? freeregs) (not current.register)) 
1015
36e7992480d0
emit code for scc based allocator
John Leuner <jewel@subvertthedominantparadigm.net>
parents:
1013
diff
changeset

261 ; should we spill another interval instead ? 
1017
f4c03e96159f
add tailcall
John Leuner <jewel@subvertthedominantparadigm.net>
parents:
1015
diff
changeset

262 ; print "spill" 
1015
36e7992480d0
emit code for scc based allocator
John Leuner <jewel@subvertthedominantparadigm.net>
parents:
1013
diff
changeset

263 spillinterval = active.last 
1025
5c8991b36582
integrate fixed intervals for call arguments
John Leuner <jewel@subvertthedominantparadigm.net>
parents:
1023
diff
changeset

264 ; cannot spill a fixed interval 
5c8991b36582
integrate fixed intervals for call arguments
John Leuner <jewel@subvertthedominantparadigm.net>
parents:
1023
diff
changeset

265 if (type? spillinterval 'lirfixedinterval) 
5c8991b36582
integrate fixed intervals for call arguments
John Leuner <jewel@subvertthedominantparadigm.net>
parents:
1023
diff
changeset

266 spillinterval = nil 
1017
f4c03e96159f
add tailcall
John Leuner <jewel@subvertthedominantparadigm.net>
parents:
1015
diff
changeset

267 ; print spillinterval 
1015
36e7992480d0
emit code for scc based allocator
John Leuner <jewel@subvertthedominantparadigm.net>
parents:
1013
diff
changeset

268 if (and spillinterval (> (end spillinterval.interval) (end current))) 
1025
5c8991b36582
integrate fixed intervals for call arguments
John Leuner <jewel@subvertthedominantparadigm.net>
parents:
1023
diff
changeset

269 ; out "spilling interval " 
5c8991b36582
integrate fixed intervals for call arguments
John Leuner <jewel@subvertthedominantparadigm.net>
parents:
1023
diff
changeset

270 ; out (lirargtostring spillinterval.interval.vreg) 
5c8991b36582
integrate fixed intervals for call arguments
John Leuner <jewel@subvertthedominantparadigm.net>
parents:
1023
diff
changeset

271 ; out " with reg " 
5c8991b36582
integrate fixed intervals for call arguments
John Leuner <jewel@subvertthedominantparadigm.net>
parents:
1023
diff
changeset

272 ; out spillinterval.interval.register 
5c8991b36582
integrate fixed intervals for call arguments
John Leuner <jewel@subvertthedominantparadigm.net>
parents:
1023
diff
changeset

273 ; out " for " 
5c8991b36582
integrate fixed intervals for call arguments
John Leuner <jewel@subvertthedominantparadigm.net>
parents:
1023
diff
changeset

274 ; print (lirargtostring current.vreg) 
1015
36e7992480d0
emit code for scc based allocator
John Leuner <jewel@subvertthedominantparadigm.net>
parents:
1013
diff
changeset

275 current.register = spillinterval.interval.register 
36e7992480d0
emit code for scc based allocator
John Leuner <jewel@subvertthedominantparadigm.net>
parents:
1013
diff
changeset

276 spillinterval.interval.spillslotindex = spillslotindex 
1017
f4c03e96159f
add tailcall
John Leuner <jewel@subvertthedominantparadigm.net>
parents:
1015
diff
changeset

277 addincreasingstartpointnew completed (new 'liveintervallistelement :interval spillinterval.interval :local spillinterval.interval.vreg) 
1015
36e7992480d0
emit code for scc based allocator
John Leuner <jewel@subvertthedominantparadigm.net>
parents:
1013
diff
changeset

278 removelistelement active spillinterval 
36e7992480d0
emit code for scc based allocator
John Leuner <jewel@subvertthedominantparadigm.net>
parents:
1013
diff
changeset

279 spillinterval.interval.register = nil 
36e7992480d0
emit code for scc based allocator
John Leuner <jewel@subvertthedominantparadigm.net>
parents:
1013
diff
changeset

280 else 
36e7992480d0
emit code for scc based allocator
John Leuner <jewel@subvertthedominantparadigm.net>
parents:
1013
diff
changeset

281 ; spill current 
36e7992480d0
emit code for scc based allocator
John Leuner <jewel@subvertthedominantparadigm.net>
parents:
1013
diff
changeset

282 current.spillslotindex = spillslotindex 
1017
f4c03e96159f
add tailcall
John Leuner <jewel@subvertthedominantparadigm.net>
parents:
1015
diff
changeset

283 addincreasingstartpointnew completed (new 'liveintervallistelement :interval current :local current.vreg) 
1015
36e7992480d0
emit code for scc based allocator
John Leuner <jewel@subvertthedominantparadigm.net>
parents:
1013
diff
changeset

284 spillslotindex = + spillslotindex 1 
1013
ac8bce46cb1e
experiment with spill handling in loops
John Leuner <jewel@subvertthedominantparadigm.net>
parents:
1011
diff
changeset

285 else 
1019
4d2a41144f33
add support for a try catch construct
John Leuner <jewel@subvertthedominantparadigm.net>
parents:
1018
diff
changeset

286 if current.vreg.mustspill? 
4d2a41144f33
add support for a try catch construct
John Leuner <jewel@subvertthedominantparadigm.net>
parents:
1018
diff
changeset

287 current.spillslotindex = spillslotindex 
4d2a41144f33
add support for a try catch construct
John Leuner <jewel@subvertthedominantparadigm.net>
parents:
1018
diff
changeset

288 spillslotindex = + spillslotindex 1 
4d2a41144f33
add support for a try catch construct
John Leuner <jewel@subvertthedominantparadigm.net>
parents:
1018
diff
changeset

289 addincreasingstartpointnew completed (new 'liveintervallistelement :interval current :local current.vreg) 
993
10b7e19129e0
finetune interval splitting
John Leuner <jewel@subvertthedominantparadigm.net>
parents:
992
diff
changeset

290 else 
1019
4d2a41144f33
add support for a try catch construct
John Leuner <jewel@subvertthedominantparadigm.net>
parents:
1018
diff
changeset

291 ; print "find reg" 
4d2a41144f33
add support for a try catch construct
John Leuner <jewel@subvertthedominantparadigm.net>
parents:
1018
diff
changeset

292 ; print current 
4d2a41144f33
add support for a try catch construct
John Leuner <jewel@subvertthedominantparadigm.net>
parents:
1018
diff
changeset

293 if current.register 
4d2a41144f33
add support for a try catch construct
John Leuner <jewel@subvertthedominantparadigm.net>
parents:
1018
diff
changeset

294 ; register is already allocated 
4d2a41144f33
add support for a try catch construct
John Leuner <jewel@subvertthedominantparadigm.net>
parents:
1018
diff
changeset

295 1 
4d2a41144f33
add support for a try catch construct
John Leuner <jewel@subvertthedominantparadigm.net>
parents:
1018
diff
changeset

296 ; print "has reg" 
4d2a41144f33
add support for a try catch construct
John Leuner <jewel@subvertthedominantparadigm.net>
parents:
1018
diff
changeset

297 else 
4d2a41144f33
add support for a try catch construct
John Leuner <jewel@subvertthedominantparadigm.net>
parents:
1018
diff
changeset

298 reg = allocateregister freeregs 
4d2a41144f33
add support for a try catch construct
John Leuner <jewel@subvertthedominantparadigm.net>
parents:
1018
diff
changeset

299 current.register = reg 
4d2a41144f33
add support for a try catch construct
John Leuner <jewel@subvertthedominantparadigm.net>
parents:
1018
diff
changeset

300 ; make current active 
4d2a41144f33
add support for a try catch construct
John Leuner <jewel@subvertthedominantparadigm.net>
parents:
1018
diff
changeset

301 addincreasingendpointnew active (new 'liveintervallistelement :interval current :local current.vreg) 
1015
36e7992480d0
emit code for scc based allocator
John Leuner <jewel@subvertthedominantparadigm.net>
parents:
1013
diff
changeset

302 li = li.next 
1006
de72781e9bb1
use fixed intervals to calculate nextFreeUntilPos in try allocate reg
John Leuner <jewel@subvertthedominantparadigm.net>
parents:
1005
diff
changeset

303 
1015
36e7992480d0
emit code for scc based allocator
John Leuner <jewel@subvertthedominantparadigm.net>
parents:
1013
diff
changeset

304 ; drain out remaining intervals 
36e7992480d0
emit code for scc based allocator
John Leuner <jewel@subvertthedominantparadigm.net>
parents:
1013
diff
changeset

305 ai = active.first 
988
686b07d79691
add new LIR representation, implement Wimmers Linear Scan allocator
John Leuner <jewel@subvertthedominantparadigm.net>
parents:
985
diff
changeset

306 loop 
1015
36e7992480d0
emit code for scc based allocator
John Leuner <jewel@subvertthedominantparadigm.net>
parents:
1013
diff
changeset

307 while ai 
988
686b07d79691
add new LIR representation, implement Wimmers Linear Scan allocator
John Leuner <jewel@subvertthedominantparadigm.net>
parents:
985
diff
changeset

308 do 
1015
36e7992480d0
emit code for scc based allocator
John Leuner <jewel@subvertthedominantparadigm.net>
parents:
1013
diff
changeset

309 completedli = new 'liveintervallistelement :interval ai.interval :local ai.local 
36e7992480d0
emit code for scc based allocator
John Leuner <jewel@subvertthedominantparadigm.net>
parents:
1013
diff
changeset

310 removelistelement active ai 
36e7992480d0
emit code for scc based allocator
John Leuner <jewel@subvertthedominantparadigm.net>
parents:
1013
diff
changeset

311 addincreasingstartpointnew completed completedli 
36e7992480d0
emit code for scc based allocator
John Leuner <jewel@subvertthedominantparadigm.net>
parents:
1013
diff
changeset

312 freeregister freeregs ai.interval.register 
36e7992480d0
emit code for scc based allocator
John Leuner <jewel@subvertthedominantparadigm.net>
parents:
1013
diff
changeset

313 ai = ai.next 
993
10b7e19129e0
finetune interval splitting
John Leuner <jewel@subvertthedominantparadigm.net>
parents:
992
diff
changeset

314 
1017
f4c03e96159f
add tailcall
John Leuner <jewel@subvertthedominantparadigm.net>
parents:
1015
diff
changeset

315 lirfunction.numspillslotsused = spillslotindex 
1015
36e7992480d0
emit code for scc based allocator
John Leuner <jewel@subvertthedominantparadigm.net>
parents:
1013
diff
changeset

316 print "done " 
1027
2868fb888d1b
flesh out test suite
John Leuner <jewel@subvertthedominantparadigm.net>
parents:
1025
diff
changeset

317 print "" 
2868fb888d1b
flesh out test suite
John Leuner <jewel@subvertthedominantparadigm.net>
parents:
1025
diff
changeset

318 print functionname 
2868fb888d1b
flesh out test suite
John Leuner <jewel@subvertthedominantparadigm.net>
parents:
1025
diff
changeset

319 print "" 
1015
36e7992480d0
emit code for scc based allocator
John Leuner <jewel@subvertthedominantparadigm.net>
parents:
1013
diff
changeset

320 dumpintervals completed 
1017
f4c03e96159f
add tailcall
John Leuner <jewel@subvertthedominantparadigm.net>
parents:
1015
diff
changeset

321 showintervals completed 
1015
36e7992480d0
emit code for scc based allocator
John Leuner <jewel@subvertthedominantparadigm.net>
parents:
1013
diff
changeset

322 1 