-
Notifications
You must be signed in to change notification settings - Fork 0
/
TODO.txt
92 lines (76 loc) · 2.25 KB
/
TODO.txt
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
81
82
83
84
85
86
87
88
89
90
91
92
next goal: bootstrap
features
- modules
- non-exported functions
- global variables
- constants
- enums
optimizations
- special case add imm+reg
probably the same as "don't generate code for immediates" below
- don't generate code for immediates; an int shouldn't be moved into a register
if it can be passed directly to an instruction
this is dumb
movl $1, %eax
movl -4(%rbp), %ecx
cmpl %eax, %ecx
it should just be
cmpl $1, -4(%rbp)
or, since I think you can't do imm+offset
movl -4(%rbp), %eax
cmpl $1, %eax
- add more cases to is_trivial_expr
- don't try to use rax for everything in comparison?
seeing stuff like:
movl $1, %eax
movl %eax, -20(%rbp) ## just a temporary
movl $2, %eax
cmpl %eax, -20(%rbp)
when it would be better to do
movl $1, %eax
movl $2, %ecx
cmpl %eax, %ecx
- avoid shuffling values between registers
some results end up in one register only to be moved to another
movl $1, %eax
movl %eax, %edx
## do something with edx
- for normal assignment don't load values back from lhs for result
for in-place ops this doesn't work, but for regular assignment it should
## (c = fgetc(f)) == -1
movq -8(%rbp), %rdi ## f
call _fgetc
movq %eax, -12(%rbp) ## store in c
cmpl $-1, %eax ## just use eax instead of loading from c
jne past_loop
- compile_reference should have a special case for locals
instead of doing this
leaq -4(%rbp), %rax
movq 0(%rax), %rax
it should just do
movq -4(%rbp), %rax
- if there is no else block, don't add the jump to end after then block
- remove "leaq 0(reg), reg" (or figure out how it's generated and fix)
- replace leaq + mov with just mov
this
leaq -16(%rbp), %rax
movl 0(%rax), %eax ## .len
can be replaced with
movl -16(%rbp), %eax ## .len
- while true should just have an unconditional jump at the bottom
- wtf
movl -28(%rbp), %eax
movl %eax, -56(%rbp) ## i
movl -56(%rbp), %eax
movslq %eax, %rax
movq %rax, -56(%rbp)
movq -24(%rbp), %rax ## num_ops
cmpq %rax, -56(%rbp)
jne L52
possible issues:
- is it fine to do movb $91, %al and then read from %eax? might need a movzbl
possible improvements:
- comments around code for arguments to function
- comments around while loop
- comment when storing to variable
- comment when loading reference to variable