commit 868667ea27271660eba1128886cfeea5ffbc4f5c
parent 6d6b1ef4b076e72623a46f45308aba80edc2b4e5
Author: Quentin Carbonneaux <quentin.carbonneaux@yale.edu>
Date: Tue, 31 Mar 2015 13:51:00 -0400
add move constant to spill
Diffstat:
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/lo2.ml b/lo2.ml
@@ -122,7 +122,7 @@ let regalloc (p: iprog): rprog =
let bb = ref [] in (* Basic block in construction. *)
let emiti l i = bb := {ri_res=l; ri_ins=i} :: !bb in
let act = H.create 101 in (* The active list. *)
- let free = ref [0;1;2;3] in (* Free registers. *)
+ let free = ref [0;1] in (* Free registers. *)
let nspill = ref 0 in
let newspill () = incr nspill; !nspill - 1 in
@@ -423,6 +423,12 @@ let codegen (p: mprog): string =
let move l l1 = match l, l1 with
| (LReg _ as r), LCon k ->
oins 0xc7 0 (regn r); outs (lite k)
+ | LSpill s, LCon k -> assert (s<256/8);
+ outb 0x48;
+ outb 0xc7;
+ outb (modrm ~md:1 0 5);
+ outb (s*4);
+ outs (lite k)
| (LReg _ as r), (LReg _ as r1) ->
let rex, r1, r = rexp (regn r1) (regn r) in
outb rex; outb 0x89; outb (modrm r1 r)