diff options
Diffstat (limited to 'asmcomp/amd64/proc.ml')
-rw-r--r-- | asmcomp/amd64/proc.ml | 53 |
1 files changed, 37 insertions, 16 deletions
diff --git a/asmcomp/amd64/proc.ml b/asmcomp/amd64/proc.ml index 351770b281..3d065bc0bf 100644 --- a/asmcomp/amd64/proc.ml +++ b/asmcomp/amd64/proc.ml @@ -45,9 +45,9 @@ let masm = r9 7 r12 8 r13 9 - rbp 10 - r10 11 - r11 12 + r10 10 + r11 11 + rbp 12 r14 trap pointer r15 allocation pointer @@ -77,10 +77,10 @@ let int_reg_name = match Config.ccomp_type with | "msvc" -> [| "rax"; "rbx"; "rdi"; "rsi"; "rdx"; "rcx"; "r8"; "r9"; - "r12"; "r13"; "rbp"; "r10"; "r11" |] + "r12"; "r13"; "r10"; "r11"; "rbp" |] | _ -> [| "%rax"; "%rbx"; "%rdi"; "%rsi"; "%rdx"; "%rcx"; "%r8"; "%r9"; - "%r12"; "%r13"; "%rbp"; "%r10"; "%r11" |] + "%r12"; "%r13"; "%r10"; "%r11"; "%rbp" |] let float_reg_name = match Config.ccomp_type with @@ -133,6 +133,7 @@ let phys_reg n = let rax = phys_reg 0 let rcx = phys_reg 5 let rdx = phys_reg 4 +let rbp = phys_reg 12 let rxmm15 = phys_reg 115 let stack_slot slot ty = @@ -242,12 +243,12 @@ let destroyed_at_c_call = if win64 then (* Win64: rbx, rbp, rsi, rdi, r12-r15, xmm6-xmm15 preserved *) Array.of_list(List.map phys_reg - [0;4;5;6;7;11;12; + [0;4;5;6;7;10;11; 100;101;102;103;104;105]) else (* Unix: rbp, rbx, r12-r15 preserved *) Array.of_list(List.map phys_reg - [0;2;3;4;5;6;7;11;12; + [0;2;3;4;5;6;7;10;11; 100;101;102;103;104;105;106;107; 108;109;110;111;112;113;114;115]) @@ -259,23 +260,37 @@ let destroyed_at_oper = function | Iop(Ialloc _ | Iintop(Icomp _) | Iintop_imm((Idiv|Imod|Icomp _), _)) -> [| rax |] | Iswitch(_, _) -> [| rax; rdx |] - | _ -> [||] + | _ -> + if Config.with_frame_pointers then +(* prevent any use of the frame pointer ! *) + [| rbp |] + else + [||] + let destroyed_at_raise = all_phys_regs (* Maximal register pressure *) +let fp() = Config.with_frame_pointers + let safe_register_pressure = function - Iextcall(_,_) -> if win64 then 8 else 0 - | _ -> 11 + Iextcall(_,_) -> if win64 then if fp() then 7 else 8 else 0 + | _ -> if fp() then 10 else 11 let max_register_pressure = function - Iextcall(_, _) -> if win64 then [| 8; 10 |] else [| 4; 0 |] - | Iintop(Idiv | Imod) -> [| 11; 16 |] - | Ialloc _ | Iintop(Icomp _) | Iintop_imm((Idiv|Imod|Icomp _), _) - -> [| 12; 16 |] - | Istore(Single, _) -> [| 13; 15 |] - | _ -> [| 13; 16 |] + Iextcall(_, _) -> + if win64 then + if fp() then [| 7; 10 |] else [| 8; 10 |] + else + if fp() then [| 3; 0 |] else [| 4; 0 |] + | Iintop(Idiv | Imod) -> + if fp() then [| 10; 16 |] else [| 11; 16 |] + | Ialloc _ | Iintop(Icomp _) | Iintop_imm((Idiv|Imod|Icomp _), _) -> + if fp() then [| 11; 16 |] else [| 12; 16 |] + | Istore(Single, _) -> + if fp() then [| 12; 15 |] else [| 13; 15 |] + | _ -> if fp() then [| 12; 16 |] else [| 13; 16 |] (* Layout of the stack frame *) @@ -292,3 +307,9 @@ let assemble_file infile outfile = else Ccomp.command (Config.asm ^ " -o " ^ Filename.quote outfile ^ " " ^ Filename.quote infile) + +let init () = + if fp () then begin + num_available_registers.(0) <- 12 + end else + num_available_registers.(0) <- 13 |