Commit graph

132 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
8020748fbf fix typos in selcmp and comment 2015-09-15 23:01:31 -04:00
Quentin Carbonneaux
b6e9041a67 comment about immutables 2015-09-15 23:01:31 -04:00
Quentin Carbonneaux
79c3d8968b fail on constant comparisons
In the future they will be eliminated by
constant propagation.
2015-09-15 23:01:31 -04:00
Quentin Carbonneaux
d37db3970f support for large constants
It was not as simple as I thought.  All constants
used in 32b context get truncated to 32 bits.
All constants in 64b contexts can either remain
as immutables are have to be evicted in a register,
this choice is taken in noimm().  The case of the
comparison needs to be documented since the context
is not clearly 32 or 64 bits.

I am still unsure if this is fully correct.
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
ec5042148e fix my sloppy understanding of x86 assembly! 2015-09-15 23:01:31 -04:00
Quentin Carbonneaux
a69fe2c6c5 ugly support for store/load 2015-09-15 23:01:30 -04:00
Quentin Carbonneaux
23846dd534 factor some comparison emitting code 2015-09-15 23:01:30 -04:00
Quentin Carbonneaux
0c5b683658 add some more specific comments 2015-09-15 23:01:30 -04:00
Quentin Carbonneaux
9d6e499132 the only wrong use count is the one of r 2015-09-15 23:01:30 -04:00
Quentin Carbonneaux
e240ec3026 I forgot cmp as flag setting instruction! 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
2482f4dbbb fix two bugs in isel 2015-09-15 23:01:30 -04:00
Quentin Carbonneaux
078522cf5d use a temporary for constant comparisons 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
0c20fda622 use regs of the correct type in isel 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
93601b6d02 patch isel to use symbol types 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
5bd9deac8d add more printing support 2015-09-15 23:01:29 -04:00
Quentin Carbonneaux
df0836e475 isel logic was moved to spill 2015-09-15 23:01:29 -04:00
Quentin Carbonneaux
226bbb5b71 fix some instruction emitting code 2015-09-15 23:01:28 -04:00
Quentin Carbonneaux
32cb8d315a define curi as a global too 2015-09-15 23:01:28 -04:00
Quentin Carbonneaux
bba9cf47c9 fix small type issues 2015-09-15 23:01:28 -04:00
Quentin Carbonneaux
a244ca17f1 start simple work on isel 2015-09-15 23:01:28 -04:00