Commit graph

61 commits

Author SHA1 Message Date
Quentin Carbonneaux
5fc8104e00 major lifting: get rid of RReg
I've been septic since I introduced it, this commit
proves that it costs more than it helps.  I've also fixed
a bad bug in rega() where I alloc'ed the wrong size for
internal arrays.  Enums now have names so I can use them
to cast in gdb to get the name corresponding to a constant.
2015-09-15 23:01:31 -04:00
Quentin Carbonneaux
78bf28f56e add basic support for stack allocation 2015-09-15 23:01:31 -04:00
Quentin Carbonneaux
1583f4bd32 split store into store{w,l} 2015-09-15 23:01:31 -04:00
Quentin Carbonneaux
29c5f508b9 cosmetics 2015-09-15 23:01:30 -04:00
Quentin Carbonneaux
e3b8ea4904 parse variants of store 2015-09-15 23:01:30 -04:00
Quentin Carbonneaux
e234a7a188 parse operations with no result 2015-09-15 23:01:30 -04:00
Quentin Carbonneaux
e5c68a88ce simplify parsing 2015-09-15 23:01:30 -04:00
Quentin Carbonneaux
76bf96b268 add nmem to opdesc for use in the spiller
This new machine-independent mechanism might not be general
enough in the long term but, now, it provides a flexible way
to inform the spiller about the maximum number of arguments
of an instruction that can be spill locations.
2015-09-15 23:01:30 -04:00
Quentin Carbonneaux
e65a615c90 jez becomes jnz, complete cmp+jmp contraction 2015-09-15 23:01:30 -04:00
Quentin Carbonneaux
ad012e9d55 implement smarter compare+branch 2015-09-15 23:01:30 -04:00
Quentin Carbonneaux
7dc3e5dcf6 split cmp in two sizes 2015-09-15 23:01:30 -04:00
Quentin Carbonneaux
27f32f26b3 get rid of the iteration macro 2015-09-15 23:01:30 -04:00
Quentin Carbonneaux
2482f4dbbb fix two bugs in isel 2015-09-15 23:01:30 -04:00
Quentin Carbonneaux
9c7b06d68f quick fix for comparisons with constants 2015-09-15 23:01:30 -04:00
Quentin Carbonneaux
246a48ba94 start work on comparisons
There are two things I overlooked so far.

1. Binary instructions like cmp that do not have a result
   in registers need the size suffix sometimes, for example
   when comparing a spill location with a constant.

2. The register allocator needs to be adapted to support the
   comparison instruction: it is not possible to compare two
   spill locations without using a register.
2015-09-15 23:01:30 -04:00
Quentin Carbonneaux
d586852552 print registers with numbers 2015-09-15 23:01:30 -04:00
Quentin Carbonneaux
9456200d91 use a new Ref type for registers
This might not be a good idea, the problem was that
many spurious registers would be added to the Bits
data-structures during compilation (and would
always remain 0).  However, doing the above
modification de-uniformizes the handling of temps
and regs, this makes the code longer and not
really nicer.  Also, additional Bits structures
are required to track the registers independently.

Overall this might be a bad idea to revert.
2015-09-15 23:01:29 -04:00
Quentin Carbonneaux
53e6393295 avoid name conflicts in enums 2015-09-15 23:01:29 -04:00
Quentin Carbonneaux
8d2d674466 start change of representation for registers 2015-09-15 23:01:29 -04:00
Quentin Carbonneaux
cf307002d9 start work on word/long handling 2015-09-15 23:01:29 -04:00
Quentin Carbonneaux
dff7044a2c replace IA with X for x64 instructions 2015-09-15 23:01:29 -04:00
Quentin Carbonneaux
0d5fb419e3 avoid keyword clash by using cons for constants 2015-09-15 23:01:29 -04:00
Quentin Carbonneaux
a2a2231027 cosmetic modifications to parse.c 2015-09-15 23:01:29 -04:00
Quentin Carbonneaux
d8d17705c4 clean the commutativity + fix bug in emit
The commutativity information only makes sense for
arithmetic expressions.  To account for that, I introduced
a new tri-valued boolean type B3.  Memory operations, for
example, will receive an undefined commutativity trit.

The code emitter was buggy when rega emitted instructions
like 'rax = add 1, rax', this is now fixed using the
commutativity information (we rewrite it in 'rax = add
rax, 1').
2015-09-15 23:01:29 -04:00
Quentin Carbonneaux
1a78659dfa cosmetics 2015-09-15 23:01:29 -04:00
Quentin Carbonneaux
390045cae1 compress parsref code a little 2015-09-15 23:01:29 -04:00
Quentin Carbonneaux
92be2fdd17 start improving constants support 2015-09-15 23:01:29 -04:00
Quentin Carbonneaux
5f14d7fd7c silence clang warning 2015-09-15 23:01:29 -04:00
Quentin Carbonneaux
854ecd4009 add crippled dce to the allocator 2015-09-15 23:01:29 -04:00
Quentin Carbonneaux
8899449c39 complete a crude register allocator 2015-09-15 23:01:29 -04:00
Quentin Carbonneaux
b6633a13bc finish spiller, now needs testing! 2015-09-15 23:01:29 -04:00
Quentin Carbonneaux
5bd9deac8d add more printing support 2015-09-15 23:01:29 -04:00
Quentin Carbonneaux
2981a267f4 add slot addressing and some more spilling 2015-09-15 23:01:29 -04:00
Quentin Carbonneaux
32cb8d315a define curi as a global too 2015-09-15 23:01:28 -04:00
Quentin Carbonneaux
a280eb6597 export error functions 2015-09-15 23:01:28 -04:00
Quentin Carbonneaux
e5a7482b54 rename mod to rem 2015-09-15 23:01:28 -04:00
Quentin Carbonneaux
77bdb3ae9e move main function out of parse.c 2015-09-15 23:01:28 -04:00
Quentin Carbonneaux
395891e95c fix phi handling in liveness 2015-09-15 23:01:28 -04:00
Quentin Carbonneaux
d7548fa5d7 add rpo test and some liveness code 2015-09-15 23:01:28 -04:00
Quentin Carbonneaux
6c5c11cb1d simplify block handling 2015-09-15 23:01:28 -04:00
Quentin Carbonneaux
7e53000a1f use argument array for all instructions 2015-09-15 23:01:28 -04:00
Quentin Carbonneaux
17e48f5221 change Ref to a struct 2015-09-15 23:01:28 -04:00
Quentin Carbonneaux
0cb8198493 fix some more parsing bugs 2015-09-15 23:01:28 -04:00
Quentin Carbonneaux
66c006eb6d fix some parsing bug of phi nodes 2015-09-15 23:01:28 -04:00
Quentin Carbonneaux
68c6feefbd add pretty printing function 2015-09-15 23:01:28 -04:00
Quentin Carbonneaux
a9b2d0338b change phi nodes representation 2015-09-15 23:01:27 -04:00
Quentin Carbonneaux
529920d4f4 give blocks an id 2015-09-15 23:01:27 -04:00
Quentin Carbonneaux
e4f07478ce fix naming 2015-09-15 23:01:27 -04:00
Quentin Carbonneaux
851e79f959 add rpo information to functions 2015-09-15 23:01:27 -04:00
Quentin Carbonneaux
935ab611f0 add predecessor computation 2015-09-15 23:01:27 -04:00