Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- diff -r -u -x '*.o' -x '*.cmi' -x '*.cmo' -x '*.cmt' -x '*.cmti' -x '*.cmx' ocaml-4.00.1/asmcomp/amd64/emit.mlp ocaml-4.00.1.orig/asmcomp/amd64/emit.mlp
- --- ocaml-4.00.1/asmcomp/amd64/emit.mlp 2013-06-19 12:38:18.296035977 -0400
- +++ ocaml-4.00.1.orig/asmcomp/amd64/emit.mlp 2013-06-19 12:48:27.742037078 -0400
- @@ -512,124 +512,21 @@
- ` incq {emit_reg i.res.(0)}\n`
- | Lop(Iintop_imm(Iadd, -1) | Iintop_imm(Isub, 1)) ->
- ` decq {emit_reg i.res.(0)}\n`
- - | Lop(Iintop_nonpow2div(n, m, s)) ->
- - (* Note: i.arg.(0) = i.res.(0) = rdx (cf. selection.ml) *)
- - ` movq {emit_reg i.res.(0)}, %rax\n`;
- - begin match Int64.one = (Int64.shift_right_logical m 63), n < 0 with
- - | false, false ->
- - ` movq {emit_reg i.res.(0)}, %rcx\n`;
- - ` movabsq ${emit_string (Int64.to_string m)}, {emit_reg i.res.(0)}\n`;
- - ` imulq {emit_reg i.res.(0)}\n`;
- - ` sarq ${emit_int s}, {emit_reg i.res.(0)}\n`;
- - ` shrq $63, %rcx\n`;
- - ` addq %rcx, {emit_reg i.res.(0)}\n`
- - | true, false ->
- - ` movq {emit_reg i.res.(0)}, %rcx\n`;
- - ` movabsq ${emit_string (Int64.to_string m)}, {emit_reg i.res.(0)}\n`;
- - ` imulq {emit_reg i.res.(0)}\n`;
- - ` addq %rcx, {emit_reg i.res.(0)}\n`;
- - ` sarq ${emit_int s}, {emit_reg i.res.(0)}\n`;
- - ` shrq $63, %rcx\n`;
- - ` addq %rcx, {emit_reg i.res.(0)}\n`
- - | false, true ->
- - ` movabsq ${emit_string (Int64.to_string m)}, {emit_reg i.res.(0)}\n`;
- - ` imulq {emit_reg i.res.(0)}\n`;
- - ` sarq ${emit_int s}, {emit_reg i.res.(0)}\n`;
- - ` movq {emit_reg i.res.(0)}, %rax\n`;
- - ` shrq $63, %rax\n`;
- - ` addq %rax, {emit_reg i.res.(0)}\n`;
- - ` negq {emit_reg i.res.(0)}\n`
- - | true, true ->
- - ` movq {emit_reg i.res.(0)}, %rcx\n`;
- - ` movabsq ${emit_string (Int64.to_string m)}, {emit_reg i.res.(0)}\n`;
- - ` imulq {emit_reg i.res.(0)}\n`;
- - ` addq %rcx, {emit_reg i.res.(0)}\n`;
- - ` sarq ${emit_int s}, {emit_reg i.res.(0)}\n`;
- - ` movq {emit_reg i.res.(0)}, %rax\n`;
- - ` shrq $63, %rax\n`;
- - ` addq %rax, {emit_reg i.res.(0)}\n`;
- - ` negq {emit_reg i.res.(0)}\n`
- - end
- - | Lop(Iintop_nonpow2mod(n, m, s)) ->
- - (* Note: i.arg.(0) = i.res.(0) = rdx (cf. selection.ml) *)
- - let l = (Misc.log2 n) + Misc.log2 ((-1) * n) in
- - ` movq {emit_reg i.res.(0)}, %rax\n`;
- - if n = (1 lsl l) || n = (-1) * (1 lsl l)
- - then begin
- - ` sarq $63, %rax\n`;
- - ` shrq ${emit_int(64-l)}, %rax\n`;
- - ` leaq (%rax, {emit_reg i.res.(0)}), {emit_reg i.res.(0)}\n`;
- - ` movabsq ${emit_int ((1 lsl l) - 1)}, %rcx\n`;
- - ` andq %rcx, {emit_reg i.res.(0)}\n`;
- - ` subq %rax, {emit_reg i.res.(0)}\n`
- - end
- - else begin
- - ` movq {emit_reg i.res.(0)}, %rcx\n`;
- - (match Int64.one = (Int64.shift_right_logical m 63), n < 0 with
- - | false, false ->
- - ` movabsq ${emit_string (Int64.to_string m)}, {emit_reg i.res.(0)}\n`;
- - ` imulq {emit_reg i.res.(0)}\n`;
- - ` sarq ${emit_int s}, {emit_reg i.res.(0)}\n`;
- - ` movq %rcx, %rax\n`;
- - ` shrq $63, %rax\n`;
- - ` addq %rax, {emit_reg i.res.(0)}\n`
- - | true, false ->
- - ` movabsq ${emit_string (Int64.to_string m)}, {emit_reg i.res.(0)}\n`;
- - ` imulq {emit_reg i.res.(0)}\n`;
- - ` addq %rcx, {emit_reg i.res.(0)}\n`;
- - ` sarq ${emit_int s}, {emit_reg i.res.(0)}\n`;
- - ` movq %rcx, %rax\n`;
- - ` shrq $63, %rax\n`;
- - ` addq %rax, {emit_reg i.res.(0)}\n`
- - | false, true ->
- - ` movabsq ${emit_string (Int64.to_string m)}, {emit_reg i.res.(0)}\n`;
- - ` imulq {emit_reg i.res.(0)}\n`;
- - ` sarq ${emit_int s}, {emit_reg i.res.(0)}\n`;
- - ` movq {emit_reg i.res.(0)}, %rax\n`;
- - ` shrq $63, %rax\n`;
- - ` addq %rax, {emit_reg i.res.(0)}\n`;
- - ` negq {emit_reg i.res.(0)}\n`
- - | true, true ->
- - ` movabsq ${emit_string (Int64.to_string m)}, {emit_reg i.res.(0)}\n`;
- - ` imulq {emit_reg i.res.(0)}\n`;
- - ` addq %rcx, {emit_reg i.res.(0)}\n`;
- - ` sarq ${emit_int s}, {emit_reg i.res.(0)}\n`;
- - ` movq {emit_reg i.res.(0)}, %rax\n`;
- - ` shrq $63, %rax\n`;
- - ` addq %rax, {emit_reg i.res.(0)}\n`;
- - ` negq {emit_reg i.res.(0)}\n`);
- - ` movabsq ${emit_int n}, %rax\n`;
- - ` imulq {emit_reg i.res.(0)}\n`;
- - ` movq %rcx, {emit_reg i.res.(0)}\n`;
- - ` subq %rax, {emit_reg i.res.(0)}\n`
- - end
- | Lop(Iintop_imm(Idiv, n)) ->
- (* Note: i.arg.(0) = i.res.(0) = rdx (cf. selection.ml) *)
- let l = Misc.log2 n in
- - let n_l = Misc.log2 ((-1) * n) in
- ` movq {emit_reg i.arg.(0)}, %rax\n`;
- - if n = (1 lsl l)
- - then begin
- - ` sarq ${emit_int(l-1)}, %rax\n`;
- - ` shrq ${emit_int(64-l)}, %rax\n`;
- - ` addq %rax, {emit_reg i.arg.(0)}\n`;
- - ` sarq ${emit_int l}, {emit_reg i.res.(0)}\n`
- - end
- - else begin
- - ` sarq ${emit_int(n_l-1)}, %rax\n`;
- - ` shrq ${emit_int(64-n_l)}, %rax\n`;
- - ` addq %rax, {emit_reg i.arg.(0)}\n`;
- - ` sarq ${emit_int n_l}, {emit_reg i.res.(0)}\n`;
- - ` negq {emit_reg i.res.(0)}\n`;
- - end
- + ` addq ${emit_int(n-1)}, {emit_reg i.arg.(0)}\n`;
- + ` testq %rax, %rax\n`;
- + ` cmovns %rax, {emit_reg i.arg.(0)}\n`;
- + ` sarq ${emit_int l}, {emit_reg i.res.(0)}\n`
- | Lop(Iintop_imm(Imod, n)) ->
- (* Note: i.arg.(0) = i.res.(0) = rdx (cf. selection.ml) *)
- - let l = (Misc.log2 n) + Misc.log2 ((-1) * n) in
- ` movq {emit_reg i.arg.(0)}, %rax\n`;
- - ` sarq $63, %rax\n`;
- - ` shrq ${emit_int(64-l)}, %rax\n`;
- - ` leaq (%rax, {emit_reg i.res.(0)}), {emit_reg i.res.(0)}\n`;
- - ` andq ${emit_int ((1 lsl l) - 1)}, {emit_reg i.res.(0)}\n`;
- + ` testq %rax, %rax\n`;
- + ` leaq {emit_int(n-1)}(%rax), %rax\n`;
- + ` cmovns {emit_reg i.arg.(0)}, %rax\n`;
- + ` andq ${emit_int (-n)}, %rax\n`;
- ` subq %rax, {emit_reg i.res.(0)}\n`
- | Lop(Iintop_imm(op, n)) ->
- (* We have i.arg.(0) = i.res.(0) *)
- diff -r -u -x '*.o' -x '*.cmi' -x '*.cmo' -x '*.cmt' -x '*.cmti' -x '*.cmx' ocaml-4.00.1/asmcomp/amd64/proc.ml ocaml-4.00.1.orig/asmcomp/amd64/proc.ml
- --- ocaml-4.00.1/asmcomp/amd64/proc.ml 2013-06-19 12:17:11.826037442 -0400
- +++ ocaml-4.00.1.orig/asmcomp/amd64/proc.ml 2013-06-19 12:48:27.745037020 -0400
- @@ -259,8 +259,6 @@
- | Iop(Iextcall(_, false)) -> destroyed_at_c_call
- | Iop(Iintop(Idiv | Imod)) -> [| rax; rdx |]
- | Iop(Istore(Single, _)) -> [| rxmm15 |]
- - | Iop(Iintop_nonpow2div( _, _, _)) -> [| rax; rcx |]
- - | Iop(Iintop_nonpow2mod( _, _, _)) -> [| rax; rcx |]
- | Iop(Ialloc _ | Iintop(Icomp _) | Iintop_imm((Idiv|Imod|Icomp _), _))
- -> [| rax |]
- | Iswitch(_, _) -> [| rax; rdx |]
- diff -r -u -x '*.o' -x '*.cmi' -x '*.cmo' -x '*.cmt' -x '*.cmti' -x '*.cmx' ocaml-4.00.1/asmcomp/amd64/reload.ml ocaml-4.00.1.orig/asmcomp/amd64/reload.ml
- --- ocaml-4.00.1/asmcomp/amd64/reload.ml 2013-06-19 12:17:11.826037442 -0400
- +++ ocaml-4.00.1.orig/asmcomp/amd64/reload.ml 2013-06-19 12:48:27.760037083 -0400
- @@ -74,8 +74,6 @@
- in registers *)
- super#reload_operation op arg res
- | Iintop(Idiv | Imod | Ilsl | Ilsr | Iasr)
- - | Iintop_nonpow2div(_, _, _)
- - | Iintop_nonpow2mod(_, _, _)
- | Iintop_imm(_, _) ->
- (* The argument(s) and results can be either in register or on stack *)
- (* Note: Idiv, Imod: arg(0) and res(0) already forced in regs
- diff -r -u -x '*.o' -x '*.cmi' -x '*.cmo' -x '*.cmt' -x '*.cmti' -x '*.cmx' ocaml-4.00.1/asmcomp/amd64/selection.ml ocaml-4.00.1.orig/asmcomp/amd64/selection.ml
- --- ocaml-4.00.1/asmcomp/amd64/selection.ml 2013-06-19 12:17:11.826037442 -0400
- +++ ocaml-4.00.1.orig/asmcomp/amd64/selection.ml 2013-06-19 12:48:27.756037143 -0400
- @@ -20,7 +20,6 @@
- open Cmm
- open Reg
- open Mach
- -open Selectgen
- (* Auxiliary for recognizing addressing modes *)
- @@ -107,8 +106,6 @@
- ([| rax; rcx |], [| rdx |])
- (* For div and mod with immediate operand, arg must not be in rax.
- Keep it simple, force it in rdx. *)
- - | Iintop_nonpow2mod(_, _, _)
- - | Iintop_nonpow2div(_, _, _)
- | Iintop_imm((Idiv|Imod), _) ->
- ([| rdx |], [| rdx |])
- (* Other instructions are regular *)
- @@ -168,25 +165,18 @@
- (* Recognize (x / cst) and (x % cst) only if cst is a power of 2. *)
- | Cdivi ->
- begin match args with
- - [arg1; Cconst_int n] when n = 1 lsl (Misc.log2 n)
- - || n = (-1) * (1 lsl (Misc.log2 ((-1) *n))) ->
- - (Iintop_imm(Idiv, n), [arg1])
- - | [arg1; Cconst_int n] ->
- - let m, s = div_opt_number n in
- - (Iintop_nonpow2div(n, m, s), [arg1])
- + [arg1; Cconst_int n] when self#is_immediate n
- + && n = 1 lsl (Misc.log2 n) ->
- + (Iintop_imm(Idiv, n), [arg1])
- | _ -> (Iintop Idiv, args)
- end
- | Cmodi ->
- - begin match args with
- + begin match args with
- [arg1; Cconst_int n] when self#is_immediate n
- - && (n = 1 lsl (Misc.log2 n)
- - || n = (-1) * (1 lsl (Misc.log2 ((-1) *n)))) ->
- - (Iintop_imm(Imod, n), [arg1])
- - | [arg1; Cconst_int n] ->
- - let m, s = div_opt_number n in
- - (Iintop_nonpow2mod(n, m, s), [arg1])
- + && n = 1 lsl (Misc.log2 n) ->
- + (Iintop_imm(Imod, n), [arg1])
- | _ -> (Iintop Imod, args)
- - end
- + end
- (* Recognize float arithmetic with memory. *)
- | Caddf ->
- self#select_floatarith true Iaddf Ifloatadd args
- diff -r -u -x '*.o' -x '*.cmi' -x '*.cmo' -x '*.cmt' -x '*.cmti' -x '*.cmx' ocaml-4.00.1/asmcomp/emit.ml ocaml-4.00.1.orig/asmcomp/emit.ml
- --- ocaml-4.00.1/asmcomp/emit.ml 2013-06-19 12:38:53.653036711 -0400
- +++ ocaml-4.00.1.orig/asmcomp/emit.ml 2013-06-19 12:48:27.982037112 -0400
- @@ -512,124 +512,21 @@
- (emit_string " incq "; emit_reg i.res.(0); emit_char '\n')
- | Lop(Iintop_imm(Iadd, -1) | Iintop_imm(Isub, 1)) ->
- (emit_string " decq "; emit_reg i.res.(0); emit_char '\n')
- - | Lop(Iintop_nonpow2div(n, m, s)) ->
- - (* Note: i.arg.(0) = i.res.(0) = rdx (cf. selection.ml) *)
- - (emit_string " movq "; emit_reg i.res.(0); emit_string ", %rax\n");
- - begin match Int64.one = (Int64.shift_right_logical m 63), n < 0 with
- - | false, false ->
- - (emit_string " movq "; emit_reg i.res.(0); emit_string ", %rcx\n");
- - (emit_string " movabsq $"; emit_string (Int64.to_string m); emit_string ", "; emit_reg i.res.(0); emit_char '\n');
- - (emit_string " imulq "; emit_reg i.res.(0); emit_char '\n');
- - (emit_string " sarq $"; emit_int s; emit_string ", "; emit_reg i.res.(0); emit_char '\n');
- - (emit_string " shrq $63, %rcx\n");
- - (emit_string " addq %rcx, "; emit_reg i.res.(0); emit_char '\n')
- - | true, false ->
- - (emit_string " movq "; emit_reg i.res.(0); emit_string ", %rcx\n");
- - (emit_string " movabsq $"; emit_string (Int64.to_string m); emit_string ", "; emit_reg i.res.(0); emit_char '\n');
- - (emit_string " imulq "; emit_reg i.res.(0); emit_char '\n');
- - (emit_string " addq %rcx, "; emit_reg i.res.(0); emit_char '\n');
- - (emit_string " sarq $"; emit_int s; emit_string ", "; emit_reg i.res.(0); emit_char '\n');
- - (emit_string " shrq $63, %rcx\n");
- - (emit_string " addq %rcx, "; emit_reg i.res.(0); emit_char '\n')
- - | false, true ->
- - (emit_string " movabsq $"; emit_string (Int64.to_string m); emit_string ", "; emit_reg i.res.(0); emit_char '\n');
- - (emit_string " imulq "; emit_reg i.res.(0); emit_char '\n');
- - (emit_string " sarq $"; emit_int s; emit_string ", "; emit_reg i.res.(0); emit_char '\n');
- - (emit_string " movq "; emit_reg i.res.(0); emit_string ", %rax\n");
- - (emit_string " shrq $63, %rax\n");
- - (emit_string " addq %rax, "; emit_reg i.res.(0); emit_char '\n');
- - (emit_string " negq "; emit_reg i.res.(0); emit_char '\n')
- - | true, true ->
- - (emit_string " movq "; emit_reg i.res.(0); emit_string ", %rcx\n");
- - (emit_string " movabsq $"; emit_string (Int64.to_string m); emit_string ", "; emit_reg i.res.(0); emit_char '\n');
- - (emit_string " imulq "; emit_reg i.res.(0); emit_char '\n');
- - (emit_string " addq %rcx, "; emit_reg i.res.(0); emit_char '\n');
- - (emit_string " sarq $"; emit_int s; emit_string ", "; emit_reg i.res.(0); emit_char '\n');
- - (emit_string " movq "; emit_reg i.res.(0); emit_string ", %rax\n");
- - (emit_string " shrq $63, %rax\n");
- - (emit_string " addq %rax, "; emit_reg i.res.(0); emit_char '\n');
- - (emit_string " negq "; emit_reg i.res.(0); emit_char '\n')
- - end
- - | Lop(Iintop_nonpow2mod(n, m, s)) ->
- - (* Note: i.arg.(0) = i.res.(0) = rdx (cf. selection.ml) *)
- - let l = (Misc.log2 n) + Misc.log2 ((-1) * n) in
- - (emit_string " movq "; emit_reg i.res.(0); emit_string ", %rax\n");
- - if n = (1 lsl l) || n = (-1) * (1 lsl l)
- - then begin
- - (emit_string " sarq $63, %rax\n");
- - (emit_string " shrq $"; emit_int(64-l); emit_string ", %rax\n");
- - (emit_string " leaq (%rax, "; emit_reg i.res.(0); emit_string "), "; emit_reg i.res.(0); emit_char '\n');
- - (emit_string " movabsq $"; emit_int ((1 lsl l) - 1); emit_string ", %rcx\n");
- - (emit_string " andq %rcx, "; emit_reg i.res.(0); emit_char '\n');
- - (emit_string " subq %rax, "; emit_reg i.res.(0); emit_char '\n')
- - end
- - else begin
- - (emit_string " movq "; emit_reg i.res.(0); emit_string ", %rcx\n");
- - (match Int64.one = (Int64.shift_right_logical m 63), n < 0 with
- - | false, false ->
- - (emit_string " movabsq $"; emit_string (Int64.to_string m); emit_string ", "; emit_reg i.res.(0); emit_char '\n');
- - (emit_string " imulq "; emit_reg i.res.(0); emit_char '\n');
- - (emit_string " sarq $"; emit_int s; emit_string ", "; emit_reg i.res.(0); emit_char '\n');
- - (emit_string " movq %rcx, %rax\n");
- - (emit_string " shrq $63, %rax\n");
- - (emit_string " addq %rax, "; emit_reg i.res.(0); emit_char '\n')
- - | true, false ->
- - (emit_string " movabsq $"; emit_string (Int64.to_string m); emit_string ", "; emit_reg i.res.(0); emit_char '\n');
- - (emit_string " imulq "; emit_reg i.res.(0); emit_char '\n');
- - (emit_string " addq %rcx, "; emit_reg i.res.(0); emit_char '\n');
- - (emit_string " sarq $"; emit_int s; emit_string ", "; emit_reg i.res.(0); emit_char '\n');
- - (emit_string " movq %rcx, %rax\n");
- - (emit_string " shrq $63, %rax\n");
- - (emit_string " addq %rax, "; emit_reg i.res.(0); emit_char '\n')
- - | false, true ->
- - (emit_string " movabsq $"; emit_string (Int64.to_string m); emit_string ", "; emit_reg i.res.(0); emit_char '\n');
- - (emit_string " imulq "; emit_reg i.res.(0); emit_char '\n');
- - (emit_string " sarq $"; emit_int s; emit_string ", "; emit_reg i.res.(0); emit_char '\n');
- - (emit_string " movq "; emit_reg i.res.(0); emit_string ", %rax\n");
- - (emit_string " shrq $63, %rax\n");
- - (emit_string " addq %rax, "; emit_reg i.res.(0); emit_char '\n');
- - (emit_string " negq "; emit_reg i.res.(0); emit_char '\n')
- - | true, true ->
- - (emit_string " movabsq $"; emit_string (Int64.to_string m); emit_string ", "; emit_reg i.res.(0); emit_char '\n');
- - (emit_string " imulq "; emit_reg i.res.(0); emit_char '\n');
- - (emit_string " addq %rcx, "; emit_reg i.res.(0); emit_char '\n');
- - (emit_string " sarq $"; emit_int s; emit_string ", "; emit_reg i.res.(0); emit_char '\n');
- - (emit_string " movq "; emit_reg i.res.(0); emit_string ", %rax\n");
- - (emit_string " shrq $63, %rax\n");
- - (emit_string " addq %rax, "; emit_reg i.res.(0); emit_char '\n');
- - (emit_string " negq "; emit_reg i.res.(0); emit_char '\n'));
- - (emit_string " movabsq $"; emit_int n; emit_string ", %rax\n");
- - (emit_string " imulq "; emit_reg i.res.(0); emit_char '\n');
- - (emit_string " movq %rcx, "; emit_reg i.res.(0); emit_char '\n');
- - (emit_string " subq %rax, "; emit_reg i.res.(0); emit_char '\n')
- - end
- | Lop(Iintop_imm(Idiv, n)) ->
- (* Note: i.arg.(0) = i.res.(0) = rdx (cf. selection.ml) *)
- let l = Misc.log2 n in
- - let n_l = Misc.log2 ((-1) * n) in
- (emit_string " movq "; emit_reg i.arg.(0); emit_string ", %rax\n");
- - if n = (1 lsl l)
- - then begin
- - (emit_string " sarq $"; emit_int(l-1); emit_string ", %rax\n");
- - (emit_string " shrq $"; emit_int(64-l); emit_string ", %rax\n");
- - (emit_string " addq %rax, "; emit_reg i.arg.(0); emit_char '\n');
- - (emit_string " sarq $"; emit_int l; emit_string ", "; emit_reg i.res.(0); emit_char '\n')
- - end
- - else begin
- - (emit_string " sarq $"; emit_int(n_l-1); emit_string ", %rax\n");
- - (emit_string " shrq $"; emit_int(64-n_l); emit_string ", %rax\n");
- - (emit_string " addq %rax, "; emit_reg i.arg.(0); emit_char '\n');
- - (emit_string " sarq $"; emit_int n_l; emit_string ", "; emit_reg i.res.(0); emit_char '\n');
- - (emit_string " negq "; emit_reg i.res.(0); emit_char '\n');
- - end
- + (emit_string " addq $"; emit_int(n-1); emit_string ", "; emit_reg i.arg.(0); emit_char '\n');
- + (emit_string " testq %rax, %rax\n");
- + (emit_string " cmovns %rax, "; emit_reg i.arg.(0); emit_char '\n');
- + (emit_string " sarq $"; emit_int l; emit_string ", "; emit_reg i.res.(0); emit_char '\n')
- | Lop(Iintop_imm(Imod, n)) ->
- (* Note: i.arg.(0) = i.res.(0) = rdx (cf. selection.ml) *)
- - let l = (Misc.log2 n) + Misc.log2 ((-1) * n) in
- (emit_string " movq "; emit_reg i.arg.(0); emit_string ", %rax\n");
- - (emit_string " sarq $63, %rax\n");
- - (emit_string " shrq $"; emit_int(64-l); emit_string ", %rax\n");
- - (emit_string " leaq (%rax, "; emit_reg i.res.(0); emit_string "), "; emit_reg i.res.(0); emit_char '\n');
- - (emit_string " andq $"; emit_int ((1 lsl l) - 1); emit_string ", "; emit_reg i.res.(0); emit_char '\n');
- + (emit_string " testq %rax, %rax\n");
- + (emit_string " leaq "; emit_int(n-1); emit_string "(%rax), %rax\n");
- + (emit_string " cmovns "; emit_reg i.arg.(0); emit_string ", %rax\n");
- + (emit_string " andq $"; emit_int (-n); emit_string ", %rax\n");
- (emit_string " subq %rax, "; emit_reg i.res.(0); emit_char '\n')
- | Lop(Iintop_imm(op, n)) ->
- (* We have i.arg.(0) = i.res.(0) *)
- diff -r -u -x '*.o' -x '*.cmi' -x '*.cmo' -x '*.cmt' -x '*.cmti' -x '*.cmx' ocaml-4.00.1/asmcomp/mach.ml ocaml-4.00.1.orig/asmcomp/mach.ml
- --- ocaml-4.00.1/asmcomp/mach.ml 2013-06-19 12:17:11.822037796 -0400
- +++ ocaml-4.00.1.orig/asmcomp/mach.ml 2013-06-19 12:48:27.968037126 -0400
- @@ -51,8 +51,6 @@
- | Ialloc of int
- | Iintop of integer_operation
- | Iintop_imm of integer_operation * int
- - | Iintop_nonpow2div of int * int64 * int
- - | Iintop_nonpow2mod of int * int64 * int
- | Inegf | Iabsf | Iaddf | Isubf | Imulf | Idivf
- | Ifloatofint | Iintoffloat
- | Ispecific of Arch.specific_operation
- diff -r -u -x '*.o' -x '*.cmi' -x '*.cmo' -x '*.cmt' -x '*.cmti' -x '*.cmx' ocaml-4.00.1/asmcomp/mach.mli ocaml-4.00.1.orig/asmcomp/mach.mli
- --- ocaml-4.00.1/asmcomp/mach.mli 2013-06-19 12:17:11.818037213 -0400
- +++ ocaml-4.00.1.orig/asmcomp/mach.mli 2013-06-19 12:48:28.104037844 -0400
- @@ -51,8 +51,6 @@
- | Ialloc of int
- | Iintop of integer_operation
- | Iintop_imm of integer_operation * int
- - | Iintop_nonpow2div of int * int64 * int
- - | Iintop_nonpow2mod of int * int64 * int
- | Inegf | Iabsf | Iaddf | Isubf | Imulf | Idivf
- | Ifloatofint | Iintoffloat
- | Ispecific of Arch.specific_operation
- diff -r -u -x '*.o' -x '*.cmi' -x '*.cmo' -x '*.cmt' -x '*.cmti' -x '*.cmx' ocaml-4.00.1/asmcomp/printmach.ml ocaml-4.00.1.orig/asmcomp/printmach.ml
- --- ocaml-4.00.1/asmcomp/printmach.ml 2013-06-19 12:17:11.817037391 -0400
- +++ ocaml-4.00.1.orig/asmcomp/printmach.ml 2013-06-19 12:48:27.567037039 -0400
- @@ -127,8 +127,6 @@
- reg arg.(0)
- | Ialloc n -> fprintf ppf "alloc %i" n
- | Iintop(op) -> fprintf ppf "%a%s%a" reg arg.(0) (intop op) reg arg.(1)
- - | Iintop_nonpow2div(n, _, _) -> fprintf ppf "%a%s%i" reg arg.(0) (intop Idiv) n
- - | Iintop_nonpow2mod(n, _, _) -> fprintf ppf "%a%s%i" reg arg.(0) (intop Imod) n
- | Iintop_imm(op, n) -> fprintf ppf "%a%s%i" reg arg.(0) (intop op) n
- | Inegf -> fprintf ppf "-f %a" reg arg.(0)
- | Iabsf -> fprintf ppf "absf %a" reg arg.(0)
- diff -r -u -x '*.o' -x '*.cmi' -x '*.cmo' -x '*.cmt' -x '*.cmti' -x '*.cmx' ocaml-4.00.1/asmcomp/proc.ml ocaml-4.00.1.orig/asmcomp/proc.ml
- --- ocaml-4.00.1/asmcomp/proc.ml 2013-06-19 12:17:11.826037442 -0400
- +++ ocaml-4.00.1.orig/asmcomp/proc.ml 2013-06-19 12:48:27.745037020 -0400
- @@ -259,8 +259,6 @@
- | Iop(Iextcall(_, false)) -> destroyed_at_c_call
- | Iop(Iintop(Idiv | Imod)) -> [| rax; rdx |]
- | Iop(Istore(Single, _)) -> [| rxmm15 |]
- - | Iop(Iintop_nonpow2div( _, _, _)) -> [| rax; rcx |]
- - | Iop(Iintop_nonpow2mod( _, _, _)) -> [| rax; rcx |]
- | Iop(Ialloc _ | Iintop(Icomp _) | Iintop_imm((Idiv|Imod|Icomp _), _))
- -> [| rax |]
- | Iswitch(_, _) -> [| rax; rdx |]
- diff -r -u -x '*.o' -x '*.cmi' -x '*.cmo' -x '*.cmt' -x '*.cmti' -x '*.cmx' ocaml-4.00.1/asmcomp/reload.ml ocaml-4.00.1.orig/asmcomp/reload.ml
- --- ocaml-4.00.1/asmcomp/reload.ml 2013-06-19 12:17:11.826037442 -0400
- +++ ocaml-4.00.1.orig/asmcomp/reload.ml 2013-06-19 12:48:27.760037083 -0400
- @@ -74,8 +74,6 @@
- in registers *)
- super#reload_operation op arg res
- | Iintop(Idiv | Imod | Ilsl | Ilsr | Iasr)
- - | Iintop_nonpow2div(_, _, _)
- - | Iintop_nonpow2mod(_, _, _)
- | Iintop_imm(_, _) ->
- (* The argument(s) and results can be either in register or on stack *)
- (* Note: Idiv, Imod: arg(0) and res(0) already forced in regs
- diff -r -u -x '*.o' -x '*.cmi' -x '*.cmo' -x '*.cmt' -x '*.cmti' -x '*.cmx' ocaml-4.00.1/asmcomp/selectgen.ml ocaml-4.00.1.orig/asmcomp/selectgen.ml
- --- ocaml-4.00.1/asmcomp/selectgen.ml 2013-06-19 12:17:11.820037273 -0400
- +++ ocaml-4.00.1.orig/asmcomp/selectgen.ml 2013-06-19 12:48:27.426037085 -0400
- @@ -76,60 +76,6 @@
- fatal_error "Selection.size_expr"
- in size Tbl.empty exp
- -(* idiv and imod optimization *)
- -
- -let div_opt_number div =
- - let zero, one, two = Int64.zero ,Int64.one, Int64.of_int 2 in
- - let ( + ), ( - ), ( * ) = Int64.add, Int64.sub, Int64.mul in
- - let (lsr), (asr), ( & ) = Int64.shift_right_logical, Int64.shift_right, Int64.logand in
- - (* unsigned comparison *)
- - let greater l r eq =
- - let comp = Int64.compare l r in
- - if eq && 0 = comp then true else
- - let s_l = Int64.compare l Int64.zero in
- - let s_r = Int64.compare r Int64.zero in
- - match l, r with
- - | l, r when (s_l = -1 && s_r = -1) || (s_l <> -1 && s_r <> -1) ->
- - if -1 = comp then false else true
- - | l, _r when s_l = -1 -> true
- - | _l, _r -> false
- - in
- - (* unsigned division *)
- - let ( / ) n d =
- - let n' = n & (Int64.lognot (d asr 63)) in
- - let q = (Int64.div (n' lsr 1) d) * two in
- - let r = n - (q * d) in
- - if greater r d true then q + one else q
- - in
- - let d = Int64.of_int div in
- - let two63 = Int64.min_int in
- - let w_size = Int64.of_int 64 in
- - let t = two63 + (d lsr 63) in
- - let ad = Int64.abs d in
- - let tdivad = t / ad in
- - let anc = t - one - (t - (tdivad * ad)) in
- - let q1o = two63 / anc in
- - let q2o = two63 / ad in
- - let r1o = two63 - (q1o * anc) in
- - let r2o = two63 - (q2o * ad) in
- - let rec loop p q1 r1 q2 r2 =
- - let q1n, r1n =
- - match greater r1 anc true with
- - | true -> q1 + one, r1 - anc
- - | false -> q1, r1
- - in
- - let q2n, r2n =
- - match greater r2 ad true with
- - | true -> q2 + one, r2 - ad
- - | false -> q2, r2
- - in
- - let delta = ad - r2 in
- - match (greater delta q1 false) || (q1 = delta && r1 = zero) with
- - | true -> loop (p+one) (two*q1n) (two*r1n) (two*q2n) (two*r2n)
- - | false -> q2 + one, Int64.to_int (p - w_size)
- - in
- - loop w_size (two*q1o) (two*r1o) (two*q2o) (two*r2o)
- -
- (* Swap the two arguments of an integer comparison *)
- let swap_intcomp = function
- @@ -321,51 +267,24 @@
- | (Ccheckbound _, _) -> self#select_arith Icheckbound args
- | _ -> fatal_error "Selection.select_oper"
- -method private select_arith_comm op args =
- - match op with
- - | Imod ->
- - begin match args with
- - [arg; Cconst_int n] when self#is_immediate n
- - && (n = 1 lsl (Misc.log2 n)
- - || n = (-1) * (1 lsl (Misc.log2 ((-1) *n)))) ->
- - (Iintop_imm(Imod, n), [arg])
- - | [arg; Cconst_int n] ->
- - let m, s = div_opt_number n in
- - (Iintop_nonpow2mod(n, m, s), [arg])
- - | _ -> (Iintop Imod, args)
- - end
- - | _ ->
- - match args with
- - [arg; Cconst_int n] when self#is_immediate n ->
- - (Iintop_imm(op, n), [arg])
- - | [arg; Cconst_pointer n] when self#is_immediate n ->
- +method private select_arith_comm op = function
- + [arg; Cconst_int n] when self#is_immediate n ->
- (Iintop_imm(op, n), [arg])
- - | [Cconst_int n; arg] when self#is_immediate n ->
- + | [arg; Cconst_pointer n] when self#is_immediate n ->
- + (Iintop_imm(op, n), [arg])
- + | [Cconst_int n; arg] when self#is_immediate n ->
- (Iintop_imm(op, n), [arg])
- - | [Cconst_pointer n; arg] when self#is_immediate n ->
- + | [Cconst_pointer n; arg] when self#is_immediate n ->
- (Iintop_imm(op, n), [arg])
- - | args ->
- + | args ->
- (Iintop op, args)
- -method private select_arith op args =
- - match op with
- - | Idiv ->
- - begin match args with
- - [arg; Cconst_int n] when n = 1 lsl (Misc.log2 n)
- - || n = (-1) * (1 lsl (Misc.log2 ((-1) *n))) ->
- - (Iintop_imm(Idiv, n), [arg])
- - | [arg; Cconst_int n] ->
- - let m, s = div_opt_number n in
- - (Iintop_nonpow2div(n, m, s), [arg])
- - | _ -> (Iintop Idiv, args)
- - end
- - | _ ->
- - match args with
- - [arg; Cconst_int n] when self#is_immediate n ->
- - (Iintop_imm(op, n), [arg])
- - | [arg; Cconst_pointer n] when self#is_immediate n ->
- +method private select_arith op = function
- + [arg; Cconst_int n] when self#is_immediate n ->
- (Iintop_imm(op, n), [arg])
- - | args ->
- + | [arg; Cconst_pointer n] when self#is_immediate n ->
- + (Iintop_imm(op, n), [arg])
- + | args ->
- (Iintop op, args)
- method private select_shift op = function
- diff -r -u -x '*.o' -x '*.cmi' -x '*.cmo' -x '*.cmt' -x '*.cmti' -x '*.cmx' ocaml-4.00.1/asmcomp/selectgen.mli ocaml-4.00.1.orig/asmcomp/selectgen.mli
- --- ocaml-4.00.1/asmcomp/selectgen.mli 2013-06-19 12:17:11.819037589 -0400
- +++ ocaml-4.00.1.orig/asmcomp/selectgen.mli 2013-06-19 12:48:27.313036931 -0400
- @@ -19,8 +19,6 @@
- val size_expr : environment -> Cmm.expression -> int
- -val div_opt_number : int -> int64 * int
- -
- class virtual selector_generic : object
- (* The following methods must or can be overridden by the processor
- description *)
- diff -r -u -x '*.o' -x '*.cmi' -x '*.cmo' -x '*.cmt' -x '*.cmti' -x '*.cmx' ocaml-4.00.1/asmcomp/selection.ml ocaml-4.00.1.orig/asmcomp/selection.ml
- --- ocaml-4.00.1/asmcomp/selection.ml 2013-06-19 12:17:11.826037442 -0400
- +++ ocaml-4.00.1.orig/asmcomp/selection.ml 2013-06-19 12:48:27.756037143 -0400
- @@ -20,7 +20,6 @@
- open Cmm
- open Reg
- open Mach
- -open Selectgen
- (* Auxiliary for recognizing addressing modes *)
- @@ -107,8 +106,6 @@
- ([| rax; rcx |], [| rdx |])
- (* For div and mod with immediate operand, arg must not be in rax.
- Keep it simple, force it in rdx. *)
- - | Iintop_nonpow2mod(_, _, _)
- - | Iintop_nonpow2div(_, _, _)
- | Iintop_imm((Idiv|Imod), _) ->
- ([| rdx |], [| rdx |])
- (* Other instructions are regular *)
- @@ -168,25 +165,18 @@
- (* Recognize (x / cst) and (x % cst) only if cst is a power of 2. *)
- | Cdivi ->
- begin match args with
- - [arg1; Cconst_int n] when n = 1 lsl (Misc.log2 n)
- - || n = (-1) * (1 lsl (Misc.log2 ((-1) *n))) ->
- - (Iintop_imm(Idiv, n), [arg1])
- - | [arg1; Cconst_int n] ->
- - let m, s = div_opt_number n in
- - (Iintop_nonpow2div(n, m, s), [arg1])
- + [arg1; Cconst_int n] when self#is_immediate n
- + && n = 1 lsl (Misc.log2 n) ->
- + (Iintop_imm(Idiv, n), [arg1])
- | _ -> (Iintop Idiv, args)
- end
- | Cmodi ->
- - begin match args with
- + begin match args with
- [arg1; Cconst_int n] when self#is_immediate n
- - && (n = 1 lsl (Misc.log2 n)
- - || n = (-1) * (1 lsl (Misc.log2 ((-1) *n)))) ->
- - (Iintop_imm(Imod, n), [arg1])
- - | [arg1; Cconst_int n] ->
- - let m, s = div_opt_number n in
- - (Iintop_nonpow2mod(n, m, s), [arg1])
- + && n = 1 lsl (Misc.log2 n) ->
- + (Iintop_imm(Imod, n), [arg1])
- | _ -> (Iintop Imod, args)
- - end
- + end
- (* Recognize float arithmetic with memory. *)
- | Caddf ->
- self#select_floatarith true Iaddf Ifloatadd args
Add Comment
Please, Sign In to add comment