Commits

Anonymous committed 3ac9458

emit_i386: MAJ et tests.
emit_alpha: utiliser subq pour les comparaisons + branchements.
linearize: suprression moves vides, discard_dead_code ds Lraise.
selection: try...with en tail position.

git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@135f963ae5c-01c2-4b8c-9fe0-0dff7051ff02

Comments (0)

Files changed (4)

asmcomp/emit_alpha.mlp

             `	bne	{emit_reg i.arg.(0)}, {emit_label lbl}\n`
         | Ifalsetest ->
             `	beq	{emit_reg i.arg.(0)}, {emit_label lbl}\n`
+        | Iinttest(Isigned _ | Iunsigned Ceq | Iunsigned Cne as cmp) ->
+            `	subq	{emit_reg i.arg.(0)}, {emit_reg i.arg.(1)}, $25\n`;
+            let branch = name_for_int_cond_branch cmp in
+            `	{emit_string branch}	$25, {emit_label lbl}\n`
         | Iinttest cmp ->
             let (comp, test) = name_for_int_comparison cmp in
             `	{emit_string comp}	{emit_reg i.arg.(0)}, {emit_reg i.arg.(1)}, $25\n`;
         | Iinttest_imm(cmp, 0) ->
             let branch = name_for_int_cond_branch cmp in
             `	{emit_string branch}	{emit_reg i.arg.(0)}, {emit_label lbl}\n`
+        | Iinttest_imm(Isigned _ | Iunsigned Ceq | Iunsigned Cne as cmp, n) ->
+            `	subq	{emit_reg i.arg.(0)}, {emit_int n}, $25\n`;
+            let branch = name_for_int_cond_branch cmp in
+            `	{emit_string branch}	$25, {emit_label lbl}\n`
         | Iinttest_imm(cmp, n) ->
             let (comp, test) = name_for_int_comparison cmp in
             `	{emit_string comp}	{emit_reg i.arg.(0)}, {emit_int n}, $25\n`;

asmcomp/emit_i386.mlp

             `	j{emit_string b}	{emit_label lbl}\n`
         | Ifloattest cmp ->
             `	fldl	{emit_reg i.arg.(0)}\n`;
+            let comp_instr =
+              match cmp with
+                Ceq | Cne -> "fucom"
+              | _ -> "fcom" in
             begin match i.arg.(1).loc with
               Stack s ->
-                `	fcompl	{emit_shift i.arg.(1)}\n`
+                `	{emit_string comp_instr}pl	{emit_shift i.arg.(1)}\n`
             | _ ->
-                `	fcomp	{emit_shift i.arg.(1)}\n`
+                `	{emit_string comp_instr}p	{emit_shift i.arg.(1)}\n`
             end;
             `	fnstsw	%ax\n`;
             begin match cmp with
               Ceq ->
-                `	andb	$69, %al\n`;
-                `	cmpb	$64, %al\n`;
+                `	andb	$69, %ah\n`;
+                `	cmpb	$64, %ah\n`;
                 `	je	{emit_label lbl}\n`
             | Cne ->
-                `	andb	$68, %al\n`;
-                `	xorb	$64, %al\n`;
+                `	andb	$68, %ah\n`;
+                `	xorb	$64, %ah\n`;
                 `	jne	{emit_label lbl}\n`
             | Cle ->
-                `	andb	$69, %al\n`;
-                `	decb	%al\n`;
-                `	cmpb	$64, %al\n`;
+                `	andb	$69, %ah\n`;
+                `	decb	%ah\n`;
+                `	cmpb	$64, %ah\n`;
                 `	jb	{emit_label lbl}\n`
             | Cge ->
-                `	andb	$5, %al\n`;
+                `	andb	$5, %ah\n`;
                 `	je	{emit_label lbl}\n`
             | Clt ->
-                `	andb	$69, %al\n`;
-                `	cmpb	$1, %al\n`;
+                `	andb	$69, %ah\n`;
+                `	cmpb	$1, %ah\n`;
                 `	je	{emit_label lbl}\n`
             | Cgt ->
-                `	andb	$69, %al\n`;
+                `	andb	$69, %ah\n`;
                 `	je	{emit_label lbl}\n`
             end
         | Ioddtest ->
   `{emit_label !tailrec_entry_point}:`;
   emit_all fundecl.fun_body;
   if !range_check_trap > 0 then
-    `{emit_label !range_check_trap}:	int	$5\n`
+    `{emit_label !range_check_trap}:	int	$5\n`;
   List.iter emit_float_constant !float_constants
 
 (* Emission of data *)

asmcomp/linearize.ml

 (* Transformation of Mach code into a list of pseudo-instructions. *)
 
+open Reg
 open Mach
 
 type label = int
     Iend -> n
   | Iop(Itailcall_ind | Itailcall_imm _ as op) ->
       copy_instr (Lop op) i (discard_dead_code n)
+  | Iop(Imove | Ireload | Ispill)
+    when i.Mach.arg.(0).loc = i.Mach.res.(0).loc ->
+      linear i.Mach.next n
   | Iop op ->
       copy_instr (Lop op) i (linear i.Mach.next n)
   | Ireturn ->
       cons_instr (Lsetuptrap lbl_body)
         (linear handler (add_branch lbl_join n2))
   | Iraise ->
-      copy_instr Lraise i n
+      copy_instr Lraise i (discard_dead_code n)
 
 let fundecl f =
   { fun_name = f.Mach.fun_name;

asmcomp/selection.ml

              [||] [||] seq
   | Cexit ->
       insert Iexit [||] [||] seq
+  | Ctrywith(e1, v, e2) ->
+      Proc.contains_calls := true;
+      let (r1, s1) = emit_sequence env e1 in
+      let rv = Reg.newv typ_addr in
+      let s2 = emit_tail_sequence (Tbl.add v rv env) e2 in
+      let loc = Proc.loc_results r1 in
+      insert
+        (Itrywith(extract_sequence s1,
+                  instr_cons (Iop Imove) [|Proc.loc_exn_bucket|] rv s2))
+        [||] [||] seq;
+      insert_moves r1 loc seq;
+      insert Ireturn loc [||] seq
   | _ ->
       emit_return env exp seq
 
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.