Fusionner Imove/Ispill/Ireload; typos; erreur dans la multiplication par 0 (...)

git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@3244 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
master
Xavier Leroy 2000-07-21 08:07:46 +00:00
parent b2236322cb
commit f7c20e30ec
1 changed files with 25 additions and 18 deletions

View File

@ -792,20 +792,27 @@ let tailrec_entry_point = ref 0
let emit_instr i = let emit_instr i =
match i.desc with match i.desc with
Lend -> () Lend -> ()
| Lop(Imove) -> | Lop(Imove | Ispill | Ireload) ->
let src = i.arg.(0) and dst = i.res.(0) in
if src.loc <> dst.loc then begin
match (src.loc, dst.loc) with
(Reg _, Reg _) ->
insert "mov" (regs i.arg) (regs i.res) insert "mov" (regs i.arg) (regs i.res)
| Lop(Ispill) -> | (Reg _, Stack _) ->
let offset = string_of_int (slot_offset_reg i.res.(0)) in let offset = string_of_int (slot_offset_reg dst) in
let r = new_temp_reg() in let r = new_temp_reg() in
insimm "addi" [| "sp" |] offset [| r |]; insimm "addi" [| "sp" |] offset [| r |];
insert (if i.res.(0).typ = Float then "stfd" else "st8") insert (if i.res.(0).typ = Float then "stfd" else "st8")
[| r; reg i.arg.(0) |] [| "stk" ^ offset |] [| r; reg src |] [| "stk" ^ offset |]
| Lop(Ireload) -> | (Stack _, Reg _) ->
let offset = string_of_int (slot_offset_reg i.arg.(0)) in let offset = string_of_int (slot_offset_reg src) in
let r = new_temp_reg() in let r = new_temp_reg() in
insimm "addi" [| "sp" |] offset [| r |]; insimm "addi" [| "sp" |] offset [| r |];
insert (if i.arg.(0).typ = Float then "ldfd" else "ld8") insert (if i.arg.(0).typ = Float then "ldfd" else "ld8")
[| r; "stk" ^ offset |] (regs i.res) [| r; "stk" ^ offset |] (regs i.res)
| (_, _) ->
assert false
end
| Lop(Iconst_int n) -> | Lop(Iconst_int n) ->
let instr = let instr =
if is_immediate_addl_nat n then "movi" else "movil" in if is_immediate_addl_nat n then "movi" else "movil" in
@ -912,7 +919,7 @@ let emit_instr i =
| Thirtytwo_unsigned -> "st4" | Thirtytwo_unsigned -> "st4"
| Thirtytwo_signed -> "st4" | Thirtytwo_signed -> "st4"
| Word -> "st8" | Word -> "st8"
| Single -> "stf4" | Single -> "stfs"
| Double -> "stfd" | Double -> "stfd"
| Double_u -> "stfd" in | Double_u -> "stfd" in
insert store_instr [| reg i.arg.(1); reg i.arg.(0) |] [| "heap" |] insert store_instr [| reg i.arg.(1); reg i.arg.(0) |] [| "heap" |]
@ -955,7 +962,7 @@ let emit_instr i =
let src = reg i.arg.(0) and dst = reg i.res.(0) in let src = reg i.arg.(0) and dst = reg i.res.(0) in
begin match ones_pos n with begin match ones_pos n with
[] -> [] ->
insert "mov" [|src|] [|dst|] insimm "movi" [||] "0" [|dst|]
| [n] -> | [n] ->
insimm "shli" [|src|] (string_of_int n) [|dst|] insimm "shli" [|src|] (string_of_int n) [|dst|]
| [n; 0] when n <= 4 -> | [n; 0] when n <= 4 ->
@ -1168,7 +1175,7 @@ let emit_instr i =
` ld4 r3 = [r3] ;;\n`; ` ld4 r3 = [r3] ;;\n`;
` sxt4 r3 = r3 ;;\n`; ` sxt4 r3 = r3 ;;\n`;
` add r2 = r2, r3 ;;\n`; ` add r2 = r2, r3 ;;\n`;
` mov br6 = r2 ;;\n`; ` mov b6 = r2 ;;\n`;
` br b6 ;;\n`; ` br b6 ;;\n`;
` .align 4\n`; ` .align 4\n`;
`{emit_label lbl_jumptbl}:\n`; `{emit_label lbl_jumptbl}:\n`;
@ -1280,7 +1287,7 @@ let emit_item = function
| Clabel_address lbl -> | Clabel_address lbl ->
` data8 {emit_label (100000 + lbl)}\n` ` data8 {emit_label (100000 + lbl)}\n`
| Cstring s -> | Cstring s ->
emit_string_directive " stringz " s emit_string_directive " string " s
| Cskip n -> | Cskip n ->
if n > 0 then ` .skip {emit_int n}\n` if n > 0 then ` .skip {emit_int n}\n`
| Calign n -> | Calign n ->