-
Notifications
You must be signed in to change notification settings - Fork 7
/
TODO
80 lines (65 loc) · 3.17 KB
/
TODO
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
2014-01-04 10:05:54 tonyg Register allocation in the presence of
infinite loops is a bit weird. Consider this procedure, for example:
(define (error/argument code arg)
(while 1
(pulse-bits code)
(pulse-bits arg)
(long-delay)))
The resulting LIR instructions:
'(peepholed-instrs
((move-word #s(preg r2) #s(preg r4))
(move-word #s(preg r1) #s(preg r5))
(move-word #s(preg r3) #s(preg r7))
(move-word #s(temporary 2) #s(preg r10))
(move-word #s(temporary 1) #s(preg r11))
(move-word #s(temporary 0) #s(preg lr))
(move-word #s(preg r4) #s(preg r0))
(move-word #s(preg r5) #s(preg r1))
#s(label L161)
(move-word #s(preg r0) #s(preg r4))
(call #s(preg r0) #s(label pulse-bits) (#s(preg r0)))
(move-word #s(preg r0) #s(preg r5))
(call #s(preg r0) #s(label pulse-bits) (#s(preg r0)))
(call #s(preg r0) #s(label long-delay) ())
(jmp #s(label L161))
#s(label L162)
(move-word #s(preg r0) #s(lit 0))
(move-word #s(preg r4) #s(preg r2))
(move-word #s(preg r5) #s(preg r1))
(move-word #s(preg r7) #s(preg r3))
(move-word #s(preg r10) #s(temporary 2))
(move-word #s(preg r11) #s(temporary 1))
(move-word #s(preg lr) #s(temporary 0))
(ret #s(preg r0))))
Because the comparison for exiting the while loop has been STATICALLY
ELIDED, the (raw-live-ranges) routine in lir.rkt decides that the
virtual registers being used to save away callee-save registers are
*not live*, which leads the register allocator to make suboptimal
(mad!) mappings for them. It's not a bug, per se: keeping the dynamic
loop exit check results in sane mappings, as expected. A good "fix"
for it would be to eliminate instructions that define a virtual
register that is never used. Care must be taken not to eliminate
instructions with side-effects (e.g. memory writes), however!
-=-=-=-
rename (use) to (kill-reg) in lir for register allocation
figure out whether the no-kills-on-tail-call-restoration-of-saves is
correct; I commented it out because it was causing spurious saves of
all savables in the (x (x (x))) example.
try to figure out a way to use STM and LDM in ARM backend
Apply lessons from "Destination-Driven Code Generation" by R. Kent
Dybvig, Robert Hieb and Tom Butler (IUCS TR 302, Feb 1990). In
particular, unkink the existing "dest" argument and augment it with
corresponding control arguments. Generalize the while loop to repeat
plus break, as shown in the paper.
-=-=-=-
I already have call and tailcall; would adding syscall make sense?
It'd allow for abstraction over the various syscall mechanisms without
having to hardcode arch-specific assembly for each syscall, and would
also avoid procedure-call overhead. For x86_64, (syscall 1 a b c)
would place a, b, c in rdi, rsi, rdx, then place 1 in rax and SYSCALL.
-=-=-=-
2017-07-19 10:31:06 Two interesting links on structuring compilers:
- https://gist.github.com/thoughtpolice/fd27b6a1a324b467f9d6657a80d1e6b1
- https://jeapostrophe.github.io/courses/2017/spring/406/notes/book.pdf
The second is a book, "Essentials of Compilation -- An Incremental
Approach", by Jeremy Siek, discovered by way of the first.