annotate genesis/baste/baste-pass4.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@subvert-the-dominant-paradigm.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@subvert-the-dominant-paradigm.net>
parents:
diff changeset
1 class live-interval-list-element
1bb246ef3934 do basic linear scan register allocation on locals (use scc numbers as live interval indicators)
John Leuner <jewel@subvert-the-dominant-paradigm.net>
parents:
diff changeset
2 with-slots
1bb246ef3934 do basic linear scan register allocation on locals (use scc numbers as live interval indicators)
John Leuner <jewel@subvert-the-dominant-paradigm.net>
parents:
diff changeset
3 local
988
686b07d79691 add new LIR representation, implement Wimmers Linear Scan allocator
John Leuner <jewel@subvert-the-dominant-paradigm.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@subvert-the-dominant-paradigm.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@subvert-the-dominant-paradigm.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@subvert-the-dominant-paradigm.net>
parents:
diff changeset
7
1bb246ef3934 do basic linear scan register allocation on locals (use scc numbers as live interval indicators)
John Leuner <jewel@subvert-the-dominant-paradigm.net>
parents:
diff changeset
8
1004
324463b1cac0 lots of messing around with fixed intervals for call arguments (sending and receiving)
John Leuner <jewel@subvert-the-dominant-paradigm.net>
parents: 1001
diff changeset
9 interval-starts-before? a b
324463b1cac0 lots of messing around with fixed intervals for call arguments (sending and receiving)
John Leuner <jewel@subvert-the-dominant-paradigm.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@subvert-the-dominant-paradigm.net>
parents: 1001
diff changeset
11 true
324463b1cac0 lots of messing around with fixed intervals for call arguments (sending and receiving)
John Leuner <jewel@subvert-the-dominant-paradigm.net>
parents: 1001
diff changeset
12 else
324463b1cac0 lots of messing around with fixed intervals for call arguments (sending and receiving)
John Leuner <jewel@subvert-the-dominant-paradigm.net>
parents: 1001
diff changeset
13 if (and (type? a 'lir-fixed-interval) (type? b 'lir-fixed-interval) (== a.ranges.start b.ranges.start))
324463b1cac0 lots of messing around with fixed intervals for call arguments (sending and receiving)
John Leuner <jewel@subvert-the-dominant-paradigm.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@subvert-the-dominant-paradigm.net>
parents: 1001
diff changeset
15 else
324463b1cac0 lots of messing around with fixed intervals for call arguments (sending and receiving)
John Leuner <jewel@subvert-the-dominant-paradigm.net>
parents: 1001
diff changeset
16 nil
324463b1cac0 lots of messing around with fixed intervals for call arguments (sending and receiving)
John Leuner <jewel@subvert-the-dominant-paradigm.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@subvert-the-dominant-paradigm.net>
parents:
diff changeset
18 class live-interval-list
1bb246ef3934 do basic linear scan register allocation on locals (use scc numbers as live interval indicators)
John Leuner <jewel@subvert-the-dominant-paradigm.net>
parents:
diff changeset
19 with-slots
1bb246ef3934 do basic linear scan register allocation on locals (use scc numbers as live interval indicators)
John Leuner <jewel@subvert-the-dominant-paradigm.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@subvert-the-dominant-paradigm.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@subvert-the-dominant-paradigm.net>
parents:
diff changeset
22 insert-after existing-li new-li
1bb246ef3934 do basic linear scan register allocation on locals (use scc numbers as live interval indicators)
John Leuner <jewel@subvert-the-dominant-paradigm.net>
parents:
diff changeset
23 if (eq? self.last existing-li)
1bb246ef3934 do basic linear scan register allocation on locals (use scc numbers as live interval indicators)
John Leuner <jewel@subvert-the-dominant-paradigm.net>
parents:
diff changeset
24 existing-li.next = new-li
1bb246ef3934 do basic linear scan register allocation on locals (use scc numbers as live interval indicators)
John Leuner <jewel@subvert-the-dominant-paradigm.net>
parents:
diff changeset
25 new-li.prev = existing-li
1bb246ef3934 do basic linear scan register allocation on locals (use scc numbers as live interval indicators)
John Leuner <jewel@subvert-the-dominant-paradigm.net>
parents:
diff changeset
26 new-li.next = nil
1bb246ef3934 do basic linear scan register allocation on locals (use scc numbers as live interval indicators)
John Leuner <jewel@subvert-the-dominant-paradigm.net>
parents:
diff changeset
27 self.last = new-li
1bb246ef3934 do basic linear scan register allocation on locals (use scc numbers as live interval indicators)
John Leuner <jewel@subvert-the-dominant-paradigm.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@subvert-the-dominant-paradigm.net>
parents:
diff changeset
29 new-li.next = existing-li.next
1bb246ef3934 do basic linear scan register allocation on locals (use scc numbers as live interval indicators)
John Leuner <jewel@subvert-the-dominant-paradigm.net>
parents:
diff changeset
30 existing-li.next = new-li
1bb246ef3934 do basic linear scan register allocation on locals (use scc numbers as live interval indicators)
John Leuner <jewel@subvert-the-dominant-paradigm.net>
parents:
diff changeset
31 new-li.prev = existing-li
1bb246ef3934 do basic linear scan register allocation on locals (use scc numbers as live interval indicators)
John Leuner <jewel@subvert-the-dominant-paradigm.net>
parents:
diff changeset
32 new-li.next.prev = new-li
1bb246ef3934 do basic linear scan register allocation on locals (use scc numbers as live interval indicators)
John Leuner <jewel@subvert-the-dominant-paradigm.net>
parents:
diff changeset
33 insert-before existing-li new-li
1bb246ef3934 do basic linear scan register allocation on locals (use scc numbers as live interval indicators)
John Leuner <jewel@subvert-the-dominant-paradigm.net>
parents:
diff changeset
34 if (eq? self.first existing-li)
1bb246ef3934 do basic linear scan register allocation on locals (use scc numbers as live interval indicators)
John Leuner <jewel@subvert-the-dominant-paradigm.net>
parents:
diff changeset
35 existing-li.prev = new-li
1bb246ef3934 do basic linear scan register allocation on locals (use scc numbers as live interval indicators)
John Leuner <jewel@subvert-the-dominant-paradigm.net>
parents:
diff changeset
36 new-li.next = existing-li
1bb246ef3934 do basic linear scan register allocation on locals (use scc numbers as live interval indicators)
John Leuner <jewel@subvert-the-dominant-paradigm.net>
parents:
diff changeset
37 new-li.prev = nil
1bb246ef3934 do basic linear scan register allocation on locals (use scc numbers as live interval indicators)
John Leuner <jewel@subvert-the-dominant-paradigm.net>
parents:
diff changeset
38 self.first = new-li
1bb246ef3934 do basic linear scan register allocation on locals (use scc numbers as live interval indicators)
John Leuner <jewel@subvert-the-dominant-paradigm.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@subvert-the-dominant-paradigm.net>
parents:
diff changeset
40 new-li.prev = existing-li.prev
1bb246ef3934 do basic linear scan register allocation on locals (use scc numbers as live interval indicators)
John Leuner <jewel@subvert-the-dominant-paradigm.net>
parents:
diff changeset
41 existing-li.prev = new-li
1bb246ef3934 do basic linear scan register allocation on locals (use scc numbers as live interval indicators)
John Leuner <jewel@subvert-the-dominant-paradigm.net>
parents:
diff changeset
42 new-li.next = existing-li
1bb246ef3934 do basic linear scan register allocation on locals (use scc numbers as live interval indicators)
John Leuner <jewel@subvert-the-dominant-paradigm.net>
parents:
diff changeset
43 new-li.prev.next = new-li
1bb246ef3934 do basic linear scan register allocation on locals (use scc numbers as live interval indicators)
John Leuner <jewel@subvert-the-dominant-paradigm.net>
parents:
diff changeset
44 add-increasing-start-point li
1017
f4c03e96159f add tail-call
John Leuner <jewel@subvert-the-dominant-paradigm.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@subvert-the-dominant-paradigm.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@subvert-the-dominant-paradigm.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@subvert-the-dominant-paradigm.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@subvert-the-dominant-paradigm.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@subvert-the-dominant-paradigm.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@subvert-the-dominant-paradigm.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@subvert-the-dominant-paradigm.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@subvert-the-dominant-paradigm.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@subvert-the-dominant-paradigm.net>
parents:
diff changeset
54 while (and (< iter.local.interval-begin li.local.interval-begin) (not (null? iter.next)))
1bb246ef3934 do basic linear scan register allocation on locals (use scc numbers as live interval indicators)
John Leuner <jewel@subvert-the-dominant-paradigm.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@subvert-the-dominant-paradigm.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@subvert-the-dominant-paradigm.net>
parents:
diff changeset
57
1bb246ef3934 do basic linear scan register allocation on locals (use scc numbers as live interval indicators)
John Leuner <jewel@subvert-the-dominant-paradigm.net>
parents:
diff changeset
58 if (< iter.local.interval-begin li.local.interval-begin)
1bb246ef3934 do basic linear scan register allocation on locals (use scc numbers as live interval indicators)
John Leuner <jewel@subvert-the-dominant-paradigm.net>
parents:
diff changeset
59 insert-after self iter li
1bb246ef3934 do basic linear scan register allocation on locals (use scc numbers as live interval indicators)
John Leuner <jewel@subvert-the-dominant-paradigm.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@subvert-the-dominant-paradigm.net>
parents:
diff changeset
61 insert-before self iter li
1bb246ef3934 do basic linear scan register allocation on locals (use scc numbers as live interval indicators)
John Leuner <jewel@subvert-the-dominant-paradigm.net>
parents:
diff changeset
62 1
1015
36e7992480d0 emit code for scc based allocator
John Leuner <jewel@subvert-the-dominant-paradigm.net>
parents: 1013
diff changeset
63 add-increasing-start-point-new li
36e7992480d0 emit code for scc based allocator
John Leuner <jewel@subvert-the-dominant-paradigm.net>
parents: 1013
diff changeset
64 if (null? self.first)
36e7992480d0 emit code for scc based allocator
John Leuner <jewel@subvert-the-dominant-paradigm.net>
parents: 1013
diff changeset
65 self.first = li
36e7992480d0 emit code for scc based allocator
John Leuner <jewel@subvert-the-dominant-paradigm.net>
parents: 1013
diff changeset
66 self.last = li
36e7992480d0 emit code for scc based allocator
John Leuner <jewel@subvert-the-dominant-paradigm.net>
parents: 1013
diff changeset
67 li.prev = nil
36e7992480d0 emit code for scc based allocator
John Leuner <jewel@subvert-the-dominant-paradigm.net>
parents: 1013
diff changeset
68 li.next = nil
36e7992480d0 emit code for scc based allocator
John Leuner <jewel@subvert-the-dominant-paradigm.net>
parents: 1013
diff changeset
69 else
36e7992480d0 emit code for scc based allocator
John Leuner <jewel@subvert-the-dominant-paradigm.net>
parents: 1013
diff changeset
70 iter = self.first
36e7992480d0 emit code for scc based allocator
John Leuner <jewel@subvert-the-dominant-paradigm.net>
parents: 1013
diff changeset
71 loop
36e7992480d0 emit code for scc based allocator
John Leuner <jewel@subvert-the-dominant-paradigm.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@subvert-the-dominant-paradigm.net>
parents: 1013
diff changeset
73 do
36e7992480d0 emit code for scc based allocator
John Leuner <jewel@subvert-the-dominant-paradigm.net>
parents: 1013
diff changeset
74 iter = iter.next
36e7992480d0 emit code for scc based allocator
John Leuner <jewel@subvert-the-dominant-paradigm.net>
parents: 1013
diff changeset
75
36e7992480d0 emit code for scc based allocator
John Leuner <jewel@subvert-the-dominant-paradigm.net>
parents: 1013
diff changeset
76 if (< (start iter.interval) (start li.interval))
36e7992480d0 emit code for scc based allocator
John Leuner <jewel@subvert-the-dominant-paradigm.net>
parents: 1013
diff changeset
77 insert-after self iter li
36e7992480d0 emit code for scc based allocator
John Leuner <jewel@subvert-the-dominant-paradigm.net>
parents: 1013
diff changeset
78 else
36e7992480d0 emit code for scc based allocator
John Leuner <jewel@subvert-the-dominant-paradigm.net>
parents: 1013
diff changeset
79 insert-before self iter li
36e7992480d0 emit code for scc based allocator
John Leuner <jewel@subvert-the-dominant-paradigm.net>
parents: 1013
diff changeset
80 1
36e7992480d0 emit code for scc based allocator
John Leuner <jewel@subvert-the-dominant-paradigm.net>
parents: 1013
diff changeset
81 add-increasing-end-point-new li
36e7992480d0 emit code for scc based allocator
John Leuner <jewel@subvert-the-dominant-paradigm.net>
parents: 1013
diff changeset
82 if (null? self.first)
36e7992480d0 emit code for scc based allocator
John Leuner <jewel@subvert-the-dominant-paradigm.net>
parents: 1013
diff changeset
83 self.first = li
36e7992480d0 emit code for scc based allocator
John Leuner <jewel@subvert-the-dominant-paradigm.net>
parents: 1013
diff changeset
84 self.last = li
36e7992480d0 emit code for scc based allocator
John Leuner <jewel@subvert-the-dominant-paradigm.net>
parents: 1013
diff changeset
85 li.prev = nil
36e7992480d0 emit code for scc based allocator
John Leuner <jewel@subvert-the-dominant-paradigm.net>
parents: 1013
diff changeset
86 li.next = nil
36e7992480d0 emit code for scc based allocator
John Leuner <jewel@subvert-the-dominant-paradigm.net>
parents: 1013
diff changeset
87 else
36e7992480d0 emit code for scc based allocator
John Leuner <jewel@subvert-the-dominant-paradigm.net>
parents: 1013
diff changeset
88 iter = self.first
36e7992480d0 emit code for scc based allocator
John Leuner <jewel@subvert-the-dominant-paradigm.net>
parents: 1013
diff changeset
89 loop
36e7992480d0 emit code for scc based allocator
John Leuner <jewel@subvert-the-dominant-paradigm.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@subvert-the-dominant-paradigm.net>
parents: 1013
diff changeset
91 do
36e7992480d0 emit code for scc based allocator
John Leuner <jewel@subvert-the-dominant-paradigm.net>
parents: 1013
diff changeset
92 iter = iter.next
36e7992480d0 emit code for scc based allocator
John Leuner <jewel@subvert-the-dominant-paradigm.net>
parents: 1013
diff changeset
93
36e7992480d0 emit code for scc based allocator
John Leuner <jewel@subvert-the-dominant-paradigm.net>
parents: 1013
diff changeset
94 if (< (end iter.interval) (end li.interval))
36e7992480d0 emit code for scc based allocator
John Leuner <jewel@subvert-the-dominant-paradigm.net>
parents: 1013
diff changeset
95 insert-after self iter li
36e7992480d0 emit code for scc based allocator
John Leuner <jewel@subvert-the-dominant-paradigm.net>
parents: 1013
diff changeset
96 else
36e7992480d0 emit code for scc based allocator
John Leuner <jewel@subvert-the-dominant-paradigm.net>
parents: 1013
diff changeset
97 insert-before self iter li
36e7992480d0 emit code for scc based allocator
John Leuner <jewel@subvert-the-dominant-paradigm.net>
parents: 1013
diff changeset
98 1
988
686b07d79691 add new LIR representation, implement Wimmers Linear Scan allocator
John Leuner <jewel@subvert-the-dominant-paradigm.net>
parents: 985
diff changeset
99 add-lir-increasing-start-point li
686b07d79691 add new LIR representation, implement Wimmers Linear Scan allocator
John Leuner <jewel@subvert-the-dominant-paradigm.net>
parents: 985
diff changeset
100 if (null? self.first)
686b07d79691 add new LIR representation, implement Wimmers Linear Scan allocator
John Leuner <jewel@subvert-the-dominant-paradigm.net>
parents: 985
diff changeset
101 self.first = li
686b07d79691 add new LIR representation, implement Wimmers Linear Scan allocator
John Leuner <jewel@subvert-the-dominant-paradigm.net>
parents: 985
diff changeset
102 self.last = li
686b07d79691 add new LIR representation, implement Wimmers Linear Scan allocator
John Leuner <jewel@subvert-the-dominant-paradigm.net>
parents: 985
diff changeset
103 li.prev = nil
686b07d79691 add new LIR representation, implement Wimmers Linear Scan allocator
John Leuner <jewel@subvert-the-dominant-paradigm.net>
parents: 985
diff changeset
104 li.next = nil
686b07d79691 add new LIR representation, implement Wimmers Linear Scan allocator
John Leuner <jewel@subvert-the-dominant-paradigm.net>
parents: 985
diff changeset
105 else
686b07d79691 add new LIR representation, implement Wimmers Linear Scan allocator
John Leuner <jewel@subvert-the-dominant-paradigm.net>
parents: 985
diff changeset
106 iter = self.first
686b07d79691 add new LIR representation, implement Wimmers Linear Scan allocator
John Leuner <jewel@subvert-the-dominant-paradigm.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@subvert-the-dominant-paradigm.net>
parents: 1001
diff changeset
108 while (and (interval-starts-before? iter.interval li.interval) (not (null? iter.next)))
988
686b07d79691 add new LIR representation, implement Wimmers Linear Scan allocator
John Leuner <jewel@subvert-the-dominant-paradigm.net>
parents: 985
diff changeset
109 do
686b07d79691 add new LIR representation, implement Wimmers Linear Scan allocator
John Leuner <jewel@subvert-the-dominant-paradigm.net>
parents: 985
diff changeset
110 iter = iter.next
686b07d79691 add new LIR representation, implement Wimmers Linear Scan allocator
John Leuner <jewel@subvert-the-dominant-paradigm.net>
parents: 985
diff changeset
111
1004
324463b1cac0 lots of messing around with fixed intervals for call arguments (sending and receiving)
John Leuner <jewel@subvert-the-dominant-paradigm.net>
parents: 1001
diff changeset
112 if (interval-starts-before? iter.interval li.interval)
988
686b07d79691 add new LIR representation, implement Wimmers Linear Scan allocator
John Leuner <jewel@subvert-the-dominant-paradigm.net>
parents: 985
diff changeset
113 insert-after self iter li
686b07d79691 add new LIR representation, implement Wimmers Linear Scan allocator
John Leuner <jewel@subvert-the-dominant-paradigm.net>
parents: 985
diff changeset
114 else
686b07d79691 add new LIR representation, implement Wimmers Linear Scan allocator
John Leuner <jewel@subvert-the-dominant-paradigm.net>
parents: 985
diff changeset
115 insert-before self iter li
686b07d79691 add new LIR representation, implement Wimmers Linear Scan allocator
John Leuner <jewel@subvert-the-dominant-paradigm.net>
parents: 985
diff changeset
116 1
991
3c09511d9bf9 filter / keep
John Leuner <jewel@subvert-the-dominant-paradigm.net>
parents: 988
diff changeset
117 map-lir-list proc
3c09511d9bf9 filter / keep
John Leuner <jewel@subvert-the-dominant-paradigm.net>
parents: 988
diff changeset
118 iter = self.first
3c09511d9bf9 filter / keep
John Leuner <jewel@subvert-the-dominant-paradigm.net>
parents: 988
diff changeset
119 loop
3c09511d9bf9 filter / keep
John Leuner <jewel@subvert-the-dominant-paradigm.net>
parents: 988
diff changeset
120 while iter
3c09511d9bf9 filter / keep
John Leuner <jewel@subvert-the-dominant-paradigm.net>
parents: 988
diff changeset
121 do
3c09511d9bf9 filter / keep
John Leuner <jewel@subvert-the-dominant-paradigm.net>
parents: 988
diff changeset
122 apply proc iter.interval
3c09511d9bf9 filter / keep
John Leuner <jewel@subvert-the-dominant-paradigm.net>
parents: 988
diff changeset
123 iter = iter.next
3c09511d9bf9 filter / keep
John Leuner <jewel@subvert-the-dominant-paradigm.net>
parents: 988
diff changeset
124
3c09511d9bf9 filter / keep
John Leuner <jewel@subvert-the-dominant-paradigm.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@subvert-the-dominant-paradigm.net>
parents:
diff changeset
126 add-increasing-end-point li
1bb246ef3934 do basic linear scan register allocation on locals (use scc numbers as live interval indicators)
John Leuner <jewel@subvert-the-dominant-paradigm.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@subvert-the-dominant-paradigm.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@subvert-the-dominant-paradigm.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@subvert-the-dominant-paradigm.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@subvert-the-dominant-paradigm.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@subvert-the-dominant-paradigm.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@subvert-the-dominant-paradigm.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@subvert-the-dominant-paradigm.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@subvert-the-dominant-paradigm.net>
parents:
diff changeset
135 while (and (< iter.local.interval-end li.local.interval-end) (not (null? iter.next)))
1bb246ef3934 do basic linear scan register allocation on locals (use scc numbers as live interval indicators)
John Leuner <jewel@subvert-the-dominant-paradigm.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@subvert-the-dominant-paradigm.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@subvert-the-dominant-paradigm.net>
parents:
diff changeset
138
1bb246ef3934 do basic linear scan register allocation on locals (use scc numbers as live interval indicators)
John Leuner <jewel@subvert-the-dominant-paradigm.net>
parents:
diff changeset
139 if (< iter.local.interval-end li.local.interval-end)
1bb246ef3934 do basic linear scan register allocation on locals (use scc numbers as live interval indicators)
John Leuner <jewel@subvert-the-dominant-paradigm.net>
parents:
diff changeset
140 insert-after self iter li
1bb246ef3934 do basic linear scan register allocation on locals (use scc numbers as live interval indicators)
John Leuner <jewel@subvert-the-dominant-paradigm.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@subvert-the-dominant-paradigm.net>
parents:
diff changeset
142 insert-before self iter li
1bb246ef3934 do basic linear scan register allocation on locals (use scc numbers as live interval indicators)
John Leuner <jewel@subvert-the-dominant-paradigm.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@subvert-the-dominant-paradigm.net>
parents:
diff changeset
144 remove-list-element li
1bb246ef3934 do basic linear scan register allocation on locals (use scc numbers as live interval indicators)
John Leuner <jewel@subvert-the-dominant-paradigm.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@subvert-the-dominant-paradigm.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@subvert-the-dominant-paradigm.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@subvert-the-dominant-paradigm.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@subvert-the-dominant-paradigm.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@subvert-the-dominant-paradigm.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@subvert-the-dominant-paradigm.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@subvert-the-dominant-paradigm.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@subvert-the-dominant-paradigm.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@subvert-the-dominant-paradigm.net>
parents:
diff changeset
154
1bb246ef3934 do basic linear scan register allocation on locals (use scc numbers as live interval indicators)
John Leuner <jewel@subvert-the-dominant-paradigm.net>
parents:
diff changeset
155
988
686b07d79691 add new LIR representation, implement Wimmers Linear Scan allocator
John Leuner <jewel@subvert-the-dominant-paradigm.net>
parents: 985
diff changeset
156 ;--------------------------------------------------------------------------------
686b07d79691 add new LIR representation, implement Wimmers Linear Scan allocator
John Leuner <jewel@subvert-the-dominant-paradigm.net>
parents: 985
diff changeset
157 ; Allocate registers (LIR)
686b07d79691 add new LIR representation, implement Wimmers Linear Scan allocator
John Leuner <jewel@subvert-the-dominant-paradigm.net>
parents: 985
diff changeset
158
1004
324463b1cac0 lots of messing around with fixed intervals for call arguments (sending and receiving)
John Leuner <jewel@subvert-the-dominant-paradigm.net>
parents: 1001
diff changeset
159 extern NUM-PHYSICAL-REGS
999
8997dd2656d6 extend machine code pass to load and store to spill slots
John Leuner <jewel@subvert-the-dominant-paradigm.net>
parents: 995
diff changeset
160
1025
5c8991b36582 integrate fixed intervals for call arguments
John Leuner <jewel@subvert-the-dominant-paradigm.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@subvert-the-dominant-paradigm.net>
parents: 1013
diff changeset
162
1025
5c8991b36582 integrate fixed intervals for call arguments
John Leuner <jewel@subvert-the-dominant-paradigm.net>
parents: 1023
diff changeset
163 global NUM-RESERVED-SPILL-SLOTS = 4
1015
36e7992480d0 emit code for scc based allocator
John Leuner <jewel@subvert-the-dominant-paradigm.net>
parents: 1013
diff changeset
164
36e7992480d0 emit code for scc based allocator
John Leuner <jewel@subvert-the-dominant-paradigm.net>
parents: 1013
diff changeset
165 ;--------------------------------------------------------------------------------
36e7992480d0 emit code for scc based allocator
John Leuner <jewel@subvert-the-dominant-paradigm.net>
parents: 1013
diff changeset
166 ; SCC based register allocation
36e7992480d0 emit code for scc based allocator
John Leuner <jewel@subvert-the-dominant-paradigm.net>
parents: 1013
diff changeset
167
988
686b07d79691 add new LIR representation, implement Wimmers Linear Scan allocator
John Leuner <jewel@subvert-the-dominant-paradigm.net>
parents: 985
diff changeset
168 pass4-lir-allocate-registers method-contexts
1019
4d2a41144f33 add support for a try catch construct
John Leuner <jewel@subvert-the-dominant-paradigm.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@subvert-the-dominant-paradigm.net>
parents: 985
diff changeset
170 loop
686b07d79691 add new LIR representation, implement Wimmers Linear Scan allocator
John Leuner <jewel@subvert-the-dominant-paradigm.net>
parents: 985
diff changeset
171 for m in method-contexts
686b07d79691 add new LIR representation, implement Wimmers Linear Scan allocator
John Leuner <jewel@subvert-the-dominant-paradigm.net>
parents: 985
diff changeset
172 do
686b07d79691 add new LIR representation, implement Wimmers Linear Scan allocator
John Leuner <jewel@subvert-the-dominant-paradigm.net>
parents: 985
diff changeset
173 lir-function = m.lir-function
1015
36e7992480d0 emit code for scc based allocator
John Leuner <jewel@subvert-the-dominant-paradigm.net>
parents: 1013
diff changeset
174 next-fixed-reg = 1
36e7992480d0 emit code for scc based allocator
John Leuner <jewel@subvert-the-dominant-paradigm.net>
parents: 1013
diff changeset
175 loop
36e7992480d0 emit code for scc based allocator
John Leuner <jewel@subvert-the-dominant-paradigm.net>
parents: 1013
diff changeset
176 for vreg across lir-function.fixed-vregs
36e7992480d0 emit code for scc based allocator
John Leuner <jewel@subvert-the-dominant-paradigm.net>
parents: 1013
diff changeset
177 do
36e7992480d0 emit code for scc based allocator
John Leuner <jewel@subvert-the-dominant-paradigm.net>
parents: 1013
diff changeset
178 if (and vreg.first-interval (not (lir-unused-vreg? vreg)))
36e7992480d0 emit code for scc based allocator
John Leuner <jewel@subvert-the-dominant-paradigm.net>
parents: 1013
diff changeset
179 vreg.first-interval.register = next-fixed-reg
36e7992480d0 emit code for scc based allocator
John Leuner <jewel@subvert-the-dominant-paradigm.net>
parents: 1013
diff changeset
180 next-fixed-reg = * next-fixed-reg 2
36e7992480d0 emit code for scc based allocator
John Leuner <jewel@subvert-the-dominant-paradigm.net>
parents: 1013
diff changeset
181
1027
2868fb888d1b flesh out test suite
John Leuner <jewel@subvert-the-dominant-paradigm.net>
parents: 1025
diff changeset
182 print "--------------------------------------------------------------------------------"
2868fb888d1b flesh out test suite
John Leuner <jewel@subvert-the-dominant-paradigm.net>
parents: 1025
diff changeset
183 print m.name
2868fb888d1b flesh out test suite
John Leuner <jewel@subvert-the-dominant-paradigm.net>
parents: 1025
diff changeset
184 print "--------------------------------------------------------------------------------"
1015
36e7992480d0 emit code for scc based allocator
John Leuner <jewel@subvert-the-dominant-paradigm.net>
parents: 1013
diff changeset
185 print "before allocation ----------------------------------------"
36e7992480d0 emit code for scc based allocator
John Leuner <jewel@subvert-the-dominant-paradigm.net>
parents: 1013
diff changeset
186 loop
36e7992480d0 emit code for scc based allocator
John Leuner <jewel@subvert-the-dominant-paradigm.net>
parents: 1013
diff changeset
187 for vreg across lir-function.vregs
36e7992480d0 emit code for scc based allocator
John Leuner <jewel@subvert-the-dominant-paradigm.net>
parents: 1013
diff changeset
188 do
36e7992480d0 emit code for scc based allocator
John Leuner <jewel@subvert-the-dominant-paradigm.net>
parents: 1013
diff changeset
189 out vreg
36e7992480d0 emit code for scc based allocator
John Leuner <jewel@subvert-the-dominant-paradigm.net>
parents: 1013
diff changeset
190 out " ("
1025
5c8991b36582 integrate fixed intervals for call arguments
John Leuner <jewel@subvert-the-dominant-paradigm.net>
parents: 1023
diff changeset
191 if (type? vreg.first-interval 'lir-fixed-interval)
5c8991b36582 integrate fixed intervals for call arguments
John Leuner <jewel@subvert-the-dominant-paradigm.net>
parents: 1023
diff changeset
192 out "F "
5c8991b36582 integrate fixed intervals for call arguments
John Leuner <jewel@subvert-the-dominant-paradigm.net>
parents: 1023
diff changeset
193 else
5c8991b36582 integrate fixed intervals for call arguments
John Leuner <jewel@subvert-the-dominant-paradigm.net>
parents: 1023
diff changeset
194 out vreg.first-interval.spill-slot-index
1015
36e7992480d0 emit code for scc based allocator
John Leuner <jewel@subvert-the-dominant-paradigm.net>
parents: 1013
diff changeset
195 out ") "
36e7992480d0 emit code for scc based allocator
John Leuner <jewel@subvert-the-dominant-paradigm.net>
parents: 1013
diff changeset
196 print vreg.first-interval.register
36e7992480d0 emit code for scc based allocator
John Leuner <jewel@subvert-the-dominant-paradigm.net>
parents: 1013
diff changeset
197
1027
2868fb888d1b flesh out test suite
John Leuner <jewel@subvert-the-dominant-paradigm.net>
parents: 1025
diff changeset
198 allocate-registers-scc lir-function m.name
1004
324463b1cac0 lots of messing around with fixed intervals for call arguments (sending and receiving)
John Leuner <jewel@subvert-the-dominant-paradigm.net>
parents: 1001
diff changeset
199 print "final register allocation --------------------------------------------------------------------------------"
1015
36e7992480d0 emit code for scc based allocator
John Leuner <jewel@subvert-the-dominant-paradigm.net>
parents: 1013
diff changeset
200 loop
36e7992480d0 emit code for scc based allocator
John Leuner <jewel@subvert-the-dominant-paradigm.net>
parents: 1013
diff changeset
201 for vreg across lir-function.vregs
36e7992480d0 emit code for scc based allocator
John Leuner <jewel@subvert-the-dominant-paradigm.net>
parents: 1013
diff changeset
202 do
36e7992480d0 emit code for scc based allocator
John Leuner <jewel@subvert-the-dominant-paradigm.net>
parents: 1013
diff changeset
203 out vreg
36e7992480d0 emit code for scc based allocator
John Leuner <jewel@subvert-the-dominant-paradigm.net>
parents: 1013
diff changeset
204 out " ("
1025
5c8991b36582 integrate fixed intervals for call arguments
John Leuner <jewel@subvert-the-dominant-paradigm.net>
parents: 1023
diff changeset
205 if (type? vreg.first-interval 'lir-fixed-interval)
5c8991b36582 integrate fixed intervals for call arguments
John Leuner <jewel@subvert-the-dominant-paradigm.net>
parents: 1023
diff changeset
206 out "F "
5c8991b36582 integrate fixed intervals for call arguments
John Leuner <jewel@subvert-the-dominant-paradigm.net>
parents: 1023
diff changeset
207 else
5c8991b36582 integrate fixed intervals for call arguments
John Leuner <jewel@subvert-the-dominant-paradigm.net>
parents: 1023
diff changeset
208 out vreg.first-interval.spill-slot-index
1015
36e7992480d0 emit code for scc based allocator
John Leuner <jewel@subvert-the-dominant-paradigm.net>
parents: 1013
diff changeset
209 out ") "
36e7992480d0 emit code for scc based allocator
John Leuner <jewel@subvert-the-dominant-paradigm.net>
parents: 1013
diff changeset
210 print vreg.first-interval.register
36e7992480d0 emit code for scc based allocator
John Leuner <jewel@subvert-the-dominant-paradigm.net>
parents: 1013
diff changeset
211
988
686b07d79691 add new LIR representation, implement Wimmers Linear Scan allocator
John Leuner <jewel@subvert-the-dominant-paradigm.net>
parents: 985
diff changeset
212
1019
4d2a41144f33 add support for a try catch construct
John Leuner <jewel@subvert-the-dominant-paradigm.net>
parents: 1018
diff changeset
213
988
686b07d79691 add new LIR representation, implement Wimmers Linear Scan allocator
John Leuner <jewel@subvert-the-dominant-paradigm.net>
parents: 985
diff changeset
214 'done
686b07d79691 add new LIR representation, implement Wimmers Linear Scan allocator
John Leuner <jewel@subvert-the-dominant-paradigm.net>
parents: 985
diff changeset
215
686b07d79691 add new LIR representation, implement Wimmers Linear Scan allocator
John Leuner <jewel@subvert-the-dominant-paradigm.net>
parents: 985
diff changeset
216
1027
2868fb888d1b flesh out test suite
John Leuner <jewel@subvert-the-dominant-paradigm.net>
parents: 1025
diff changeset
217 allocate-registers-scc lir-function function-name
1015
36e7992480d0 emit code for scc based allocator
John Leuner <jewel@subvert-the-dominant-paradigm.net>
parents: 1013
diff changeset
218 free-regs = new 'baste-register-set
36e7992480d0 emit code for scc based allocator
John Leuner <jewel@subvert-the-dominant-paradigm.net>
parents: 1013
diff changeset
219 ; reserve the fixed regs
988
686b07d79691 add new LIR representation, implement Wimmers Linear Scan allocator
John Leuner <jewel@subvert-the-dominant-paradigm.net>
parents: 985
diff changeset
220 loop
1015
36e7992480d0 emit code for scc based allocator
John Leuner <jewel@subvert-the-dominant-paradigm.net>
parents: 1013
diff changeset
221 for vreg across lir-function.fixed-vregs
988
686b07d79691 add new LIR representation, implement Wimmers Linear Scan allocator
John Leuner <jewel@subvert-the-dominant-paradigm.net>
parents: 985
diff changeset
222 do
1015
36e7992480d0 emit code for scc based allocator
John Leuner <jewel@subvert-the-dominant-paradigm.net>
parents: 1013
diff changeset
223 if vreg.first-interval.register
36e7992480d0 emit code for scc based allocator
John Leuner <jewel@subvert-the-dominant-paradigm.net>
parents: 1013
diff changeset
224 allocate-specific-register free-regs vreg.first-interval.register
988
686b07d79691 add new LIR representation, implement Wimmers Linear Scan allocator
John Leuner <jewel@subvert-the-dominant-paradigm.net>
parents: 985
diff changeset
225
1017
f4c03e96159f add tail-call
John Leuner <jewel@subvert-the-dominant-paradigm.net>
parents: 1015
diff changeset
226 spill-slot-index = NUM-RESERVED-SPILL-SLOTS
1015
36e7992480d0 emit code for scc based allocator
John Leuner <jewel@subvert-the-dominant-paradigm.net>
parents: 1013
diff changeset
227 print "live intervals"
36e7992480d0 emit code for scc based allocator
John Leuner <jewel@subvert-the-dominant-paradigm.net>
parents: 1013
diff changeset
228 ; collect intervals into the unhandled list
36e7992480d0 emit code for scc based allocator
John Leuner <jewel@subvert-the-dominant-paradigm.net>
parents: 1013
diff changeset
229 live = new 'live-interval-list
36e7992480d0 emit code for scc based allocator
John Leuner <jewel@subvert-the-dominant-paradigm.net>
parents: 1013
diff changeset
230 completed = new 'live-interval-list
1017
f4c03e96159f add tail-call
John Leuner <jewel@subvert-the-dominant-paradigm.net>
parents: 1015
diff changeset
231 ; print "live intervals"
f4c03e96159f add tail-call
John Leuner <jewel@subvert-the-dominant-paradigm.net>
parents: 1015
diff changeset
232 ; print lir-function
1015
36e7992480d0 emit code for scc based allocator
John Leuner <jewel@subvert-the-dominant-paradigm.net>
parents: 1013
diff changeset
233 loop
36e7992480d0 emit code for scc based allocator
John Leuner <jewel@subvert-the-dominant-paradigm.net>
parents: 1013
diff changeset
234 for vreg across lir-function.vregs
36e7992480d0 emit code for scc based allocator
John Leuner <jewel@subvert-the-dominant-paradigm.net>
parents: 1013
diff changeset
235 do
36e7992480d0 emit code for scc based allocator
John Leuner <jewel@subvert-the-dominant-paradigm.net>
parents: 1013
diff changeset
236 if (not (lir-unused-vreg? vreg))
36e7992480d0 emit code for scc based allocator
John Leuner <jewel@subvert-the-dominant-paradigm.net>
parents: 1013
diff changeset
237 add-increasing-start-point-new live (new 'live-interval-list-element :interval vreg.first-interval :local vreg)
988
686b07d79691 add new LIR representation, implement Wimmers Linear Scan allocator
John Leuner <jewel@subvert-the-dominant-paradigm.net>
parents: 985
diff changeset
238
1015
36e7992480d0 emit code for scc based allocator
John Leuner <jewel@subvert-the-dominant-paradigm.net>
parents: 1013
diff changeset
239 print "done live intervals"
36e7992480d0 emit code for scc based allocator
John Leuner <jewel@subvert-the-dominant-paradigm.net>
parents: 1013
diff changeset
240 dump-intervals live
36e7992480d0 emit code for scc based allocator
John Leuner <jewel@subvert-the-dominant-paradigm.net>
parents: 1013
diff changeset
241 active = new 'live-interval-list
36e7992480d0 emit code for scc based allocator
John Leuner <jewel@subvert-the-dominant-paradigm.net>
parents: 1013
diff changeset
242 ; for each interval
36e7992480d0 emit code for scc based allocator
John Leuner <jewel@subvert-the-dominant-paradigm.net>
parents: 1013
diff changeset
243 li = live.first
988
686b07d79691 add new LIR representation, implement Wimmers Linear Scan allocator
John Leuner <jewel@subvert-the-dominant-paradigm.net>
parents: 985
diff changeset
244 loop
1015
36e7992480d0 emit code for scc based allocator
John Leuner <jewel@subvert-the-dominant-paradigm.net>
parents: 1013
diff changeset
245 while li
988
686b07d79691 add new LIR representation, implement Wimmers Linear Scan allocator
John Leuner <jewel@subvert-the-dominant-paradigm.net>
parents: 985
diff changeset
246 do
1015
36e7992480d0 emit code for scc based allocator
John Leuner <jewel@subvert-the-dominant-paradigm.net>
parents: 1013
diff changeset
247 current = li.interval
36e7992480d0 emit code for scc based allocator
John Leuner <jewel@subvert-the-dominant-paradigm.net>
parents: 1013
diff changeset
248 ; expire active intervals that end before current
36e7992480d0 emit code for scc based allocator
John Leuner <jewel@subvert-the-dominant-paradigm.net>
parents: 1013
diff changeset
249 ai = active.first
36e7992480d0 emit code for scc based allocator
John Leuner <jewel@subvert-the-dominant-paradigm.net>
parents: 1013
diff changeset
250 loop
36e7992480d0 emit code for scc based allocator
John Leuner <jewel@subvert-the-dominant-paradigm.net>
parents: 1013
diff changeset
251 while ai
36e7992480d0 emit code for scc based allocator
John Leuner <jewel@subvert-the-dominant-paradigm.net>
parents: 1013
diff changeset
252 do
36e7992480d0 emit code for scc based allocator
John Leuner <jewel@subvert-the-dominant-paradigm.net>
parents: 1013
diff changeset
253 if (< (end ai.interval) (start current))
36e7992480d0 emit code for scc based allocator
John Leuner <jewel@subvert-the-dominant-paradigm.net>
parents: 1013
diff changeset
254 completed-li = new 'live-interval-list-element :interval ai.interval :local ai.local
36e7992480d0 emit code for scc based allocator
John Leuner <jewel@subvert-the-dominant-paradigm.net>
parents: 1013
diff changeset
255 remove-list-element active ai
36e7992480d0 emit code for scc based allocator
John Leuner <jewel@subvert-the-dominant-paradigm.net>
parents: 1013
diff changeset
256 add-increasing-start-point-new completed completed-li
36e7992480d0 emit code for scc based allocator
John Leuner <jewel@subvert-the-dominant-paradigm.net>
parents: 1013
diff changeset
257 free-register free-regs ai.interval.register
36e7992480d0 emit code for scc based allocator
John Leuner <jewel@subvert-the-dominant-paradigm.net>
parents: 1013
diff changeset
258 ai = ai.next
1013
ac8bce46cb1e experiment with spill handling in loops
John Leuner <jewel@subvert-the-dominant-paradigm.net>
parents: 1011
diff changeset
259
1025
5c8991b36582 integrate fixed intervals for call arguments
John Leuner <jewel@subvert-the-dominant-paradigm.net>
parents: 1023
diff changeset
260 if (and (not current.vreg.must-spill?) (empty? free-regs) (not current.register))
1015
36e7992480d0 emit code for scc based allocator
John Leuner <jewel@subvert-the-dominant-paradigm.net>
parents: 1013
diff changeset
261 ; should we spill another interval instead ?
1017
f4c03e96159f add tail-call
John Leuner <jewel@subvert-the-dominant-paradigm.net>
parents: 1015
diff changeset
262 ; print "spill"
1015
36e7992480d0 emit code for scc based allocator
John Leuner <jewel@subvert-the-dominant-paradigm.net>
parents: 1013
diff changeset
263 spill-interval = active.last
1025
5c8991b36582 integrate fixed intervals for call arguments
John Leuner <jewel@subvert-the-dominant-paradigm.net>
parents: 1023
diff changeset
264 ; cannot spill a fixed interval
5c8991b36582 integrate fixed intervals for call arguments
John Leuner <jewel@subvert-the-dominant-paradigm.net>
parents: 1023
diff changeset
265 if (type? spill-interval 'lir-fixed-interval)
5c8991b36582 integrate fixed intervals for call arguments
John Leuner <jewel@subvert-the-dominant-paradigm.net>
parents: 1023
diff changeset
266 spill-interval = nil
1017
f4c03e96159f add tail-call
John Leuner <jewel@subvert-the-dominant-paradigm.net>
parents: 1015
diff changeset
267 ; print spill-interval
1015
36e7992480d0 emit code for scc based allocator
John Leuner <jewel@subvert-the-dominant-paradigm.net>
parents: 1013
diff changeset
268 if (and spill-interval (> (end spill-interval.interval) (end current)))
1025
5c8991b36582 integrate fixed intervals for call arguments
John Leuner <jewel@subvert-the-dominant-paradigm.net>
parents: 1023
diff changeset
269 ; out "spilling interval "
5c8991b36582 integrate fixed intervals for call arguments
John Leuner <jewel@subvert-the-dominant-paradigm.net>
parents: 1023
diff changeset
270 ; out (lir-arg-to-string spill-interval.interval.vreg)
5c8991b36582 integrate fixed intervals for call arguments
John Leuner <jewel@subvert-the-dominant-paradigm.net>
parents: 1023
diff changeset
271 ; out " with reg "
5c8991b36582 integrate fixed intervals for call arguments
John Leuner <jewel@subvert-the-dominant-paradigm.net>
parents: 1023
diff changeset
272 ; out spill-interval.interval.register
5c8991b36582 integrate fixed intervals for call arguments
John Leuner <jewel@subvert-the-dominant-paradigm.net>
parents: 1023
diff changeset
273 ; out " for "
5c8991b36582 integrate fixed intervals for call arguments
John Leuner <jewel@subvert-the-dominant-paradigm.net>
parents: 1023
diff changeset
274 ; print (lir-arg-to-string current.vreg)
1015
36e7992480d0 emit code for scc based allocator
John Leuner <jewel@subvert-the-dominant-paradigm.net>
parents: 1013
diff changeset
275 current.register = spill-interval.interval.register
36e7992480d0 emit code for scc based allocator
John Leuner <jewel@subvert-the-dominant-paradigm.net>
parents: 1013
diff changeset
276 spill-interval.interval.spill-slot-index = spill-slot-index
1017
f4c03e96159f add tail-call
John Leuner <jewel@subvert-the-dominant-paradigm.net>
parents: 1015
diff changeset
277 add-increasing-start-point-new completed (new 'live-interval-list-element :interval spill-interval.interval :local spill-interval.interval.vreg)
1015
36e7992480d0 emit code for scc based allocator
John Leuner <jewel@subvert-the-dominant-paradigm.net>
parents: 1013
diff changeset
278 remove-list-element active spill-interval
36e7992480d0 emit code for scc based allocator
John Leuner <jewel@subvert-the-dominant-paradigm.net>
parents: 1013
diff changeset
279 spill-interval.interval.register = nil
36e7992480d0 emit code for scc based allocator
John Leuner <jewel@subvert-the-dominant-paradigm.net>
parents: 1013
diff changeset
280 else
36e7992480d0 emit code for scc based allocator
John Leuner <jewel@subvert-the-dominant-paradigm.net>
parents: 1013
diff changeset
281 ; spill current
36e7992480d0 emit code for scc based allocator
John Leuner <jewel@subvert-the-dominant-paradigm.net>
parents: 1013
diff changeset
282 current.spill-slot-index = spill-slot-index
1017
f4c03e96159f add tail-call
John Leuner <jewel@subvert-the-dominant-paradigm.net>
parents: 1015
diff changeset
283 add-increasing-start-point-new completed (new 'live-interval-list-element :interval current :local current.vreg)
1015
36e7992480d0 emit code for scc based allocator
John Leuner <jewel@subvert-the-dominant-paradigm.net>
parents: 1013
diff changeset
284 spill-slot-index = + spill-slot-index 1
1013
ac8bce46cb1e experiment with spill handling in loops
John Leuner <jewel@subvert-the-dominant-paradigm.net>
parents: 1011
diff changeset
285 else
1019
4d2a41144f33 add support for a try catch construct
John Leuner <jewel@subvert-the-dominant-paradigm.net>
parents: 1018
diff changeset
286 if current.vreg.must-spill?
4d2a41144f33 add support for a try catch construct
John Leuner <jewel@subvert-the-dominant-paradigm.net>
parents: 1018
diff changeset
287 current.spill-slot-index = spill-slot-index
4d2a41144f33 add support for a try catch construct
John Leuner <jewel@subvert-the-dominant-paradigm.net>
parents: 1018
diff changeset
288 spill-slot-index = + spill-slot-index 1
4d2a41144f33 add support for a try catch construct
John Leuner <jewel@subvert-the-dominant-paradigm.net>
parents: 1018
diff changeset
289 add-increasing-start-point-new completed (new 'live-interval-list-element :interval current :local current.vreg)
993
10b7e19129e0 fine-tune interval splitting
John Leuner <jewel@subvert-the-dominant-paradigm.net>
parents: 992
diff changeset
290 else
1019
4d2a41144f33 add support for a try catch construct
John Leuner <jewel@subvert-the-dominant-paradigm.net>
parents: 1018
diff changeset
291 ; print "find reg"
4d2a41144f33 add support for a try catch construct
John Leuner <jewel@subvert-the-dominant-paradigm.net>
parents: 1018
diff changeset
292 ; print current
4d2a41144f33 add support for a try catch construct
John Leuner <jewel@subvert-the-dominant-paradigm.net>
parents: 1018
diff changeset
293 if current.register
4d2a41144f33 add support for a try catch construct
John Leuner <jewel@subvert-the-dominant-paradigm.net>
parents: 1018
diff changeset
294 ; register is already allocated
4d2a41144f33 add support for a try catch construct
John Leuner <jewel@subvert-the-dominant-paradigm.net>
parents: 1018
diff changeset
295 1
4d2a41144f33 add support for a try catch construct
John Leuner <jewel@subvert-the-dominant-paradigm.net>
parents: 1018
diff changeset
296 ; print "has reg"
4d2a41144f33 add support for a try catch construct
John Leuner <jewel@subvert-the-dominant-paradigm.net>
parents: 1018
diff changeset
297 else
4d2a41144f33 add support for a try catch construct
John Leuner <jewel@subvert-the-dominant-paradigm.net>
parents: 1018
diff changeset
298 reg = allocate-register free-regs
4d2a41144f33 add support for a try catch construct
John Leuner <jewel@subvert-the-dominant-paradigm.net>
parents: 1018
diff changeset
299 current.register = reg
4d2a41144f33 add support for a try catch construct
John Leuner <jewel@subvert-the-dominant-paradigm.net>
parents: 1018
diff changeset
300 ; make current active
4d2a41144f33 add support for a try catch construct
John Leuner <jewel@subvert-the-dominant-paradigm.net>
parents: 1018
diff changeset
301 add-increasing-end-point-new active (new 'live-interval-list-element :interval current :local current.vreg)
1015
36e7992480d0 emit code for scc based allocator
John Leuner <jewel@subvert-the-dominant-paradigm.net>
parents: 1013
diff changeset
302 li = li.next
1006
de72781e9bb1 use fixed intervals to calculate nextFreeUntilPos in try allocate reg
John Leuner <jewel@subvert-the-dominant-paradigm.net>
parents: 1005
diff changeset
303
1015
36e7992480d0 emit code for scc based allocator
John Leuner <jewel@subvert-the-dominant-paradigm.net>
parents: 1013
diff changeset
304 ; drain out remaining intervals
36e7992480d0 emit code for scc based allocator
John Leuner <jewel@subvert-the-dominant-paradigm.net>
parents: 1013
diff changeset
305 ai = active.first
988
686b07d79691 add new LIR representation, implement Wimmers Linear Scan allocator
John Leuner <jewel@subvert-the-dominant-paradigm.net>
parents: 985
diff changeset
306 loop
1015
36e7992480d0 emit code for scc based allocator
John Leuner <jewel@subvert-the-dominant-paradigm.net>
parents: 1013
diff changeset
307 while ai
988
686b07d79691 add new LIR representation, implement Wimmers Linear Scan allocator
John Leuner <jewel@subvert-the-dominant-paradigm.net>
parents: 985
diff changeset
308 do
1015
36e7992480d0 emit code for scc based allocator
John Leuner <jewel@subvert-the-dominant-paradigm.net>
parents: 1013
diff changeset
309 completed-li = new 'live-interval-list-element :interval ai.interval :local ai.local
36e7992480d0 emit code for scc based allocator
John Leuner <jewel@subvert-the-dominant-paradigm.net>
parents: 1013
diff changeset
310 remove-list-element active ai
36e7992480d0 emit code for scc based allocator
John Leuner <jewel@subvert-the-dominant-paradigm.net>
parents: 1013
diff changeset
311 add-increasing-start-point-new completed completed-li
36e7992480d0 emit code for scc based allocator
John Leuner <jewel@subvert-the-dominant-paradigm.net>
parents: 1013
diff changeset
312 free-register free-regs ai.interval.register
36e7992480d0 emit code for scc based allocator
John Leuner <jewel@subvert-the-dominant-paradigm.net>
parents: 1013
diff changeset
313 ai = ai.next
993
10b7e19129e0 fine-tune interval splitting
John Leuner <jewel@subvert-the-dominant-paradigm.net>
parents: 992
diff changeset
314
1017
f4c03e96159f add tail-call
John Leuner <jewel@subvert-the-dominant-paradigm.net>
parents: 1015
diff changeset
315 lir-function.num-spill-slots-used = spill-slot-index
1015
36e7992480d0 emit code for scc based allocator
John Leuner <jewel@subvert-the-dominant-paradigm.net>
parents: 1013
diff changeset
316 print "done "
1027
2868fb888d1b flesh out test suite
John Leuner <jewel@subvert-the-dominant-paradigm.net>
parents: 1025
diff changeset
317 print "--------------------------------------------------------------------------------"
2868fb888d1b flesh out test suite
John Leuner <jewel@subvert-the-dominant-paradigm.net>
parents: 1025
diff changeset
318 print function-name
2868fb888d1b flesh out test suite
John Leuner <jewel@subvert-the-dominant-paradigm.net>
parents: 1025
diff changeset
319 print "--------------------------------------------------------------------------------"
1015
36e7992480d0 emit code for scc based allocator
John Leuner <jewel@subvert-the-dominant-paradigm.net>
parents: 1013
diff changeset
320 dump-intervals completed
1017
f4c03e96159f add tail-call
John Leuner <jewel@subvert-the-dominant-paradigm.net>
parents: 1015
diff changeset
321 show-intervals completed
1015
36e7992480d0 emit code for scc based allocator
John Leuner <jewel@subvert-the-dominant-paradigm.net>
parents: 1013
diff changeset
322 1