new hinting in the register allocator

The previous heuristics were ad hoc and it was
hard to understand why they worked at all.

This patch can be summarized in three points:

 1. When a register is freed (an instruction
    assigns it), we try to find if a temporary
    would like to be in it, and if we find one,
    we move it in the newly freed register.
    I call this an "eager move".

 2. Temporaries now remember in what register
    they were last allocated; this information
    is stored in the field Tmp.visit, and
    prevails on the field Tmp.hint when it is
    set.  (This makes having the same hint for
    interfering temporaries not so disastrous.)

 3. Blocks are now allocated in "onion" order,
    from the innermost loop to the outermost.
    This is the change I am the least sure
    about; it should be evaluated thorougly.
This commit is contained in:
Quentin Carbonneaux 2017-05-16 11:47:46 -04:00
parent 436d0fc07e
commit 2d02070af0
2 changed files with 264 additions and 167 deletions

5
all.h
View file

@ -288,8 +288,9 @@ struct Tmp {
short slot; /* -1 for unset */
short cls;
struct {
int r;
bits m;
int r; /* register or -1 */
int w; /* weight */
bits m; /* avoid these registers */
} hint;
int phi;
Alias alias;