summaryrefslogtreecommitdiff
path: root/asmcomp
diff options
context:
space:
mode:
authorXavier Leroy <xavier.leroy@inria.fr>1995-07-24 12:44:17 +0000
committerXavier Leroy <xavier.leroy@inria.fr>1995-07-24 12:44:17 +0000
commit428f9d2303fd5fa1285ef64bb899ff2c1d22fdf9 (patch)
treeff1ff43c4cf0bb613348f9fb27e19a80f3c5e8b5 /asmcomp
parent9438561275b7419b044519ad438a1db882c12291 (diff)
downloadocaml-428f9d2303fd5fa1285ef64bb899ff2c1d22fdf9.tar.gz
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@135 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
Diffstat (limited to 'asmcomp')
-rw-r--r--asmcomp/emit_alpha.mlp8
-rw-r--r--asmcomp/emit_i386.mlp32
-rw-r--r--asmcomp/linearize.ml6
-rw-r--r--asmcomp/selection.ml12
4 files changed, 43 insertions, 15 deletions
diff --git a/asmcomp/emit_alpha.mlp b/asmcomp/emit_alpha.mlp
index 88d5222591..ae1f250b64 100644
--- a/asmcomp/emit_alpha.mlp
+++ b/asmcomp/emit_alpha.mlp
@@ -472,6 +472,10 @@ let emit_instr i =
` 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`;
@@ -482,6 +486,10 @@ let emit_instr i =
| 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`;
diff --git a/asmcomp/emit_i386.mlp b/asmcomp/emit_i386.mlp
index 3aa3d2492b..cc8e50bf32 100644
--- a/asmcomp/emit_i386.mlp
+++ b/asmcomp/emit_i386.mlp
@@ -405,36 +405,40 @@ let emit_instr i =
` 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 ->
@@ -506,7 +510,7 @@ let fundecl fundecl =
`{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 *)
diff --git a/asmcomp/linearize.ml b/asmcomp/linearize.ml
index a28be5e044..03f04aeca8 100644
--- a/asmcomp/linearize.ml
+++ b/asmcomp/linearize.ml
@@ -1,5 +1,6 @@
(* Transformation of Mach code into a list of pseudo-instructions. *)
+open Reg
open Mach
type label = int
@@ -109,6 +110,9 @@ let rec linear i n =
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 ->
@@ -171,7 +175,7 @@ let rec linear i n =
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;
diff --git a/asmcomp/selection.ml b/asmcomp/selection.ml
index 8244defad8..855c6b7782 100644
--- a/asmcomp/selection.ml
+++ b/asmcomp/selection.ml
@@ -612,6 +612,18 @@ let rec emit_tail env exp seq =
[||] [||] 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