From 47a4ccade6f73e95be34cd2d55be3655302fff97 Mon Sep 17 00:00:00 2001 From: David Monniaux Date: Thu, 21 Mar 2019 20:29:57 +0100 Subject: begin jumptables (does not work) --- common/Switchaux.ml | 5 ----- mppa_k1c/Asm.v | 2 ++ mppa_k1c/Asmblock.v | 11 +++++++++++ mppa_k1c/Asmblockdeps.v | 42 +++++++++++++++++++++++++++++++++++++++++- mppa_k1c/Asmblockgen.v | 5 +++-- 5 files changed, 57 insertions(+), 8 deletions(-) diff --git a/common/Switchaux.ml b/common/Switchaux.ml index 06337e7d..69300feb 100644 --- a/common/Switchaux.ml +++ b/common/Switchaux.ml @@ -80,10 +80,6 @@ let compile_switch_as_jumptable default cases minkey maxkey = CTaction default) let dense_enough (numcases: int) (minkey: Z.t) (maxkey: Z.t) = - (* FIXME DMonniaux disable jump tables until we can prove them through *) - false - -(* let span = Z.sub maxkey minkey in assert (Z.ge span Z.zero); let tree_size = Z.mul (Z.of_uint 4) (Z.of_uint numcases) @@ -91,7 +87,6 @@ let dense_enough (numcases: int) (minkey: Z.t) (maxkey: Z.t) = numcases >= 7 (* small jump tables are always less efficient *) && Z.le table_size tree_size && Z.lt span (Z.of_uint Sys.max_array_length) - *) let compile_switch modulus default table = let (tbl, keys) = normalize_table table in diff --git a/mppa_k1c/Asm.v b/mppa_k1c/Asm.v index 493f4a05..8c918c2d 100644 --- a/mppa_k1c/Asm.v +++ b/mppa_k1c/Asm.v @@ -69,6 +69,7 @@ Inductive instruction : Type := | Pj_l (l: label) (**r jump to label *) | Pcb (bt: btest) (r: ireg) (l: label) (**r branch based on btest *) | Pcbu (bt: btest) (r: ireg) (l: label) (**r branch based on btest with unsigned semantics *) + | Pjumptable (r: ireg) (labels: list label) | Ploopdo (count: ireg) (loopend: label) (** Loads **) @@ -228,6 +229,7 @@ Definition control_to_instruction (c: control) := | PCtlFlow (Asmblock.Pj_l l) => Pj_l l | PCtlFlow (Asmblock.Pcb bt r l) => Pcb bt r l | PCtlFlow (Asmblock.Pcbu bt r l) => Pcbu bt r l + | PCtlFlow (Asmblock.Pjumptable r label) => Pjumptable r label end. Definition basic_to_instruction (b: basic) := diff --git a/mppa_k1c/Asmblock.v b/mppa_k1c/Asmblock.v index d335801e..dfe46e04 100644 --- a/mppa_k1c/Asmblock.v +++ b/mppa_k1c/Asmblock.v @@ -233,6 +233,7 @@ Inductive cf_instruction : Type := | Pret (**r return *) | Pcall (l: label) (**r function call *) | Picall (r: ireg) (**r function call on register value *) + | Pjumptable (r: ireg) (labels: list label) (**r N-way branch through a jump table (pseudo) *) (* Pgoto is for tailcalls, Pj_l is for jumping to a particular label *) | Pgoto (l: label) (**r goto *) @@ -1470,6 +1471,16 @@ Definition exec_control (f: function) (oc: option control) (rs: regset) (m: mem) Next (rs#PC <- (rs#r)) m | Pj_l l => goto_label f l rs m + | Pjumptable r tbl => + match rs#r with + | Vint n => + match list_nth_z tbl (Int.unsigned n) with + | None => Stuck + | Some lbl => goto_label f lbl (rs #GPR62 <- Vundef #GPR63 <- Vundef) m + end + | _ => Stuck + end + | Pcb bt r l => match cmp_for_btest bt with | (Some c, Int) => eval_branch f l rs m (Val.cmp_bool c rs#r (Vint (Int.repr 0))) diff --git a/mppa_k1c/Asmblockdeps.v b/mppa_k1c/Asmblockdeps.v index 501ec212..8c799927 100644 --- a/mppa_k1c/Asmblockdeps.v +++ b/mppa_k1c/Asmblockdeps.v @@ -42,6 +42,7 @@ Inductive control_op := | Odivu | OError | OIncremPC (sz: Z) + | Ojumptable (l: list label) . Inductive arith_op := @@ -180,6 +181,15 @@ Definition eval_branch_deps (f: function) (l: label) (vpc: val) (res: option boo Definition control_eval (o: control_op) (l: list value) := let (ge, fn) := Ge in match o, l with + | (Ojumptable tbl), [Val index; Val vpc] => + match index with + | Vint n => + match list_nth_z tbl (Int.unsigned n) with + | None => None + | Some lbl => goto_label_deps fn lbl vpc + end + | _ => None + end | Oj_l l, [Val vpc] => goto_label_deps fn l vpc | Ocb bt l, [Val v; Val vpc] => match cmp_for_btest bt with @@ -540,6 +550,7 @@ Definition trans_control (ctl: control) : macro := | Pj_l l => [(#PC, Op (Control (Oj_l l)) (Name (#PC) @ Enil))] | Pcb bt r l => [(#PC, Op (Control (Ocb bt l)) (Name (#r) @ Name (#PC) @ Enil))] | Pcbu bt r l => [(#PC, Op (Control (Ocbu bt l)) (Name (#r) @ Name (#PC) @ Enil))] + | Pjumptable r labels => [(#PC, Op (Control (Ojumptable labels)) (Name (#r) @ Name (#PC) @ Enil)) ] | Pdiv => [(#GPR0, Op (Control Odiv) (Name (#GPR0) @ Name (#GPR1) @ Enil)); (#RA, Name (#RA))] | Pdivu => [(#GPR0, Op (Control Odivu) (Name (#GPR0) @ Name (#GPR1) @ Enil)); (#RA, Name (#RA))] | Pbuiltin ef args res => [(#PC, Op (Control (OError)) Enil)] @@ -879,8 +890,37 @@ Proof. Simpl. * Simpl. * intros rr; destruct rr; Simpl. destruct (preg_eq GPR0 g); Simpl. rewrite e. Simpl. + (* Pjumptable *) + + unfold goto_label in *. + destruct (nextblock b rs r) eqn:NB_r in *; try discriminate. + destruct (list_nth_z _ _) eqn:LI in *; try discriminate. + destruct (label_pos _ _ _) eqn:LPOS in *; try discriminate. + rewrite Pregmap.gso in H0; try discriminate. + rewrite Pregmap.gso in H0; try discriminate. + eexists; split; try split. + * simpl control_eval. + rewrite (H3 PC). + simpl. + unfold goto_label_deps. + Simpl. + rewrite H3. + destruct (rs r); try discriminate. + ++ + destruct (nextblock b rs PC) eqn:NB_PC in *; try discriminate. + inv H0. + + destruct (s (# PC)) eqn:sPC in *; try discriminate. + rewrite Pregmap.gso; try discriminate. + destruct (nextblock b rs r) eqn:NB_r in *; try discriminate. + destruct (list_nth_z _ _) eqn:LI in *; try discriminate. + destruct (label_pos _ _ _) eqn:LPOS in *; try discriminate. + destruct (nextblock b rs PC) eqn:NB_PC in *; try discriminate. + inv H1; try discriminate. + assumption. (* Pj_l *) - + unfold goto_label in H0. destruct (label_pos _ _ _) eqn:LPOS; try discriminate. destruct (nextblock _ _ _) eqn:NB; try discriminate. inv H0. + + unfold goto_label in H0. + destruct (label_pos _ _ _) eqn:LPOS; try discriminate. + destruct (nextblock _ _ _) eqn:NB; try discriminate. inv H0. eexists; split; try split. * simpl control_eval. pose (H3 PC); simpl in e; rewrite e. simpl. unfold goto_label_deps. rewrite LPOS. rewrite nextblock_pc in NB. rewrite NB. reflexivity. diff --git a/mppa_k1c/Asmblockgen.v b/mppa_k1c/Asmblockgen.v index 5b00a64f..f3b4b921 100644 --- a/mppa_k1c/Asmblockgen.v +++ b/mppa_k1c/Asmblockgen.v @@ -911,8 +911,9 @@ Definition transl_instr_control (f: Machblock.function) (oi: option Machblock.co | MBreturn => OK (make_epilogue f (Pret ::g nil)) (*OK (make_epilogue f (Pj_r RA f.(Mach.fn_sig) :: k))*) - | MBjumptable _ _ => - Error (msg "Asmblockgen.transl_instr_control MBjumptable") + | MBjumptable arg tbl => + do r <- ireg_of arg; + OK (Pjumptable r tbl ::g nil) end end. -- cgit From 44cfe47f9e5d0c40fad23fccdb4b37b1ea3c1071 Mon Sep 17 00:00:00 2001 From: Cyril SIX Date: Fri, 22 Mar 2019 12:04:43 +0100 Subject: Fixed proof of Asmblockdeps wrt Pjumptable --- mppa_k1c/Asmblockdeps.v | 53 ++++++++++++++++++++++++++----------------------- 1 file changed, 28 insertions(+), 25 deletions(-) diff --git a/mppa_k1c/Asmblockdeps.v b/mppa_k1c/Asmblockdeps.v index 8c799927..1acc3b58 100644 --- a/mppa_k1c/Asmblockdeps.v +++ b/mppa_k1c/Asmblockdeps.v @@ -366,6 +366,7 @@ Definition control_op_eq (c1 c2: control_op): ?? bool := | Oj_l l1, Oj_l l2 => phys_eq l1 l2 | Ocb bt1 l1, Ocb bt2 l2 => iandb (phys_eq bt1 bt2) (phys_eq l1 l2) | Ocbu bt1 l1, Ocbu bt2 l2 => iandb (phys_eq bt1 bt2) (phys_eq l1 l2) + | Ojumptable tbl1, Ojumptable tbl2 => phys_eq tbl1 tbl2 | Odiv, Odiv => RET true | Odivu, Odivu => RET true | OIncremPC sz1, OIncremPC sz2 => RET (Z.eqb sz1 sz2) @@ -381,6 +382,7 @@ Proof. - apply andb_prop in H1; inversion H1; apply H in H2; apply H0 in H3; congruence. - apply andb_prop in H1; inversion H1; apply H in H2; apply H0 in H3; congruence. - rewrite Z.eqb_eq in * |-. congruence. + - congruence. Qed. @@ -550,7 +552,9 @@ Definition trans_control (ctl: control) : macro := | Pj_l l => [(#PC, Op (Control (Oj_l l)) (Name (#PC) @ Enil))] | Pcb bt r l => [(#PC, Op (Control (Ocb bt l)) (Name (#r) @ Name (#PC) @ Enil))] | Pcbu bt r l => [(#PC, Op (Control (Ocbu bt l)) (Name (#r) @ Name (#PC) @ Enil))] - | Pjumptable r labels => [(#PC, Op (Control (Ojumptable labels)) (Name (#r) @ Name (#PC) @ Enil)) ] + | Pjumptable r labels => [(#PC, Op (Control (Ojumptable labels)) (Name (#r) @ Name (#PC) @ Enil)); + (#GPR62, Op (Constant Vundef) Enil); + (#GPR63, Op (Constant Vundef) Enil) ] | Pdiv => [(#GPR0, Op (Control Odiv) (Name (#GPR0) @ Name (#GPR1) @ Enil)); (#RA, Name (#RA))] | Pdivu => [(#GPR0, Op (Control Odivu) (Name (#GPR0) @ Name (#GPR1) @ Enil)); (#RA, Name (#RA))] | Pbuiltin ef args res => [(#PC, Op (Control (OError)) Enil)] @@ -892,31 +896,21 @@ Proof. * intros rr; destruct rr; Simpl. destruct (preg_eq GPR0 g); Simpl. rewrite e. Simpl. (* Pjumptable *) + unfold goto_label in *. - destruct (nextblock b rs r) eqn:NB_r in *; try discriminate. - destruct (list_nth_z _ _) eqn:LI in *; try discriminate. - destruct (label_pos _ _ _) eqn:LPOS in *; try discriminate. - rewrite Pregmap.gso in H0; try discriminate. - rewrite Pregmap.gso in H0; try discriminate. + repeat (rewrite Pregmap.gso in H0; try discriminate). + destruct (nextblock _ _ _) eqn:NB; try discriminate. + destruct (list_nth_z _ _) eqn:LI; try discriminate. + destruct (label_pos _ _ _) eqn:LPOS; try discriminate. + destruct (nextblock b rs PC) eqn:MB2; try discriminate. inv H0. eexists; split; try split. - * simpl control_eval. - rewrite (H3 PC). - simpl. - unfold goto_label_deps. - Simpl. - rewrite H3. - destruct (rs r); try discriminate. - ++ - destruct (nextblock b rs PC) eqn:NB_PC in *; try discriminate. - inv H0. - - destruct (s (# PC)) eqn:sPC in *; try discriminate. - rewrite Pregmap.gso; try discriminate. - destruct (nextblock b rs r) eqn:NB_r in *; try discriminate. - destruct (list_nth_z _ _) eqn:LI in *; try discriminate. - destruct (label_pos _ _ _) eqn:LPOS in *; try discriminate. - destruct (nextblock b rs PC) eqn:NB_PC in *; try discriminate. - inv H1; try discriminate. - assumption. + * simpl control_eval. rewrite (H3 PC). simpl. Simpl. + rewrite H3. unfold nextblock in NB. rewrite Pregmap.gso in NB; try discriminate. rewrite NB. + rewrite LI. unfold goto_label_deps. rewrite LPOS. + unfold nextblock in MB2. rewrite Pregmap.gss in MB2. rewrite MB2. + reflexivity. + * Simpl. + * intros rr; destruct rr; Simpl. + destruct (preg_eq GPR62 g); Simpl. rewrite e. Simpl. + destruct (preg_eq GPR63 g); Simpl. rewrite e. Simpl. (* Pj_l *) + unfold goto_label in H0. destruct (label_pos _ _ _) eqn:LPOS; try discriminate. @@ -1116,6 +1110,11 @@ Proof. (* Pdivu *) - simpl in *. pose (H3 GPR0); rewrite e in H1; clear e. pose (H3 GPR1); rewrite e in H1; clear e. destruct (Val.divu _ _); try discriminate; auto. +(* Pjumptable *) + - simpl in *. repeat (rewrite H3 in H1). + destruct (rs r); try discriminate; auto. destruct (list_nth_z _ _); try discriminate; auto. + unfold goto_label_deps in H1. unfold goto_label. Simpl. + destruct (label_pos _ _ _); auto. destruct (rs PC); auto. discriminate. (* Pj_l *) - simpl in *. pose (H3 PC); simpl in e; rewrite e in H1. clear e. unfold goto_label_deps in H1. unfold goto_label. @@ -1232,6 +1231,9 @@ Proof. destruct (Val.divs _ _); try discriminate; auto. - simpl in *. pose (H3 GPR0); simpl in e; rewrite e; clear e. pose (H3 GPR1); simpl in e; rewrite e; clear e. destruct (Val.divu _ _); try discriminate; auto. + - simpl in *. repeat (rewrite H3). destruct (rs r); try discriminate; auto. destruct (list_nth_z _ _); try discriminate; auto. + unfold goto_label_deps. unfold goto_label in H0. + destruct (label_pos _ _ _); auto. repeat (rewrite Pregmap.gso in H0; try discriminate). destruct (rs PC); auto. discriminate. (* Pj_l *) - simpl in *. pose (H3 PC); simpl in e; rewrite e. unfold goto_label_deps. unfold goto_label in H0. destruct (label_pos _ _ _); auto. clear e. destruct (rs PC); auto. discriminate. @@ -1573,6 +1575,7 @@ Definition string_of_control (op: control_op) : pstring := | Ocbu _ _ => "Ocbu" | Odiv => "Odiv" | Odivu => "Odivu" + | Ojumptable _ => "Ojumptable" | OError => "OError" | OIncremPC _ => "OIncremPC" end. -- cgit From 13effac30e636d890f891863f04c3d379713b34a Mon Sep 17 00:00:00 2001 From: David Monniaux Date: Fri, 22 Mar 2019 14:23:35 +0100 Subject: jumptable avance --- mppa_k1c/Asmblockgenproof.v | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/mppa_k1c/Asmblockgenproof.v b/mppa_k1c/Asmblockgenproof.v index ea4d1918..f07cb6a4 100644 --- a/mppa_k1c/Asmblockgenproof.v +++ b/mppa_k1c/Asmblockgenproof.v @@ -883,11 +883,16 @@ Proof. intros until x2. intros Hbuiltin TIC. destruct ex. - destruct c. + (* MBcall *) + simpl in TIC. exploreInst; simpl; eauto. + (* MBtailcall *) + simpl in TIC. exploreInst; simpl; eauto. + (* MBbuiltin *) + assert (H: Some (MBbuiltin e l b) <> Some (MBbuiltin e l b)). apply Hbuiltin. contradict H; auto. + (* MBgoto *) + simpl in TIC. exploreInst; simpl; eauto. + (* MBcond *) + simpl in TIC. unfold transl_cbranch in TIC. exploreInst; simpl; eauto. * unfold transl_opt_compuimm. exploreInst; simpl; eauto. * unfold transl_opt_compluimm. exploreInst; simpl; eauto. @@ -895,7 +900,9 @@ Proof. * unfold transl_comp_notfloat64. exploreInst; simpl; eauto. * unfold transl_comp_float32. exploreInst; simpl; eauto. * unfold transl_comp_notfloat32. exploreInst; simpl; eauto. - + simpl in TIC. inv TIC. + (* MBjumptable *) + + simpl in TIC. exploreInst; simpl; eauto. + (* MBreturn *) + simpl in TIC. monadInv TIC. simpl. eauto. - monadInv TIC. simpl; auto. Qed. -- cgit From 355736095980774b06c4feef9a313f1eb2528091 Mon Sep 17 00:00:00 2001 From: David Monniaux Date: Fri, 22 Mar 2019 14:47:03 +0100 Subject: on avance sur la jumptable --- mppa_k1c/Asmblockgenproof.v | 5 ++--- mppa_k1c/PostpassSchedulingproof.v | 1 + 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/mppa_k1c/Asmblockgenproof.v b/mppa_k1c/Asmblockgenproof.v index f07cb6a4..5d952d02 100644 --- a/mppa_k1c/Asmblockgenproof.v +++ b/mppa_k1c/Asmblockgenproof.v @@ -1364,8 +1364,7 @@ Proof. all: rewrite <- C; try discriminate; unfold nextblock; Simpl. } intros. discriminate. + (* MBjumptable *) - destruct bb' as [mhd' mbdy' mex']; simpl in *. subst. - inv TBC. inv TIC. + admit. + (* MBreturn *) destruct bb' as [mhd' mbdy' mex']; simpl in *. subst. inv TBC. inv TIC. inv H0. @@ -1400,7 +1399,7 @@ Proof. generalize (code_tail_next_int _ _ _ _ NOOV TAIL). intro CT1. eauto. eapply agree_exten; eauto. intros. Simpl. discriminate. -Qed. +Admitted. Definition mb_remove_first (bb: MB.bblock) := {| MB.header := MB.header bb; MB.body := tail (MB.body bb); MB.exit := MB.exit bb |}. diff --git a/mppa_k1c/PostpassSchedulingproof.v b/mppa_k1c/PostpassSchedulingproof.v index 33912203..b59c381c 100644 --- a/mppa_k1c/PostpassSchedulingproof.v +++ b/mppa_k1c/PostpassSchedulingproof.v @@ -550,6 +550,7 @@ Proof. - unfold eval_branch. unfold goto_label. erewrite label_pos_preserved_blocks; eauto. - unfold eval_branch. unfold goto_label. erewrite label_pos_preserved_blocks; eauto. - unfold eval_branch. unfold goto_label. erewrite label_pos_preserved_blocks; eauto. + - unfold eval_branch. unfold goto_label. erewrite label_pos_preserved_blocks; eauto. Qed. Lemma eval_offset_preserved: -- cgit From 88448ee297d8894ecfb09d7925663cf6eb12cf01 Mon Sep 17 00:00:00 2001 From: David Monniaux Date: Fri, 22 Mar 2019 15:44:07 +0100 Subject: Jump tables now work. There is still an "Admitted" subcase in a proof. --- mppa_k1c/Machregs.v | 3 +-- mppa_k1c/PostpassSchedulingOracle.ml | 1 + mppa_k1c/TargetPrinter.ml | 16 +++++++++++++--- 3 files changed, 15 insertions(+), 5 deletions(-) diff --git a/mppa_k1c/Machregs.v b/mppa_k1c/Machregs.v index 4de37af4..60142797 100644 --- a/mppa_k1c/Machregs.v +++ b/mppa_k1c/Machregs.v @@ -152,8 +152,7 @@ Definition destroyed_by_store (chunk: memory_chunk) (addr: addressing): list mre Definition destroyed_by_cond (cond: condition): list mreg := nil. -(* Definition destroyed_by_jumptable: list mreg := R5 :: nil. *) -Definition destroyed_by_jumptable: list mreg := nil. +Definition destroyed_by_jumptable: list mreg := R62 :: R63 :: nil. Fixpoint destroyed_by_clobber (cl: list string): list mreg := match cl with diff --git a/mppa_k1c/PostpassSchedulingOracle.ml b/mppa_k1c/PostpassSchedulingOracle.ml index 2c39e342..25262af2 100644 --- a/mppa_k1c/PostpassSchedulingOracle.ml +++ b/mppa_k1c/PostpassSchedulingOracle.ml @@ -234,6 +234,7 @@ let ctl_flow_rec = function | Pj_l lbl -> { inst = "Pj_l"; write_locs = []; read_locs = []; imm = None ; is_control = true} | Pcb (bt, rs, lbl) -> { inst = "Pcb"; write_locs = []; read_locs = [Reg (IR rs)]; imm = None ; is_control = true} | Pcbu (bt, rs, lbl) -> { inst = "Pcbu"; write_locs = []; read_locs = [Reg (IR rs)]; imm = None ; is_control = true} + | Pjumptable (r, _) -> { inst = "Pjumptable"; write_locs = [Reg (IR GPR62); Reg (IR GPR63)]; read_locs = [Reg (IR r)]; imm = None ; is_control = true} let control_rec i = match i with diff --git a/mppa_k1c/TargetPrinter.ml b/mppa_k1c/TargetPrinter.ml index d4e2afc9..5bcb5cc8 100644 --- a/mppa_k1c/TargetPrinter.ml +++ b/mppa_k1c/TargetPrinter.ml @@ -268,7 +268,17 @@ module Target (*: TARGET*) = fprintf oc " cb.%a %a? %a\n" bcond bt ireg r print_label lbl | Ploopdo (r, lbl) -> fprintf oc " loopdo %a, %a\n" ireg r print_label lbl - + | Pjumptable (idx_reg, tbl) -> + let lbl = new_label() in + jumptables := (lbl, tbl) :: !jumptables; + let base_reg = if idx_reg=Asmblock.GPR63 then Asmblock.GPR62 else Asmblock.GPR63 in + fprintf oc "%s jumptable [ " comment; + List.iter (fun l -> fprintf oc "%a " print_label l) tbl; + fprintf oc "]\n"; + fprintf oc " make %a = %a\n ;;\n" ireg base_reg label lbl; + fprintf oc " lwz.xs %a = %a[%a]\n ;;\n" ireg base_reg ireg idx_reg ireg base_reg; + fprintf oc " igoto %a\n ;;\n" ireg base_reg + (* Load/Store instructions *) | Plb(rd, ra, ofs) -> fprintf oc " lbs %a = %a[%a]\n" ireg rd offset ofs ireg ra @@ -522,8 +532,8 @@ module Target (*: TARGET*) = let print_tbl oc (lbl, tbl) = fprintf oc "%a:\n" label lbl; List.iter - (fun l -> fprintf oc " .long %a - %a\n" - print_label l label lbl) + (fun l -> fprintf oc " .4byte %a\n" + print_label l) tbl in if !jumptables <> [] then begin -- cgit From c042c12fc4728a3db1f4c619c37108244086d07c Mon Sep 17 00:00:00 2001 From: David Monniaux Date: Fri, 22 Mar 2019 16:45:30 +0100 Subject: some more testing --- test/monniaux/csmith/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/monniaux/csmith/Makefile b/test/monniaux/csmith/Makefile index b094e425..e6961036 100644 --- a/test/monniaux/csmith/Makefile +++ b/test/monniaux/csmith/Makefile @@ -1,5 +1,5 @@ CSMITH=csmith -MAX=100 +MAX=1000 include ../rules.mk K1C_CCOMPFLAGS+=-I/usr/include/csmith -fstruct-passing -fbitfields -- cgit From dbc2baea8d77745e4808aa223fce16816d2acccd Mon Sep 17 00:00:00 2001 From: David Monniaux Date: Fri, 22 Mar 2019 16:52:40 +0100 Subject: uses yarpgen random generator --- test/monniaux/yarpgen/Makefile | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 test/monniaux/yarpgen/Makefile diff --git a/test/monniaux/yarpgen/Makefile b/test/monniaux/yarpgen/Makefile new file mode 100644 index 00000000..378717a0 --- /dev/null +++ b/test/monniaux/yarpgen/Makefile @@ -0,0 +1,37 @@ +YARPGEN=yarpgen +MAX=10 +PREFIX=ran%06.f +include ../rules.mk + +K1C_CCOMPFLAGS += -funprototyped -fbitfields + +TARGETS_C=$(shell seq --format $(PREFIX)/func.c 0 $(MAX)) \ + $(shell seq --format $(PREFIX)/driver.c 0 $(MAX)) \ + $(shell seq --format $(PREFIX)/init.h 0 $(MAX)) +TARGETS_CCOMP_S=$(shell seq --format $(PREFIX)/func.ccomp.k1c.s 0 $(MAX)) \ + $(shell seq --format $(PREFIX)/driver.ccomp.k1c.s 0 $(MAX)) +TARGETS_GCC_S=$(shell seq --format $(PREFIX)/func.gcc.k1c.s 0 $(MAX)) \ + $(shell seq --format $(PREFIX)/driver.gcc.k1c.s 0 $(MAX)) +TARGETS_CCOMP_OUT=$(shell seq --format $(PREFIX)/example.ccomp.k1c.out 0 $(MAX)) +TARGETS_GCC_OUT=$(shell seq --format $(PREFIX)/example.gcc.k1c.out 0 $(MAX)) +TARGETS_GCC_HOST_OUT=$(shell seq --format $(PREFIX)/example.gcc.host.out 0 $(MAX)) + +all: $(TARGETS_CCOMP_OUT) $(TARGETS_GCC_OUT) $(TARGETS_GCC_HOST_OUT) + +ran%/example.ccomp.k1c: ran%/func.ccomp.k1c.o ran%/driver.ccomp.k1c.o + $(K1C_CCOMP) $(K1C_CCOMPFLAGS) $+ -o $@ + +ran%/example.gcc.k1c: ran%/func.gcc.k1c.o ran%/driver.gcc.k1c.o + $(K1C_CC) $(K1C_CFLAGS) $+ -o $@ + +ran%/example.gcc.host: ran%/func.gcc.host.o ran%/driver.gcc.host.o + $(CC) $(CFLAGS) $+ -o $@ + +ran%/driver.c ran%/func.c ran%/init.h: + -mkdir ran$* + $(YARPGEN) --seed=$* --out-dir=ran$*/ --std=c99 + +.PHONY: all clean + +clean: + -rm -rf ran* -- cgit From d60821fc996345c00d8b28e9a2e729c540c4f4f8 Mon Sep 17 00:00:00 2001 From: David Monniaux Date: Fri, 22 Mar 2019 17:09:54 +0100 Subject: improved testing --- test/monniaux/yarpgen/Makefile | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/test/monniaux/yarpgen/Makefile b/test/monniaux/yarpgen/Makefile index 378717a0..3c22ccfd 100644 --- a/test/monniaux/yarpgen/Makefile +++ b/test/monniaux/yarpgen/Makefile @@ -4,19 +4,27 @@ PREFIX=ran%06.f include ../rules.mk K1C_CCOMPFLAGS += -funprototyped -fbitfields +CCOMPFLAGS += -funprototyped -fbitfields TARGETS_C=$(shell seq --format $(PREFIX)/func.c 0 $(MAX)) \ $(shell seq --format $(PREFIX)/driver.c 0 $(MAX)) \ $(shell seq --format $(PREFIX)/init.h 0 $(MAX)) -TARGETS_CCOMP_S=$(shell seq --format $(PREFIX)/func.ccomp.k1c.s 0 $(MAX)) \ +TARGETS_CCOMP_K1C_S=$(shell seq --format $(PREFIX)/func.ccomp.k1c.s 0 $(MAX)) \ $(shell seq --format $(PREFIX)/driver.ccomp.k1c.s 0 $(MAX)) -TARGETS_GCC_S=$(shell seq --format $(PREFIX)/func.gcc.k1c.s 0 $(MAX)) \ +TARGETS_GCC_K1C_S=$(shell seq --format $(PREFIX)/func.gcc.k1c.s 0 $(MAX)) \ $(shell seq --format $(PREFIX)/driver.gcc.k1c.s 0 $(MAX)) -TARGETS_CCOMP_OUT=$(shell seq --format $(PREFIX)/example.ccomp.k1c.out 0 $(MAX)) -TARGETS_GCC_OUT=$(shell seq --format $(PREFIX)/example.gcc.k1c.out 0 $(MAX)) +TARGETS_CCOMP_HOST_S=$(shell seq --format $(PREFIX)/func.ccomp.host.s 0 $(MAX)) \ + $(shell seq --format $(PREFIX)/driver.ccomp.host.s 0 $(MAX)) +TARGETS_GCC_HOST_S=$(shell seq --format $(PREFIX)/func.gcc.host.s 0 $(MAX)) \ + $(shell seq --format $(PREFIX)/driver.gcc.host.s 0 $(MAX)) +TARGETS_CCOMP_K1C_OUT=$(shell seq --format $(PREFIX)/example.ccomp.k1c.out 0 $(MAX)) +TARGETS_GCC_K1C_OUT=$(shell seq --format $(PREFIX)/example.gcc.k1c.out 0 $(MAX)) TARGETS_GCC_HOST_OUT=$(shell seq --format $(PREFIX)/example.gcc.host.out 0 $(MAX)) +TARGETS_CCOMP_HOST_OUT=$(shell seq --format $(PREFIX)/example.ccomp.host.out 0 $(MAX)) -all: $(TARGETS_CCOMP_OUT) $(TARGETS_GCC_OUT) $(TARGETS_GCC_HOST_OUT) +all: $(TARGETS_CCOMP_K1C_OUT) $(TARGETS_GCC_K1C_OUT) $(TARGETS_GCC_HOST_OUT) $(TARGETS_CCOMP_HOST_OUT) $(TARGETS_CCOMP_K1C_S) $(TARGETS_GCC_K1C_S) $(TARGETS_GCC_HOST_S) $(TARGETS_CCOMP_HOST_S) + +ran%/func.ccomp.k1c.s ran%/func.gcc.k1c.s ran%/func.ccomp.host.s ran%/func.gcc.host.s : ran%/init.h ran%/example.ccomp.k1c: ran%/func.ccomp.k1c.o ran%/driver.ccomp.k1c.o $(K1C_CCOMP) $(K1C_CCOMPFLAGS) $+ -o $@ @@ -27,6 +35,9 @@ ran%/example.gcc.k1c: ran%/func.gcc.k1c.o ran%/driver.gcc.k1c.o ran%/example.gcc.host: ran%/func.gcc.host.o ran%/driver.gcc.host.o $(CC) $(CFLAGS) $+ -o $@ +ran%/example.ccomp.host: ran%/func.ccomp.host.o ran%/driver.ccomp.host.o + $(CCOMP) $(CCOMPFLAGS) $+ -o $@ + ran%/driver.c ran%/func.c ran%/init.h: -mkdir ran$* $(YARPGEN) --seed=$* --out-dir=ran$*/ --std=c99 -- cgit From c1b481f7eb46000110b71cfa9ea73694adc6b009 Mon Sep 17 00:00:00 2001 From: David Monniaux Date: Fri, 22 Mar 2019 19:49:31 +0100 Subject: FIX BUG in TargetPrinter (nandd immediate wrongly printed as andd) --- mppa_k1c/TargetPrinter.ml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mppa_k1c/TargetPrinter.ml b/mppa_k1c/TargetPrinter.ml index 233dffec..29e0fef4 100644 --- a/mppa_k1c/TargetPrinter.ml +++ b/mppa_k1c/TargetPrinter.ml @@ -498,7 +498,7 @@ module Target (*: TARGET*) = | Pandil (rd, rs, imm) -> assert Archi.ptr64; fprintf oc " andd %a = %a, %a\n" ireg rd ireg rs coqint64 imm | Pnandil (rd, rs, imm) -> assert Archi.ptr64; - fprintf oc " andd %a = %a, %a\n" ireg rd ireg rs coqint64 imm + fprintf oc " nandd %a = %a, %a\n" ireg rd ireg rs coqint64 imm | Poril (rd, rs, imm) -> assert Archi.ptr64; fprintf oc " ord %a = %a, %a\n" ireg rd ireg rs coqint64 imm | Pnoril (rd, rs, imm) -> assert Archi.ptr64; -- cgit From 60c426f4eb1872a85cf35c349aa176932773cc97 Mon Sep 17 00:00:00 2001 From: David Monniaux Date: Fri, 22 Mar 2019 21:27:01 +0100 Subject: check that gcc and ccomp compiled k1c code return the same --- test/monniaux/yarpgen/Makefile | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/test/monniaux/yarpgen/Makefile b/test/monniaux/yarpgen/Makefile index 3c22ccfd..9da82deb 100644 --- a/test/monniaux/yarpgen/Makefile +++ b/test/monniaux/yarpgen/Makefile @@ -1,5 +1,5 @@ YARPGEN=yarpgen -MAX=10 +MAX=300 PREFIX=ran%06.f include ../rules.mk @@ -21,8 +21,9 @@ TARGETS_CCOMP_K1C_OUT=$(shell seq --format $(PREFIX)/example.ccomp.k1c.out 0 $(M TARGETS_GCC_K1C_OUT=$(shell seq --format $(PREFIX)/example.gcc.k1c.out 0 $(MAX)) TARGETS_GCC_HOST_OUT=$(shell seq --format $(PREFIX)/example.gcc.host.out 0 $(MAX)) TARGETS_CCOMP_HOST_OUT=$(shell seq --format $(PREFIX)/example.ccomp.host.out 0 $(MAX)) +TARGETS_CMP=$(shell seq --format $(PREFIX)/example.k1c.cmp 0 $(MAX)) -all: $(TARGETS_CCOMP_K1C_OUT) $(TARGETS_GCC_K1C_OUT) $(TARGETS_GCC_HOST_OUT) $(TARGETS_CCOMP_HOST_OUT) $(TARGETS_CCOMP_K1C_S) $(TARGETS_GCC_K1C_S) $(TARGETS_GCC_HOST_S) $(TARGETS_CCOMP_HOST_S) +all: $(TARGETS_CCOMP_K1C_OUT) $(TARGETS_GCC_K1C_OUT) $(TARGETS_GCC_HOST_OUT) $(TARGETS_CCOMP_HOST_OUT) $(TARGETS_CCOMP_K1C_S) $(TARGETS_GCC_K1C_S) $(TARGETS_GCC_HOST_S) $(TARGETS_CCOMP_HOST_S) $(TARGETS_CMP) $(TARGETS_C) ran%/func.ccomp.k1c.s ran%/func.gcc.k1c.s ran%/func.ccomp.host.s ran%/func.gcc.host.s : ran%/init.h @@ -42,6 +43,9 @@ ran%/driver.c ran%/func.c ran%/init.h: -mkdir ran$* $(YARPGEN) --seed=$* --out-dir=ran$*/ --std=c99 +ran%/example.k1c.cmp : ran%/example.gcc.k1c.out ran%/example.ccomp.k1c.out + cmp $+ > $@ + .PHONY: all clean clean: -- cgit From 402a7c3eead452af1d40a2cf5d51907a07473640 Mon Sep 17 00:00:00 2001 From: David Monniaux Date: Fri, 22 Mar 2019 22:36:51 +0100 Subject: for testing with quest --- test/monniaux/quest/Makefile | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 test/monniaux/quest/Makefile diff --git a/test/monniaux/quest/Makefile b/test/monniaux/quest/Makefile new file mode 100644 index 00000000..c049238b --- /dev/null +++ b/test/monniaux/quest/Makefile @@ -0,0 +1,24 @@ +# install Quest using: opam install quest +MAX=300 + +include ../rules.mk + +QUEST=quest +K1C_CCOMPFLAGS += -fstruct-passing -fbitfields + +PREFIX=ran%06.f +TARGETS_C=$(shell seq --format $(PREFIX).c 0 $(MAX)) +TARGETS_OUT=$(shell seq --format $(PREFIX).ccomp.k1c.out 0 $(MAX)) + +all: $(TARGETS_C) $(TARGETS_OUT) + +ran%.c : + $(QUEST) -seed $* -test ansi > $@ + +%.ccomp.k1c : %.ccomp.k1c.s + $(K1C_CCOMP) $(K1C_CCOMPFLAGS) $+ -o $@ + +clean: + -rm -f $(TARGETS_C) $(TARGETS_OUT) + +.PHONY: all clean -- cgit From fa3dc1da271794a5143fe4bca50c656b70aba2de Mon Sep 17 00:00:00 2001 From: David Monniaux Date: Thu, 28 Mar 2019 12:56:10 +0100 Subject: picosat now uses the same Makefile system as the rest we are 27% slower than gcc --- test/monniaux/picosat-965/Makefile | 28 ++++++++++++++++++++++++++++ test/monniaux/picosat-965/app.c | 4 ++-- test/monniaux/picosat-965/main.c | 20 +++++++++++++++++++- 3 files changed, 49 insertions(+), 3 deletions(-) create mode 100644 test/monniaux/picosat-965/Makefile diff --git a/test/monniaux/picosat-965/Makefile b/test/monniaux/picosat-965/Makefile new file mode 100644 index 00000000..d2f7689a --- /dev/null +++ b/test/monniaux/picosat-965/Makefile @@ -0,0 +1,28 @@ +EXECUTE_ARGS=sudoku.sat + +include ../rules.mk + +EMBEDDED_CFLAGS = -DNALARM -DNZIP -DNGETRUSAGE +K1C_CFLAGS += $(EMBEDDED_CFLAGS) +K1C_CCOMPFLAGS += $(EMBEDDED_CFLAGS) +CCOMPFLAGS += -fbitfields +K1C_CCOMPFLAGS += -fbitfields + +all: picosat.ccomp.k1c.s version.ccomp.k1c.s app.ccomp.k1c.s main.ccomp.k1c.s picosat.gcc.k1c.s version.gcc.k1c.s app.gcc.k1c.s main.gcc.k1c.s picosat.ccomp.k1c.out picosat.gcc.k1c.out picosat.ccomp.host.out picosat.gcc.host.out + +picosat.ccomp.k1c : picosat.ccomp.k1c.s version.ccomp.k1c.s app.ccomp.k1c.s main.ccomp.k1c.s ../clock.gcc.k1c.o + $(K1C_CCOMP) $(K1C_CCOMPFLAGS) $+ -o $@ + +picosat.gcc.k1c : picosat.gcc.k1c.s version.gcc.k1c.s app.gcc.k1c.s main.gcc.k1c.s ../clock.gcc.k1c.o + $(K1C_CC) $(K1C_CFLAGS) $+ -o $@ + +picosat.ccomp.host : picosat.ccomp.host.s version.ccomp.host.s app.ccomp.host.s main.ccomp.host.s ../clock.gcc.host.o + $(CCOMP) $(CCOMPFLAGS) $+ -o $@ + +picosat.gcc.host : picosat.gcc.host.s version.gcc.host.s app.gcc.host.s main.gcc.host.s ../clock.gcc.host.o + $(CC) $(FLAGS) $+ -o $@ + +clean: + -rm -f *.s *.k1c *.out + +.PHONY: clean diff --git a/test/monniaux/picosat-965/app.c b/test/monniaux/picosat-965/app.c index d817cf21..64ebdbd0 100644 --- a/test/monniaux/picosat-965/app.c +++ b/test/monniaux/picosat-965/app.c @@ -12,7 +12,7 @@ #define BUNZIP2 "bzcat %s" #define GZIP "gzip -c -f > %s" -#if 0 +#ifndef NZIP FILE * popen (const char *, const char*); int pclose (FILE *); #endif @@ -542,7 +542,7 @@ picosat_main (int argc, char **argv) unsigned seed; FILE *file; int trace; - + start_time = picosat_time_stamp (); sargc = argc; diff --git a/test/monniaux/picosat-965/main.c b/test/monniaux/picosat-965/main.c index 03fad79f..13d7b0e5 100644 --- a/test/monniaux/picosat-965/main.c +++ b/test/monniaux/picosat-965/main.c @@ -1,7 +1,25 @@ +#define VERIMAG_MEASUREMENTS +#ifdef VERIMAG_MEASUREMENTS +#include "../clock.h" +#endif + int picosat_main (int, char **); int main (int argc, char **argv) { - return picosat_main (argc, argv); + +#ifdef VERIMAG_MEASUREMENTS + clock_prepare(); + clock_start(); +#endif + + int ret= picosat_main (argc, argv); + +#ifdef VERIMAG_MEASUREMENTS + clock_stop(); + print_total_clock(); +#endif + + return ret; } -- cgit From ae18d304656aced623fcef6a7eb6f22ec9abaca8 Mon Sep 17 00:00:00 2001 From: David Monniaux Date: Thu, 28 Mar 2019 13:23:39 +0100 Subject: add some INLINE markers --- test/monniaux/picosat-965/picosat.c | 74 +++++++++++++++++++------------------ 1 file changed, 38 insertions(+), 36 deletions(-) diff --git a/test/monniaux/picosat-965/picosat.c b/test/monniaux/picosat-965/picosat.c index aca9d962..ac7003bf 100644 --- a/test/monniaux/picosat-965/picosat.c +++ b/test/monniaux/picosat-965/picosat.c @@ -31,6 +31,8 @@ IN THE SOFTWARE. #include "picosat.h" +#define INLINE inline + /* By default code for 'all different constraints' is disabled, since 'NADC' * is defined. */ @@ -730,7 +732,7 @@ struct PicoSAT typedef PicoSAT PS; -static Flt +static INLINE Flt packflt (unsigned m, int e) { Flt res; @@ -942,13 +944,13 @@ flt2double (Flt f) #endif -static int +static INLINE int log2flt (Flt a) { return FLTEXPONENT (a) + 24; } -static int +static INLINE int cmpflt (Flt a, Flt b) { if (a < b) @@ -1058,19 +1060,19 @@ resize (PS * ps, void *void_ptr, size_t old_size, size_t new_size) return b->data; } -static unsigned +static INLINE unsigned int2unsigned (int l) { return (l < 0) ? 1 + 2 * -l : 2 * l; } -static Lit * +static INLINE Lit * int2lit (PS * ps, int l) { return ps->lits + int2unsigned (l); } -static Lit ** +static INLINE Lit ** end_of_lits (Cls * c) { return (Lit**)c->lits + c->size; @@ -1153,7 +1155,7 @@ dumpcnf (PS * ps) #endif -static void +static INLINE void delete_prefix (PS * ps) { if (!ps->prefix) @@ -1437,7 +1439,7 @@ lrelease (PS * ps, Ltk * stk) #ifndef NADC -static unsigned +static INLINE unsigned llength (Lit ** a) { Lit ** p; @@ -1446,7 +1448,7 @@ llength (Lit ** a) return p - a; } -static void +static INLINE void resetadoconflict (PS * ps) { assert (ps->adoconflict); @@ -1454,7 +1456,7 @@ resetadoconflict (PS * ps) ps->adoconflict = 0; } -static void +static INLINE void reset_ados (PS * ps) { Lit *** p; @@ -1565,7 +1567,7 @@ tpush (PS * ps, Lit * lit) *ps->thead++ = lit; } -static void +static INLINE void assign_reason (PS * ps, Var * v, Cls * reason) { #if defined(NO_BINARY_CLAUSES) && !defined(NDEBUG) @@ -1665,7 +1667,7 @@ cmp_added (PS * ps, Lit * k, Lit * l) return u - v; /* smaller index first */ } -static void +static INLINE void sorttwolits (Lit ** v) { Lit * a = v[0], * b = v[1]; @@ -1689,7 +1691,7 @@ sortlits (PS * ps, Lit ** v, unsigned size) } #ifdef NO_BINARY_CLAUSES -static Cls * +static INLINE Cls * setimpl (PS * ps, Lit * a, Lit * b) { assert (!ps->implvalid); @@ -1704,7 +1706,7 @@ setimpl (PS * ps, Lit * a, Lit * b) return &ps->impl; } -static void +static INLINE void resetimpl (PS * ps) { ps->implvalid = 0; @@ -1725,7 +1727,7 @@ setcimpl (PS * ps, Lit * a, Lit * b) return &ps->cimpl; } -static void +static INLINE void resetcimpl (PS * ps) { assert (ps->cimplvalid); @@ -1734,7 +1736,7 @@ resetcimpl (PS * ps) #endif -static int +static INLINE int cmp_ptr (PS * ps, void *l, void *k) { (void) ps; @@ -1831,7 +1833,7 @@ add_antecedent (PS * ps, Cls * c) #endif /* TRACE */ -static void +static INLINE void add_lit (PS * ps, Lit * lit) { assert (lit); @@ -1842,7 +1844,7 @@ add_lit (PS * ps, Lit * lit) *ps->ahead++ = lit; } -static void +static INLINE void push_var_as_marked (PS * ps, Var * v) { if (ps->mhead == ps->eom) @@ -1851,7 +1853,7 @@ push_var_as_marked (PS * ps, Var * v) *ps->mhead++ = v; } -static void +static INLINE void mark_var (PS * ps, Var * v) { assert (!v->mark); @@ -1960,7 +1962,7 @@ fixvar (PS * ps, Var * v) hup (ps, r); } -static void +static INLINE void use_var (PS * ps, Var * v) { if (v->used) @@ -2104,7 +2106,7 @@ zpush (PS * ps, Zhn * zhain) *ps->zhead++ = zhain; } -static int +static INLINE int cmp_resolved (PS * ps, Cls * c, Cls * d) { #ifndef NDEBUG @@ -2115,7 +2117,7 @@ cmp_resolved (PS * ps, Cls * c, Cls * d) return CLS2IDX (c) - CLS2IDX (d); } -static void +static INLINE void bpushc (PS * ps, unsigned char ch) { if (ps->bhead == ps->eob) @@ -2124,7 +2126,7 @@ bpushc (PS * ps, unsigned char ch) *ps->bhead++ = ch; } -static void +static INLINE void bpushu (PS * ps, unsigned u) { while (u & ~0x7f) @@ -2136,7 +2138,7 @@ bpushu (PS * ps, unsigned u) bpushc (ps, u); } -static void +static INLINE void bpushd (PS * ps, unsigned prev, unsigned this) { unsigned delta; @@ -2802,7 +2804,7 @@ hpush (PS * ps, Rnk * r) hup (ps, r); } -static void +static INLINE void fix_trail_lits (PS * ps, long delta) { Lit **p; @@ -2847,7 +2849,7 @@ fix_clause_lits (PS * ps, long delta) } } -static void +static INLINE void fix_added_lits (PS * ps, long delta) { Lit **p; @@ -2855,7 +2857,7 @@ fix_added_lits (PS * ps, long delta) *p += delta; } -static void +static INLINE void fix_assumed_lits (PS * ps, long delta) { Lit **p; @@ -2863,7 +2865,7 @@ fix_assumed_lits (PS * ps, long delta) *p += delta; } -static void +static INLINE void fix_cls_lits (PS * ps, long delta) { Lit **p; @@ -2871,7 +2873,7 @@ fix_cls_lits (PS * ps, long delta) *p += delta; } -static void +static INLINE void fix_heap_rnks (PS * ps, long delta) { Rnk **p; @@ -2882,7 +2884,7 @@ fix_heap_rnks (PS * ps, long delta) #ifndef NADC -static void +static INLINE void fix_ado (long delta, Lit ** ado) { Lit ** p; @@ -2890,7 +2892,7 @@ fix_ado (long delta, Lit ** ado) *p += delta; } -static void +static INLINE void fix_ados (PS * ps, long delta) { Lit *** p; @@ -3051,7 +3053,7 @@ var2reason (PS * ps, Var * var) return res; } -static void +static INLINE void mark_clause_to_be_collected (Cls * c) { assert (!c->collect); @@ -3171,7 +3173,7 @@ mb (PS * ps) return ps->current_bytes / (double) (1 << 20); } -static double +static INLINE double avglevel (PS * ps) { return ps->decisions ? ps->levelsum / ps->decisions : 0.0; @@ -3497,13 +3499,13 @@ inc_activity (PS * ps, Cls * c) *p = addflt (*p, ps->cinc); } -static unsigned +static INLINE unsigned hashlevel (unsigned l) { return 1u << (l & 31); } -static void +static INLINE void push (PS * ps, Var * v) { if (ps->dhead == ps->eod) @@ -3512,7 +3514,7 @@ push (PS * ps, Var * v) *ps->dhead++ = v; } -static Var * +static INLINE Var * pop (PS * ps) { assert (ps->dfs < ps->dhead); -- cgit From 0541343719a382bce51619839344652d73453f37 Mon Sep 17 00:00:00 2001 From: David Monniaux Date: Thu, 28 Mar 2019 13:36:57 +0100 Subject: some more inline --- test/monniaux/picosat-965/picosat.c | 20 ++++++++++---------- test/monniaux/rules.mk | 5 +++-- 2 files changed, 13 insertions(+), 12 deletions(-) diff --git a/test/monniaux/picosat-965/picosat.c b/test/monniaux/picosat-965/picosat.c index ac7003bf..21442f44 100644 --- a/test/monniaux/picosat-965/picosat.c +++ b/test/monniaux/picosat-965/picosat.c @@ -4553,7 +4553,7 @@ force (PS * ps, Cls * c) assign_forced (ps, forced, reason); } -static void +static INLINE void inc_lreduce (PS * ps) { #ifdef STATS @@ -4813,7 +4813,7 @@ collect_clauses (PS * ps) return res; } -static int +static INLINE int need_to_reduce (PS * ps) { return ps->nlclauses >= reduce_limit_on_lclauses (ps); @@ -4977,7 +4977,7 @@ assign_decision (PS * ps, Lit * lit) #ifndef NFL -static int +static INLINE int lit_has_binary_clauses (PS * ps, Lit * lit) { #ifdef NO_BINARY_CLAUSES @@ -5000,7 +5000,7 @@ flbcp (PS * ps) #endif } -inline static int +inline static INLINE int cmp_inverse_rnk (PS * ps, Rnk * a, Rnk * b) { (void) ps; @@ -5637,7 +5637,7 @@ init_reduce (PS * ps) ps->prefix, ps->prefix, ps->lreduce, ps->prefix); } -static unsigned +static INLINE unsigned rng (PS * ps) { unsigned res = ps->srng; @@ -6431,25 +6431,25 @@ reset_assumptions (PS * ps) ps->adecidelevel = 0; } -static void +static INLINE void check_ready (PS * ps) { ABORTIF (!ps || ps->state == RESET, "API usage: uninitialized"); } -static void +static INLINE void check_sat_state (PS * ps) { ABORTIF (ps->state != SAT, "API usage: expected to be in SAT state"); } -static void +static INLINE void check_unsat_state (PS * ps) { ABORTIF (ps->state != UNSAT, "API usage: expected to be in UNSAT state"); } -static void +static INLINE void check_sat_or_unsat_or_unknown_state (PS * ps) { ABORTIF (ps->state != SAT && ps->state != UNSAT && ps->state != UNKNOWN, @@ -6527,7 +6527,7 @@ enter (PS * ps) ps->entered = picosat_time_stamp (); } -static void +static INLINE void leave (PS * ps) { assert (ps->nentered); diff --git a/test/monniaux/rules.mk b/test/monniaux/rules.mk index eec216bd..fcd6ed0a 100644 --- a/test/monniaux/rules.mk +++ b/test/monniaux/rules.mk @@ -10,6 +10,7 @@ K1C_CCOMP = ../../../ccomp K1C_CCOMPFLAGS=-O3 -Wall -Wno-c11-extensions -fno-unprototyped # -fpostpass-ilp EXECUTE=k1-cluster --syscall=libstd_scalls.so -- +EXECUTE_CYCLES=k1-cluster --syscall=libstd_scalls.so --cycle-based -- %.gcc.host.o : %.gcc.host.s $(CC) $(CFLAGS) -c -o $@ $< @@ -48,7 +49,7 @@ EXECUTE=k1-cluster --syscall=libstd_scalls.so -- $(CCOMP) $(CCOMPFLAGS) $+ -o $@ %.k1c.out : %.k1c - k1-cluster --cycle-based -- $< |tee $@ + $(EXECUTE_CYCLES) $< $(EXECUTE_ARGS) |tee $@ %.host.out : %.host - ./$< |tee $@ + ./$< $(EXECUTE_ARGS) |tee $@ -- cgit From 2a970d557d49e3fe71ecccc33fe8269b1b27c046 Mon Sep 17 00:00:00 2001 From: David Monniaux Date: Thu, 28 Mar 2019 14:30:27 +0100 Subject: NDEBUG --- test/monniaux/picosat-965/Makefile | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/test/monniaux/picosat-965/Makefile b/test/monniaux/picosat-965/Makefile index d2f7689a..69613a79 100644 --- a/test/monniaux/picosat-965/Makefile +++ b/test/monniaux/picosat-965/Makefile @@ -2,12 +2,18 @@ EXECUTE_ARGS=sudoku.sat include ../rules.mk +ALL_CFLAGS = -DNDEBUG EMBEDDED_CFLAGS = -DNALARM -DNZIP -DNGETRUSAGE K1C_CFLAGS += $(EMBEDDED_CFLAGS) K1C_CCOMPFLAGS += $(EMBEDDED_CFLAGS) CCOMPFLAGS += -fbitfields K1C_CCOMPFLAGS += -fbitfields +K1C_CFLAGS += $(ALL_CFLAGS) +K1C_CCOMPFLAGS += $(ALL_CFLAGS) +CCOMPFLAGS += $(ALL_CFLAGS) +CFLAGS += $(ALL_CFLAGS) + all: picosat.ccomp.k1c.s version.ccomp.k1c.s app.ccomp.k1c.s main.ccomp.k1c.s picosat.gcc.k1c.s version.gcc.k1c.s app.gcc.k1c.s main.gcc.k1c.s picosat.ccomp.k1c.out picosat.gcc.k1c.out picosat.ccomp.host.out picosat.gcc.host.out picosat.ccomp.k1c : picosat.ccomp.k1c.s version.ccomp.k1c.s app.ccomp.k1c.s main.ccomp.k1c.s ../clock.gcc.k1c.o -- cgit From b42d24cb2e1472da5859516511238a0771f137d8 Mon Sep 17 00:00:00 2001 From: David Monniaux Date: Thu, 28 Mar 2019 22:51:41 +0100 Subject: Makefile --- test/monniaux/ocaml/Makefile | 32 +- test/monniaux/ocaml/byterun/caml/finalise.h | 2 +- test/monniaux/ocaml/byterun/caml/version.h | 6 + test/monniaux/ocaml/byterun/compact.c | 1 + test/monniaux/ocaml/byterun/win32.c | 1019 --------------------------- 5 files changed, 35 insertions(+), 1025 deletions(-) create mode 100644 test/monniaux/ocaml/byterun/caml/version.h delete mode 100644 test/monniaux/ocaml/byterun/win32.c diff --git a/test/monniaux/ocaml/Makefile b/test/monniaux/ocaml/Makefile index 46ce8994..fc72d6ab 100644 --- a/test/monniaux/ocaml/Makefile +++ b/test/monniaux/ocaml/Makefile @@ -1,7 +1,29 @@ -test: byterun/ocamlrun - k1-cluster --syscall=libstd_scalls.so -- byterun/ocamlrun examples/quicksort +ALL_CFLAGS=-Ibyterun +EXECUTE_ARGS=examples/quicksort -byterun/ocamlrun: - (cd byterun ; $(MAKE)) +include ../rules.mk -.PHONY: test +ALL_CCOMPFLAGS= +LDLIBS=-lm + +CFILES=$(wildcard byterun/*.c) + +CCOMP_K1C_S=$(patsubst %.c,%.ccomp.k1c.s,$(CFILES)) +CCOMP_HOST_S=$(patsubst %.c,%.ccomp.host.s,$(CFILES)) + +GCC_K1C_S=$(patsubst %.c,%.gcc.k1c.s,$(CFILES)) +GCC_HOST_S=$(patsubst %.c,%.gcc.host.s,$(CFILES)) + +all: $(CCOMP_K1C_S) $(GCC_K1C_S) ocamlrun.ccomp.k1c.out ocamlrun.gcc.k1c.out + +ocamlrun.ccomp.k1c : $(CCOMP_K1C_S) + $(K1C_CCOMP) $(K1C_CCOMPFLAGS) $+ -o $@ $(LDLIBS) + +ocamlrun.ccomp.host : $(CCOMP_HOST_S) + $(CCOMP) $(CCOMPFLAGS) $+ -o $@ $(LDLIBS) + +ocamlrun.gcc.k1c : $(GCC_K1C_S) + $(K1C_CC) $(K1C_CFLAGS) $+ -o $@ $(LDLIBS) + +ocamlrun.gcc.host : $(GCC_HOST_S) + $(CC) $(CFLAGS) $+ -o $@ $(LDLIBS) diff --git a/test/monniaux/ocaml/byterun/caml/finalise.h b/test/monniaux/ocaml/byterun/caml/finalise.h index 5315ac21..b2052c21 100644 --- a/test/monniaux/ocaml/byterun/caml/finalise.h +++ b/test/monniaux/ocaml/byterun/caml/finalise.h @@ -25,7 +25,7 @@ void caml_final_update_clean_phase (void); void caml_final_do_calls (void); void caml_final_do_roots (scanning_action f); void caml_final_invert_finalisable_values (); -void caml_final_oldify_young_roots (); +void caml_final_oldify_young_roots (void); void caml_final_empty_young (void); void caml_final_update_minor_roots(void); value caml_final_register (value f, value v); diff --git a/test/monniaux/ocaml/byterun/caml/version.h b/test/monniaux/ocaml/byterun/caml/version.h new file mode 100644 index 00000000..68d7000e --- /dev/null +++ b/test/monniaux/ocaml/byterun/caml/version.h @@ -0,0 +1,6 @@ +#define OCAML_VERSION_MAJOR 4 +#define OCAML_VERSION_MINOR 7 +#define OCAML_VERSION_PATCHLEVEL 1 +#undef OCAML_VERSION_ADDITIONAL +#define OCAML_VERSION 40701 +#define OCAML_VERSION_STRING "4.07.1" diff --git a/test/monniaux/ocaml/byterun/compact.c b/test/monniaux/ocaml/byterun/compact.c index 7b7188ab..83e7ed0a 100644 --- a/test/monniaux/ocaml/byterun/compact.c +++ b/test/monniaux/ocaml/byterun/compact.c @@ -32,6 +32,7 @@ extern uintnat caml_percent_free; /* major_gc.c */ extern void caml_shrink_heap (char *); /* memory.c */ +extern void caml_final_invert_finalisable_values (void); /* Encoded headers: the color is stored in the 2 least significant bits. (For pointer inversion, we need to distinguish headers from pointers.) diff --git a/test/monniaux/ocaml/byterun/win32.c b/test/monniaux/ocaml/byterun/win32.c deleted file mode 100644 index 1ce8ad5e..00000000 --- a/test/monniaux/ocaml/byterun/win32.c +++ /dev/null @@ -1,1019 +0,0 @@ -/**************************************************************************/ -/* */ -/* OCaml */ -/* */ -/* Xavier Leroy, projet Cristal, INRIA Rocquencourt */ -/* */ -/* Copyright 1996 Institut National de Recherche en Informatique et */ -/* en Automatique. */ -/* */ -/* All rights reserved. This file is distributed under the terms of */ -/* the GNU Lesser General Public License version 2.1, with the */ -/* special exception on linking described in the file LICENSE. */ -/* */ -/**************************************************************************/ - -#define CAML_INTERNALS - -/* Win32-specific stuff */ - -/* FILE_INFO_BY_HANDLE_CLASS and FILE_NAME_INFO are only available from Windows - Vista onwards */ -#undef _WIN32_WINNT -#define _WIN32_WINNT 0x0600 - -#define WIN32_LEAN_AND_MEAN -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "caml/alloc.h" -#include "caml/address_class.h" -#include "caml/fail.h" -#include "caml/io.h" -#include "caml/memory.h" -#include "caml/misc.h" -#include "caml/osdeps.h" -#include "caml/signals.h" -#include "caml/sys.h" - -#include "caml/config.h" -#ifdef SUPPORT_DYNAMIC_LINKING -#include -#endif - -#ifndef S_ISREG -#define S_ISREG(mode) (((mode) & S_IFMT) == S_IFREG) -#endif - -unsigned short caml_win32_major = 0; -unsigned short caml_win32_minor = 0; -unsigned short caml_win32_build = 0; -unsigned short caml_win32_revision = 0; - -CAMLnoreturn_start -static void caml_win32_sys_error (int errnum) -CAMLnoreturn_end; - -static void caml_win32_sys_error(int errnum) -{ - wchar_t buffer[512]; - value msg; - if (FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, - NULL, - errnum, - 0, - buffer, - sizeof(buffer)/sizeof(wchar_t), - NULL)) { - msg = caml_copy_string_of_utf16(buffer); - } else { - msg = caml_alloc_sprintf("unknown error #%d", errnum); - } - caml_raise_sys_error(msg); -} - -int caml_read_fd(int fd, int flags, void * buf, int n) -{ - int retcode; - if ((flags & CHANNEL_FLAG_FROM_SOCKET) == 0) { - caml_enter_blocking_section(); - retcode = read(fd, buf, n); - /* Large reads from console can fail with ENOMEM. Reduce requested size - and try again. */ - if (retcode == -1 && errno == ENOMEM && n > 16384) { - retcode = read(fd, buf, 16384); - } - caml_leave_blocking_section(); - if (retcode == -1) caml_sys_io_error(NO_ARG); - } else { - caml_enter_blocking_section(); - retcode = recv((SOCKET) _get_osfhandle(fd), buf, n, 0); - caml_leave_blocking_section(); - if (retcode == -1) caml_win32_sys_error(WSAGetLastError()); - } - return retcode; -} - -int caml_write_fd(int fd, int flags, void * buf, int n) -{ - int retcode; - if ((flags & CHANNEL_FLAG_FROM_SOCKET) == 0) { -#if defined(NATIVE_CODE) && defined(WITH_SPACETIME) - if (flags & CHANNEL_FLAG_BLOCKING_WRITE) { - retcode = write(fd, buf, n); - } else { -#endif - caml_enter_blocking_section(); - retcode = write(fd, buf, n); - caml_leave_blocking_section(); -#if defined(NATIVE_CODE) && defined(WITH_SPACETIME) - } -#endif - if (retcode == -1) caml_sys_io_error(NO_ARG); - } else { - caml_enter_blocking_section(); - retcode = send((SOCKET) _get_osfhandle(fd), buf, n, 0); - caml_leave_blocking_section(); - if (retcode == -1) caml_win32_sys_error(WSAGetLastError()); - } - CAMLassert (retcode > 0); - return retcode; -} - -wchar_t * caml_decompose_path(struct ext_table * tbl, wchar_t * path) -{ - wchar_t * p, * q; - int n; - - if (path == NULL) return NULL; - p = caml_stat_wcsdup(path); - q = p; - while (1) { - for (n = 0; q[n] != 0 && q[n] != L';'; n++) /*nothing*/; - caml_ext_table_add(tbl, q); - q = q + n; - if (*q == 0) break; - *q = 0; - q += 1; - } - return p; -} - -wchar_t * caml_search_in_path(struct ext_table * path, const wchar_t * name) -{ - wchar_t * dir, * fullname; - char * u8; - const wchar_t * p; - int i; - struct _stati64 st; - - for (p = name; *p != 0; p++) { - if (*p == '/' || *p == '\\') goto not_found; - } - for (i = 0; i < path->size; i++) { - dir = path->contents[i]; - if (dir[0] == 0) continue; - /* not sure what empty path components mean under Windows */ - fullname = caml_stat_wcsconcat(3, dir, L"\\", name); - u8 = caml_stat_strdup_of_utf16(fullname); - caml_gc_message(0x100, "Searching %s\n", u8); - caml_stat_free(u8); - if (_wstati64(fullname, &st) == 0 && S_ISREG(st.st_mode)) - return fullname; - caml_stat_free(fullname); - } - not_found: - u8 = caml_stat_strdup_of_utf16(name); - caml_gc_message(0x100, "%s not found in search path\n", u8); - caml_stat_free(u8); - return caml_stat_wcsdup(name); -} - -CAMLexport wchar_t * caml_search_exe_in_path(const wchar_t * name) -{ - wchar_t * fullname, * filepart; - char * u8; - size_t fullnamelen; - DWORD retcode; - - fullnamelen = wcslen(name) + 1; - if (fullnamelen < 256) fullnamelen = 256; - while (1) { - fullname = caml_stat_alloc(fullnamelen*sizeof(wchar_t)); - retcode = SearchPath(NULL, /* use system search path */ - name, - L".exe", /* add .exe extension if needed */ - fullnamelen, - fullname, - &filepart); - if (retcode == 0) { - u8 = caml_stat_strdup_of_utf16(name); - caml_gc_message(0x100, "%s not found in search path\n", u8); - caml_stat_free(u8); - caml_stat_free(fullname); - return caml_stat_strdup_os(name); - } - if (retcode < fullnamelen) - return fullname; - caml_stat_free(fullname); - fullnamelen = retcode + 1; - } -} - -wchar_t * caml_search_dll_in_path(struct ext_table * path, const wchar_t * name) -{ - wchar_t * dllname; - wchar_t * res; - - dllname = caml_stat_wcsconcat(2, name, L".dll"); - res = caml_search_in_path(path, dllname); - caml_stat_free(dllname); - return res; -} - -#ifdef SUPPORT_DYNAMIC_LINKING - -void * caml_dlopen(wchar_t * libname, int for_execution, int global) -{ - void *handle; - int flags = (global ? FLEXDLL_RTLD_GLOBAL : 0); - if (!for_execution) flags |= FLEXDLL_RTLD_NOEXEC; - handle = flexdll_wdlopen(libname, flags); - if ((handle != NULL) && ((caml_verb_gc & 0x100) != 0)) { - flexdll_dump_exports(handle); - fflush(stdout); - } - return handle; -} - -void caml_dlclose(void * handle) -{ - flexdll_dlclose(handle); -} - -void * caml_dlsym(void * handle, const char * name) -{ - return flexdll_dlsym(handle, name); -} - -void * caml_globalsym(const char * name) -{ - return flexdll_dlsym(flexdll_dlopen(NULL,0), name); -} - -char * caml_dlerror(void) -{ - return flexdll_dlerror(); -} - -#else - -void * caml_dlopen(wchar_t * libname, int for_execution, int global) -{ - return NULL; -} - -void caml_dlclose(void * handle) -{ -} - -void * caml_dlsym(void * handle, const char * name) -{ - return NULL; -} - -void * caml_globalsym(const char * name) -{ - return NULL; -} - -char * caml_dlerror(void) -{ - return "dynamic loading not supported on this platform"; -} - -#endif - -/* Proper emulation of signal(), including ctrl-C and ctrl-break */ - -typedef void (*sighandler)(int sig); -static int ctrl_handler_installed = 0; -static volatile sighandler ctrl_handler_action = SIG_DFL; - -static BOOL WINAPI ctrl_handler(DWORD event) -{ - /* Only ctrl-C and ctrl-Break are handled */ - if (event != CTRL_C_EVENT && event != CTRL_BREAK_EVENT) return FALSE; - /* Default behavior is to exit, which we get by not handling the event */ - if (ctrl_handler_action == SIG_DFL) return FALSE; - /* Ignore behavior is to do nothing, which we get by claiming that we - have handled the event */ - if (ctrl_handler_action == SIG_IGN) return TRUE; - /* Win32 doesn't like it when we do a longjmp() at this point - (it looks like we're running in a different thread than - the main program!). So, just record the signal. */ - caml_record_signal(SIGINT); - /* We have handled the event */ - return TRUE; -} - -sighandler caml_win32_signal(int sig, sighandler action) -{ - sighandler oldaction; - - if (sig != SIGINT) return signal(sig, action); - if (! ctrl_handler_installed) { - SetConsoleCtrlHandler(ctrl_handler, TRUE); - ctrl_handler_installed = 1; - } - oldaction = ctrl_handler_action; - ctrl_handler_action = action; - return oldaction; -} - -/* Expansion of @responsefile and *? file patterns in the command line */ - -static int argc; -static wchar_t ** argv; -static int argvsize; - -static void store_argument(wchar_t * arg); -static void expand_argument(wchar_t * arg); -static void expand_pattern(wchar_t * arg); - -static void out_of_memory(void) -{ - fprintf(stderr, "Out of memory while expanding command line\n"); - exit(2); -} - -static void store_argument(wchar_t * arg) -{ - if (argc + 1 >= argvsize) { - argvsize *= 2; - argv = (wchar_t **) caml_stat_resize_noexc(argv, argvsize * sizeof(wchar_t *)); - if (argv == NULL) out_of_memory(); - } - argv[argc++] = arg; -} - -static void expand_argument(wchar_t * arg) -{ - wchar_t * p; - - for (p = arg; *p != 0; p++) { - if (*p == L'*' || *p == L'?') { - expand_pattern(arg); - return; - } - } - store_argument(arg); -} - -static void expand_pattern(wchar_t * pat) -{ - wchar_t * prefix, * p, * name; - intptr_t handle; - struct _wfinddata_t ffblk; - size_t i; - - handle = _wfindfirst(pat, &ffblk); - if (handle == -1) { - store_argument(pat); /* a la Bourne shell */ - return; - } - prefix = caml_stat_wcsdup(pat); - /* We need to stop at the first directory or drive boundary, because the - * _findata_t structure contains the filename, not the leading directory. */ - for (i = wcslen(prefix); i > 0; i--) { - wchar_t c = prefix[i - 1]; - if (c == L'\\' || c == L'/' || c == L':') { prefix[i] = 0; break; } - } - /* No separator was found, it's a filename pattern without a leading directory. */ - if (i == 0) - prefix[0] = 0; - do { - name = caml_stat_wcsconcat(2, prefix, ffblk.name); - store_argument(name); - } while (_wfindnext(handle, &ffblk) != -1); - _findclose(handle); - caml_stat_free(prefix); -} - - -CAMLexport void caml_expand_command_line(int * argcp, wchar_t *** argvp) -{ - int i; - argc = 0; - argvsize = 16; - argv = (wchar_t **) caml_stat_alloc_noexc(argvsize * sizeof(wchar_t *)); - if (argv == NULL) out_of_memory(); - for (i = 0; i < *argcp; i++) expand_argument((*argvp)[i]); - argv[argc] = NULL; - *argcp = argc; - *argvp = argv; -} - -/* Add to [contents] the (short) names of the files contained in - the directory named [dirname]. No entries are added for [.] and [..]. - Return 0 on success, -1 on error; set errno in the case of error. */ - -int caml_read_directory(wchar_t * dirname, struct ext_table * contents) -{ - size_t dirnamelen; - wchar_t * template; - intptr_t h; - struct _wfinddata_t fileinfo; - - dirnamelen = wcslen(dirname); - if (dirnamelen > 0 && - (dirname[dirnamelen - 1] == L'/' - || dirname[dirnamelen - 1] == L'\\' - || dirname[dirnamelen - 1] == L':')) - template = caml_stat_wcsconcat(2, dirname, L"*.*"); - else - template = caml_stat_wcsconcat(2, dirname, L"\\*.*"); - h = _wfindfirst(template, &fileinfo); - if (h == -1) { - caml_stat_free(template); - return errno == ENOENT ? 0 : -1; - } - do { - if (wcscmp(fileinfo.name, L".") != 0 && wcscmp(fileinfo.name, L"..") != 0) { - caml_ext_table_add(contents, caml_stat_strdup_of_utf16(fileinfo.name)); - } - } while (_wfindnext(h, &fileinfo) == 0); - _findclose(h); - caml_stat_free(template); - return 0; -} - -#ifndef NATIVE_CODE - -/* Set up a new thread for control-C emulation and termination */ - -void caml_signal_thread(void * lpParam) -{ - wchar_t *endptr; - HANDLE h; - /* Get an hexa-code raw handle through the environment */ - h = (HANDLE) (uintptr_t) - wcstol(caml_secure_getenv(_T("CAMLSIGPIPE")), &endptr, 16); - while (1) { - DWORD numread; - BOOL ret; - char iobuf[2]; - /* This shall always return a single character */ - ret = ReadFile(h, iobuf, 1, &numread, NULL); - if (!ret || numread != 1) caml_sys_exit(Val_int(2)); - switch (iobuf[0]) { - case 'C': - caml_record_signal(SIGINT); - break; - case 'T': - raise(SIGTERM); - return; - } - } -} - -#endif /* NATIVE_CODE */ - -#if defined(NATIVE_CODE) - -/* Handling of system stack overflow. - * Based on code provided by Olivier Andrieu. - - * An EXCEPTION_STACK_OVERFLOW is signaled when the guard page at the - * end of the stack has been accessed. Windows clears the PAGE_GUARD - * protection (making it a regular PAGE_READWRITE) and then calls our - * exception handler. This means that although we're handling an "out - * of stack" condition, there is a bit of stack available to call - * functions and allocate temporaries. - * - * PAGE_GUARD is a one-shot access protection mechanism: we need to - * restore the PAGE_GUARD protection on this page otherwise the next - * stack overflow won't be detected and the program will abruptly exit - * with STATUS_ACCESS_VIOLATION. - * - * Visual Studio 2003 and later (_MSC_VER >= 1300) have a - * _resetstkoflw() function that resets this protection. - * Unfortunately, it cannot work when called directly from the - * exception handler because at this point we are using the page that - * is to be protected. - * - * A solution is to use an alternate stack when restoring the - * protection. However it's not possible to use _resetstkoflw() then - * since it determines the stack pointer by calling alloca(): it would - * try to protect the alternate stack. - * - * Finally, we call caml_raise_stack_overflow; it will either call - * caml_raise_exception which switches back to the normal stack, or - * call caml_fatal_uncaught_exception which terminates the program - * quickly. - */ - -static uintnat win32_alt_stack[0x100]; - -static void caml_reset_stack (void *faulting_address) -{ - SYSTEM_INFO si; - DWORD page_size; - MEMORY_BASIC_INFORMATION mbi; - DWORD oldprot; - - /* get the system's page size. */ - GetSystemInfo (&si); - page_size = si.dwPageSize; - - /* get some information on the page the fault occurred */ - if (! VirtualQuery (faulting_address, &mbi, sizeof mbi)) - goto failed; - - VirtualProtect (mbi.BaseAddress, page_size, - mbi.Protect | PAGE_GUARD, &oldprot); - - failed: - caml_raise_stack_overflow(); -} - - -#ifndef _WIN64 -static LONG CALLBACK - caml_stack_overflow_VEH (EXCEPTION_POINTERS* exn_info) -{ - DWORD code = exn_info->ExceptionRecord->ExceptionCode; - CONTEXT *ctx = exn_info->ContextRecord; - DWORD *ctx_ip = &(ctx->Eip); - DWORD *ctx_sp = &(ctx->Esp); - - if (code == EXCEPTION_STACK_OVERFLOW && Is_in_code_area (*ctx_ip)) - { - uintnat faulting_address; - uintnat * alt_esp; - - /* grab the address that caused the fault */ - faulting_address = exn_info->ExceptionRecord->ExceptionInformation[1]; - - /* call caml_reset_stack(faulting_address) using the alternate stack */ - alt_esp = win32_alt_stack + sizeof(win32_alt_stack) / sizeof(uintnat); - *--alt_esp = faulting_address; - *ctx_sp = (uintnat) (alt_esp - 1); - *ctx_ip = (uintnat) &caml_reset_stack; - - return EXCEPTION_CONTINUE_EXECUTION; - } - - return EXCEPTION_CONTINUE_SEARCH; -} - -#else -extern char *caml_exception_pointer; -extern value *caml_young_ptr; - -/* Do not use the macro from address_class.h here. */ -#undef Is_in_code_area -#define Is_in_code_area(pc) \ - ( ((char *)(pc) >= caml_code_area_start && \ - (char *)(pc) <= caml_code_area_end) \ -|| ((char *)(pc) >= &caml_system__code_begin && \ - (char *)(pc) <= &caml_system__code_end) \ -|| (Classify_addr(pc) & In_code_area) ) -extern char caml_system__code_begin, caml_system__code_end; - - -static LONG CALLBACK - caml_stack_overflow_VEH (EXCEPTION_POINTERS* exn_info) -{ - DWORD code = exn_info->ExceptionRecord->ExceptionCode; - CONTEXT *ctx = exn_info->ContextRecord; - - if (code == EXCEPTION_STACK_OVERFLOW && Is_in_code_area (ctx->Rip)) - { - uintnat faulting_address; - uintnat * alt_rsp; - - /* grab the address that caused the fault */ - faulting_address = exn_info->ExceptionRecord->ExceptionInformation[1]; - - /* refresh runtime parameters from registers */ - caml_exception_pointer = (char *) ctx->R14; - caml_young_ptr = (value *) ctx->R15; - - /* call caml_reset_stack(faulting_address) using the alternate stack */ - alt_rsp = win32_alt_stack + sizeof(win32_alt_stack) / sizeof(uintnat); - ctx->Rcx = faulting_address; - ctx->Rsp = (uintnat) (alt_rsp - 4 - 1); - ctx->Rip = (uintnat) &caml_reset_stack; - - return EXCEPTION_CONTINUE_EXECUTION; - } - - return EXCEPTION_CONTINUE_SEARCH; -} -#endif /* _WIN64 */ - -void caml_win32_overflow_detection(void) -{ - AddVectoredExceptionHandler(1, caml_stack_overflow_VEH); -} - -#endif /* NATIVE_CODE */ - -/* Seeding of pseudo-random number generators */ - -int caml_win32_random_seed (intnat data[16]) -{ - /* For better randomness, consider: - http://msdn.microsoft.com/library/en-us/seccrypto/security/rtlgenrandom.asp - http://blogs.msdn.com/b/michael_howard/archive/2005/01/14/353379.aspx - */ - FILETIME t; - LARGE_INTEGER pc; - GetSystemTimeAsFileTime(&t); - QueryPerformanceCounter(&pc); /* PR#6032 */ - data[0] = t.dwLowDateTime; - data[1] = t.dwHighDateTime; - data[2] = GetCurrentProcessId(); - data[3] = pc.LowPart; - data[4] = pc.HighPart; - return 5; -} - - -#if defined(_MSC_VER) && __STDC_SECURE_LIB__ >= 200411L - -static void invalid_parameter_handler(const wchar_t* expression, - const wchar_t* function, - const wchar_t* file, - unsigned int line, - uintptr_t pReserved) -{ - /* no crash box */ -} - - -void caml_install_invalid_parameter_handler() -{ - _set_invalid_parameter_handler(invalid_parameter_handler); -} - -#endif - - -/* Recover executable name */ - -wchar_t * caml_executable_name(void) -{ - wchar_t * name; - DWORD namelen, ret; - - namelen = 256; - while (1) { - name = caml_stat_alloc(namelen*sizeof(wchar_t)); - ret = GetModuleFileName(NULL, name, namelen); - if (ret == 0) { caml_stat_free(name); return NULL; } - if (ret < namelen) break; - caml_stat_free(name); - if (namelen >= 1024*1024) return NULL; /* avoid runaway and overflow */ - namelen *= 2; - } - return name; -} - -/* snprintf emulation */ - -#ifdef LACKS_VSCPRINTF -/* No _vscprintf until Visual Studio .NET 2002 and sadly no version number - in the CRT headers until Visual Studio 2005 so forced to predicate this - on the compiler version instead */ -int _vscprintf(const char * format, va_list args) -{ - int n; - int sz = 5; - char* buf = (char*)malloc(sz); - n = _vsnprintf(buf, sz, format, args); - while (n < 0 || n > sz) { - sz += 512; - buf = (char*)realloc(buf, sz); - n = _vsnprintf(buf, sz, format, args); - } - free(buf); - return n; -} -#endif - -#if defined(_WIN32) && !defined(_UCRT) -int caml_snprintf(char * buf, size_t size, const char * format, ...) -{ - int len; - va_list args; - - if (size > 0) { - va_start(args, format); - len = _vsnprintf(buf, size, format, args); - va_end(args); - if (len >= 0 && len < size) { - /* [len] characters were stored in [buf], - a null-terminator was appended. */ - return len; - } - /* [size] characters were stored in [buf], without null termination. - Put a null terminator, truncating the output. */ - buf[size - 1] = 0; - } - /* Compute the actual length of output, excluding null terminator */ - va_start(args, format); - len = _vscprintf(format, args); - va_end(args); - return len; -} -#endif - -wchar_t *caml_secure_getenv (wchar_t const *var) -{ - /* Win32 doesn't have a notion of setuid bit, so getenv is safe. */ - return _wgetenv(var); -} - -/* caml_win32_getenv is used to implement Sys.getenv and Unix.getenv in such a - way that they get direct access to the Win32 environment rather than to the - copy that is cached by the C runtime system. The result of caml_win32_getenv - is dynamically allocated and must be explicitly deallocated. - - In contrast, the OCaml runtime system still calls _wgetenv from the C runtime - system, via caml_secure_getenv. The result is statically allocated and needs - no deallocation. */ -CAMLexport wchar_t *caml_win32_getenv(wchar_t const *lpName) -{ - wchar_t * lpBuffer; - DWORD nSize = 256, res; - - lpBuffer = caml_stat_alloc_noexc(nSize * sizeof(wchar_t)); - - if (lpBuffer == NULL) - return NULL; - - res = GetEnvironmentVariable(lpName, lpBuffer, nSize); - - if (res == 0) { - caml_stat_free(lpBuffer); - return NULL; - } - - if (res < nSize) - return lpBuffer; - - nSize = res; - lpBuffer = caml_stat_resize_noexc(lpBuffer, nSize * sizeof(wchar_t)); - - if (lpBuffer == NULL) - return NULL; - - res = GetEnvironmentVariable(lpName, lpBuffer, nSize); - - if (res == 0 || res >= nSize) { - caml_stat_free(lpBuffer); - return NULL; - } - - return lpBuffer; -} - -/* The rename() implementation in MSVC's CRT is based on MoveFile() - and therefore fails if the new name exists. This is inconsistent - with POSIX and a problem in practice. Here we reimplement - rename() using MoveFileEx() to make it more POSIX-like. - There are no official guarantee that the rename operation is atomic, - but it is widely believed to be atomic on NTFS. */ - -int caml_win32_rename(const wchar_t * oldpath, const wchar_t * newpath) -{ - /* MOVEFILE_REPLACE_EXISTING: to be closer to POSIX - MOVEFILE_COPY_ALLOWED: MoveFile performs a copy if old and new - paths are on different devices, so we do the same here for - compatibility with the old rename()-based implementation. - MOVEFILE_WRITE_THROUGH: not sure it's useful; affects only - the case where a copy is done. */ - if (MoveFileEx(oldpath, newpath, - MOVEFILE_REPLACE_EXISTING | MOVEFILE_WRITE_THROUGH | - MOVEFILE_COPY_ALLOWED)) { - return 0; - } - /* Modest attempt at mapping Win32 error codes to POSIX error codes. - The __dosmaperr() function from the CRT does a better job but is - generally not accessible. */ - switch (GetLastError()) { - case ERROR_FILE_NOT_FOUND: case ERROR_PATH_NOT_FOUND: - errno = ENOENT; break; - case ERROR_ACCESS_DENIED: case ERROR_WRITE_PROTECT: case ERROR_CANNOT_MAKE: - errno = EACCES; break; - case ERROR_CURRENT_DIRECTORY: case ERROR_BUSY: - errno = EBUSY; break; - case ERROR_NOT_SAME_DEVICE: - errno = EXDEV; break; - case ERROR_ALREADY_EXISTS: - errno = EEXIST; break; - default: - errno = EINVAL; - } - return -1; -} - -/* Windows Unicode support */ -static uintnat windows_unicode_enabled = WINDOWS_UNICODE; - -/* If [windows_unicode_strict] is non-zero, then illegal UTF-8 characters (on - the OCaml side) or illegal UTF-16 characters (on the Windows side) cause an - error to be signaled. What happens then depends on the variable - [windows_unicode_fallback]. - - If [windows_unicode_strict] is zero, then illegal characters are silently - dropped. */ -static uintnat windows_unicode_strict = 1; - -/* If [windows_unicode_fallback] is non-zero, then if an error is signaled when - translating to UTF-16, the translation is re-done under the assumption that - the argument string is encoded in the local codepage. */ -static uintnat windows_unicode_fallback = 1; - -CAMLexport int win_multi_byte_to_wide_char(const char *s, int slen, wchar_t *out, int outlen) -{ - int retcode; - - CAMLassert (s != NULL); - - if (slen == 0) - return 0; - - if (windows_unicode_enabled != 0) { - retcode = MultiByteToWideChar(CP_UTF8, windows_unicode_strict ? MB_ERR_INVALID_CHARS : 0, s, slen, out, outlen); - if (retcode == 0 && windows_unicode_fallback != 0) - retcode = MultiByteToWideChar(CP_THREAD_ACP, 0, s, slen, out, outlen); - } else { - retcode = MultiByteToWideChar(CP_THREAD_ACP, 0, s, slen, out, outlen); - } - - if (retcode == 0) - caml_win32_sys_error(GetLastError()); - - return retcode; -} - -#ifndef WC_ERR_INVALID_CHARS /* For old versions of Windows we simply ignore the flag */ -#define WC_ERR_INVALID_CHARS 0 -#endif - -CAMLexport int win_wide_char_to_multi_byte(const wchar_t *s, int slen, char *out, int outlen) -{ - int retcode; - - CAMLassert(s != NULL); - - if (slen == 0) - return 0; - - if (windows_unicode_enabled != 0) - retcode = WideCharToMultiByte(CP_UTF8, windows_unicode_strict ? WC_ERR_INVALID_CHARS : 0, s, slen, out, outlen, NULL, NULL); - else - retcode = WideCharToMultiByte(CP_THREAD_ACP, 0, s, slen, out, outlen, NULL, NULL); - - if (retcode == 0) - caml_win32_sys_error(GetLastError()); - - return retcode; -} - -CAMLexport value caml_copy_string_of_utf16(const wchar_t *s) -{ - int retcode, slen; - value v; - - slen = wcslen(s); - retcode = win_wide_char_to_multi_byte(s, slen, NULL, 0); /* Do not include final NULL */ - v = caml_alloc_string(retcode); - win_wide_char_to_multi_byte(s, slen, String_val(v), retcode); - - return v; -} - -CAMLexport inline wchar_t* caml_stat_strdup_to_utf16(const char *s) -{ - wchar_t * ws; - int retcode; - - retcode = win_multi_byte_to_wide_char(s, -1, NULL, 0); - ws = malloc(retcode * sizeof(*ws)); - win_multi_byte_to_wide_char(s, -1, ws, retcode); - - return ws; -} - -CAMLexport caml_stat_string caml_stat_strdup_of_utf16(const wchar_t *s) -{ - caml_stat_string out; - int retcode; - - retcode = win_wide_char_to_multi_byte(s, -1, NULL, 0); - out = caml_stat_alloc(retcode); - win_wide_char_to_multi_byte(s, -1, out, retcode); - - return out; -} - -void caml_probe_win32_version(void) -{ - /* Determine the version of Windows we're running, and cache it */ - WCHAR fileName[MAX_PATH]; - DWORD size = - GetModuleFileName(GetModuleHandle(L"kernel32"), fileName, MAX_PATH); - DWORD dwHandle = 0; - BYTE* versionInfo; - fileName[size] = 0; - size = GetFileVersionInfoSize(fileName, &dwHandle); - versionInfo = (BYTE*)malloc(size * sizeof(BYTE)); - if (GetFileVersionInfo(fileName, 0, size, versionInfo)) { - UINT len = 0; - VS_FIXEDFILEINFO* vsfi = NULL; - VerQueryValue(versionInfo, L"\\", (void**)&vsfi, &len); - caml_win32_major = HIWORD(vsfi->dwProductVersionMS); - caml_win32_minor = LOWORD(vsfi->dwProductVersionMS); - caml_win32_build = HIWORD(vsfi->dwProductVersionLS); - caml_win32_revision = LOWORD(vsfi->dwProductVersionLS); - } - free(versionInfo); -} - -static UINT startup_codepage = 0; - -void caml_setup_win32_terminal(void) -{ - if (caml_win32_major >= 10) { - startup_codepage = GetConsoleOutputCP(); - if (startup_codepage != CP_UTF8) - SetConsoleOutputCP(CP_UTF8); - } -} - -void caml_restore_win32_terminal(void) -{ - if (startup_codepage != 0) - SetConsoleOutputCP(startup_codepage); -} - -/* Detect if a named pipe corresponds to a Cygwin/MSYS pty: see - https://github.com/mirror/newlib-cygwin/blob/00e9bf2/winsup/cygwin/dtable.cc#L932 -*/ -typedef -BOOL (WINAPI *tGetFileInformationByHandleEx)(HANDLE, FILE_INFO_BY_HANDLE_CLASS, - LPVOID, DWORD); - -static int caml_win32_is_cygwin_pty(HANDLE hFile) -{ - char buffer[1024]; - FILE_NAME_INFO * nameinfo = (FILE_NAME_INFO *) buffer; - static tGetFileInformationByHandleEx pGetFileInformationByHandleEx = INVALID_HANDLE_VALUE; - - if (pGetFileInformationByHandleEx == INVALID_HANDLE_VALUE) - pGetFileInformationByHandleEx = - (tGetFileInformationByHandleEx)GetProcAddress(GetModuleHandle(L"KERNEL32.DLL"), - "GetFileInformationByHandleEx"); - - if (pGetFileInformationByHandleEx == NULL) - return 0; - - /* Get pipe name. GetFileInformationByHandleEx does not NULL-terminate the string, so reduce - the buffer size to allow for adding one. */ - if (! pGetFileInformationByHandleEx(hFile, FileNameInfo, buffer, sizeof(buffer) - sizeof(WCHAR))) - return 0; - - nameinfo->FileName[nameinfo->FileNameLength / sizeof(WCHAR)] = L'\0'; - - /* check if this could be a msys pty pipe ('msys-XXXX-ptyN-XX') - or a cygwin pty pipe ('cygwin-XXXX-ptyN-XX') */ - if ((wcsstr(nameinfo->FileName, L"msys-") || - wcsstr(nameinfo->FileName, L"cygwin-")) && wcsstr(nameinfo->FileName, L"-pty")) - return 1; - - return 0; -} - -CAMLexport int caml_win32_isatty(int fd) -{ - DWORD lpMode; - HANDLE hFile = (HANDLE)_get_osfhandle(fd); - - if (hFile == INVALID_HANDLE_VALUE) - return 0; - - switch (GetFileType(hFile)) { - case FILE_TYPE_CHAR: - /* Both console handles and the NUL device are FILE_TYPE_CHAR. The NUL - device returns FALSE for a GetConsoleMode call. _isatty incorrectly - only uses GetFileType (see GPR#1321). */ - return GetConsoleMode(hFile, &lpMode); - case FILE_TYPE_PIPE: - /* Cygwin PTYs are implemented using named pipes */ - return caml_win32_is_cygwin_pty(hFile); - default: - break; - } - - return 0; -} - -int caml_num_rows_fd(int fd) -{ - return -1; -} -- cgit From 522d7e88ef611de8edde6ae49cb985da58b8963c Mon Sep 17 00:00:00 2001 From: David Monniaux Date: Thu, 28 Mar 2019 23:13:56 +0100 Subject: ocaml benchmark --- test/monniaux/ocaml/Makefile | 8 ++++---- test/monniaux/ocaml/byterun/main.c | 13 +++++++++++++ test/monniaux/rules.mk | 9 +++++---- 3 files changed, 22 insertions(+), 8 deletions(-) diff --git a/test/monniaux/ocaml/Makefile b/test/monniaux/ocaml/Makefile index fc72d6ab..0ae7c22f 100644 --- a/test/monniaux/ocaml/Makefile +++ b/test/monniaux/ocaml/Makefile @@ -16,14 +16,14 @@ GCC_HOST_S=$(patsubst %.c,%.gcc.host.s,$(CFILES)) all: $(CCOMP_K1C_S) $(GCC_K1C_S) ocamlrun.ccomp.k1c.out ocamlrun.gcc.k1c.out -ocamlrun.ccomp.k1c : $(CCOMP_K1C_S) +ocamlrun.ccomp.k1c : $(CCOMP_K1C_S) ../clock.gcc.k1c.o $(K1C_CCOMP) $(K1C_CCOMPFLAGS) $+ -o $@ $(LDLIBS) -ocamlrun.ccomp.host : $(CCOMP_HOST_S) +ocamlrun.ccomp.host : $(CCOMP_HOST_S) ../clock.gcc.host.o $(CCOMP) $(CCOMPFLAGS) $+ -o $@ $(LDLIBS) -ocamlrun.gcc.k1c : $(GCC_K1C_S) +ocamlrun.gcc.k1c : $(GCC_K1C_S) ../clock.gcc.k1c.o $(K1C_CC) $(K1C_CFLAGS) $+ -o $@ $(LDLIBS) -ocamlrun.gcc.host : $(GCC_HOST_S) +ocamlrun.gcc.host : $(GCC_HOST_S) ../clock.gcc.host.o $(CC) $(CFLAGS) $+ -o $@ $(LDLIBS) diff --git a/test/monniaux/ocaml/byterun/main.c b/test/monniaux/ocaml/byterun/main.c index 5e5839ff..498f3d18 100644 --- a/test/monniaux/ocaml/byterun/main.c +++ b/test/monniaux/ocaml/byterun/main.c @@ -13,6 +13,7 @@ /* */ /**************************************************************************/ +#define VERIMAG_MEASUREMENTS #define CAML_INTERNALS /* Main entry point (can be overridden by a user-provided main() @@ -26,6 +27,10 @@ #include #endif +#ifdef VERIMAG_MEASUREMENTS +#include "../../clock.h" +#endif + CAMLextern void caml_main (char_os **); #ifdef _WIN32 @@ -41,7 +46,15 @@ int main(int argc, char **argv) caml_expand_command_line(&argc, &argv); #endif +#ifdef VERIMAG_MEASUREMENTS + clock_prepare(); + clock_start(); +#endif caml_main(argv); +#ifdef VERIMAG_MEASUREMENTS + clock_stop(); + print_total_clock(); +#endif caml_sys_exit(Val_int(0)); return 0; /* not reached */ } diff --git a/test/monniaux/rules.mk b/test/monniaux/rules.mk index fcd6ed0a..f1f26fe2 100644 --- a/test/monniaux/rules.mk +++ b/test/monniaux/rules.mk @@ -1,13 +1,14 @@ +ALL_CCOMPFLAGS=-fno-unprototyped CCOMP=ccomp -CCOMPFLAGS=-g -O3 -Wall -fno-unprototyped +CCOMPFLAGS=-g -O3 -Wall $(ALL_CCOMPFLAGS) $(ALL_CFLAGS) -CFLAGS=-g -std=c99 -O3 -Wall -Wextra -Werror=implicit +CFLAGS=-g -std=c99 -O3 -Wall -Wextra -Werror=implicit $(ALL_CFLAGS) K1C_CC=k1-mbr-gcc -K1C_CFLAGS =-g -std=c99 -O2 -Wall -Wextra -Werror=implicit +K1C_CFLAGS =-g -std=c99 -O2 -Wall -Wextra -Werror=implicit $(ALL_CFLAGS) K1C_CCOMP = ../../../ccomp -K1C_CCOMPFLAGS=-O3 -Wall -Wno-c11-extensions -fno-unprototyped # -fpostpass-ilp +K1C_CCOMPFLAGS=-O3 -Wall -Wno-c11-extensions $(ALL_CCOMPFLAGS) $(ALL_CFLAGS) # -fpostpass-ilp EXECUTE=k1-cluster --syscall=libstd_scalls.so -- EXECUTE_CYCLES=k1-cluster --syscall=libstd_scalls.so --cycle-based -- -- cgit From 7633cb38e0440160acf3f60f7795a19224850eec Mon Sep 17 00:00:00 2001 From: Cyril SIX Date: Fri, 29 Mar 2019 10:30:46 +0100 Subject: No more Admitted --- mppa_k1c/Asmblockdeps.v | 157 +++++++++++++++++++++++++++++++----------------- 1 file changed, 102 insertions(+), 55 deletions(-) diff --git a/mppa_k1c/Asmblockdeps.v b/mppa_k1c/Asmblockdeps.v index 500fc504..6f872188 100644 --- a/mppa_k1c/Asmblockdeps.v +++ b/mppa_k1c/Asmblockdeps.v @@ -1731,6 +1731,37 @@ Proof. - simpl in H. inv H. inv MSR. inv MSW. eexists. split; try split. assumption. assumption. Qed. +Theorem forward_simu_par_wio_basic_Stuck ge fn rsr rsw mr mw sr sw bi: + Ge = Genv ge fn -> + match_states (State rsr mr) sr -> + match_states (State rsw mw) sw -> + parexec_basic_instr ge bi rsr rsw mr mw = Stuck -> + macro_prun Ge (trans_basic bi) sw sr sr = None. +Proof. + intros GENV MSR MSW H0. inv MSR; inv MSW. + unfold parexec_basic_instr in H0. destruct bi; try discriminate. +(* PLoad *) + - destruct i; destruct i. + all: simpl; rewrite H; rewrite (H1 ra); unfold parexec_load in H0; + destruct (eval_offset _ _); auto; destruct (Mem.loadv _ _ _); auto; discriminate. +(* PStore *) + - destruct i; destruct i; + simpl; rewrite H; rewrite (H1 ra); rewrite (H1 rs); + unfold parexec_store in H0; destruct (eval_offset _ _); auto; destruct (Mem.storev _ _ _); auto; discriminate. +(* Pallocframe *) + - simpl. Simpl. rewrite (H1 SP). rewrite H. destruct (Mem.alloc _ _ _). simpl in H0. + destruct (Mem.store _ _ _ _); try discriminate. reflexivity. +(* Pfreeframe *) + - simpl. Simpl. rewrite (H1 SP). rewrite H. + destruct (Mem.loadv _ _ _); auto. destruct (rsr GPR12); auto. destruct (Mem.free _ _ _ _); auto. + discriminate. +(* Pget *) + - simpl. destruct rs; subst; try discriminate. + all: simpl; auto. + - simpl. destruct rd; subst; try discriminate. + all: simpl; auto. +Qed. + Theorem forward_simu_par_body: forall bdy ge fn rsr mr sr rsw mw sw rs' m', Ge = Genv ge fn -> @@ -1856,20 +1887,52 @@ Proof. intros rr. destruct rr; unfold par_nextblock; Simpl. Qed. -Definition trans_block_aux bdy sz ex := (trans_body bdy) ++ (trans_pcincr sz (trans_exit ex) :: nil). - -(* Lemma put in Parallelizability. -Lemma prun_iw_app_some: - forall c c' sr sw s' s'', - prun_iw Ge c sw sr = Some s' -> - prun_iw Ge c' s' sr = Some s'' -> - prun_iw Ge (c ++ c') sw sr = Some s''. +Lemma forward_simu_par_control_Stuck ge fn rsr rsw mr mw sr sw sz ex: + Ge = Genv ge fn -> + match_states (State rsr mr) sr -> + match_states (State rsw mw) sw -> + parexec_control ge fn ex (par_nextblock (Ptrofs.repr sz) rsr) (par_nextblock (Ptrofs.repr sz) rsw) mw = Stuck -> + macro_prun Ge (trans_pcincr sz (trans_exit ex)) sw sr sr = None. Proof. - induction c. - - simpl. intros. congruence. - - intros. simpl in *. destruct (macro_prun _ _ _ _); auto. eapply IHc; eauto. discriminate. + intros GENV MSR MSW H0. inv MSR; inv MSW. destruct ex as [ctl|]; try discriminate. + destruct ctl; destruct i; try discriminate; try (simpl; reflexivity). +(* Pbuiltin *) + - simpl in *. rewrite (H1 PC). reflexivity. +(* Pj_l *) + - simpl in *. rewrite (H1 PC). unfold goto_label_deps. unfold par_goto_label in H0. + destruct (label_pos _ _ _); auto. simpl in *. unfold par_nextblock in H0. rewrite Pregmap.gss in H0. + destruct (Val.offset_ptr _ _); try discriminate; auto. +(* Pcb *) + - simpl in *. destruct (cmp_for_btest bt). destruct i. + -- destruct o. + + unfold par_eval_branch in H0; unfold eval_branch_deps. + rewrite (H1 PC). Simpl. rewrite (H1 r). unfold par_nextblock in H0. rewrite Pregmap.gso in H0; try discriminate. + destruct (Val.cmp_bool _ _ _); auto. destruct b; try discriminate. unfold goto_label_deps; unfold par_goto_label in H0. + destruct (label_pos _ _ _); auto. rewrite Pregmap.gss in H0. destruct (Val.offset_ptr _ _); auto. discriminate. + + rewrite (H1 PC). Simpl. rewrite (H1 r). reflexivity. + -- destruct o. + + unfold par_eval_branch in H0; unfold eval_branch_deps. + rewrite (H1 PC). Simpl. rewrite (H1 r). unfold par_nextblock in H0. rewrite Pregmap.gso in H0; try discriminate. + destruct (Val.cmpl_bool _ _ _); auto. destruct b; try discriminate. unfold goto_label_deps; unfold par_goto_label in H0. + destruct (label_pos _ _ _); auto. rewrite Pregmap.gss in H0. destruct (Val.offset_ptr _ _); auto. discriminate. + + rewrite (H1 PC). Simpl. rewrite (H1 r). reflexivity. +(* Pcbu *) + - simpl in *. destruct (cmpu_for_btest bt). destruct i. + -- destruct o. + + unfold par_eval_branch in H0; unfold eval_branch_deps. + rewrite (H1 PC). Simpl. rewrite (H1 r). unfold par_nextblock in H0. rewrite Pregmap.gso in H0; try discriminate. + destruct (Val_cmpu_bool _ _ _); auto. destruct b; try discriminate. unfold goto_label_deps; unfold par_goto_label in H0. + destruct (label_pos _ _ _); auto. rewrite Pregmap.gss in H0. destruct (Val.offset_ptr _ _); auto. discriminate. + + rewrite (H1 PC). Simpl. rewrite (H1 r). reflexivity. + -- destruct o. + + unfold par_eval_branch in H0; unfold eval_branch_deps. + rewrite (H1 PC). Simpl. rewrite (H1 r). unfold par_nextblock in H0. rewrite Pregmap.gso in H0; try discriminate. + destruct (Val_cmplu_bool _ _ _); auto. destruct b; try discriminate. unfold goto_label_deps; unfold par_goto_label in H0. + destruct (label_pos _ _ _); auto. rewrite Pregmap.gss in H0. destruct (Val.offset_ptr _ _); auto. discriminate. + + rewrite (H1 PC). Simpl. rewrite (H1 r). reflexivity. Qed. -*) + +Definition trans_block_aux bdy sz ex := (trans_body bdy) ++ (trans_pcincr sz (trans_exit ex) :: nil). Theorem forward_simu_par_wio_bblock_aux ge fn rsr mr sr rsw mw sw bdy ex sz rs' m': Ge = Genv ge fn -> @@ -1908,41 +1971,6 @@ Proof. erewrite prun_iw_app_Some; eauto. eassumption. Qed. -Lemma trans_body_perserves_permutation bdy1 bdy2: - Permutation bdy1 bdy2 -> - Permutation (trans_body bdy1) (trans_body bdy2). -Proof. - induction 1; simpl; econstructor; eauto. -Qed. - -Lemma trans_body_app bdy1: forall bdy2, - trans_body (bdy1++bdy2) = (trans_body bdy1) ++ (trans_body bdy2). -Proof. - induction bdy1; simpl; congruence. -Qed. - -Theorem trans_block_perserves_permutation bdy1 bdy2 b: - Permutation (bdy1 ++ bdy2) (body b) -> - Permutation (trans_block b) ((trans_block_aux bdy1 (size b) (exit b))++(trans_body bdy2)). -Proof. - intro H; unfold trans_block, trans_block_aux. - eapply perm_trans. - - eapply Permutation_app_tail. - apply trans_body_perserves_permutation. - apply Permutation_sym; eapply H. - - rewrite trans_body_app. rewrite <-! app_assoc. - apply Permutation_app_head. - apply Permutation_app_comm. -Qed. - -Lemma forward_simu_par_wio_basic_Stuck ge fn rsr rsw mr mw sr sw bi: - Ge = Genv ge fn -> - match_states (State rsr mr) sr -> - match_states (State rsw mw) sw -> - parexec_basic_instr ge bi rsr rsw mr mw = Stuck -> - macro_prun Ge (trans_basic bi) sw sr sr = None. -Admitted. - Lemma forward_simu_par_body_Stuck bdy: forall ge fn rsr mr sr rsw mw sw, Ge = Genv ge fn -> match_states (State rsr mr) sr -> @@ -1962,14 +1990,6 @@ Proof. intros X; simpl; rewrite X; auto. Qed. -Lemma forward_simu_par_control_Stuck ge fn rsr rsw mr mw sr sw sz ex: - Ge = Genv ge fn -> - match_states (State rsr mr) sr -> - match_states (State rsw mw) sw -> - parexec_control ge fn ex (par_nextblock (Ptrofs.repr sz) rsr) (par_nextblock (Ptrofs.repr sz) rsw) mw = Stuck -> - macro_prun Ge (trans_pcincr sz (trans_exit ex)) sw sr sr = None. -Admitted. - Lemma forward_simu_par_wio_stuck_bdy1 ge fn rs m s1' bdy1 sz ex: Ge = Genv ge fn -> match_states (State rs m) s1' -> @@ -1999,6 +2019,33 @@ Proof. eapply forward_simu_par_body_Stuck. 4: eauto. all: eauto. Qed. +Lemma trans_body_perserves_permutation bdy1 bdy2: + Permutation bdy1 bdy2 -> + Permutation (trans_body bdy1) (trans_body bdy2). +Proof. + induction 1; simpl; econstructor; eauto. +Qed. + +Lemma trans_body_app bdy1: forall bdy2, + trans_body (bdy1++bdy2) = (trans_body bdy1) ++ (trans_body bdy2). +Proof. + induction bdy1; simpl; congruence. +Qed. + +Theorem trans_block_perserves_permutation bdy1 bdy2 b: + Permutation (bdy1 ++ bdy2) (body b) -> + Permutation (trans_block b) ((trans_block_aux bdy1 (size b) (exit b))++(trans_body bdy2)). +Proof. + intro H; unfold trans_block, trans_block_aux. + eapply perm_trans. + - eapply Permutation_app_tail. + apply trans_body_perserves_permutation. + apply Permutation_sym; eapply H. + - rewrite trans_body_app. rewrite <-! app_assoc. + apply Permutation_app_head. + apply Permutation_app_comm. +Qed. + Theorem forward_simu_par: forall rs1 m1 s1' b ge fn rs2 m2, Ge = Genv ge fn -> -- cgit From e9a05f4ca3157a88a03f71ab31ef59bd96650142 Mon Sep 17 00:00:00 2001 From: Cyril SIX Date: Fri, 29 Mar 2019 11:30:41 +0100 Subject: Avancement dans la preuve du MBjumptable --- mppa_k1c/Asmblockgenproof.v | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/mppa_k1c/Asmblockgenproof.v b/mppa_k1c/Asmblockgenproof.v index 5d952d02..2a238c7c 100644 --- a/mppa_k1c/Asmblockgenproof.v +++ b/mppa_k1c/Asmblockgenproof.v @@ -1364,7 +1364,27 @@ Proof. all: rewrite <- C; try discriminate; unfold nextblock; Simpl. } intros. discriminate. + (* MBjumptable *) - admit. + destruct bb' as [mhd' mbdy' mex']; simpl in *. subst. + inv TBC. inv TIC. inv H0. + + assert (f0 = f) by congruence. subst f0. + monadInv H1. + generalize (transf_function_no_overflow _ _ TRANSF0); intro NOOV. + assert (f1 = f) by congruence. subst f1. + exploit find_label_goto_label. 4: eapply H16. 1-2: eauto. instantiate (2 := (nextblock tbb rs2) # GPR62 <- Vundef # GPR63 <- Vundef). + unfold nextblock. Simpl. unfold Val.offset_ptr. rewrite PCeq. reflexivity. + exploit functions_transl. eapply FIND0. eapply TRANSF0. intros FIND3. assert (fn = tf) by congruence. subst fn. + + intros [tc' [rs' [A [B C]]]]. + exploit ireg_val; eauto. rewrite H13. intros LD; inv LD. + + repeat eexists. + rewrite H6. simpl extract_basic. simpl. eauto. + rewrite H7. simpl extract_ctl. simpl. Simpl. rewrite <- H1. unfold Mach.label in H14. unfold label. rewrite H14. eapply A. + econstructor; eauto. + eapply agree_undef_regs; eauto. intros. rewrite C; auto with asmgen. + { admit. } + discriminate. + (* MBreturn *) destruct bb' as [mhd' mbdy' mex']; simpl in *. subst. inv TBC. inv TIC. inv H0. -- cgit From 10462d01d7ed4585cece61f756f12d2978593b1a Mon Sep 17 00:00:00 2001 From: Cyril SIX Date: Fri, 29 Mar 2019 14:54:05 +0100 Subject: Finition de la preuve de Asmblockgenproof --- mppa_k1c/Asmblockgenproof.v | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/mppa_k1c/Asmblockgenproof.v b/mppa_k1c/Asmblockgenproof.v index 2a238c7c..63f4c136 100644 --- a/mppa_k1c/Asmblockgenproof.v +++ b/mppa_k1c/Asmblockgenproof.v @@ -1383,7 +1383,10 @@ Proof. rewrite H7. simpl extract_ctl. simpl. Simpl. rewrite <- H1. unfold Mach.label in H14. unfold label. rewrite H14. eapply A. econstructor; eauto. eapply agree_undef_regs; eauto. intros. rewrite C; auto with asmgen. - { admit. } + { assert (destroyed_by_jumptable = R62 :: R63 :: nil) by auto. rewrite H2 in H0. simpl in H0. inv H0. + destruct (preg_eq r' GPR63). subst. contradiction. + destruct (preg_eq r' GPR62). subst. contradiction. + destruct r'; Simpl. } discriminate. + (* MBreturn *) destruct bb' as [mhd' mbdy' mex']; simpl in *. subst. @@ -1419,7 +1422,7 @@ Proof. generalize (code_tail_next_int _ _ _ _ NOOV TAIL). intro CT1. eauto. eapply agree_exten; eauto. intros. Simpl. discriminate. -Admitted. +Qed. Definition mb_remove_first (bb: MB.bblock) := {| MB.header := MB.header bb; MB.body := tail (MB.body bb); MB.exit := MB.exit bb |}. -- cgit From 0dc6f0aadfa95c722324b10c56768900760337a0 Mon Sep 17 00:00:00 2001 From: Cyril SIX Date: Fri, 29 Mar 2019 16:11:27 +0100 Subject: Preuve de Jumptable dans Asmblockdeps.v --- mppa_k1c/Asmblockdeps.v | 15 +++++++++++++++ mppa_k1c/Asmvliw.v | 10 +++++++++- 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/mppa_k1c/Asmblockdeps.v b/mppa_k1c/Asmblockdeps.v index 7f03c66a..dd876485 100644 --- a/mppa_k1c/Asmblockdeps.v +++ b/mppa_k1c/Asmblockdeps.v @@ -1845,6 +1845,17 @@ Proof. - destruct c; destruct i; try discriminate. all: try (inv H0; inv MSR; inv MSW; eexists; split; [| split]; [simpl; rewrite (H0 PC); reflexivity | Simpl | intros rr; destruct rr; unfold par_nextblock; Simpl]). + (* Pjumptable *) + + simpl in H0. destruct (par_nextblock _ _ _) eqn:PNEXT; try discriminate. + destruct (list_nth_z _ _) eqn:LISTS; try discriminate. unfold par_goto_label in H0. + destruct (label_pos _ _ _) eqn:LPOS; try discriminate. destruct (par_nextblock _ rsr PC) eqn:NB; try discriminate. inv H0. + inv MSR; inv MSW. eexists; split; try split. + * simpl. rewrite (H0 PC). Simpl. rewrite (H0 r). unfold par_nextblock in PNEXT. rewrite Pregmap.gso in PNEXT; try discriminate. rewrite PNEXT. + rewrite LISTS. unfold goto_label_deps. rewrite LPOS. unfold par_nextblock in NB. rewrite Pregmap.gss in NB. rewrite NB. reflexivity. + * Simpl. + * intros rr; destruct rr; unfold par_nextblock; Simpl. + destruct (preg_eq g GPR62). rewrite e. Simpl. + destruct (preg_eq g GPR63). rewrite e. Simpl. Simpl. (* Pj_l *) + simpl in H0. unfold par_goto_label in H0. destruct (label_pos _ _ _) eqn:LPOS; try discriminate. destruct (par_nextblock _ _ _) eqn:NB; try discriminate. inv H0. inv MSR; inv MSW. @@ -1942,6 +1953,10 @@ Proof. destruct ctl; destruct i; try discriminate; try (simpl; reflexivity). (* Pbuiltin *) - simpl in *. rewrite (H1 PC). reflexivity. +(* Pjumptable *) + - simpl in *. rewrite (H1 PC). Simpl. rewrite (H1 r). unfold par_nextblock in H0. rewrite Pregmap.gso in H0; try discriminate. + destruct (rsr r); auto. destruct (list_nth_z _ _); auto. unfold par_goto_label in H0. unfold goto_label_deps. + destruct (label_pos _ _ _); auto. rewrite Pregmap.gss in H0. destruct (Val.offset_ptr _ _); try discriminate; auto. (* Pj_l *) - simpl in *. rewrite (H1 PC). unfold goto_label_deps. unfold par_goto_label in H0. destruct (label_pos _ _ _); auto. simpl in *. unfold par_nextblock in H0. rewrite Pregmap.gss in H0. diff --git a/mppa_k1c/Asmvliw.v b/mppa_k1c/Asmvliw.v index a6e9f04b..d553c612 100644 --- a/mppa_k1c/Asmvliw.v +++ b/mppa_k1c/Asmvliw.v @@ -211,6 +211,15 @@ Definition parexec_control (f: function) (oc: option control) (rsr rsw: regset) Next (rsw#RA <- (rsr#PC) #PC <- (Genv.symbol_address ge s Ptrofs.zero)) mw | Picall r => Next (rsw#RA <- (rsr#PC) #PC <- (rsr#r)) mw + | Pjumptable r tbl => + match rsr#r with + | Vint n => + match list_nth_z tbl (Int.unsigned n) with + | None => Stuck + | Some lbl => par_goto_label f lbl rsr (rsw #GPR62 <- Vundef #GPR63 <- Vundef) mw + end + | _ => Stuck + end | Pgoto s => Next (rsw#PC <- (Genv.symbol_address ge s Ptrofs.zero)) mw | Pigoto r => @@ -230,7 +239,6 @@ Definition parexec_control (f: function) (oc: option control) (rsr rsw: regset) | (None, _) => Stuck end - (** Pseudo-instructions *) | Pbuiltin ef args res => Stuck (**r treated specially below *) -- cgit From c0558ea2fd66679eeca136b41c4378ebebb9b3a0 Mon Sep 17 00:00:00 2001 From: David Monniaux Date: Fri, 29 Mar 2019 18:30:07 +0100 Subject: use C99 mode --- test/monniaux/mod_int_mat/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/monniaux/mod_int_mat/Makefile b/test/monniaux/mod_int_mat/Makefile index f904c1e4..d1365b34 100644 --- a/test/monniaux/mod_int_mat/Makefile +++ b/test/monniaux/mod_int_mat/Makefile @@ -1,4 +1,4 @@ -CFLAGS=-Wall -O3 +CFLAGS=-Wall -O3 -std=c99 K1C_CC=k1-mbr-gcc K1C_CFLAGS=-Wall -O3 -std=c99 K1C_CCOMP=../../../ccomp -- cgit From e7b0556e74a1fd029f13aaaf2db0253832cb2668 Mon Sep 17 00:00:00 2001 From: David Monniaux Date: Fri, 29 Mar 2019 18:36:46 +0100 Subject: Makefile for picosat --- test/monniaux/picosat-965/dm_configure_ccomp.sh | 2 - test/monniaux/picosat-965/dm_configure_gcc.sh | 1 - test/monniaux/picosat-965/makefile.in | 59 ------------------------- 3 files changed, 62 deletions(-) delete mode 100755 test/monniaux/picosat-965/dm_configure_ccomp.sh delete mode 100755 test/monniaux/picosat-965/dm_configure_gcc.sh delete mode 100644 test/monniaux/picosat-965/makefile.in diff --git a/test/monniaux/picosat-965/dm_configure_ccomp.sh b/test/monniaux/picosat-965/dm_configure_ccomp.sh deleted file mode 100755 index 3be58a48..00000000 --- a/test/monniaux/picosat-965/dm_configure_ccomp.sh +++ /dev/null @@ -1,2 +0,0 @@ -# BUG -CC=../../../ccomp CFLAGS="-fall -Wall -fno-unprototyped -O3 -DNALARM -DNZIP -DNGETRUSAGE" ./configure.sh diff --git a/test/monniaux/picosat-965/dm_configure_gcc.sh b/test/monniaux/picosat-965/dm_configure_gcc.sh deleted file mode 100755 index 4b0e66fe..00000000 --- a/test/monniaux/picosat-965/dm_configure_gcc.sh +++ /dev/null @@ -1 +0,0 @@ -CC=k1-mbr-gcc CFLAGS="-Wall -O3 -DNALARM -DNZIP -DNGETRUSAGE" ./configure.sh diff --git a/test/monniaux/picosat-965/makefile.in b/test/monniaux/picosat-965/makefile.in deleted file mode 100644 index 8e0e7403..00000000 --- a/test/monniaux/picosat-965/makefile.in +++ /dev/null @@ -1,59 +0,0 @@ -CC=@CC@ -CFLAGS=@CFLAGS@ - -all: @TARGETS@ - -clean: - rm -f picosat picomcs picomus picogcnf - rm -f *.exe *.s *.o *.a *.so *.plist - rm -f makefile config.h - rm -f gmon.out *~ - -analyze: - clang --analyze $(CFLAGS) *.c *.h - -picosat: libpicosat.a app.o main.o - $(CC) $(CFLAGS) -o $@ main.o app.o -L. -lpicosat - -picomcs: libpicosat.a picomcs.o - $(CC) $(CFLAGS) -o $@ picomcs.o -L. -lpicosat - -picomus: libpicosat.a picomus.o - $(CC) $(CFLAGS) -o $@ picomus.o -L. -lpicosat - -picogcnf: libpicosat.a picogcnf.o - $(CC) $(CFLAGS) -o $@ picogcnf.o -L. -lpicosat - -app.o: app.c picosat.h makefile - $(CC) $(CFLAGS) -c $< - -picomcs.o: picomcs.c picosat.h makefile - $(CC) $(CFLAGS) -c $< - -picomus.o: picomus.c picosat.h makefile - $(CC) $(CFLAGS) -c $< - -picogcnf.o: picogcnf.c picosat.h makefile - $(CC) $(CFLAGS) -c $< - -main.o: main.c picosat.h makefile - $(CC) $(CFLAGS) -c $< - -picosat.o: picosat.c picosat.h makefile - $(CC) $(CFLAGS) -c $< - -version.o: version.c config.h makefile - $(CC) $(CFLAGS) -c $< - -config.h: makefile VERSION mkconfig.sh # and actually picosat.c - rm -f $@; ./mkconfig.sh > $@ - -libpicosat.a: picosat.o version.o - ar rc $@ picosat.o version.o - ranlib $@ - -SONAME=-Xlinker -soname -Xlinker libpicosat.so -libpicosat.so: picosat.o version.o - $(CC) $(CFLAGS) -shared -o $@ picosat.o version.o $(SONAME) - -.PHONY: all clean -- cgit From 0fdfe307defb3af858e0016e9d3d0883524aec20 Mon Sep 17 00:00:00 2001 From: David Monniaux Date: Fri, 29 Mar 2019 18:37:42 +0100 Subject: rm rules that conflict --- test/monniaux/rules.mk | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/test/monniaux/rules.mk b/test/monniaux/rules.mk index eec216bd..c8412479 100644 --- a/test/monniaux/rules.mk +++ b/test/monniaux/rules.mk @@ -35,17 +35,17 @@ EXECUTE=k1-cluster --syscall=libstd_scalls.so -- %.ccomp.k1c.o: %.ccomp.k1c.s $(K1C_CCOMP) $(K1C_CCOMPFLAGS) -c $< -o $@ -%.gcc.k1c : %.gcc.k1c.o - $(K1C_CC) $(K1C_CFLAGS) $+ -o $@ +# %.gcc.k1c : %.gcc.k1c.o +# $(K1C_CC) $(K1C_CFLAGS) $+ -o $@ -%.ccomp.k1c : %.ccomp.k1c.o - $(K1C_CCOMP) $(K1C_CCOMPFLAGS) $+ -o $@ +# %.ccomp.k1c : %.ccomp.k1c.o +# $(K1C_CCOMP) $(K1C_CCOMPFLAGS) $+ -o $@ -%.gcc.host : %.gcc.host.o - $(CC) $(CFLAGS) $+ -o $@ +# %.gcc.host : %.gcc.host.o +# $(CC) $(CFLAGS) $+ -o $@ -%.ccomp.host : %.ccomp.host.o - $(CCOMP) $(CCOMPFLAGS) $+ -o $@ +# %.ccomp.host : %.ccomp.host.o +# $(CCOMP) $(CCOMPFLAGS) $+ -o $@ %.k1c.out : %.k1c k1-cluster --cycle-based -- $< |tee $@ -- cgit From 4c35899ac3f057d66784e658be5d21582b2d7e9c Mon Sep 17 00:00:00 2001 From: David Monniaux Date: Fri, 29 Mar 2019 18:39:34 +0100 Subject: missing config.h --- test/monniaux/picosat-965/config.h | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 test/monniaux/picosat-965/config.h diff --git a/test/monniaux/picosat-965/config.h b/test/monniaux/picosat-965/config.h new file mode 100644 index 00000000..36ffc6b6 --- /dev/null +++ b/test/monniaux/picosat-965/config.h @@ -0,0 +1,3 @@ +#define PICOSAT_CC "../../../ccomp" +#define PICOSAT_CFLAGS "-fall -Wall -fno-unprototyped -O3 -DNALARM -DNZIP -DNGETRUSAGE" +#define PICOSAT_VERSION "965" -- cgit From c24042a694b960237827c6255d5d407fb58227dc Mon Sep 17 00:00:00 2001 From: David Monniaux Date: Fri, 29 Mar 2019 20:23:27 +0100 Subject: FIXME: Jumptables have linking issues. --- common/Switchaux.ml | 4 + test/monniaux/ocaml/byterun/caml/jumptbl.h | 40 + test/monniaux/ocaml/byterun/caml/opnames.h | 48 ++ test/monniaux/ocaml/byterun/prims.c | 1153 ++++++++++++++++++++++++++++ 4 files changed, 1245 insertions(+) create mode 100644 test/monniaux/ocaml/byterun/caml/jumptbl.h create mode 100644 test/monniaux/ocaml/byterun/caml/opnames.h create mode 100644 test/monniaux/ocaml/byterun/prims.c diff --git a/common/Switchaux.ml b/common/Switchaux.ml index 69300feb..81d7208f 100644 --- a/common/Switchaux.ml +++ b/common/Switchaux.ml @@ -80,6 +80,9 @@ let compile_switch_as_jumptable default cases minkey maxkey = CTaction default) let dense_enough (numcases: int) (minkey: Z.t) (maxkey: Z.t) = + false + + (* DM FIXME 2019-03-29 do not use jump tables bug in assembly/link let span = Z.sub maxkey minkey in assert (Z.ge span Z.zero); let tree_size = Z.mul (Z.of_uint 4) (Z.of_uint numcases) @@ -87,6 +90,7 @@ let dense_enough (numcases: int) (minkey: Z.t) (maxkey: Z.t) = numcases >= 7 (* small jump tables are always less efficient *) && Z.le table_size tree_size && Z.lt span (Z.of_uint Sys.max_array_length) + *) let compile_switch modulus default table = let (tbl, keys) = normalize_table table in diff --git a/test/monniaux/ocaml/byterun/caml/jumptbl.h b/test/monniaux/ocaml/byterun/caml/jumptbl.h new file mode 100644 index 00000000..30588756 --- /dev/null +++ b/test/monniaux/ocaml/byterun/caml/jumptbl.h @@ -0,0 +1,40 @@ + &&lbl_ACC0, &&lbl_ACC1, &&lbl_ACC2, &&lbl_ACC3, &&lbl_ACC4, &&lbl_ACC5, &&lbl_ACC6, &&lbl_ACC7, + &&lbl_ACC, &&lbl_PUSH, + &&lbl_PUSHACC0, &&lbl_PUSHACC1, &&lbl_PUSHACC2, &&lbl_PUSHACC3, + &&lbl_PUSHACC4, &&lbl_PUSHACC5, &&lbl_PUSHACC6, &&lbl_PUSHACC7, + &&lbl_PUSHACC, &&lbl_POP, &&lbl_ASSIGN, + &&lbl_ENVACC1, &&lbl_ENVACC2, &&lbl_ENVACC3, &&lbl_ENVACC4, &&lbl_ENVACC, + &&lbl_PUSHENVACC1, &&lbl_PUSHENVACC2, &&lbl_PUSHENVACC3, &&lbl_PUSHENVACC4, &&lbl_PUSHENVACC, + &&lbl_PUSH_RETADDR, &&lbl_APPLY, &&lbl_APPLY1, &&lbl_APPLY2, &&lbl_APPLY3, + &&lbl_APPTERM, &&lbl_APPTERM1, &&lbl_APPTERM2, &&lbl_APPTERM3, + &&lbl_RETURN, &&lbl_RESTART, &&lbl_GRAB, + &&lbl_CLOSURE, &&lbl_CLOSUREREC, + &&lbl_OFFSETCLOSUREM2, &&lbl_OFFSETCLOSURE0, &&lbl_OFFSETCLOSURE2, &&lbl_OFFSETCLOSURE, + &&lbl_PUSHOFFSETCLOSUREM2, &&lbl_PUSHOFFSETCLOSURE0, + &&lbl_PUSHOFFSETCLOSURE2, &&lbl_PUSHOFFSETCLOSURE, + &&lbl_GETGLOBAL, &&lbl_PUSHGETGLOBAL, &&lbl_GETGLOBALFIELD, &&lbl_PUSHGETGLOBALFIELD, &&lbl_SETGLOBAL, + &&lbl_ATOM0, &&lbl_ATOM, &&lbl_PUSHATOM0, &&lbl_PUSHATOM, + &&lbl_MAKEBLOCK, &&lbl_MAKEBLOCK1, &&lbl_MAKEBLOCK2, &&lbl_MAKEBLOCK3, &&lbl_MAKEFLOATBLOCK, + &&lbl_GETFIELD0, &&lbl_GETFIELD1, &&lbl_GETFIELD2, &&lbl_GETFIELD3, &&lbl_GETFIELD, &&lbl_GETFLOATFIELD, + &&lbl_SETFIELD0, &&lbl_SETFIELD1, &&lbl_SETFIELD2, &&lbl_SETFIELD3, &&lbl_SETFIELD, &&lbl_SETFLOATFIELD, + &&lbl_VECTLENGTH, &&lbl_GETVECTITEM, &&lbl_SETVECTITEM, + &&lbl_GETBYTESCHAR, &&lbl_SETBYTESCHAR, + &&lbl_BRANCH, &&lbl_BRANCHIF, &&lbl_BRANCHIFNOT, &&lbl_SWITCH, &&lbl_BOOLNOT, + &&lbl_PUSHTRAP, &&lbl_POPTRAP, &&lbl_RAISE, + &&lbl_CHECK_SIGNALS, + &&lbl_C_CALL1, &&lbl_C_CALL2, &&lbl_C_CALL3, &&lbl_C_CALL4, &&lbl_C_CALL5, &&lbl_C_CALLN, + &&lbl_CONST0, &&lbl_CONST1, &&lbl_CONST2, &&lbl_CONST3, &&lbl_CONSTINT, + &&lbl_PUSHCONST0, &&lbl_PUSHCONST1, &&lbl_PUSHCONST2, &&lbl_PUSHCONST3, &&lbl_PUSHCONSTINT, + &&lbl_NEGINT, &&lbl_ADDINT, &&lbl_SUBINT, &&lbl_MULINT, &&lbl_DIVINT, &&lbl_MODINT, + &&lbl_ANDINT, &&lbl_ORINT, &&lbl_XORINT, &&lbl_LSLINT, &&lbl_LSRINT, &&lbl_ASRINT, + &&lbl_EQ, &&lbl_NEQ, &&lbl_LTINT, &&lbl_LEINT, &&lbl_GTINT, &&lbl_GEINT, + &&lbl_OFFSETINT, &&lbl_OFFSETREF, &&lbl_ISINT, + &&lbl_GETMETHOD, + &&lbl_BEQ, &&lbl_BNEQ, &&lbl_BLTINT, &&lbl_BLEINT, &&lbl_BGTINT, &&lbl_BGEINT, + &&lbl_ULTINT, &&lbl_UGEINT, + &&lbl_BULTINT, &&lbl_BUGEINT, + &&lbl_GETPUBMET, &&lbl_GETDYNMET, + &&lbl_STOP, + &&lbl_EVENT, &&lbl_BREAK, + &&lbl_RERAISE, &&lbl_RAISE_NOTRACE, + &&lbl_GETSTRINGCHAR, diff --git a/test/monniaux/ocaml/byterun/caml/opnames.h b/test/monniaux/ocaml/byterun/caml/opnames.h new file mode 100644 index 00000000..bf6144cf --- /dev/null +++ b/test/monniaux/ocaml/byterun/caml/opnames.h @@ -0,0 +1,48 @@ + + + + +char * names_of_instructions [] = { + "ACC0", "ACC1", "ACC2", "ACC3", "ACC4", "ACC5", "ACC6", "ACC7", + "ACC", "PUSH", + "PUSHACC0", "PUSHACC1", "PUSHACC2", "PUSHACC3", + "PUSHACC4", "PUSHACC5", "PUSHACC6", "PUSHACC7", + "PUSHACC", "POP", "ASSIGN", + "ENVACC1", "ENVACC2", "ENVACC3", "ENVACC4", "ENVACC", + "PUSHENVACC1", "PUSHENVACC2", "PUSHENVACC3", "PUSHENVACC4", "PUSHENVACC", + "PUSH_RETADDR", "APPLY", "APPLY1", "APPLY2", "APPLY3", + "APPTERM", "APPTERM1", "APPTERM2", "APPTERM3", + "RETURN", "RESTART", "GRAB", + "CLOSURE", "CLOSUREREC", + "OFFSETCLOSUREM2", "OFFSETCLOSURE0", "OFFSETCLOSURE2", "OFFSETCLOSURE", + "PUSHOFFSETCLOSUREM2", "PUSHOFFSETCLOSURE0", + "PUSHOFFSETCLOSURE2", "PUSHOFFSETCLOSURE", + "GETGLOBAL", "PUSHGETGLOBAL", "GETGLOBALFIELD", "PUSHGETGLOBALFIELD", "SETGLOBAL", + "ATOM0", "ATOM", "PUSHATOM0", "PUSHATOM", + "MAKEBLOCK", "MAKEBLOCK1", "MAKEBLOCK2", "MAKEBLOCK3", "MAKEFLOATBLOCK", + "GETFIELD0", "GETFIELD1", "GETFIELD2", "GETFIELD3", "GETFIELD", "GETFLOATFIELD", + "SETFIELD0", "SETFIELD1", "SETFIELD2", "SETFIELD3", "SETFIELD", "SETFLOATFIELD", + "VECTLENGTH", "GETVECTITEM", "SETVECTITEM", + "GETBYTESCHAR", "SETBYTESCHAR", + "BRANCH", "BRANCHIF", "BRANCHIFNOT", "SWITCH", "BOOLNOT", + "PUSHTRAP", "POPTRAP", "RAISE", + "CHECK_SIGNALS", + "C_CALL1", "C_CALL2", "C_CALL3", "C_CALL4", "C_CALL5", "C_CALLN", + "CONST0", "CONST1", "CONST2", "CONST3", "CONSTINT", + "PUSHCONST0", "PUSHCONST1", "PUSHCONST2", "PUSHCONST3", "PUSHCONSTINT", + "NEGINT", "ADDINT", "SUBINT", "MULINT", "DIVINT", "MODINT", + "ANDINT", "ORINT", "XORINT", "LSLINT", "LSRINT", "ASRINT", + "EQ", "NEQ", "LTINT", "LEINT", "GTINT", "GEINT", + "OFFSETINT", "OFFSETREF", "ISINT", + "GETMETHOD", + "BEQ", "BNEQ", "BLTINT", "BLEINT", "BGTINT", "BGEINT", + "ULTINT", "UGEINT", + "BULTINT", "BUGEINT", + "GETPUBMET", "GETDYNMET", + "STOP", + "EVENT", "BREAK", + "RERAISE", "RAISE_NOTRACE", + "GETSTRINGCHAR", +"FIRST_UNIMPLEMENTED_OP"}; + + diff --git a/test/monniaux/ocaml/byterun/prims.c b/test/monniaux/ocaml/byterun/prims.c new file mode 100644 index 00000000..15ebf593 --- /dev/null +++ b/test/monniaux/ocaml/byterun/prims.c @@ -0,0 +1,1153 @@ +#define CAML_INTERNALS +#include "caml/mlvalues.h" +#include "caml/prims.h" +extern value caml_abs_float(); +extern value caml_acos_float(); +extern value caml_add_debug_info(); +extern value caml_add_float(); +extern value caml_alloc_dummy(); +extern value caml_alloc_dummy_float(); +extern value caml_alloc_dummy_function(); +extern value caml_array_append(); +extern value caml_array_blit(); +extern value caml_array_concat(); +extern value caml_array_get(); +extern value caml_array_get_addr(); +extern value caml_array_get_float(); +extern value caml_array_set(); +extern value caml_array_set_addr(); +extern value caml_array_set_float(); +extern value caml_array_sub(); +extern value caml_array_unsafe_get(); +extern value caml_array_unsafe_get_float(); +extern value caml_array_unsafe_set(); +extern value caml_array_unsafe_set_addr(); +extern value caml_array_unsafe_set_float(); +extern value caml_asin_float(); +extern value caml_atan2_float(); +extern value caml_atan_float(); +extern value caml_ba_blit(); +extern value caml_ba_change_layout(); +extern value caml_ba_create(); +extern value caml_ba_dim(); +extern value caml_ba_dim_1(); +extern value caml_ba_dim_2(); +extern value caml_ba_dim_3(); +extern value caml_ba_fill(); +extern value caml_ba_get_1(); +extern value caml_ba_get_2(); +extern value caml_ba_get_3(); +extern value caml_ba_get_generic(); +extern value caml_ba_kind(); +extern value caml_ba_layout(); +extern value caml_ba_num_dims(); +extern value caml_ba_reshape(); +extern value caml_ba_set_1(); +extern value caml_ba_set_2(); +extern value caml_ba_set_3(); +extern value caml_ba_set_generic(); +extern value caml_ba_slice(); +extern value caml_ba_sub(); +extern value caml_ba_uint8_get16(); +extern value caml_ba_uint8_get32(); +extern value caml_ba_uint8_get64(); +extern value caml_ba_uint8_set16(); +extern value caml_ba_uint8_set32(); +extern value caml_ba_uint8_set64(); +extern value caml_backtrace_status(); +extern value caml_blit_bytes(); +extern value caml_blit_string(); +extern value caml_bswap16(); +extern value caml_bytes_compare(); +extern value caml_bytes_equal(); +extern value caml_bytes_get(); +extern value caml_bytes_get16(); +extern value caml_bytes_get32(); +extern value caml_bytes_get64(); +extern value caml_bytes_greaterequal(); +extern value caml_bytes_greaterthan(); +extern value caml_bytes_lessequal(); +extern value caml_bytes_lessthan(); +extern value caml_bytes_notequal(); +extern value caml_bytes_of_string(); +extern value caml_bytes_set(); +extern value caml_bytes_set16(); +extern value caml_bytes_set32(); +extern value caml_bytes_set64(); +extern value caml_ceil_float(); +extern value caml_channel_descriptor(); +extern value caml_classify_float(); +extern value caml_compare(); +extern value caml_convert_raw_backtrace(); +extern value caml_convert_raw_backtrace_slot(); +extern value caml_copysign_float(); +extern value caml_cos_float(); +extern value caml_cosh_float(); +extern value caml_create_bytes(); +extern value caml_create_string(); +extern value caml_div_float(); +extern value caml_dynlink_add_primitive(); +extern value caml_dynlink_close_lib(); +extern value caml_dynlink_get_current_libs(); +extern value caml_dynlink_lookup_symbol(); +extern value caml_dynlink_open_lib(); +extern value caml_ensure_stack_capacity(); +extern value caml_ephe_blit_data(); +extern value caml_ephe_blit_key(); +extern value caml_ephe_check_data(); +extern value caml_ephe_check_key(); +extern value caml_ephe_create(); +extern value caml_ephe_get_data(); +extern value caml_ephe_get_data_copy(); +extern value caml_ephe_get_key(); +extern value caml_ephe_get_key_copy(); +extern value caml_ephe_set_data(); +extern value caml_ephe_set_key(); +extern value caml_ephe_unset_data(); +extern value caml_ephe_unset_key(); +extern value caml_eq_float(); +extern value caml_equal(); +extern value caml_exp_float(); +extern value caml_expm1_float(); +extern value caml_fill_bytes(); +extern value caml_fill_string(); +extern value caml_final_register(); +extern value caml_final_register_called_without_value(); +extern value caml_final_release(); +extern value caml_float_compare(); +extern value caml_float_of_int(); +extern value caml_float_of_string(); +extern value caml_floatarray_create(); +extern value caml_floatarray_get(); +extern value caml_floatarray_set(); +extern value caml_floatarray_unsafe_get(); +extern value caml_floatarray_unsafe_set(); +extern value caml_floor_float(); +extern value caml_fmod_float(); +extern value caml_format_float(); +extern value caml_format_int(); +extern value caml_fresh_oo_id(); +extern value caml_frexp_float(); +extern value caml_gc_compaction(); +extern value caml_gc_counters(); +extern value caml_gc_full_major(); +extern value caml_gc_get(); +extern value caml_gc_huge_fallback_count(); +extern value caml_gc_major(); +extern value caml_gc_major_slice(); +extern value caml_gc_minor(); +extern value caml_gc_minor_words(); +extern value caml_gc_quick_stat(); +extern value caml_gc_set(); +extern value caml_gc_stat(); +extern value caml_ge_float(); +extern value caml_get_current_callstack(); +extern value caml_get_current_environment(); +extern value caml_get_exception_backtrace(); +extern value caml_get_exception_raw_backtrace(); +extern value caml_get_global_data(); +extern value caml_get_major_bucket(); +extern value caml_get_major_credit(); +extern value caml_get_minor_free(); +extern value caml_get_public_method(); +extern value caml_get_section_table(); +extern value caml_greaterequal(); +extern value caml_greaterthan(); +extern value caml_gt_float(); +extern value caml_hash(); +extern value caml_hash_univ_param(); +extern value caml_hexstring_of_float(); +extern value caml_hypot_float(); +extern value caml_input_value(); +extern value caml_input_value_from_bytes(); +extern value caml_input_value_from_string(); +extern value caml_input_value_to_outside_heap(); +extern value caml_install_signal_handler(); +extern value caml_int32_add(); +extern value caml_int32_and(); +extern value caml_int32_bits_of_float(); +extern value caml_int32_bswap(); +extern value caml_int32_compare(); +extern value caml_int32_div(); +extern value caml_int32_float_of_bits(); +extern value caml_int32_format(); +extern value caml_int32_mod(); +extern value caml_int32_mul(); +extern value caml_int32_neg(); +extern value caml_int32_of_float(); +extern value caml_int32_of_int(); +extern value caml_int32_of_string(); +extern value caml_int32_or(); +extern value caml_int32_shift_left(); +extern value caml_int32_shift_right(); +extern value caml_int32_shift_right_unsigned(); +extern value caml_int32_sub(); +extern value caml_int32_to_float(); +extern value caml_int32_to_int(); +extern value caml_int32_xor(); +extern value caml_int64_add(); +extern value caml_int64_and(); +extern value caml_int64_bits_of_float(); +extern value caml_int64_bswap(); +extern value caml_int64_compare(); +extern value caml_int64_div(); +extern value caml_int64_float_of_bits(); +extern value caml_int64_format(); +extern value caml_int64_mod(); +extern value caml_int64_mul(); +extern value caml_int64_neg(); +extern value caml_int64_of_float(); +extern value caml_int64_of_int(); +extern value caml_int64_of_int32(); +extern value caml_int64_of_nativeint(); +extern value caml_int64_of_string(); +extern value caml_int64_or(); +extern value caml_int64_shift_left(); +extern value caml_int64_shift_right(); +extern value caml_int64_shift_right_unsigned(); +extern value caml_int64_sub(); +extern value caml_int64_to_float(); +extern value caml_int64_to_int(); +extern value caml_int64_to_int32(); +extern value caml_int64_to_nativeint(); +extern value caml_int64_xor(); +extern value caml_int_as_pointer(); +extern value caml_int_compare(); +extern value caml_int_of_float(); +extern value caml_int_of_string(); +extern value caml_invoke_traced_function(); +extern value caml_lazy_follow_forward(); +extern value caml_lazy_make_forward(); +extern value caml_ldexp_float(); +extern value caml_le_float(); +extern value caml_lessequal(); +extern value caml_lessthan(); +extern value caml_lex_engine(); +extern value caml_log10_float(); +extern value caml_log1p_float(); +extern value caml_log_float(); +extern value caml_lt_float(); +extern value caml_make_array(); +extern value caml_make_float_vect(); +extern value caml_make_vect(); +extern value caml_marshal_data_size(); +extern value caml_md5_chan(); +extern value caml_md5_string(); +extern value caml_ml_bytes_length(); +extern value caml_ml_channel_size(); +extern value caml_ml_channel_size_64(); +extern value caml_ml_close_channel(); +extern value caml_ml_enable_runtime_warnings(); +extern value caml_ml_flush(); +extern value caml_ml_flush_partial(); +extern value caml_ml_input(); +extern value caml_ml_input_char(); +extern value caml_ml_input_int(); +extern value caml_ml_input_scan_line(); +extern value caml_ml_open_descriptor_in(); +extern value caml_ml_open_descriptor_out(); +extern value caml_ml_out_channels_list(); +extern value caml_ml_output(); +extern value caml_ml_output_bytes(); +extern value caml_ml_output_char(); +extern value caml_ml_output_int(); +extern value caml_ml_output_partial(); +extern value caml_ml_pos_in(); +extern value caml_ml_pos_in_64(); +extern value caml_ml_pos_out(); +extern value caml_ml_pos_out_64(); +extern value caml_ml_runtime_warnings_enabled(); +extern value caml_ml_seek_in(); +extern value caml_ml_seek_in_64(); +extern value caml_ml_seek_out(); +extern value caml_ml_seek_out_64(); +extern value caml_ml_set_binary_mode(); +extern value caml_ml_set_channel_name(); +extern value caml_ml_string_length(); +extern value caml_modf_float(); +extern value caml_mul_float(); +extern value caml_nativeint_add(); +extern value caml_nativeint_and(); +extern value caml_nativeint_bswap(); +extern value caml_nativeint_compare(); +extern value caml_nativeint_div(); +extern value caml_nativeint_format(); +extern value caml_nativeint_mod(); +extern value caml_nativeint_mul(); +extern value caml_nativeint_neg(); +extern value caml_nativeint_of_float(); +extern value caml_nativeint_of_int(); +extern value caml_nativeint_of_int32(); +extern value caml_nativeint_of_string(); +extern value caml_nativeint_or(); +extern value caml_nativeint_shift_left(); +extern value caml_nativeint_shift_right(); +extern value caml_nativeint_shift_right_unsigned(); +extern value caml_nativeint_sub(); +extern value caml_nativeint_to_float(); +extern value caml_nativeint_to_int(); +extern value caml_nativeint_to_int32(); +extern value caml_nativeint_xor(); +extern value caml_neg_float(); +extern value caml_neq_float(); +extern value caml_new_lex_engine(); +extern value caml_notequal(); +extern value caml_obj_add_offset(); +extern value caml_obj_block(); +extern value caml_obj_dup(); +extern value caml_obj_is_block(); +extern value caml_obj_reachable_words(); +extern value caml_obj_set_tag(); +extern value caml_obj_tag(); +extern value caml_obj_truncate(); +extern value caml_output_value(); +extern value caml_output_value_to_buffer(); +extern value caml_output_value_to_bytes(); +extern value caml_output_value_to_string(); +extern value caml_parse_engine(); +extern value caml_power_float(); +extern value caml_raw_backtrace_length(); +extern value caml_raw_backtrace_next_slot(); +extern value caml_raw_backtrace_slot(); +extern value caml_realloc_global(); +extern value caml_record_backtrace(); +extern value caml_register_channel_for_spacetime(); +extern value caml_register_code_fragment(); +extern value caml_register_named_value(); +extern value caml_reify_bytecode(); +extern value caml_remove_debug_info(); +extern value caml_reset_afl_instrumentation(); +extern value caml_restore_raw_backtrace(); +extern value caml_runtime_parameters(); +extern value caml_runtime_variant(); +extern value caml_set_oo_id(); +extern value caml_set_parser_trace(); +extern value caml_setup_afl(); +extern value caml_sin_float(); +extern value caml_sinh_float(); +extern value caml_spacetime_enabled(); +extern value caml_spacetime_only_works_for_native_code(); +extern value caml_sqrt_float(); +extern value caml_static_alloc(); +extern value caml_static_free(); +extern value caml_static_release_bytecode(); +extern value caml_static_resize(); +extern value caml_string_compare(); +extern value caml_string_equal(); +extern value caml_string_get(); +extern value caml_string_get16(); +extern value caml_string_get32(); +extern value caml_string_get64(); +extern value caml_string_greaterequal(); +extern value caml_string_greaterthan(); +extern value caml_string_lessequal(); +extern value caml_string_lessthan(); +extern value caml_string_notequal(); +extern value caml_string_of_bytes(); +extern value caml_string_set(); +extern value caml_sub_float(); +extern value caml_sys_chdir(); +extern value caml_sys_close(); +extern value caml_sys_const_backend_type(); +extern value caml_sys_const_big_endian(); +extern value caml_sys_const_int_size(); +extern value caml_sys_const_max_wosize(); +extern value caml_sys_const_ostype_cygwin(); +extern value caml_sys_const_ostype_unix(); +extern value caml_sys_const_ostype_win32(); +extern value caml_sys_const_word_size(); +extern value caml_sys_exit(); +extern value caml_sys_file_exists(); +extern value caml_sys_get_argv(); +extern value caml_sys_get_config(); +extern value caml_sys_getcwd(); +extern value caml_sys_getenv(); +extern value caml_sys_is_directory(); +extern value caml_sys_isatty(); +extern value caml_sys_open(); +extern value caml_sys_random_seed(); +extern value caml_sys_read_directory(); +extern value caml_sys_remove(); +extern value caml_sys_rename(); +extern value caml_sys_system_command(); +extern value caml_sys_time(); +extern value caml_sys_time_include_children(); +extern value caml_sys_unsafe_getenv(); +extern value caml_tan_float(); +extern value caml_tanh_float(); +extern value caml_terminfo_rows(); +extern value caml_update_dummy(); +extern value caml_weak_blit(); +extern value caml_weak_check(); +extern value caml_weak_create(); +extern value caml_weak_get(); +extern value caml_weak_get_copy(); +extern value caml_weak_set(); +c_primitive caml_builtin_cprim[] = { + caml_abs_float, + caml_acos_float, + caml_add_debug_info, + caml_add_float, + caml_alloc_dummy, + caml_alloc_dummy_float, + caml_alloc_dummy_function, + caml_array_append, + caml_array_blit, + caml_array_concat, + caml_array_get, + caml_array_get_addr, + caml_array_get_float, + caml_array_set, + caml_array_set_addr, + caml_array_set_float, + caml_array_sub, + caml_array_unsafe_get, + caml_array_unsafe_get_float, + caml_array_unsafe_set, + caml_array_unsafe_set_addr, + caml_array_unsafe_set_float, + caml_asin_float, + caml_atan2_float, + caml_atan_float, + caml_ba_blit, + caml_ba_change_layout, + caml_ba_create, + caml_ba_dim, + caml_ba_dim_1, + caml_ba_dim_2, + caml_ba_dim_3, + caml_ba_fill, + caml_ba_get_1, + caml_ba_get_2, + caml_ba_get_3, + caml_ba_get_generic, + caml_ba_kind, + caml_ba_layout, + caml_ba_num_dims, + caml_ba_reshape, + caml_ba_set_1, + caml_ba_set_2, + caml_ba_set_3, + caml_ba_set_generic, + caml_ba_slice, + caml_ba_sub, + caml_ba_uint8_get16, + caml_ba_uint8_get32, + caml_ba_uint8_get64, + caml_ba_uint8_set16, + caml_ba_uint8_set32, + caml_ba_uint8_set64, + caml_backtrace_status, + caml_blit_bytes, + caml_blit_string, + caml_bswap16, + caml_bytes_compare, + caml_bytes_equal, + caml_bytes_get, + caml_bytes_get16, + caml_bytes_get32, + caml_bytes_get64, + caml_bytes_greaterequal, + caml_bytes_greaterthan, + caml_bytes_lessequal, + caml_bytes_lessthan, + caml_bytes_notequal, + caml_bytes_of_string, + caml_bytes_set, + caml_bytes_set16, + caml_bytes_set32, + caml_bytes_set64, + caml_ceil_float, + caml_channel_descriptor, + caml_classify_float, + caml_compare, + caml_convert_raw_backtrace, + caml_convert_raw_backtrace_slot, + caml_copysign_float, + caml_cos_float, + caml_cosh_float, + caml_create_bytes, + caml_create_string, + caml_div_float, + caml_dynlink_add_primitive, + caml_dynlink_close_lib, + caml_dynlink_get_current_libs, + caml_dynlink_lookup_symbol, + caml_dynlink_open_lib, + caml_ensure_stack_capacity, + caml_ephe_blit_data, + caml_ephe_blit_key, + caml_ephe_check_data, + caml_ephe_check_key, + caml_ephe_create, + caml_ephe_get_data, + caml_ephe_get_data_copy, + caml_ephe_get_key, + caml_ephe_get_key_copy, + caml_ephe_set_data, + caml_ephe_set_key, + caml_ephe_unset_data, + caml_ephe_unset_key, + caml_eq_float, + caml_equal, + caml_exp_float, + caml_expm1_float, + caml_fill_bytes, + caml_fill_string, + caml_final_register, + caml_final_register_called_without_value, + caml_final_release, + caml_float_compare, + caml_float_of_int, + caml_float_of_string, + caml_floatarray_create, + caml_floatarray_get, + caml_floatarray_set, + caml_floatarray_unsafe_get, + caml_floatarray_unsafe_set, + caml_floor_float, + caml_fmod_float, + caml_format_float, + caml_format_int, + caml_fresh_oo_id, + caml_frexp_float, + caml_gc_compaction, + caml_gc_counters, + caml_gc_full_major, + caml_gc_get, + caml_gc_huge_fallback_count, + caml_gc_major, + caml_gc_major_slice, + caml_gc_minor, + caml_gc_minor_words, + caml_gc_quick_stat, + caml_gc_set, + caml_gc_stat, + caml_ge_float, + caml_get_current_callstack, + caml_get_current_environment, + caml_get_exception_backtrace, + caml_get_exception_raw_backtrace, + caml_get_global_data, + caml_get_major_bucket, + caml_get_major_credit, + caml_get_minor_free, + caml_get_public_method, + caml_get_section_table, + caml_greaterequal, + caml_greaterthan, + caml_gt_float, + caml_hash, + caml_hash_univ_param, + caml_hexstring_of_float, + caml_hypot_float, + caml_input_value, + caml_input_value_from_bytes, + caml_input_value_from_string, + caml_input_value_to_outside_heap, + caml_install_signal_handler, + caml_int32_add, + caml_int32_and, + caml_int32_bits_of_float, + caml_int32_bswap, + caml_int32_compare, + caml_int32_div, + caml_int32_float_of_bits, + caml_int32_format, + caml_int32_mod, + caml_int32_mul, + caml_int32_neg, + caml_int32_of_float, + caml_int32_of_int, + caml_int32_of_string, + caml_int32_or, + caml_int32_shift_left, + caml_int32_shift_right, + caml_int32_shift_right_unsigned, + caml_int32_sub, + caml_int32_to_float, + caml_int32_to_int, + caml_int32_xor, + caml_int64_add, + caml_int64_and, + caml_int64_bits_of_float, + caml_int64_bswap, + caml_int64_compare, + caml_int64_div, + caml_int64_float_of_bits, + caml_int64_format, + caml_int64_mod, + caml_int64_mul, + caml_int64_neg, + caml_int64_of_float, + caml_int64_of_int, + caml_int64_of_int32, + caml_int64_of_nativeint, + caml_int64_of_string, + caml_int64_or, + caml_int64_shift_left, + caml_int64_shift_right, + caml_int64_shift_right_unsigned, + caml_int64_sub, + caml_int64_to_float, + caml_int64_to_int, + caml_int64_to_int32, + caml_int64_to_nativeint, + caml_int64_xor, + caml_int_as_pointer, + caml_int_compare, + caml_int_of_float, + caml_int_of_string, + caml_invoke_traced_function, + caml_lazy_follow_forward, + caml_lazy_make_forward, + caml_ldexp_float, + caml_le_float, + caml_lessequal, + caml_lessthan, + caml_lex_engine, + caml_log10_float, + caml_log1p_float, + caml_log_float, + caml_lt_float, + caml_make_array, + caml_make_float_vect, + caml_make_vect, + caml_marshal_data_size, + caml_md5_chan, + caml_md5_string, + caml_ml_bytes_length, + caml_ml_channel_size, + caml_ml_channel_size_64, + caml_ml_close_channel, + caml_ml_enable_runtime_warnings, + caml_ml_flush, + caml_ml_flush_partial, + caml_ml_input, + caml_ml_input_char, + caml_ml_input_int, + caml_ml_input_scan_line, + caml_ml_open_descriptor_in, + caml_ml_open_descriptor_out, + caml_ml_out_channels_list, + caml_ml_output, + caml_ml_output_bytes, + caml_ml_output_char, + caml_ml_output_int, + caml_ml_output_partial, + caml_ml_pos_in, + caml_ml_pos_in_64, + caml_ml_pos_out, + caml_ml_pos_out_64, + caml_ml_runtime_warnings_enabled, + caml_ml_seek_in, + caml_ml_seek_in_64, + caml_ml_seek_out, + caml_ml_seek_out_64, + caml_ml_set_binary_mode, + caml_ml_set_channel_name, + caml_ml_string_length, + caml_modf_float, + caml_mul_float, + caml_nativeint_add, + caml_nativeint_and, + caml_nativeint_bswap, + caml_nativeint_compare, + caml_nativeint_div, + caml_nativeint_format, + caml_nativeint_mod, + caml_nativeint_mul, + caml_nativeint_neg, + caml_nativeint_of_float, + caml_nativeint_of_int, + caml_nativeint_of_int32, + caml_nativeint_of_string, + caml_nativeint_or, + caml_nativeint_shift_left, + caml_nativeint_shift_right, + caml_nativeint_shift_right_unsigned, + caml_nativeint_sub, + caml_nativeint_to_float, + caml_nativeint_to_int, + caml_nativeint_to_int32, + caml_nativeint_xor, + caml_neg_float, + caml_neq_float, + caml_new_lex_engine, + caml_notequal, + caml_obj_add_offset, + caml_obj_block, + caml_obj_dup, + caml_obj_is_block, + caml_obj_reachable_words, + caml_obj_set_tag, + caml_obj_tag, + caml_obj_truncate, + caml_output_value, + caml_output_value_to_buffer, + caml_output_value_to_bytes, + caml_output_value_to_string, + caml_parse_engine, + caml_power_float, + caml_raw_backtrace_length, + caml_raw_backtrace_next_slot, + caml_raw_backtrace_slot, + caml_realloc_global, + caml_record_backtrace, + caml_register_channel_for_spacetime, + caml_register_code_fragment, + caml_register_named_value, + caml_reify_bytecode, + caml_remove_debug_info, + caml_reset_afl_instrumentation, + caml_restore_raw_backtrace, + caml_runtime_parameters, + caml_runtime_variant, + caml_set_oo_id, + caml_set_parser_trace, + caml_setup_afl, + caml_sin_float, + caml_sinh_float, + caml_spacetime_enabled, + caml_spacetime_only_works_for_native_code, + caml_sqrt_float, + caml_static_alloc, + caml_static_free, + caml_static_release_bytecode, + caml_static_resize, + caml_string_compare, + caml_string_equal, + caml_string_get, + caml_string_get16, + caml_string_get32, + caml_string_get64, + caml_string_greaterequal, + caml_string_greaterthan, + caml_string_lessequal, + caml_string_lessthan, + caml_string_notequal, + caml_string_of_bytes, + caml_string_set, + caml_sub_float, + caml_sys_chdir, + caml_sys_close, + caml_sys_const_backend_type, + caml_sys_const_big_endian, + caml_sys_const_int_size, + caml_sys_const_max_wosize, + caml_sys_const_ostype_cygwin, + caml_sys_const_ostype_unix, + caml_sys_const_ostype_win32, + caml_sys_const_word_size, + caml_sys_exit, + caml_sys_file_exists, + caml_sys_get_argv, + caml_sys_get_config, + caml_sys_getcwd, + caml_sys_getenv, + caml_sys_is_directory, + caml_sys_isatty, + caml_sys_open, + caml_sys_random_seed, + caml_sys_read_directory, + caml_sys_remove, + caml_sys_rename, + caml_sys_system_command, + caml_sys_time, + caml_sys_time_include_children, + caml_sys_unsafe_getenv, + caml_tan_float, + caml_tanh_float, + caml_terminfo_rows, + caml_update_dummy, + caml_weak_blit, + caml_weak_check, + caml_weak_create, + caml_weak_get, + caml_weak_get_copy, + caml_weak_set, + 0 }; +char * caml_names_of_builtin_cprim[] = { + "caml_abs_float", + "caml_acos_float", + "caml_add_debug_info", + "caml_add_float", + "caml_alloc_dummy", + "caml_alloc_dummy_float", + "caml_alloc_dummy_function", + "caml_array_append", + "caml_array_blit", + "caml_array_concat", + "caml_array_get", + "caml_array_get_addr", + "caml_array_get_float", + "caml_array_set", + "caml_array_set_addr", + "caml_array_set_float", + "caml_array_sub", + "caml_array_unsafe_get", + "caml_array_unsafe_get_float", + "caml_array_unsafe_set", + "caml_array_unsafe_set_addr", + "caml_array_unsafe_set_float", + "caml_asin_float", + "caml_atan2_float", + "caml_atan_float", + "caml_ba_blit", + "caml_ba_change_layout", + "caml_ba_create", + "caml_ba_dim", + "caml_ba_dim_1", + "caml_ba_dim_2", + "caml_ba_dim_3", + "caml_ba_fill", + "caml_ba_get_1", + "caml_ba_get_2", + "caml_ba_get_3", + "caml_ba_get_generic", + "caml_ba_kind", + "caml_ba_layout", + "caml_ba_num_dims", + "caml_ba_reshape", + "caml_ba_set_1", + "caml_ba_set_2", + "caml_ba_set_3", + "caml_ba_set_generic", + "caml_ba_slice", + "caml_ba_sub", + "caml_ba_uint8_get16", + "caml_ba_uint8_get32", + "caml_ba_uint8_get64", + "caml_ba_uint8_set16", + "caml_ba_uint8_set32", + "caml_ba_uint8_set64", + "caml_backtrace_status", + "caml_blit_bytes", + "caml_blit_string", + "caml_bswap16", + "caml_bytes_compare", + "caml_bytes_equal", + "caml_bytes_get", + "caml_bytes_get16", + "caml_bytes_get32", + "caml_bytes_get64", + "caml_bytes_greaterequal", + "caml_bytes_greaterthan", + "caml_bytes_lessequal", + "caml_bytes_lessthan", + "caml_bytes_notequal", + "caml_bytes_of_string", + "caml_bytes_set", + "caml_bytes_set16", + "caml_bytes_set32", + "caml_bytes_set64", + "caml_ceil_float", + "caml_channel_descriptor", + "caml_classify_float", + "caml_compare", + "caml_convert_raw_backtrace", + "caml_convert_raw_backtrace_slot", + "caml_copysign_float", + "caml_cos_float", + "caml_cosh_float", + "caml_create_bytes", + "caml_create_string", + "caml_div_float", + "caml_dynlink_add_primitive", + "caml_dynlink_close_lib", + "caml_dynlink_get_current_libs", + "caml_dynlink_lookup_symbol", + "caml_dynlink_open_lib", + "caml_ensure_stack_capacity", + "caml_ephe_blit_data", + "caml_ephe_blit_key", + "caml_ephe_check_data", + "caml_ephe_check_key", + "caml_ephe_create", + "caml_ephe_get_data", + "caml_ephe_get_data_copy", + "caml_ephe_get_key", + "caml_ephe_get_key_copy", + "caml_ephe_set_data", + "caml_ephe_set_key", + "caml_ephe_unset_data", + "caml_ephe_unset_key", + "caml_eq_float", + "caml_equal", + "caml_exp_float", + "caml_expm1_float", + "caml_fill_bytes", + "caml_fill_string", + "caml_final_register", + "caml_final_register_called_without_value", + "caml_final_release", + "caml_float_compare", + "caml_float_of_int", + "caml_float_of_string", + "caml_floatarray_create", + "caml_floatarray_get", + "caml_floatarray_set", + "caml_floatarray_unsafe_get", + "caml_floatarray_unsafe_set", + "caml_floor_float", + "caml_fmod_float", + "caml_format_float", + "caml_format_int", + "caml_fresh_oo_id", + "caml_frexp_float", + "caml_gc_compaction", + "caml_gc_counters", + "caml_gc_full_major", + "caml_gc_get", + "caml_gc_huge_fallback_count", + "caml_gc_major", + "caml_gc_major_slice", + "caml_gc_minor", + "caml_gc_minor_words", + "caml_gc_quick_stat", + "caml_gc_set", + "caml_gc_stat", + "caml_ge_float", + "caml_get_current_callstack", + "caml_get_current_environment", + "caml_get_exception_backtrace", + "caml_get_exception_raw_backtrace", + "caml_get_global_data", + "caml_get_major_bucket", + "caml_get_major_credit", + "caml_get_minor_free", + "caml_get_public_method", + "caml_get_section_table", + "caml_greaterequal", + "caml_greaterthan", + "caml_gt_float", + "caml_hash", + "caml_hash_univ_param", + "caml_hexstring_of_float", + "caml_hypot_float", + "caml_input_value", + "caml_input_value_from_bytes", + "caml_input_value_from_string", + "caml_input_value_to_outside_heap", + "caml_install_signal_handler", + "caml_int32_add", + "caml_int32_and", + "caml_int32_bits_of_float", + "caml_int32_bswap", + "caml_int32_compare", + "caml_int32_div", + "caml_int32_float_of_bits", + "caml_int32_format", + "caml_int32_mod", + "caml_int32_mul", + "caml_int32_neg", + "caml_int32_of_float", + "caml_int32_of_int", + "caml_int32_of_string", + "caml_int32_or", + "caml_int32_shift_left", + "caml_int32_shift_right", + "caml_int32_shift_right_unsigned", + "caml_int32_sub", + "caml_int32_to_float", + "caml_int32_to_int", + "caml_int32_xor", + "caml_int64_add", + "caml_int64_and", + "caml_int64_bits_of_float", + "caml_int64_bswap", + "caml_int64_compare", + "caml_int64_div", + "caml_int64_float_of_bits", + "caml_int64_format", + "caml_int64_mod", + "caml_int64_mul", + "caml_int64_neg", + "caml_int64_of_float", + "caml_int64_of_int", + "caml_int64_of_int32", + "caml_int64_of_nativeint", + "caml_int64_of_string", + "caml_int64_or", + "caml_int64_shift_left", + "caml_int64_shift_right", + "caml_int64_shift_right_unsigned", + "caml_int64_sub", + "caml_int64_to_float", + "caml_int64_to_int", + "caml_int64_to_int32", + "caml_int64_to_nativeint", + "caml_int64_xor", + "caml_int_as_pointer", + "caml_int_compare", + "caml_int_of_float", + "caml_int_of_string", + "caml_invoke_traced_function", + "caml_lazy_follow_forward", + "caml_lazy_make_forward", + "caml_ldexp_float", + "caml_le_float", + "caml_lessequal", + "caml_lessthan", + "caml_lex_engine", + "caml_log10_float", + "caml_log1p_float", + "caml_log_float", + "caml_lt_float", + "caml_make_array", + "caml_make_float_vect", + "caml_make_vect", + "caml_marshal_data_size", + "caml_md5_chan", + "caml_md5_string", + "caml_ml_bytes_length", + "caml_ml_channel_size", + "caml_ml_channel_size_64", + "caml_ml_close_channel", + "caml_ml_enable_runtime_warnings", + "caml_ml_flush", + "caml_ml_flush_partial", + "caml_ml_input", + "caml_ml_input_char", + "caml_ml_input_int", + "caml_ml_input_scan_line", + "caml_ml_open_descriptor_in", + "caml_ml_open_descriptor_out", + "caml_ml_out_channels_list", + "caml_ml_output", + "caml_ml_output_bytes", + "caml_ml_output_char", + "caml_ml_output_int", + "caml_ml_output_partial", + "caml_ml_pos_in", + "caml_ml_pos_in_64", + "caml_ml_pos_out", + "caml_ml_pos_out_64", + "caml_ml_runtime_warnings_enabled", + "caml_ml_seek_in", + "caml_ml_seek_in_64", + "caml_ml_seek_out", + "caml_ml_seek_out_64", + "caml_ml_set_binary_mode", + "caml_ml_set_channel_name", + "caml_ml_string_length", + "caml_modf_float", + "caml_mul_float", + "caml_nativeint_add", + "caml_nativeint_and", + "caml_nativeint_bswap", + "caml_nativeint_compare", + "caml_nativeint_div", + "caml_nativeint_format", + "caml_nativeint_mod", + "caml_nativeint_mul", + "caml_nativeint_neg", + "caml_nativeint_of_float", + "caml_nativeint_of_int", + "caml_nativeint_of_int32", + "caml_nativeint_of_string", + "caml_nativeint_or", + "caml_nativeint_shift_left", + "caml_nativeint_shift_right", + "caml_nativeint_shift_right_unsigned", + "caml_nativeint_sub", + "caml_nativeint_to_float", + "caml_nativeint_to_int", + "caml_nativeint_to_int32", + "caml_nativeint_xor", + "caml_neg_float", + "caml_neq_float", + "caml_new_lex_engine", + "caml_notequal", + "caml_obj_add_offset", + "caml_obj_block", + "caml_obj_dup", + "caml_obj_is_block", + "caml_obj_reachable_words", + "caml_obj_set_tag", + "caml_obj_tag", + "caml_obj_truncate", + "caml_output_value", + "caml_output_value_to_buffer", + "caml_output_value_to_bytes", + "caml_output_value_to_string", + "caml_parse_engine", + "caml_power_float", + "caml_raw_backtrace_length", + "caml_raw_backtrace_next_slot", + "caml_raw_backtrace_slot", + "caml_realloc_global", + "caml_record_backtrace", + "caml_register_channel_for_spacetime", + "caml_register_code_fragment", + "caml_register_named_value", + "caml_reify_bytecode", + "caml_remove_debug_info", + "caml_reset_afl_instrumentation", + "caml_restore_raw_backtrace", + "caml_runtime_parameters", + "caml_runtime_variant", + "caml_set_oo_id", + "caml_set_parser_trace", + "caml_setup_afl", + "caml_sin_float", + "caml_sinh_float", + "caml_spacetime_enabled", + "caml_spacetime_only_works_for_native_code", + "caml_sqrt_float", + "caml_static_alloc", + "caml_static_free", + "caml_static_release_bytecode", + "caml_static_resize", + "caml_string_compare", + "caml_string_equal", + "caml_string_get", + "caml_string_get16", + "caml_string_get32", + "caml_string_get64", + "caml_string_greaterequal", + "caml_string_greaterthan", + "caml_string_lessequal", + "caml_string_lessthan", + "caml_string_notequal", + "caml_string_of_bytes", + "caml_string_set", + "caml_sub_float", + "caml_sys_chdir", + "caml_sys_close", + "caml_sys_const_backend_type", + "caml_sys_const_big_endian", + "caml_sys_const_int_size", + "caml_sys_const_max_wosize", + "caml_sys_const_ostype_cygwin", + "caml_sys_const_ostype_unix", + "caml_sys_const_ostype_win32", + "caml_sys_const_word_size", + "caml_sys_exit", + "caml_sys_file_exists", + "caml_sys_get_argv", + "caml_sys_get_config", + "caml_sys_getcwd", + "caml_sys_getenv", + "caml_sys_is_directory", + "caml_sys_isatty", + "caml_sys_open", + "caml_sys_random_seed", + "caml_sys_read_directory", + "caml_sys_remove", + "caml_sys_rename", + "caml_sys_system_command", + "caml_sys_time", + "caml_sys_time_include_children", + "caml_sys_unsafe_getenv", + "caml_tan_float", + "caml_tanh_float", + "caml_terminfo_rows", + "caml_update_dummy", + "caml_weak_blit", + "caml_weak_check", + "caml_weak_create", + "caml_weak_get", + "caml_weak_get_copy", + "caml_weak_set", + 0 }; -- cgit From 3451ed469864c10b2fc5892d46dab08e57e68416 Mon Sep 17 00:00:00 2001 From: David Monniaux Date: Sat, 30 Mar 2019 16:20:20 +0100 Subject: fix for jump tables --- common/Switchaux.ml | 5 +---- mppa_k1c/TargetPrinter.ml | 32 ++++++++++++++++++-------------- 2 files changed, 19 insertions(+), 18 deletions(-) diff --git a/common/Switchaux.ml b/common/Switchaux.ml index 81d7208f..1744a932 100644 --- a/common/Switchaux.ml +++ b/common/Switchaux.ml @@ -80,9 +80,7 @@ let compile_switch_as_jumptable default cases minkey maxkey = CTaction default) let dense_enough (numcases: int) (minkey: Z.t) (maxkey: Z.t) = - false - - (* DM FIXME 2019-03-29 do not use jump tables bug in assembly/link + (* DM Settings this to constant false disables jump tables *) let span = Z.sub maxkey minkey in assert (Z.ge span Z.zero); let tree_size = Z.mul (Z.of_uint 4) (Z.of_uint numcases) @@ -90,7 +88,6 @@ let dense_enough (numcases: int) (minkey: Z.t) (maxkey: Z.t) = numcases >= 7 (* small jump tables are always less efficient *) && Z.le table_size tree_size && Z.lt span (Z.of_uint Sys.max_array_length) - *) let compile_switch modulus default table = let (tbl, keys) = normalize_table table in diff --git a/mppa_k1c/TargetPrinter.ml b/mppa_k1c/TargetPrinter.ml index 29e0fef4..6416b65b 100644 --- a/mppa_k1c/TargetPrinter.ml +++ b/mppa_k1c/TargetPrinter.ml @@ -99,6 +99,14 @@ module Target (*: TARGET*) = (* Associate labels to floating-point constants and to symbols. *) + let print_tbl oc (lbl, tbl) = + fprintf oc " .balign 4\n"; + fprintf oc "%a:\n" label lbl; + List.iter + (fun l -> fprintf oc " .4byte %a\n" + print_label l) + tbl + let emit_constants oc lit = if exists_constants () then begin section oc lit; @@ -266,15 +274,18 @@ module Target (*: TARGET*) = fprintf oc " loopdo %a, %a\n" ireg r print_label lbl | Pjumptable (idx_reg, tbl) -> let lbl = new_label() in - jumptables := (lbl, tbl) :: !jumptables; + (* jumptables := (lbl, tbl) :: !jumptables; *) let base_reg = if idx_reg=Asmblock.GPR63 then Asmblock.GPR62 else Asmblock.GPR63 in fprintf oc "%s jumptable [ " comment; List.iter (fun l -> fprintf oc "%a " print_label l) tbl; fprintf oc "]\n"; fprintf oc " make %a = %a\n ;;\n" ireg base_reg label lbl; fprintf oc " lwz.xs %a = %a[%a]\n ;;\n" ireg base_reg ireg idx_reg ireg base_reg; - fprintf oc " igoto %a\n ;;\n" ireg base_reg - + fprintf oc " igoto %a\n ;;\n" ireg base_reg; + section oc Section_jumptable; + print_tbl oc (lbl, tbl); + section oc Section_text + (* Load/Store instructions *) | Plb(rd, ra, ofs) -> fprintf oc " lbs %a = %a[%a]\n" ireg rd offset ofs ireg ra @@ -523,21 +534,14 @@ module Target (*: TARGET*) = let print_align oc alignment = fprintf oc " .balign %d\n" alignment - - let print_jumptable oc jmptbl = - let print_tbl oc (lbl, tbl) = - fprintf oc "%a:\n" label lbl; - List.iter - (fun l -> fprintf oc " .4byte %a\n" - print_label l) - tbl in - if !jumptables <> [] then + + let print_jumptable oc jmptbl = () + (* if !jumptables <> [] then begin section oc jmptbl; - fprintf oc " .balign 4\n"; List.iter (print_tbl oc) !jumptables; jumptables := [] - end + end *) let print_fun_info = elf_print_fun_info -- cgit From 2cbb81b2679a6d2b25bf490528060b321117294c Mon Sep 17 00:00:00 2001 From: Sylvain Boulmé Date: Mon, 1 Apr 2019 10:25:41 +0200 Subject: delete useless DepExample* files in order to avoid to keep these files up-to-date here... --- mppa_k1c/abstractbb/DepExample.v | 151 ---------- mppa_k1c/abstractbb/DepExampleDemo.v | 400 --------------------------- mppa_k1c/abstractbb/DepExampleEqTest.v | 334 ---------------------- mppa_k1c/abstractbb/DepExampleParallelTest.v | 166 ----------- 4 files changed, 1051 deletions(-) delete mode 100644 mppa_k1c/abstractbb/DepExample.v delete mode 100644 mppa_k1c/abstractbb/DepExampleDemo.v delete mode 100644 mppa_k1c/abstractbb/DepExampleEqTest.v delete mode 100644 mppa_k1c/abstractbb/DepExampleParallelTest.v diff --git a/mppa_k1c/abstractbb/DepExample.v b/mppa_k1c/abstractbb/DepExample.v deleted file mode 100644 index a239e24f..00000000 --- a/mppa_k1c/abstractbb/DepExample.v +++ /dev/null @@ -1,151 +0,0 @@ -(** Specification of the example illustrating how to use ImpDep. *) - -Require Export ZArith. - -Require Export ZArith. -Require Export List. -Export ListNotations. - -(* Syntax *) - -Definition reg := positive. - -Inductive operand := - | Imm (i:Z) - | Reg (r:reg) - . - -Inductive arith_op := ADD | SUB | MUL. - -Inductive inst := - | MOVE (dest: reg) (src: operand) - | ARITH (dest: reg) (op: arith_op) (src1 src2: operand) - | LOAD (dest base: reg) (offset: operand) - | STORE (src base: reg) (offset: operand) - | MEMSWAP (r base: reg) (offset: operand) - . - -Definition bblock := list inst. - -(* Semantics *) - -Definition value := Z. - -Definition addr := positive. - -Definition mem := addr -> value. - -Definition assign (m: mem) (x:addr) (v: value) := - fun y => if Pos.eq_dec x y then v else (m y). - -Definition regmem := reg -> value. - -Record state := { sm: mem; rm: regmem }. - -Definition operand_eval (x: operand) (rm: regmem): value := - match x with - | Imm i => i - | Reg r => rm r - end. - -Definition arith_op_eval (o: arith_op): value -> value -> value := - match o with - | ADD => Z.add - | SUB => Z.sub - | MUL => Z.mul - end. - -Definition get_addr (base:reg) (offset:operand) (rm: regmem): option addr := - let b := rm base in - let ofs := operand_eval offset rm in - match Z.add b ofs with - | Zpos p => Some p - | _ => None - end. - -(* two-state semantics -- dissociating read from write access. - - all read access on [sin] state - - all register write access modifies [sout] state - - all memory write access modifies [sin] state - => useful for parallel semantics - NB: in this parallel semantics -- there is at most one STORE by bundle - which is non-deterministically chosen... -*) -Definition sem_inst (i: inst) (sin sout: state): option state := - match i with - | MOVE dest src => - let v := operand_eval src (rm sin) in - Some {| sm := sm sout; - rm := assign (rm sout) dest v |} - | ARITH dest op src1 src2 => - let v1 := operand_eval src1 (rm sin) in - let v2 := operand_eval src2 (rm sin) in - let v := arith_op_eval op v1 v2 in - Some {| sm := sm sout; - rm := assign (rm sout) dest v |} - | LOAD dest base offset => - match get_addr base offset (rm sin) with - | Some srce => - Some {| sm := sm sout; - rm := assign (rm sout) dest (sm sin srce) |} - | None => None - end - | STORE srce base offset => - match get_addr base offset (rm sin) with - | Some dest => - Some {| sm := assign (sm sin) dest (rm sin srce); - rm := rm sout |} - | None => None - end - | MEMSWAP x base offset => - match get_addr base offset (rm sin) with - | Some ad => - Some {| sm := assign (sm sin) ad (rm sin x); - rm := assign (rm sout) x (sm sin ad) |} - | None => None - end - end. - -Local Open Scope list_scope. - -(** usual sequential semantics *) -Fixpoint sem_bblock (p: bblock) (s: state): option state := - match p with - | nil => Some s - | i::p' => - match sem_inst i s s with - | Some s' => sem_bblock p' s' - | None => None - end - end. - -Definition state_equiv (s1 s2: state): Prop := - (forall x, sm s1 x = sm s2 x) /\ - (forall x, rm s1 x = rm s2 x). - -(* equalities on bblockram outputs *) -Definition res_equiv (os1 os2: option state): Prop := - match os1 with - | Some s1 => exists s2, os2 = Some s2 /\ state_equiv s1 s2 - | None => os2 = None - end. - - -Definition bblock_equiv (p1 p2: bblock): Prop := - forall s, res_equiv (sem_bblock p1 s) (sem_bblock p2 s). - -(** parallel semantics with in-order writes *) -Fixpoint sem_bblock_par_iw (p: bblock) (sin sout: state): option state := - match p with - | nil => Some sout - | i::p' => - match sem_inst i sin sout with - | Some sout' => sem_bblock_par_iw p' sin sout' - | None => None - end - end. - -(** parallelism semantics with arbitrary order writes *) -Require Import Sorting.Permutation. - -Definition sem_bblock_par (p: bblock) (sin: state) (sout: option state) := exists p', res_equiv sout (sem_bblock_par_iw p' sin sin) /\ Permutation p p'. diff --git a/mppa_k1c/abstractbb/DepExampleDemo.v b/mppa_k1c/abstractbb/DepExampleDemo.v deleted file mode 100644 index 74e8f35e..00000000 --- a/mppa_k1c/abstractbb/DepExampleDemo.v +++ /dev/null @@ -1,400 +0,0 @@ -(** Demo of the example illustrating how to use ImpDep. *) - -Require Import DepExampleEqTest. -Require Import Bool. - -Open Scope Z_scope. - -Module EqTests. - -Section TESTS. - -Variable ge: P.genv. - -(**** TESTS DRIVER ! ****) - -Record test_input := { - name: pstring; - expected: bool; - verbose: bool; - p1: bblock; - p2: bblock; -}. - -Definition run1 (t: test_input): ?? unit := - print ((name t) +; " =>");; - DO result <~ bblock_eq_test ge (verbose t) (p1 t) (p2 t);; - assert_b (eqb result (expected t)) "UNEXPECTED RESULT";; - if expected t - then println " SUCCESS" - else RET tt (* NB: in this case - bblock_eq_test is expected to have print an ERROR mesg *) - . - -Local Hint Resolve eqb_prop. - -Lemma run1_correctness (t: test_input): - WHEN run1 t ~> _ THEN (expected t)=true -> bblock_equiv (p1 t) (p2 t). -Proof. - unfold run1; destruct t; simpl; wlp_simplify; subst. -Qed. -Global Opaque run1. -Hint Resolve run1_correctness: wlp. - -Fixpoint run_all (l: list test_input): ?? unit := - match l with - | nil => RET tt - | t::l' => - println "" ;; (* SOME SPACES ! *) - run1 t;; - run_all l' - end. - -Lemma run_all_correctness l: - WHEN run_all l ~> _ THEN (forall t, List.In t l -> (expected t)=true -> bblock_equiv (p1 t) (p2 t)). -Proof. - induction l; simpl; wlp_simplify; subst; auto. -Qed. -Global Opaque run_all. - -(**** TESTS ****) - -Definition move (dst src: reg) := MOVE dst (Reg src). -Definition add_imm (dst src: reg) (z:Z) := ARITH dst ADD (Reg src) (Imm z). -Definition incr (r: reg) (z:Z) := add_imm r r z. -Definition add (dst src1 src2: reg) := ARITH dst ADD (Reg src1) (Reg src2). - -Definition load (dst src:reg) (ofs:Z) := LOAD dst src (Imm ofs). -Definition store (src dst:reg) (ofs:Z) := STORE src dst (Imm ofs). -Definition memswap (r base:reg) (ofs:Z) := MEMSWAP r base (Imm ofs). - -Definition R1: reg := 1%positive. -Definition R2: reg := 2%positive. -Definition R3: reg := 3%positive. -Definition R4: reg := 4%positive. - - -Definition demo: ?? unit := run_all [ - - {| name:="move_ok" ; - expected:=true; - verbose:=true; - p1:=[ move R2 R1; move R3 R1 ]; - p2:=[ move R3 R1; move R2 R3 ]; - |} ; - {| name:="move_ko" ; - expected:=false; - verbose:=true; - p1:=[ move R2 R1; move R3 R1 ]; - p2:=[ move R3 R1 ]; - |} ; - - {| name:="add_load_RAR_ok" ; - expected:=true; - verbose:=true; - p1:=[ add_imm R1 R2 5; move R4 R2; load R3 R2 2 ]; - p2:=[ load R3 R2 2; add_imm R1 R2 5; move R4 R2 ]; |} ; - - {| name:="add_load_RAW_ko"; - expected:=false; - verbose:=true; - p1:=[ add_imm R1 R2 5; move R4 R2; load R3 R1 2 ]; - p2:=[ load R3 R1 2; add_imm R1 R2 5; move R4 R2 ]; |} ; - - {| name:="add_load_WAW_ko"; - expected:=false; - verbose:=true; - p1:=[ add_imm R3 R2 5; move R4 R2; load R3 R1 2 ]; - p2:=[ load R3 R1 2; add_imm R3 R2 5; move R4 R2 ]; |} ; - - {| name:="memswap_ok1"; - expected:=true; - verbose:=true; - p1:=[ add_imm R1 R2 5; memswap R3 R2 2 ]; - p2:=[ memswap R3 R2 2; add_imm R1 R2 5 ]; |} ; - - {| name:="memswap_ok2" ; - expected:=true; - verbose:=true; - p1:=[ load R1 R2 2; store R3 R2 2; move R3 R1]; - p2:=[ memswap R3 R2 2 ; move R1 R3 ]; - |} ; - - {| name:="memswap_ko" ; - expected:=false; - verbose:=true; - p1:=[ load R3 R2 2; store R3 R2 2]; - p2:=[ memswap R3 R2 2 ]; - |} -]. - - -Fixpoint repeat_aux (n:nat) (rev_body next: bblock): bblock := - match n with - | O => next - | (S n) => repeat_aux n rev_body (List.rev_append rev_body next) - end. - -Definition repeat n body next := repeat_aux n (List.rev_append body []) next. - - -Definition inst1 := add R1 R1 R2. - -(* NB: returns [inst1^10; next] *) -Definition dummy1 next:= repeat 10%nat [inst1] next. - -Definition main: ?? unit := run_all [ - - {| name:="move_never_skips1" ; - expected:=false; - verbose:=false; - p1:=[ move R2 R2 ]; - p2:=[ ]; - |} ; - - {| name:="move_compress_ok" ; - expected:=true; - verbose:=false; - p1:=[ move R1 R2; move R2 R1; MOVE R1 (Imm 7) ]; - p2:=[ MOVE R1 (Imm 7); move R2 R2 ]; - |} ; - - {| name:="move_never_skip2" ; - expected:=false; - verbose:=false; - p1:=[ move R1 R2; move R2 R1; MOVE R1 (Imm 7) ]; - p2:=[ MOVE R1 (Imm 7) ]; - |} ; - - {| name:="R2_RAR_ok1"; - expected:=true; - verbose:=false; - p1:=dummy1 [ load R3 R2 2; store R3 R4 7 ]; - p2:=load R3 R2 2::store R3 R4 7::(dummy1 nil) |} ; - {| name:="R2_RAR_ok2"; - expected:=true; - verbose:=false; - p1:=dummy1 [ load R3 R2 2; store R3 R4 7 ]; - p2:=load R3 R2 2::(dummy1 [store R3 R4 7]) |} ; - {| name:="R2_RAR_ok3"; - expected:=true; - verbose:=false; - p1:=dummy1 [ load R3 R2 2; store R3 R4 7 ]; - p2:=load R3 R2 2::(repeat 4%nat [inst1;inst1] [store R3 R4 7; inst1; inst1]) |} ; - {| name:="bad_register_name_ko"; - expected:=false; - verbose:=false; - p1:=dummy1 [ load R3 R2 2 ]; - p2:=dummy1 [ load R3 R3 2 ] |} ; - {| name:="bad_instruction_ko"; - expected:=false; - verbose:=false; - p1:=dummy1 [ load R3 R2 2 ]; - p2:=dummy1 [ store R3 R2 2 ] |} ; - {| name:="incompleteness_ko"; - expected:=false; - verbose:=false; - p1:=dummy1 [ load R3 R2 2 ]; - p2:=[inst1; load R3 R2 2] |} ; - - - {| name:="R2_WAR_ko"; - expected:=false; - verbose:=false; - p1:=dummy1 [ load R2 R3 2 ]; - p2:=load R2 R3 2::(dummy1 nil) |} ; - {| name:="bad_register_name_ko2"; - expected:=false; - verbose:=false; - p1:=dummy1 [ load R2 R3 2 ]; - p2:=load R3 R2 2::(dummy1 nil) |} ; - - - {| name:="load_RAR_ok1"; - expected:=true; - verbose:=false; - p1:=[ load R1 R2 2; load R3 R4 5]; - p2:=[ load R3 R4 5; load R1 R2 2]; |} ; - {| name:="load_RAR_ok2"; - expected:=true; - verbose:=false; - p1:=[ load R1 R2 2; load R3 R2 5]; - p2:=[ load R3 R2 5; load R1 R2 2]; |} ; - {| name:="load_WAW_ko"; - expected:=false; - verbose:=false; - p1:=[ load R1 R2 2; load R1 R4 5]; - p2:=[ load R1 R4 5; load R1 R2 2]; |} ; - {| name:="load_store_WAR_ko"; - expected:=false; - verbose:=false; - p1:=[ load R1 R2 2; store R3 R4 5]; - p2:=[ store R3 R4 5; load R1 R2 2]; |} - - ]. - -Definition incr_R1_5 := incr R1 5. -Definition incr_R2_3 := incr R2 3. - -Definition big_test (bigN:nat) (name: pstring): ?? unit := - println "";; - println("---- Time of bigtest " +; name);; - timer(run_all, [ - - {| name:="big_test_ok1"; - expected:=true; - verbose:=false; - p1:=repeat bigN [incr_R1_5;incr_R2_3] [incr_R2_3]; - p2:=repeat bigN [incr_R1_5] (repeat (S bigN) [incr_R2_3] nil) |} ; - {| name:="big_test_ok2"; - expected:=true; - verbose:=false; - p1:=repeat bigN [incr_R1_5;incr_R2_3] [incr_R2_3]; - p2:=repeat bigN [incr_R2_3;incr_R1_5] [incr_R2_3] |} ; - {| name:="big_test_ok3"; - expected:=true; - verbose:=false; - p1:=repeat bigN [incr_R1_5;incr_R2_3] [incr_R2_3]; - p2:=repeat (S bigN) [incr_R2_3] (repeat bigN [incr_R1_5] nil) |} ; - {| name:="big_test_ko1"; - expected:=false; - verbose:=false; - p1:=repeat bigN [incr_R1_5;incr_R2_3] [incr_R2_3]; - p2:=repeat bigN [incr_R1_5] (repeat bigN [incr_R2_3] nil) |} ; - {| name:="big_test_ko2"; - expected:=false; - verbose:=false; - p1:=repeat bigN [incr_R1_5;incr_R2_3] [incr_R2_3]; - p2:=repeat (S bigN) [incr_R1_5] (repeat bigN [incr_R2_3] nil) |} - - ]). - -Fixpoint big_tests (l:list (nat * string)) := - match l with - | nil => RET tt - | (x,s)::l' => big_test x s;; big_tests l' - end. - -Local Open Scope nat_scope. -Local Open Scope string_scope. - -Definition big_runs: ?? unit := - big_tests [(2500, "2500"); (5000, "5000"); (10000, "10000"); (20000, "20000")]. - - -End EqTests. - - -Require Import DepExampleParallelTest. - -Module ParaTests. - - -(**** TESTS DRIVER ! ****) - -Record test_input := { - name: pstring; - expected: bool; - bundle: bblock; -}. - -Definition run1 (t: test_input): ?? unit := - print ((name t) +; " =>");; - assert_b (eqb (bblock_is_para (bundle t)) (expected t)) "UNEXPECTED RESULT";; - if expected t - then println " SUCCESS" - else println " FAILED (as expected)" - . - -Local Hint Resolve eqb_prop. - -Definition correct_bundle p := forall s os', (sem_bblock_par p s os' <-> res_equiv os' (sem_bblock p s)). - -Lemma run1_correctness (t: test_input): - WHEN run1 t ~> _ THEN (expected t)=true -> correct_bundle (bundle t). -Proof. - unfold run1; destruct t; simpl; wlp_simplify; subst. - - unfold correct_bundle; intros; apply bblock_is_para_correct; auto. - - discriminate. -Qed. -Global Opaque run1. -Hint Resolve run1_correctness: wlp. - -Fixpoint run_all (l: list test_input): ?? unit := - match l with - | nil => RET tt - | t::l' => - run1 t;; - run_all l' - end. - -Lemma run_all_correctness l: - WHEN run_all l ~> _ THEN (forall t, List.In t l -> (expected t)=true -> correct_bundle (bundle t)). -Proof. - induction l; simpl; wlp_simplify; subst; auto. -Qed. -Global Opaque run_all. - -(**** TESTS ****) - -Definition add_imm (dst src: reg) (z:Z) := ARITH dst ADD (Reg src) (Imm z). - -Definition load (dst src:reg) (ofs:Z) := LOAD dst src (Imm ofs). -Definition store (src dst:reg) (ofs:Z) := STORE src dst (Imm ofs). -Definition memswap (r base:reg) (ofs:Z) := MEMSWAP r base (Imm ofs). - -Definition R1: reg := 1%positive. -Definition R2: reg := 2%positive. -Definition R3: reg := 3%positive. -Definition R4: reg := 4%positive. -Definition R5: reg := 5%positive. -Definition R6: reg := 5%positive. - - -Definition main: ?? unit := - println "";; - println "-- Parallel Checks --";; - run_all [ - {| name:="test_war_ok"; - expected:=true; - bundle:=[add_imm R1 R2 2;add_imm R2 R2 3] - |}; - {| name:="test_raw_ko"; - expected:=false; - bundle:=[add_imm R1 R2 2;add_imm R2 R1 3] - |}; - {| name:="test_waw_ko"; - expected:=false; - bundle:=[add_imm R1 R2 2;add_imm R1 R2 3] - |}; - {| name:="test_war_load_store_ok"; - expected:=true; - bundle:=[load R1 R2 2;load R2 R3 3; store R3 R4 4] - |}; - {| name:="test_raw_load_store_ko"; - expected:=false; - bundle:=[load R1 R2 2;store R5 R4 4;load R2 R3 3] - |}; - {| name:="test_waw_load_store_ko"; - expected:=false; - bundle:=[load R1 R2 2;store R3 R2 3;store R5 R4 4] - |}; - {| name:="test_arith_load_store_ok"; - expected:=true; - bundle:=[load R1 R2 2; add_imm R2 R4 3; load R3 R6 3; add_imm R4 R4 3; store R6 R5 4; add_imm R6 R6 7] - |} - ]. - -End ParaTests. - -(*************************) -(* Extraction directives *) - -Require Import ExtrOcamlString. -Require Import ExtrOcamlBasic. - -Import ImpConfig. - -Extraction Blacklist List String. - -Separate Extraction BinIntDef EqTests ParaTests. - diff --git a/mppa_k1c/abstractbb/DepExampleEqTest.v b/mppa_k1c/abstractbb/DepExampleEqTest.v deleted file mode 100644 index a633ee07..00000000 --- a/mppa_k1c/abstractbb/DepExampleEqTest.v +++ /dev/null @@ -1,334 +0,0 @@ -(** Implementation of the example illustrating how to use ImpDep. *) - -Require Export DepExample. -Require Export Impure.ImpIO. -Export Notations. - -Require Import ImpDep. - -Open Scope impure. - -Module P<: ImpParam. - -Module R := Pos. - -Definition genv := unit. - -Section IMP. - -Inductive value_wrap := - | Std (v:value) (* value = DepExample.value *) - | Mem (m:mem) - . - -Inductive op_wrap := - (* constants *) - | Imm (i:Z) - (* arithmetic operation *) - | ARITH (op: arith_op) - | LOAD - | STORE - . - -Definition op_eval (ge: genv) (op: op_wrap) (l:list value_wrap): option value_wrap := - match op, l with - | Imm i, [] => Some (Std i) - | ARITH op, [Std v1; Std v2] => Some (Std (arith_op_eval op v1 v2)) - | LOAD, [Mem m; Std base; Std offset] => - match (Z.add base offset) with - | Zpos srce => Some (Std (m srce)) - | _ => None - end - | STORE, [Mem m; Std srce; Std base; Std offset] => - match (Z.add base offset) with - | Zpos dest => Some (Mem (assign m dest srce)) - | _ => None - end - | _, _ => None - end. - - -Definition value:=value_wrap. -Definition op:=op_wrap. - -Definition op_eq (o1 o2: op_wrap): ?? bool := - match o1, o2 with - | Imm i1, Imm i2 => phys_eq i1 i2 - | ARITH o1, ARITH o2 => phys_eq o1 o2 - | LOAD, LOAD => RET true - | STORE, STORE => RET true - | _, _ => RET false - end. - -Lemma op_eq_correct o1 o2: - WHEN op_eq o1 o2 ~> b THEN b=true -> o1 = o2. -Proof. - destruct o1, o2; wlp_simplify; congruence. -Qed. - -End IMP. -End P. - - -Module L <: ISeqLanguage with Module LP:=P. - -Module LP:=P. - -Include MkSeqLanguage P. - -End L. - - -Module IDT := ImpDepTree L ImpPosDict. - -Section SECT. -Variable ge: P.genv. - -(** Compilation from DepExample to L *) - -Definition the_mem: P.R.t := 1. -Definition reg_map (r: reg): P.R.t := Pos.succ r. - -Coercion L.Name: P.R.t >-> L.exp. - -Definition comp_op (o:operand): L.exp := - match o with - | Imm i => L.Op (P.Imm i) L.Enil - | Reg r => reg_map r - end. - -Definition comp_inst (i: inst): L.macro := - match i with - | MOVE dest src => - [ (reg_map dest, (comp_op src)) ] - | ARITH dest op src1 src2 => - [ (reg_map dest, L.Op (P.ARITH op) (L.Econs (comp_op src1) (L.Econs (comp_op src2) L.Enil))) ] - | LOAD dest base offset => - [ (reg_map dest, L.Op P.LOAD (L.Econs the_mem (L.Econs (reg_map base) (L.Econs (comp_op offset) L.Enil)))) ] - | STORE srce base offset => - [ (the_mem, L.Op P.STORE (L.Econs the_mem (L.Econs (reg_map srce) (L.Econs (reg_map base) (L.Econs (comp_op offset) L.Enil))))) ] - | MEMSWAP x base offset => - [ (reg_map x, L.Op P.LOAD (L.Econs the_mem (L.Econs (reg_map base) (L.Econs (comp_op offset) L.Enil)))); - (the_mem, L.Old (L.Op P.STORE (L.Econs the_mem (L.Econs (reg_map x) (L.Econs (reg_map base) (L.Econs (comp_op offset) L.Enil)))))) ] - end. - -Fixpoint comp_bblock (p: bblock): L.bblock := - match p with - | nil => nil - | i::p' => (comp_inst i)::(comp_bblock p') - end. - -(** Correctness proof of the compiler *) - -Lemma the_mem_separation: forall r, reg_map r <> the_mem. -Proof. - intros r; apply Pos.succ_not_1. -Qed. - -Lemma reg_map_separation: forall r1 r2, r1 <> r2 -> reg_map r1 <> reg_map r2. -Proof. - unfold reg_map; intros r1 r2 H1 H2; lapply (Pos.succ_inj r1 r2); auto. -Qed. - -Local Hint Resolve the_mem_separation reg_map_separation. - -Definition match_state (s: state) (m:L.mem): Prop := - m the_mem = P.Mem (sm s) /\ forall r, m (reg_map r) = P.Std (rm s r). - -Definition trans_state (s: state): L.mem := - fun x => - if Pos.eq_dec x the_mem - then P.Mem (sm s) - else P.Std (rm s (Pos.pred x)). - -Lemma match_trans_state (s:state): match_state s (trans_state s). -Proof. - unfold trans_state; constructor 1. - - destruct (Pos.eq_dec the_mem the_mem); try congruence. - - intros r; destruct (Pos.eq_dec (reg_map r) the_mem). - * generalize the_mem_separation; subst; congruence. - * unfold reg_map; rewrite Pos.pred_succ. auto. -Qed. - -Definition match_option_state (os: option state) (om:option L.mem): Prop := - match os with - | Some s => exists m, om = Some m /\ match_state s m - | None => om = None - end. - -Lemma comp_op_correct o s m old: match_state s m -> L.exp_eval ge (comp_op o) m old = Some (P.Std (operand_eval o (rm s))). -Proof. - destruct 1 as [H1 H2]; destruct o; simpl; auto. - rewrite H2; auto. -Qed. - -Lemma comp_bblock_correct_aux p: forall s m, match_state s m -> match_option_state (sem_bblock p s) (L.run ge (comp_bblock p) m). -Proof. - induction p as [| i p IHp]; simpl; eauto. - intros s m H; destruct i; simpl; erewrite !comp_op_correct; eauto; simpl. - - (* MOVE *) - apply IHp. - destruct H as [H1 H2]; constructor 1; simpl. - + rewrite L.assign_diff; auto. - + unfold assign; intros r; destruct (Pos.eq_dec dest r). - * subst; rewrite L.assign_eq; auto. - * rewrite L.assign_diff; auto. - - (* ARITH *) - apply IHp. - destruct H as [H1 H2]; constructor 1; simpl. - + rewrite L.assign_diff; auto. - + unfold assign; intros r; destruct (Pos.eq_dec dest r). - * subst; rewrite L.assign_eq; auto. - * rewrite L.assign_diff; auto. - - (* LOAD *) - destruct H as [H1 H2]. - rewrite H1, H2; simpl. - unfold get_addr. - destruct (rm s base + operand_eval offset (rm s))%Z; simpl; auto. - apply IHp. - constructor 1; simpl. - + rewrite L.assign_diff; auto. - + unfold assign; intros r; destruct (Pos.eq_dec dest r). - * subst; rewrite L.assign_eq; auto. - * rewrite L.assign_diff; auto. - - (* STORE *) - destruct H as [H1 H2]. - rewrite H1, !H2; simpl. - unfold get_addr. - destruct (rm s base + operand_eval offset (rm s))%Z; simpl; auto. - apply IHp. - constructor 1; simpl; auto. - + intros r; rewrite L.assign_diff; auto. - - (* MEMSWAP *) - destruct H as [H1 H2]. - rewrite H1, !H2; simpl. - unfold get_addr. - destruct (rm s base + operand_eval offset (rm s))%Z; simpl; auto. - apply IHp. - constructor 1; simpl; auto. - intros r0; rewrite L.assign_diff; auto. - unfold assign; destruct (Pos.eq_dec r r0). - * subst; rewrite L.assign_eq; auto. - * rewrite L.assign_diff; auto. -Qed. - -Lemma comp_bblock_correct p s: match_option_state (sem_bblock p s) (L.run ge (comp_bblock p) (trans_state s)). -Proof. - eapply comp_bblock_correct_aux. apply match_trans_state. -Qed. - -Lemma state_equiv_from_match (s1 s2: state) (m: L.mem) : - (match_state s1 m) -> (match_state s2 m) -> (state_equiv s1 s2). -Proof. - unfold state_equiv, match_state. intuition. - - congruence. - - assert (P.Std (rm s1 x) = P.Std (rm s2 x)); congruence. -Qed. - -Definition match_option_stateX (om:option L.mem) (os:option state): Prop := - match om with - | Some m => exists s, os = Some s /\ match_state s m - | None => os = None - end. - -Local Hint Resolve state_equiv_from_match. - -Lemma res_equiv_from_match (os1 os2: option state) (om: option L.mem): - (match_option_state os1 om) -> (match_option_stateX om os2) -> (res_equiv os1 os2). -Proof. - destruct os1 as [s1|]; simpl. - - intros [m [H1 H2]]; subst; simpl. - intros [s2 [H3 H4]]; subst; simpl. - eapply ex_intro; intuition eauto. - - intro; subst; simpl; auto. -Qed. - - -Lemma match_option_state_intro_X om os: match_option_state os om -> match_option_stateX om os. -Proof. - destruct os as [s | ]; simpl. - - intros [m [H1 H2]]. subst; simpl. eapply ex_intro; intuition eauto. - - intros; subst; simpl; auto. -Qed. - - -Lemma match_from_res_eq om1 om2 os: - L.res_eq om2 om1 -> match_option_stateX om1 os -> match_option_stateX om2 os. -Proof. - destruct om2 as [m2 | ]; simpl. - - intros [m [H1 H2]]. subst; simpl. - intros [s [H3 H4]]; subst; simpl. - eapply ex_intro; intuition eauto. - unfold match_state in * |- *. - intuition (rewrite H2; auto). - - intros; subst; simpl; auto. -Qed. - -Lemma bblock_equiv_reduce p1 p2: L.bblock_equiv ge (comp_bblock p1) (comp_bblock p2) -> bblock_equiv p1 p2. -Proof. - unfold L.bblock_equiv, bblock_equiv. - intros; eapply res_equiv_from_match. - apply comp_bblock_correct. - eapply match_from_res_eq. eauto. - apply match_option_state_intro_X. - apply comp_bblock_correct. -Qed. - - - - -(* NB: pretty-printing functions below only mandatory for IDT.verb_bblock_eq_test *) -Local Open Scope string_scope. - -Definition string_of_name (x: P.R.t): ?? pstring := - match x with - | xH => RET (Str ("the_mem")) - | _ as x => - DO s <~ string_of_Z (Zpos (Pos.pred x)) ;; - RET ("R" +; s) - end. - -Definition string_of_op (op: P.op): ?? pstring := - match op with - | P.Imm i => - DO s <~ string_of_Z i ;; - RET s - | P.ARITH ADD => RET (Str "ADD") - | P.ARITH SUB => RET (Str "SUB") - | P.ARITH MUL => RET (Str "MUL") - | P.LOAD => RET (Str "LOAD") - | P.STORE => RET (Str "STORE") - end. - -Definition bblock_eq_test (verb: bool) (p1 p2: bblock) : ?? bool := - if verb then - IDT.verb_bblock_eq_test string_of_name string_of_op ge (comp_bblock p1) (comp_bblock p2) - else - IDT.bblock_eq_test ge (comp_bblock p1) (comp_bblock p2). - -Local Hint Resolve IDT.bblock_eq_test_correct bblock_equiv_reduce IDT.verb_bblock_eq_test_correct: wlp. - - -Theorem bblock_eq_test_correct verb p1 p2 : - WHEN bblock_eq_test verb p1 p2 ~> b THEN b=true -> bblock_equiv p1 p2. -Proof. - wlp_simplify. -Qed. -Global Opaque bblock_eq_test. -Hint Resolve bblock_eq_test_correct: wlp. - -End SECT. -(* TEST: we can coerce this bblock_eq_test into a pure function (even if this is a little unsafe). *) -(* -Import UnsafeImpure. - -Definition pure_eq_test v (p1 p2: bblock) : bool := unsafe_coerce (bblock_eq_test v p1 p2). - -Theorem pure_eq_test_correct v p1 p2 : - pure_eq_test v p1 p2 = true -> bblock_equiv p1 p2. -Proof. - unfold pure_eq_test. intros; eapply bblock_eq_test_correct. - - apply unsafe_coerce_not_really_correct; eauto. - - eauto. -Qed. -*) \ No newline at end of file diff --git a/mppa_k1c/abstractbb/DepExampleParallelTest.v b/mppa_k1c/abstractbb/DepExampleParallelTest.v deleted file mode 100644 index 35b44683..00000000 --- a/mppa_k1c/abstractbb/DepExampleParallelTest.v +++ /dev/null @@ -1,166 +0,0 @@ -Require Import DepExampleEqTest. -Require Import Parallelizability. - -Module PChk := ParallelChecks L PosResourceSet. - -Definition bblock_is_para (p: bblock) : bool := - PChk.is_parallelizable (comp_bblock p). - -Local Hint Resolve the_mem_separation reg_map_separation. - -Section SEC. -Variable ge: P.genv. - -(* Actually, almost the same proof script than [comp_bblock_correct_aux] ! - We could definitely factorize the proof through a lemma on compilation to macros. -*) -Lemma comp_bblock_correct_para_iw p: forall sin sout min mout, - match_state sin min -> - match_state sout mout -> - match_option_state (sem_bblock_par_iw p sin sout) (PChk.prun_iw ge (comp_bblock p) mout min). -Proof. - induction p as [|i p IHp]; simpl; eauto. - intros sin sout min mout Hin Hout; destruct i; simpl; erewrite !comp_op_correct; eauto; simpl. - - (* MOVE *) - apply IHp; auto. - destruct Hin as [H1 H2]; destruct Hout as [H3 H4]; constructor 1; simpl; auto. - + rewrite L.assign_diff; auto. - + unfold assign; intros r; destruct (Pos.eq_dec dest r). - * subst; rewrite L.assign_eq; auto. - * rewrite L.assign_diff; auto. - - (* ARITH *) - apply IHp; auto. - destruct Hin as [H1 H2]; destruct Hout as [H3 H4]; constructor 1; simpl; auto. - + rewrite L.assign_diff; auto. - + unfold assign; intros r; destruct (Pos.eq_dec dest r). - * subst; rewrite L.assign_eq; auto. - * rewrite L.assign_diff; auto. - - (* LOAD *) - destruct Hin as [H1 H2]; destruct Hout as [H3 H4]. - rewrite H1, H2; simpl. - unfold get_addr. - destruct (rm sin base + operand_eval offset (rm sin))%Z; simpl; auto. - apply IHp. { constructor 1; auto. } - constructor 1; simpl. - + rewrite L.assign_diff; auto. - + unfold assign; intros r; destruct (Pos.eq_dec dest r). - * subst; rewrite L.assign_eq; auto. - * rewrite L.assign_diff; auto. - - (* STORE *) - destruct Hin as [H1 H2]; destruct Hout as [H3 H4]. - rewrite H1, !H2; simpl. - unfold get_addr. - destruct (rm sin base + operand_eval offset (rm sin))%Z; simpl; auto. - apply IHp. { constructor 1; auto. } - constructor 1; simpl; auto. - intros r; rewrite L.assign_diff; auto. - - (* MEMSWAP *) - destruct Hin as [H1 H2]; destruct Hout as [H3 H4]. - rewrite H1, !H2; simpl. - unfold get_addr. - destruct (rm sin base + operand_eval offset (rm sin))%Z; simpl; auto. - apply IHp. { constructor 1; auto. } - constructor 1; simpl; auto. - + intros r0; rewrite L.assign_diff; auto. - unfold assign; destruct (Pos.eq_dec r r0). - * subst; rewrite L.assign_eq; auto. - * rewrite L.assign_diff; auto. -Qed. - -Local Hint Resolve match_trans_state. - -Definition trans_option_state (os: option state): option L.mem := - match os with - | Some s => Some (trans_state s) - | None => None - end. - -Lemma match_trans_option_state os: match_option_state os (trans_option_state os). -Proof. - destruct os; simpl; eauto. -Qed. - -Local Hint Resolve match_trans_option_state comp_bblock_correct match_option_state_intro_X match_from_res_eq res_equiv_from_match. - -Lemma is_mem_reg (x: P.R.t): x=the_mem \/ exists r, x=reg_map r. -Proof. - case (Pos.eq_dec x the_mem); auto. - unfold the_mem, reg_map; constructor 2. - eexists (Pos.pred x). rewrite Pos.succ_pred; auto. -Qed. - -Lemma res_eq_from_match (os: option state) (om1 om2: option L.mem): - (match_option_stateX om1 os) -> (match_option_state os om2) -> (L.res_eq om1 om2). -Proof. - destruct om1 as [m1|]; simpl. - - intros (s & H1 & H2 & H3); subst; simpl. - intros (m2 & H4 & H5 & H6); subst; simpl. - eapply ex_intro; intuition eauto. - destruct (is_mem_reg x) as [H|(r & H)]; subst; congruence. - - intro; subst; simpl; auto. -Qed. - -(* We use axiom of functional extensionality ! *) -Require Coq.Logic.FunctionalExtensionality. - -Lemma match_from_res_equiv os1 os2 om: - res_equiv os2 os1 -> match_option_state os1 om -> match_option_state os2 om. -Proof. - destruct os2 as [s2 | ]; simpl. - - intros (s & H1 & H2 & H3). subst; simpl. - intros (m & H4 & H5 & H6); subst; simpl. - eapply ex_intro; intuition eauto. - constructor 1. - + rewrite H5; apply f_equal; eapply FunctionalExtensionality.functional_extensionality; auto. - + congruence. - - intros; subst; simpl; auto. -Qed. - - -Require Import Sorting.Permutation. - -Local Hint Constructors Permutation. - -Lemma comp_bblock_Permutation p p': Permutation p p' -> Permutation (comp_bblock p) (comp_bblock p'). -Proof. - induction 1; simpl; eauto. -Qed. - -Lemma comp_bblock_Permutation_back p1 p1': Permutation p1 p1' -> - forall p, p1=comp_bblock p -> - exists p', p1'=comp_bblock p' /\ Permutation p p'. -Proof. - induction 1; simpl; eauto. - - destruct p as [|i p]; simpl; intro X; inversion X; subst. - destruct (IHPermutation p) as (p' & H1 & H2); subst; auto. - eexists (i::p'). simpl; eauto. - - destruct p as [|i1 p]; simpl; intro X; inversion X as [(H & H1)]; subst; clear X. - destruct p as [|i2 p]; simpl; inversion_clear H1. - eexists (i2::i1::p). simpl; eauto. - - intros p H1; destruct (IHPermutation1 p) as (p' & H2 & H3); subst; auto. - destruct (IHPermutation2 p') as (p'' & H4 & H5); subst; eauto. -Qed. - -Local Hint Resolve comp_bblock_Permutation res_eq_from_match match_from_res_equiv comp_bblock_correct_para_iw. - -Lemma bblock_par_iff_prun p s os': - sem_bblock_par p s os' <-> PChk.prun ge (comp_bblock p) (trans_state s) (trans_option_state os'). -Proof. - unfold sem_bblock_par, PChk.prun. constructor 1. - - intros (p' & H1 & H2). - eexists (comp_bblock p'); intuition eauto. - - intros (p' & H1 & H2). - destruct (comp_bblock_Permutation_back _ _ H2 p) as (p0 & H3 & H4); subst; auto. - eexists p0; constructor 1; eauto. -Qed. - -Theorem bblock_is_para_correct p: - bblock_is_para p = true -> forall s os', (sem_bblock_par p s os' <-> res_equiv os' (sem_bblock p s)). -Proof. - intros H; generalize (PChk.is_parallelizable_correct ge _ H); clear H. - intros H s os'. - rewrite bblock_par_iff_prun, H. - constructor; eauto. -Qed. - -End SEC. \ No newline at end of file -- cgit From 1036dcaa7a99870aa1859a9a1c683ad8f9b3b0d8 Mon Sep 17 00:00:00 2001 From: Cyril SIX Date: Mon, 1 Apr 2019 12:20:11 +0200 Subject: Using fixedd.rz in longofsingle instead of i64_dtos --- mppa_k1c/SelectLong.vp | 5 ++--- mppa_k1c/SelectLongproof.v | 16 +++++++++++----- 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/mppa_k1c/SelectLong.vp b/mppa_k1c/SelectLong.vp index 0c3618d7..31112dca 100644 --- a/mppa_k1c/SelectLong.vp +++ b/mppa_k1c/SelectLong.vp @@ -364,10 +364,9 @@ Definition floatoflongu (e: expr) := if Archi.splitlong then SplitLong.floatoflongu e else Eop Ofloatoflongu (e:::Enil). -(* SplitLong.longofsingle splits the operation into (longoffloat (floatofsingle e)) *) -Definition longofsingle (e: expr) := SplitLong.longofsingle e. +Definition longofsingle (e: expr) := longoffloat (floatofsingle e). -Definition longuofsingle (e: expr) := SplitLong.longuofsingle e. +Definition longuofsingle (e: expr) := longuoffloat (floatofsingle e). Definition singleoflong (e: expr) := SplitLong.singleoflong e. diff --git a/mppa_k1c/SelectLongproof.v b/mppa_k1c/SelectLongproof.v index 79187338..51b989d6 100644 --- a/mppa_k1c/SelectLongproof.v +++ b/mppa_k1c/SelectLongproof.v @@ -600,16 +600,22 @@ Qed. Theorem eval_longofsingle: partial_unary_constructor_sound longofsingle Val.longofsingle. Proof. - unfold longofsingle; red; intros. (* destruct Archi.splitlong eqn:SL. *) - eapply SplitLongproof.eval_longofsingle; eauto. -(* TrivialExists. *) + unfold longofsingle; red; intros. + destruct x; simpl in H0; inv H0. destruct (Float32.to_long f) as [n|] eqn:EQ; simpl in H2; inv H2. + exploit eval_floatofsingle; eauto. intros (v & A & B). simpl in B. inv B. + apply Float32.to_long_double in EQ. + eapply eval_longoffloat; eauto. simpl. + change (Float.of_single f) with (Float32.to_double f); rewrite EQ; auto. Qed. Theorem eval_longuofsingle: partial_unary_constructor_sound longuofsingle Val.longuofsingle. Proof. unfold longuofsingle; red; intros. (* destruct Archi.splitlong eqn:SL. *) - eapply SplitLongproof.eval_longuofsingle; eauto. -(* TrivialExists. *) + destruct x; simpl in H0; inv H0. destruct (Float32.to_longu f) as [n|] eqn:EQ; simpl in H2; inv H2. + exploit eval_floatofsingle; eauto. intros (v & A & B). simpl in B. inv B. + apply Float32.to_longu_double in EQ. + eapply eval_longuoffloat; eauto. simpl. + change (Float.of_single f) with (Float32.to_double f); rewrite EQ; auto. Qed. Theorem eval_singleoflong: partial_unary_constructor_sound singleoflong Val.singleoflong. -- cgit From 27d53418eff4e246a842a46b0883edda6860e3c2 Mon Sep 17 00:00:00 2001 From: Sylvain Boulmé Date: Mon, 1 Apr 2019 13:07:02 +0200 Subject: cleaning Asmvliw semantics --- mppa_k1c/Asmblock.v | 5 ++- mppa_k1c/Asmblockdeps.v | 8 ++-- mppa_k1c/Asmvliw.v | 80 +++++++++++++++++++++++++++++--------- mppa_k1c/PostpassSchedulingproof.v | 22 +++-------- 4 files changed, 73 insertions(+), 42 deletions(-) diff --git a/mppa_k1c/Asmblock.v b/mppa_k1c/Asmblock.v index b4cf57ae..f3f59f7d 100644 --- a/mppa_k1c/Asmblock.v +++ b/mppa_k1c/Asmblock.v @@ -1636,6 +1636,8 @@ Inductive final_state: state -> int -> Prop := Definition semantics (p: program) := Semantics step (initial_state p) final_state (Genv.globalenv p). +(* Useless + Remark extcall_arguments_determ: forall rs m sg args1 args2, extcall_arguments rs m sg args1 -> extcall_arguments rs m sg args2 -> args1 = args2. @@ -1695,6 +1697,7 @@ Ltac Equalities := - (* final states *) inv H; inv H0. congruence. Qed. +*) Definition data_preg (r: preg) : bool := match r with @@ -1707,7 +1710,7 @@ Definition data_preg (r: preg) : bool := (** Determinacy of the [Asm] semantics. *) -(* TODO. +(* Useless. Remark extcall_arguments_determ: forall rs m sg args1 args2, diff --git a/mppa_k1c/Asmblockdeps.v b/mppa_k1c/Asmblockdeps.v index dd876485..6d98ab9b 100644 --- a/mppa_k1c/Asmblockdeps.v +++ b/mppa_k1c/Asmblockdeps.v @@ -2158,15 +2158,13 @@ Proof. constructor; auto. Qed. -Lemma bblock_para_check_correct: - forall ge fn bb rs m rs' m' o, +Lemma bblock_para_check_correct ge fn bb rs m rs' m': Ge = Genv ge fn -> exec_bblock ge fn bb rs m = Next rs' m' -> bblock_para_check bb = true -> - parexec_bblock ge fn bb rs m o -> - o = Next rs' m'. + det_parexec ge fn bb rs m rs' m'. Proof. - intros. unfold bblock_para_check in H1. + intros H H0 H1 o H2. unfold bblock_para_check in H1. exploit forward_simu; eauto. eapply trans_state_match. intros (s2' & EXEC & MS). exploit forward_simu_par_alt. 2: apply (trans_state_match (State rs m)). all: eauto. diff --git a/mppa_k1c/Asmvliw.v b/mppa_k1c/Asmvliw.v index d553c612..1b3e0897 100644 --- a/mppa_k1c/Asmvliw.v +++ b/mppa_k1c/Asmvliw.v @@ -256,12 +256,14 @@ Definition parexec_wio_bblock_aux (f: function) bdy ext size_b (rsr rsw: regset) | Stuck => Stuck end. +(** parallel in-order writes execution of bundles *) Definition parexec_wio_bblock (f: function) (b: bblock) (rs: regset) (m: mem): outcome := parexec_wio_bblock_aux f (body b) (exit b) (Ptrofs.repr (size b)) rs rs m m. -Definition parexec_bblock (f: function) (b: bblock) (rs: regset) (m: mem) (o: outcome): Prop := - exists bdy1 bdy2, Permutation (bdy1++bdy2) (body b) /\ - o=match parexec_wio_bblock_aux f bdy1 (exit b) (Ptrofs.repr (size b)) rs rs m m with +(** non-deterministic (out-of-order writes) parallel execution of bundles *) +Definition parexec_bblock (f: function) (bundle: bblock) (rs: regset) (m: mem) (o: outcome): Prop := + exists bdy1 bdy2, Permutation (bdy1++bdy2) (body bundle) /\ + o=match parexec_wio_bblock_aux f bdy1 (exit bundle) (Ptrofs.repr (size bundle)) rs rs m m with | Next rsw mw => parexec_wio_body bdy2 rs rsw m mw | Stuck => Stuck end. @@ -276,14 +278,26 @@ Proof. destruct (parexec_wio_bblock_aux f _ _ _ _ _); simpl; auto. Qed. +(** deterministic parallel (out-of-order writes) execution of bundles *) +Definition det_parexec (f: function) (bundle: bblock) (rs: regset) (m: mem) rs' m': Prop := + forall o, parexec_bblock f bundle rs m o -> o = Next rs' m'. + + +Local Hint Resolve parexec_bblock_write_in_order. + +Lemma det_parexec_write_in_order f b rs m rs' m': + det_parexec f b rs m rs' m' -> parexec_wio_bblock f b rs m = Next rs' m'. +Proof. + unfold det_parexec; auto. +Qed. + Inductive step: state -> trace -> state -> Prop := | exec_step_internal: - forall b ofs f bi rs m rs' m', + forall b ofs f bundle rs m rs' m', rs PC = Vptr b ofs -> Genv.find_funct_ptr ge b = Some (Internal f) -> - find_bblock (Ptrofs.unsigned ofs) (fn_blocks f) = Some bi -> - parexec_wio_bblock f bi rs m = Next rs' m' -> - (forall o, parexec_bblock f bi rs m o -> o=(Next rs' m')) -> + find_bblock (Ptrofs.unsigned ofs) (fn_blocks f) = Some bundle -> + det_parexec f bundle rs m rs' m' -> step (State rs m) E0 (State rs' m') | exec_step_builtin: forall b ofs f ef args res rs m vargs t vres rs' m' bi, @@ -315,7 +329,29 @@ End RELSEM. Definition semantics (p: program) := Semantics step (initial_state p) final_state (Genv.globalenv p). -Lemma semantics_determinate: forall p, determinate (semantics p). +Remark extcall_arguments_determ: + forall rs m sg args1 args2, + extcall_arguments rs m sg args1 -> extcall_arguments rs m sg args2 -> args1 = args2. +Proof. + intros until m. + assert (A: forall l v1 v2, + extcall_arg rs m l v1 -> extcall_arg rs m l v2 -> v1 = v2). + { intros. inv H; inv H0; congruence. } + assert (B: forall p v1 v2, + extcall_arg_pair rs m p v1 -> extcall_arg_pair rs m p v2 -> v1 = v2). + { intros. inv H; inv H0. + eapply A; eauto. + f_equal; eapply A; eauto. } + assert (C: forall ll vl1, list_forall2 (extcall_arg_pair rs m) ll vl1 -> + forall vl2, list_forall2 (extcall_arg_pair rs m) ll vl2 -> vl1 = vl2). + { + induction 1; intros vl2 EA; inv EA. + auto. + f_equal; eauto. } + intros. eapply C; eauto. +Qed. + +Lemma semantics_determinate p: determinate (semantics p). Proof. Ltac Equalities := match goal with @@ -323,14 +359,20 @@ Ltac Equalities := rewrite H1 in H2; inv H2; Equalities | _ => idtac end. - intros; constructor; simpl; intros. -- (* determ *) - inv H; inv H0; Equalities. +Ltac Det_WIO X := + match goal with + | [ H: det_parexec _ _ _ _ _ _ _ |- _ ] => + exploit det_parexec_write_in_order; [ eapply H | idtac]; clear H; intro X + | _ => idtac + end. + intros; constructor; simpl. +- (* determ *) intros s t1 s1 t2 s2 H H0. inv H; Det_WIO X1; + inv H0; Det_WIO X2; Equalities. + split. constructor. auto. - + unfold parexec_wio_bblock, parexec_wio_bblock_aux in H4. destruct (parexec_wio_body _ _ _ _ _ _); try discriminate. - rewrite H10 in H4. discriminate. - + unfold parexec_wio_bblock, parexec_wio_bblock_aux in H11. destruct (parexec_wio_body _ _ _ _ _ _); try discriminate. - rewrite H4 in H11. discriminate. + + unfold parexec_wio_bblock, parexec_wio_bblock_aux in X1. destruct (parexec_wio_body _ _ _ _ _ _); try discriminate. + rewrite H8 in X1. discriminate. + + unfold parexec_wio_bblock, parexec_wio_bblock_aux in X2. destruct (parexec_wio_body _ _ _ _ _ _); try discriminate. + rewrite H4 in X2. discriminate. + assert (vargs0 = vargs) by (eapply eval_builtin_args_determ; eauto). subst vargs0. exploit external_call_determ. eexact H6. eexact H13. intros [A B]. split. auto. intros. destruct B; auto. subst. auto. @@ -343,12 +385,12 @@ Ltac Equalities := eapply external_call_trace_length; eauto. eapply external_call_trace_length; eauto. - (* initial states *) - inv H; inv H0. f_equal. congruence. + intros s1 s2 H H0; inv H; inv H0; f_equal; congruence. - (* final no step *) - assert (NOTNULL: forall b ofs, Vnullptr <> Vptr b ofs). + intros s r H; assert (NOTNULL: forall b ofs, Vnullptr <> Vptr b ofs). { intros; unfold Vnullptr; destruct Archi.ptr64; congruence. } - inv H. unfold Vzero in H0. red; intros; red; intros. + inv H. red; intros; red; intros. inv H; rewrite H0 in *; eelim NOTNULL; eauto. - (* final states *) - inv H; inv H0. congruence. + intros s r1 r2 H H0; inv H; inv H0. congruence. Qed. \ No newline at end of file diff --git a/mppa_k1c/PostpassSchedulingproof.v b/mppa_k1c/PostpassSchedulingproof.v index 4e33fc90..4433bb1d 100644 --- a/mppa_k1c/PostpassSchedulingproof.v +++ b/mppa_k1c/PostpassSchedulingproof.v @@ -776,37 +776,26 @@ Proof. intros; eapply find_bblock_Some_in; eauto. Qed. -Lemma checked_bundles_are_parexec_equiv f bundle rs rs' m m' o: +Lemma checked_bundles_are_parexec_equiv f bundle rs rs' m m': exec_bblock (globalenv (Asmblock.semantics tprog)) f bundle rs m = Next rs' m' -> verify_par_bblock bundle = OK tt -> - parexec_bblock (globalenv (semantics tprog)) f bundle rs m o -> o = Next rs' m'. + det_parexec (globalenv (semantics tprog)) f bundle rs m rs' m'. Proof. intros. unfold verify_par_bblock in H0. destruct (Asmblockdeps.bblock_para_check _) eqn:BPC; try discriminate. clear H0. - simpl in H. simpl in H1. + simpl in H. eapply Asmblockdeps.bblock_para_check_correct; eauto. Qed. -Lemma seqexec_parexec_equiv b ofs f bundle rs rs' m m' o: +Lemma seqexec_parexec_equiv b ofs f bundle rs rs' m m': Genv.find_funct_ptr (globalenv (Asmblock.semantics tprog)) b = Some (Internal f) -> find_bblock (Ptrofs.unsigned ofs) (fn_blocks f) = Some bundle -> exec_bblock (globalenv (Asmblock.semantics tprog)) f bundle rs m = Next rs' m' -> - parexec_bblock (globalenv (semantics tprog)) f bundle rs m o -> o = Next rs' m'. + det_parexec (globalenv (semantics tprog)) f bundle rs m rs' m'. Proof. intros; eapply checked_bundles_are_parexec_equiv; eauto. eapply all_bundles_are_checked; eauto. Qed. -Lemma seqexec_parexec_wio b ofs f bundle rs rs' m m': - Genv.find_funct_ptr (globalenv (Asmblock.semantics tprog)) b = Some (Internal f) -> - find_bblock (Ptrofs.unsigned ofs) (fn_blocks f) = Some bundle -> - exec_bblock (globalenv (Asmblock.semantics tprog)) f bundle rs m = Next rs' m' -> - parexec_wio_bblock (globalenv (semantics tprog)) f bundle rs m = Next rs' m'. -Proof. - intros; erewrite <- seqexec_parexec_equiv; eauto. - eapply parexec_bblock_write_in_order. -Qed. - - Theorem transf_program_correct_Asmvliw: forward_simulation (Asmblock.semantics tprog) (Asmvliw.semantics tprog). Proof. @@ -814,7 +803,6 @@ Proof. - intros; subst; auto. - intros s1 t s1' H s2 H0; subst; inversion H; clear H; subst; eexists; split; eauto. + eapply exec_step_internal; eauto. - eapply seqexec_parexec_wio; eauto. intros; eapply seqexec_parexec_equiv; eauto. + eapply exec_step_builtin; eauto. + eapply exec_step_external; eauto. -- cgit From 57abaaef9428e55830c9f82196c857daf04fb027 Mon Sep 17 00:00:00 2001 From: Sylvain Boulmé Date: Mon, 1 Apr 2019 14:23:36 +0200 Subject: simpler parexec_wio_bblock_aux --- mppa_k1c/Asmblockdeps.v | 4 ++-- mppa_k1c/Asmvliw.v | 1 - 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/mppa_k1c/Asmblockdeps.v b/mppa_k1c/Asmblockdeps.v index 6d98ab9b..b5b53fda 100644 --- a/mppa_k1c/Asmblockdeps.v +++ b/mppa_k1c/Asmblockdeps.v @@ -1834,7 +1834,7 @@ Theorem forward_simu_par_control ge fn rsr rsw mr mw sr sw sz rs' ex m': Ge = Genv ge fn -> match_states (State rsr mr) sr -> match_states (State rsw mw) sw -> - parexec_control ge fn ex (par_nextblock (Ptrofs.repr sz) rsr) (par_nextblock (Ptrofs.repr sz) rsw) mw = Next rs' m' -> + parexec_control ge fn ex (par_nextblock (Ptrofs.repr sz) rsr) rsw mw = Next rs' m' -> exists s', macro_prun Ge (trans_pcincr sz (trans_exit ex)) sw sr sr = Some s' /\ match_states (State rs' m') s'. @@ -1946,7 +1946,7 @@ Lemma forward_simu_par_control_Stuck ge fn rsr rsw mr mw sr sw sz ex: Ge = Genv ge fn -> match_states (State rsr mr) sr -> match_states (State rsw mw) sw -> - parexec_control ge fn ex (par_nextblock (Ptrofs.repr sz) rsr) (par_nextblock (Ptrofs.repr sz) rsw) mw = Stuck -> + parexec_control ge fn ex (par_nextblock (Ptrofs.repr sz) rsr) rsw mw = Stuck -> macro_prun Ge (trans_pcincr sz (trans_exit ex)) sw sr sr = None. Proof. intros GENV MSR MSW H0. inv MSR; inv MSW. destruct ex as [ctl|]; try discriminate. diff --git a/mppa_k1c/Asmvliw.v b/mppa_k1c/Asmvliw.v index 1b3e0897..ac73853d 100644 --- a/mppa_k1c/Asmvliw.v +++ b/mppa_k1c/Asmvliw.v @@ -251,7 +251,6 @@ Definition parexec_wio_bblock_aux (f: function) bdy ext size_b (rsr rsw: regset) match parexec_wio_body bdy rsr rsw mr mw with | Next rsw mw => let rsr := par_nextblock size_b rsr in - let rsw := par_nextblock size_b rsw in parexec_control f ext rsr rsw mw | Stuck => Stuck end. -- cgit From 7a8fabc6669ebc3fa953820e424a9ba712061ec7 Mon Sep 17 00:00:00 2001 From: Sylvain Boulmé Date: Mon, 1 Apr 2019 14:47:22 +0200 Subject: minor simpl --- mppa_k1c/abstractbb/Parallelizability.v | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/mppa_k1c/abstractbb/Parallelizability.v b/mppa_k1c/abstractbb/Parallelizability.v index 065c0922..c2efd552 100644 --- a/mppa_k1c/abstractbb/Parallelizability.v +++ b/mppa_k1c/abstractbb/Parallelizability.v @@ -79,31 +79,37 @@ Proof. + intros H1; rewrite H1; simpl; auto. Qed. + +Lemma prun_iw_app p1: forall m1 old p2, + prun_iw (p1++p2) m1 old = + match prun_iw p1 m1 old with + | Some m2 => prun_iw p2 m2 old + | None => None + end. +Proof. + induction p1; simpl; try congruence. + intros; destruct (macro_prun _ _ _); simpl; auto. +Qed. + Lemma prun_iw_app_None p1: forall m1 old p2, prun_iw p1 m1 old = None -> prun_iw (p1++p2) m1 old = None. Proof. - induction p1; simpl; try congruence. - intros; destruct (macro_prun _ _ _); simpl; auto. + intros m1 old p2 H; rewrite prun_iw_app. rewrite H; auto. Qed. Lemma prun_iw_app_Some p1: forall m1 old m2 p2, prun_iw p1 m1 old = Some m2 -> prun_iw (p1++p2) m1 old = prun_iw p2 m2 old. Proof. - induction p1; simpl; try congruence. - intros; destruct (macro_prun _ _ _); simpl; auto. - congruence. + intros m1 old m2 p2 H; rewrite prun_iw_app. rewrite H; auto. Qed. - End PARALLEL. End ParallelSemantics. - - Fixpoint notIn {A} (x: A) (l:list A): Prop := match l with | nil => True -- cgit From 31d1adf2a19515b97c32cb5f1a68b5befc276ce5 Mon Sep 17 00:00:00 2001 From: Sylvain Boulmé Date: Mon, 1 Apr 2019 16:49:55 +0200 Subject: petite factorisation de preuve --- mppa_k1c/Asmblockdeps.v | 128 ++++++++++++++++++++++-------------------------- 1 file changed, 59 insertions(+), 69 deletions(-) diff --git a/mppa_k1c/Asmblockdeps.v b/mppa_k1c/Asmblockdeps.v index b5b53fda..a98ab53a 100644 --- a/mppa_k1c/Asmblockdeps.v +++ b/mppa_k1c/Asmblockdeps.v @@ -1631,16 +1631,16 @@ Arguments ppos: simpl never. Variable Ge: genv. -Lemma trans_arith_par_correct ge fn rsr mr sr rsw mw sw rsw' mw' i: +Lemma trans_arith_par_correct ge fn rsr mr sr rsw mw sw rsw' i: Ge = Genv ge fn -> match_states (State rsr mr) sr -> match_states (State rsw mw) sw -> - parexec_arith_instr ge i rsr rsw = rsw' -> mw = mw' -> + parexec_arith_instr ge i rsr rsw = rsw' -> exists sw', macro_prun Ge (trans_arith i) sw sr sr = Some sw' - /\ match_states (State rsw' mw') sw'. + /\ match_states (State rsw' mw) sw'. Proof. - intros GENV MSR MSW PARARITH MWEQ. subst. inv MSR. inv MSW. + intros GENV MSR MSW PARARITH. subst. inv MSR. inv MSW. unfold parexec_arith_instr. destruct i. (* Ploadsymbol *) - destruct i. eexists; split; [| split]. @@ -1716,63 +1716,73 @@ Proof. destruct (ireg_eq g rd); subst; Simpl. Qed. -Theorem forward_simu_par_wio_basic ge fn rsr rsw mr mw sr sw bi rsw' mw': +Theorem forward_simu_par_wio_basic_gen ge fn rsr rsw mr mw sr sw bi: Ge = Genv ge fn -> match_states (State rsr mr) sr -> match_states (State rsw mw) sw -> - parexec_basic_instr ge bi rsr rsw mr mw = Next rsw' mw' -> - exists sw', - macro_prun Ge (trans_basic bi) sw sr sr = Some sw' - /\ match_states (State rsw' mw') sw'. + match_outcome (parexec_basic_instr ge bi rsr rsw mr mw) (macro_prun Ge (trans_basic bi) sw sr sr). Proof. - intros GENV MSR MSW H. - destruct bi. + intros GENV MSR MSW; inversion MSR as (H & H0); inversion MSW as (H1 & H2). + destruct bi; simpl. (* Arith *) - - simpl in H. inversion H. subst rsw' mw'. simpl macro_prun. eapply trans_arith_par_correct; eauto. + - exploit trans_arith_par_correct. 5: eauto. all: eauto. (* Load *) - - simpl in H. destruct i. - unfold parexec_load in H; destruct (eval_offset _ _) eqn:EVALOFF; try discriminate; - destruct (Mem.loadv _ _ _) eqn:MEML; try discriminate; inv H. inv MSR; inv MSW; - eexists; split; try split; - [ simpl; rewrite EVALOFF; rewrite H; pose (H0 ra); simpl in e; rewrite e; rewrite MEML; reflexivity| - Simpl| - intros rr; destruct rr; Simpl; - destruct (ireg_eq g rd); [ - subst; Simpl| - Simpl; rewrite assign_diff; pose (H1 g); simpl in e; try assumption; Simpl; unfold ppos; apply not_eq_ireg_to_pos; assumption]]. + - destruct i; unfold parexec_load; simpl; unfold exec_load_deps. + erewrite GENV, H, H0. + destruct (eval_offset _ _) eqn:EVALOFF; simpl; auto. + destruct (Mem.loadv _ _ _) eqn:MEML; simpl; auto. + eexists; intuition eauto; Simpl. + destruct r; Simpl; + destruct (ireg_eq g rd); [ + subst; Simpl| + Simpl; rewrite assign_diff; pose (H1 g); simpl in e; try assumption; Simpl; unfold ppos; apply not_eq_ireg_to_pos; assumption]. (* Store *) - - simpl in H. destruct i. - unfold parexec_store in H; destruct (eval_offset _ _) eqn:EVALOFF; try discriminate. - destruct (Mem.storev _ _ _ _) eqn:MEML; try discriminate. inv H; inv MSR; inv MSW. - eexists; split; try split. - * simpl. rewrite EVALOFF. rewrite H. rewrite (H0 ra). rewrite (H0 rs). rewrite MEML. reflexivity. - * Simpl. - * intros rr; destruct rr; Simpl. + - destruct i; unfold parexec_store; simpl; unfold exec_store_deps. + erewrite GENV, H, ! H0. + destruct (eval_offset _ _) eqn:EVALOFF; simpl; auto. + destruct (Mem.storev _ _ _ _) eqn:MEML; simpl; auto. + eexists; intuition eauto; Simpl. (* Allocframe *) - - simpl in H. destruct (Mem.alloc _ _ _) eqn:MEMAL. destruct (Mem.store _ _ _ _) eqn:MEMS; try discriminate. - inv H. inv MSR. inv MSW. eexists. split; try split. - * simpl. Simpl. rewrite (H0 GPR12). rewrite H. rewrite MEMAL. rewrite MEMS. Simpl. - rewrite H. rewrite MEMAL. rewrite MEMS. reflexivity. - * Simpl. - * intros rr; destruct rr; Simpl. - destruct (ireg_eq g GPR32); [| destruct (ireg_eq g GPR12); [| destruct (ireg_eq g GPR17)]]; subst; Simpl. -(* Freeframe *) - - simpl in H. destruct (Mem.loadv _ _ _) eqn:MLOAD; try discriminate. destruct (rsr GPR12) eqn:SPeq; try discriminate. - destruct (Mem.free _ _ _ _) eqn:MFREE; try discriminate. inv H. inv MSR. inv MSW. - eexists. split; try split. - * simpl. rewrite (H0 GPR12). rewrite H. rewrite SPeq. rewrite MLOAD. rewrite MFREE. - Simpl. rewrite (H0 GPR12). rewrite SPeq. rewrite MLOAD. rewrite MFREE. reflexivity. + - destruct (Mem.alloc _ _ _) eqn:MEMAL. destruct (Mem.store _ _ _ _) eqn:MEMS. + * eexists; repeat split. + { Simpl. erewrite !H0, H, MEMAL, MEMS. Simpl. + rewrite H, MEMAL. rewrite MEMS. reflexivity. } + { Simpl. } + { intros rr; destruct rr; Simpl. + destruct (ireg_eq g GPR32); [| destruct (ireg_eq g GPR12); [| destruct (ireg_eq g GPR17)]]; subst; Simpl. } + * simpl; Simpl; erewrite !H0, H, MEMAL, MEMS; auto. + (* Freeframe *) + - erewrite !H0, H. + destruct (Mem.loadv _ _ _) eqn:MLOAD; simpl; auto. + destruct (rsr GPR12) eqn:SPeq; simpl; auto. + destruct (Mem.free _ _ _ _) eqn:MFREE; simpl; auto. + eexists; repeat split. + * simpl. Simpl. erewrite H0, SPeq, MLOAD, MFREE. reflexivity. * Simpl. * intros rr; destruct rr; Simpl. destruct (ireg_eq g GPR32); [| destruct (ireg_eq g GPR12); [| destruct (ireg_eq g GPR17)]]; subst; Simpl. (* Pget *) - - simpl in H. destruct rs eqn:rseq; try discriminate. inv H. inv MSR. inv MSW. - eexists. split; try split. Simpl. intros rr; destruct rr; Simpl. + - destruct rs eqn:rseq; simpl; auto. + eexists. repeat split. Simpl. intros rr; destruct rr; Simpl. destruct (ireg_eq g rd); subst; Simpl. (* Pset *) - - simpl in H. destruct rd eqn:rdeq; try discriminate. inv H. inv MSR; inv MSW. - eexists. split; try split. Simpl. intros rr; destruct rr; Simpl. + - destruct rd eqn:rdeq; simpl; auto. + eexists. repeat split. Simpl. intros rr; destruct rr; Simpl. (* Pnop *) - - simpl in H. inv H. inv MSR. inv MSW. eexists. split; try split. assumption. assumption. + - eexists. repeat split; assumption. +Qed. + + +Theorem forward_simu_par_wio_basic ge fn rsr rsw mr mw sr sw bi rsw' mw': + Ge = Genv ge fn -> + match_states (State rsr mr) sr -> + match_states (State rsw mw) sw -> + parexec_basic_instr ge bi rsr rsw mr mw = Next rsw' mw' -> + exists sw', + macro_prun Ge (trans_basic bi) sw sr sr = Some sw' + /\ match_states (State rsw' mw') sw'. +Proof. + intros H H0 H1 H2; exploit forward_simu_par_wio_basic_gen; [ eapply H | eapply H0 | eapply H1 | erewrite H2 ]. + simpl; auto. Qed. Theorem forward_simu_par_wio_basic_Stuck ge fn rsr rsw mr mw sr sw bi: @@ -1782,28 +1792,8 @@ Theorem forward_simu_par_wio_basic_Stuck ge fn rsr rsw mr mw sr sw bi: parexec_basic_instr ge bi rsr rsw mr mw = Stuck -> macro_prun Ge (trans_basic bi) sw sr sr = None. Proof. - intros GENV MSR MSW H0. inv MSR; inv MSW. - unfold parexec_basic_instr in H0. destruct bi; try discriminate. -(* PLoad *) - - destruct i; destruct i. - all: simpl; rewrite H; rewrite (H1 ra); unfold parexec_load in H0; - destruct (eval_offset _ _); auto; destruct (Mem.loadv _ _ _); auto; discriminate. -(* PStore *) - - destruct i; destruct i; - simpl; rewrite H; rewrite (H1 ra); rewrite (H1 rs); - unfold parexec_store in H0; destruct (eval_offset _ _); auto; destruct (Mem.storev _ _ _); auto; discriminate. -(* Pallocframe *) - - simpl. Simpl. rewrite (H1 SP). rewrite H. destruct (Mem.alloc _ _ _). simpl in H0. - destruct (Mem.store _ _ _ _); try discriminate. reflexivity. -(* Pfreeframe *) - - simpl. Simpl. rewrite (H1 SP). rewrite H. - destruct (Mem.loadv _ _ _); auto. destruct (rsr GPR12); auto. destruct (Mem.free _ _ _ _); auto. - discriminate. -(* Pget *) - - simpl. destruct rs; subst; try discriminate. - all: simpl; auto. - - simpl. destruct rd; subst; try discriminate. - all: simpl; auto. + intros H H0 H1 H2; exploit forward_simu_par_wio_basic_gen; [ eapply H | eapply H0 | eapply H1 | erewrite H2 ]. + simpl; auto. Qed. Theorem forward_simu_par_body: -- cgit From 714a1fb988da03066629970325089e16dd146432 Mon Sep 17 00:00:00 2001 From: Sylvain Boulmé Date: Mon, 1 Apr 2019 17:55:08 +0200 Subject: renommages abstract_bb Resource -> PseudoReg macro -> inst --- mppa_k1c/Asmblockdeps.v | 48 ++++----- mppa_k1c/abstractbb/AbstractBasicBlocksDef.v | 24 ++--- mppa_k1c/abstractbb/DepTreeTheory.v | 58 +++++----- mppa_k1c/abstractbb/ImpDep.v | 28 ++--- mppa_k1c/abstractbb/Parallelizability.v | 154 +++++++++++++-------------- 5 files changed, 156 insertions(+), 156 deletions(-) diff --git a/mppa_k1c/Asmblockdeps.v b/mppa_k1c/Asmblockdeps.v index a98ab53a..7043bd32 100644 --- a/mppa_k1c/Asmblockdeps.v +++ b/mppa_k1c/Asmblockdeps.v @@ -542,7 +542,7 @@ Definition inv_ppos (p: R.t) : option preg := Notation "a @ b" := (Econs a b) (at level 102, right associativity). -Definition trans_control (ctl: control) : macro := +Definition trans_control (ctl: control) : inst := match ctl with | Pret => [(#PC, Name (#RA))] | Pcall s => [(#RA, Name (#PC)); (#PC, Op (Arith (OArithR (Ploadsymbol s Ptrofs.zero))) Enil)] @@ -558,14 +558,14 @@ Definition trans_control (ctl: control) : macro := | Pbuiltin ef args res => [(#PC, Op (Control (OError)) Enil)] end. -Definition trans_exit (ex: option control) : L.macro := +Definition trans_exit (ex: option control) : L.inst := match ex with | None => [] | Some ctl => trans_control ctl end . -Definition trans_arith (ai: ar_instruction) : macro := +Definition trans_arith (ai: ar_instruction) : inst := match ai with | PArithR n d => [(#d, Op (Arith (OArithR n)) Enil)] | PArithRR n d s => [(#d, Op (Arith (OArithRR n)) (Name (#s) @ Enil))] @@ -582,7 +582,7 @@ Definition trans_arith (ai: ar_instruction) : macro := end. -Definition trans_basic (b: basic) : macro := +Definition trans_basic (b: basic) : inst := match b with | PArith ai => trans_arith ai | PLoadRRO n d a ofs => [(#d, Op (Load (OLoadRRO n ofs)) (Name (#a) @ Name pmem @ Enil))] @@ -603,13 +603,13 @@ Definition trans_basic (b: basic) : macro := | Pnop => [] end. -Fixpoint trans_body (b: list basic) : list L.macro := +Fixpoint trans_body (b: list basic) : list L.inst := match b with | nil => nil | b :: lb => (trans_basic b) :: (trans_body lb) end. -Definition trans_pcincr (sz: Z) (k: L.macro) := (#PC, Op (Control (OIncremPC sz)) (Name (#PC) @ Enil)) :: k. +Definition trans_pcincr (sz: Z) (k: L.inst) := (#PC, Op (Control (OIncremPC sz)) (Name (#PC) @ Enil)) :: k. Definition trans_block (b: Asmblock.bblock) : L.bblock := trans_body (body b) ++ (trans_pcincr (size b) (trans_exit (exit b)) :: nil). @@ -686,7 +686,7 @@ Lemma exec_app_some: Proof. induction c. - simpl. intros. congruence. - - intros. simpl in *. destruct (macro_run _ _ _ _); auto. eapply IHc; eauto. discriminate. + - intros. simpl in *. destruct (inst_run _ _ _ _); auto. eapply IHc; eauto. discriminate. Qed. Lemma exec_app_none: @@ -696,7 +696,7 @@ Lemma exec_app_none: Proof. induction c. - simpl. discriminate. - - intros. simpl. simpl in H. destruct (macro_run _ _ _ _); auto. + - intros. simpl. simpl in H. destruct (inst_run _ _ _ _); auto. Qed. Lemma trans_arith_correct: @@ -704,7 +704,7 @@ Lemma trans_arith_correct: exec_arith_instr ge i rs = rs' -> match_states (State rs m) s -> exists s', - macro_run (Genv ge fn) (trans_arith i) s s = Some s' + inst_run (Genv ge fn) (trans_arith i) s s = Some s' /\ match_states (State rs' m) s'. Proof. intros. unfold exec_arith_instr in H. destruct i. @@ -793,12 +793,12 @@ Lemma forward_simu_basic: exec_basic_instr ge b rs m = Next rs' m' -> match_states (State rs m) s -> exists s', - macro_run (Genv ge fn) (trans_basic b) s s = Some s' + inst_run (Genv ge fn) (trans_basic b) s s = Some s' /\ match_states (State rs' m') s'. Proof. intros. destruct b. (* Arith *) - - simpl in H. inv H. simpl macro_run. eapply trans_arith_correct; eauto. + - simpl in H. inv H. simpl inst_run. eapply trans_arith_correct; eauto. (* Load *) - simpl in H. destruct i. unfold exec_load in H; destruct (eval_offset _ _) eqn:EVALOFF; try discriminate; @@ -1040,11 +1040,11 @@ Proof. eapply IHc; eauto. Qed. -Lemma exec_trans_pcincr_exec_macrorun: +Lemma exec_trans_pcincr_exec_instrun: forall rs m s b k, match_states (State rs m) s -> exists s', - macro_run Ge ((# PC, Op (OIncremPC (size b)) (Name (# PC) @ Enil)) :: k) s s = macro_run Ge k s' s + inst_run Ge ((# PC, Op (OIncremPC (size b)) (Name (# PC) @ Enil)) :: k) s s = inst_run Ge k s' s /\ match_states (State (nextblock b rs) m) s'. Proof. intros. inv H. eexists. split. simpl. pose (H1 PC); simpl in e; rewrite e. destruct Ge. simpl. eapply eq_refl. @@ -1053,9 +1053,9 @@ Proof. - intros rr; destruct rr; Simpl. Qed. -Lemma macro_run_trans_exit_noold: +Lemma inst_run_trans_exit_noold: forall ex s s' s'', - macro_run Ge (trans_exit ex) s s' = macro_run Ge (trans_exit ex) s s''. + inst_run Ge (trans_exit ex) s s' = inst_run Ge (trans_exit ex) s s''. Proof. intros. destruct ex. - destruct c; destruct i; reflexivity. @@ -1070,10 +1070,10 @@ Lemma exec_trans_pcincr_exec: /\ match_states (State (nextblock b rs) m) s'. Proof. intros. - exploit exec_trans_pcincr_exec_macrorun; eauto. + exploit exec_trans_pcincr_exec_instrun; eauto. intros (s' & MRUN & MS). eexists. split. unfold exec. unfold trans_pcincr. unfold run. rewrite MRUN. - erewrite macro_run_trans_exit_noold; eauto. + erewrite inst_run_trans_exit_noold; eauto. assumption. Qed. @@ -1603,7 +1603,7 @@ End SECT. (** Parallelizability of a bblock *) -Module PChk := ParallelChecks L PosResourceSet. +Module PChk := ParallelChecks L PosPseudoRegSet. Definition bblock_para_check (p: Asmblock.bblock) : bool := PChk.is_parallelizable (trans_block p). @@ -1637,7 +1637,7 @@ Lemma trans_arith_par_correct ge fn rsr mr sr rsw mw sw rsw' i: match_states (State rsw mw) sw -> parexec_arith_instr ge i rsr rsw = rsw' -> exists sw', - macro_prun Ge (trans_arith i) sw sr sr = Some sw' + inst_prun Ge (trans_arith i) sw sr sr = Some sw' /\ match_states (State rsw' mw) sw'. Proof. intros GENV MSR MSW PARARITH. subst. inv MSR. inv MSW. @@ -1720,7 +1720,7 @@ Theorem forward_simu_par_wio_basic_gen ge fn rsr rsw mr mw sr sw bi: Ge = Genv ge fn -> match_states (State rsr mr) sr -> match_states (State rsw mw) sw -> - match_outcome (parexec_basic_instr ge bi rsr rsw mr mw) (macro_prun Ge (trans_basic bi) sw sr sr). + match_outcome (parexec_basic_instr ge bi rsr rsw mr mw) (inst_prun Ge (trans_basic bi) sw sr sr). Proof. intros GENV MSR MSW; inversion MSR as (H & H0); inversion MSW as (H1 & H2). destruct bi; simpl. @@ -1778,7 +1778,7 @@ Theorem forward_simu_par_wio_basic ge fn rsr rsw mr mw sr sw bi rsw' mw': match_states (State rsw mw) sw -> parexec_basic_instr ge bi rsr rsw mr mw = Next rsw' mw' -> exists sw', - macro_prun Ge (trans_basic bi) sw sr sr = Some sw' + inst_prun Ge (trans_basic bi) sw sr sr = Some sw' /\ match_states (State rsw' mw') sw'. Proof. intros H H0 H1 H2; exploit forward_simu_par_wio_basic_gen; [ eapply H | eapply H0 | eapply H1 | erewrite H2 ]. @@ -1790,7 +1790,7 @@ Theorem forward_simu_par_wio_basic_Stuck ge fn rsr rsw mr mw sr sw bi: match_states (State rsr mr) sr -> match_states (State rsw mw) sw -> parexec_basic_instr ge bi rsr rsw mr mw = Stuck -> - macro_prun Ge (trans_basic bi) sw sr sr = None. + inst_prun Ge (trans_basic bi) sw sr sr = None. Proof. intros H H0 H1 H2; exploit forward_simu_par_wio_basic_gen; [ eapply H | eapply H0 | eapply H1 | erewrite H2 ]. simpl; auto. @@ -1826,7 +1826,7 @@ Theorem forward_simu_par_control ge fn rsr rsw mr mw sr sw sz rs' ex m': match_states (State rsw mw) sw -> parexec_control ge fn ex (par_nextblock (Ptrofs.repr sz) rsr) rsw mw = Next rs' m' -> exists s', - macro_prun Ge (trans_pcincr sz (trans_exit ex)) sw sr sr = Some s' + inst_prun Ge (trans_pcincr sz (trans_exit ex)) sw sr sr = Some s' /\ match_states (State rs' m') s'. Proof. intros GENV MSR MSW H0. @@ -1937,7 +1937,7 @@ Lemma forward_simu_par_control_Stuck ge fn rsr rsw mr mw sr sw sz ex: match_states (State rsr mr) sr -> match_states (State rsw mw) sw -> parexec_control ge fn ex (par_nextblock (Ptrofs.repr sz) rsr) rsw mw = Stuck -> - macro_prun Ge (trans_pcincr sz (trans_exit ex)) sw sr sr = None. + inst_prun Ge (trans_pcincr sz (trans_exit ex)) sw sr sr = None. Proof. intros GENV MSR MSW H0. inv MSR; inv MSW. destruct ex as [ctl|]; try discriminate. destruct ctl; destruct i; try discriminate; try (simpl; reflexivity). diff --git a/mppa_k1c/abstractbb/AbstractBasicBlocksDef.v b/mppa_k1c/abstractbb/AbstractBasicBlocksDef.v index 904fb72c..0bab9426 100644 --- a/mppa_k1c/abstractbb/AbstractBasicBlocksDef.v +++ b/mppa_k1c/abstractbb/AbstractBasicBlocksDef.v @@ -2,19 +2,19 @@ *) -Module Type ResourceNames. +Module Type PseudoRegisters. Parameter t: Type. Parameter eq_dec: forall (x y: t), { x = y } + { x<>y }. -End ResourceNames. +End PseudoRegisters. (** * Parameters of the language of Basic Blocks *) Module Type LangParam. -Declare Module R: ResourceNames. +Declare Module R: PseudoRegisters. Parameter value: Type. @@ -85,25 +85,25 @@ with list_exp_eval (le: list_exp) (m old: mem): option (list value) := | LOld le => list_exp_eval le old old end. -Definition macro := list (R.t * exp). (* = a sequence of assignments *) +Definition inst := list (R.t * exp). (* = a sequence of assignments *) -Fixpoint macro_run (i: macro) (m old: mem): option mem := +Fixpoint inst_run (i: inst) (m old: mem): option mem := match i with | nil => Some m | (x, e)::i' => match exp_eval e m old with - | Some v' => macro_run i' (assign m x v') old + | Some v' => inst_run i' (assign m x v') old | None => None end end. -Definition bblock := list macro. +Definition bblock := list inst. Fixpoint run (p: bblock) (m: mem): option mem := match p with | nil => Some m | i::p' => - match macro_run i m m with + match inst_run i m m with | Some m' => run p' m' | None => None end @@ -166,10 +166,10 @@ Qed. Definition bblock_equiv (p1 p2: bblock): Prop := forall m, res_eq (run p1 m) (run p2 m). -Lemma alt_macro_equiv_refl i old1 old2: +Lemma alt_inst_equiv_refl i old1 old2: (forall x, old1 x = old2 x) -> forall m1 m2, (forall x, m1 x = m2 x) -> - res_eq (macro_run i m1 old1) (macro_run i m2 old2). + res_eq (inst_run i m1 old1) (inst_run i m2 old2). Proof. intro H; induction i as [ | [x e]]; simpl; eauto. intros m1 m2 H1. erewrite exp_equiv; eauto. @@ -181,9 +181,9 @@ Qed. Lemma alt_bblock_equiv_refl p: forall m1 m2, (forall x, m1 x = m2 x) -> res_eq (run p m1) (run p m2). Proof. induction p as [ | i p']; simpl; eauto. - intros m1 m2 H; lapply (alt_macro_equiv_refl i m1 m2); auto. + intros m1 m2 H; lapply (alt_inst_equiv_refl i m1 m2); auto. intros X; lapply (X m1 m2); auto; clear X. - destruct (macro_run i m1 m1); simpl. + destruct (inst_run i m1 m1); simpl. - intros [m3 [H1 H2]]; rewrite H1; simpl; auto. - intros H1; rewrite H1; simpl; auto. Qed. diff --git a/mppa_k1c/abstractbb/DepTreeTheory.v b/mppa_k1c/abstractbb/DepTreeTheory.v index 353e9160..4d5c71b3 100644 --- a/mppa_k1c/abstractbb/DepTreeTheory.v +++ b/mppa_k1c/abstractbb/DepTreeTheory.v @@ -9,9 +9,9 @@ Require Setoid. (* in order to rewrite <-> *) Require Export AbstractBasicBlocksDef. -Module Type ResourceDictionary. +Module Type PseudoRegDictionary. -Declare Module R: ResourceNames. +Declare Module R: PseudoRegisters. Parameter t: Type -> Type. @@ -30,12 +30,12 @@ Parameter empty: forall {A}, t A. Parameter empty_spec: forall A x, get (empty (A:=A)) x = None. -End ResourceDictionary. +End PseudoRegDictionary. (** * Computations of "bblock" Dependencies and application to the equality test *) -Module DepTree (L: SeqLanguage) (Dict: ResourceDictionary with Module R:=L.LP.R). +Module DepTree (L: SeqLanguage) (Dict: PseudoRegDictionary with Module R:=L.LP.R). Export L. Export LP. @@ -142,21 +142,21 @@ Proof. eauto. Qed. -Fixpoint macro_deps (i: macro) (d old: deps): deps := +Fixpoint inst_deps (i: inst) (d old: deps): deps := match i with | nil => d | (x, e)::i' => let t0:=deps_get d x in let t1:=exp_tree e d old in let v':=if failsafe t0 then t1 else (Terase t1 t0) in - macro_deps i' (Dict.set d x v') old + inst_deps i' (Dict.set d x v') old end. Fixpoint bblock_deps_rec (p: bblock) (d: deps): deps := match p with | nil => d | i::p' => - let d':=macro_deps i d d in + let d':=inst_deps i d d in bblock_deps_rec p' d' end. @@ -177,9 +177,9 @@ Proof. - intros; erewrite IHe, IHe0; eauto. Qed. -Lemma tree_eval_macro_abort i m0 x old: forall d, +Lemma tree_eval_inst_abort i m0 x old: forall d, tree_eval (deps_get d x) m0 = None -> - tree_eval (deps_get (macro_deps i d old) x) m0 = None. + tree_eval (deps_get (inst_deps i d old) x) m0 = None. Proof. induction i as [|[y e] i IHi]; simpl; auto. intros d H; erewrite IHi; eauto. clear IHi. @@ -197,15 +197,15 @@ Lemma tree_eval_abort p m0 x: forall d, Proof. induction p; simpl; auto. intros d H; erewrite IHp; eauto. clear IHp. - eapply tree_eval_macro_abort; eauto. + eapply tree_eval_inst_abort; eauto. Qed. -Lemma tree_eval_macro_Some_correct1 i m0 old od: +Lemma tree_eval_inst_Some_correct1 i m0 old od: (forall x, tree_eval (deps_get od x) m0 = Some (old x)) -> forall (m1 m2: mem) d, - macro_run ge i m1 old = Some m2 -> + inst_run ge i m1 old = Some m2 -> (forall x, tree_eval (deps_get d x) m0 = Some (m1 x)) -> - (forall x, tree_eval (deps_get (macro_deps i d od) x) m0 = Some (m2 x)). + (forall x, tree_eval (deps_get (inst_deps i d od) x) m0 = Some (m2 x)). Proof. intro X; induction i as [|[x e] i IHi]; simpl; intros m1 m2 d H. - inversion_clear H; eauto. @@ -222,7 +222,7 @@ Proof. + inversion H. Qed. -Local Hint Resolve tree_eval_macro_Some_correct1 tree_eval_abort. +Local Hint Resolve tree_eval_inst_Some_correct1 tree_eval_abort. Lemma tree_eval_Some_correct1 p m0: forall (m1 m2: mem) d, run ge p m1 = Some m2 -> @@ -232,7 +232,7 @@ Proof. induction p as [ | i p]; simpl; intros m1 m2 d H. - inversion_clear H; eauto. - intros H0 x0. - remember (macro_run ge i m1 m1) as om. + remember (inst_run ge i m1 m1) as om. destruct om. + refine (IHp _ _ _ _ _ _); eauto. + inversion H. @@ -246,10 +246,10 @@ Proof. intros; autorewrite with dict_rw; simpl; eauto. Qed. -Lemma tree_eval_macro_None_correct i m0 old od: +Lemma tree_eval_inst_None_correct i m0 old od: (forall x, tree_eval (deps_get od x) m0 = Some (old x)) -> forall m1 d, (forall x, tree_eval (deps_get d x) m0 = Some (m1 x)) -> - macro_run ge i m1 old = None <-> exists x, tree_eval (deps_get (macro_deps i d od) x) m0 = None. + inst_run ge i m1 old = None <-> exists x, tree_eval (deps_get (inst_deps i d od) x) m0 = None. Proof. intro X; induction i as [|[x e] i IHi]; simpl; intros m1 d. - constructor 1; [discriminate | intros [x H']; rewrite H in H'; discriminate]. @@ -264,7 +264,7 @@ Proof. * rewrite set_spec_diff; auto. + intuition. constructor 1 with (x:=x); simpl. - apply tree_eval_macro_abort. + apply tree_eval_inst_abort. autorewrite with dict_rw. destruct (failsafe (deps_get d x)); simpl; try rewrite H0; erewrite tree_eval_exp; eauto. @@ -278,12 +278,12 @@ Proof. induction p as [|i p IHp]; simpl; intros m1 d. - constructor 1; [discriminate | intros [x H']; rewrite H in H'; discriminate]. - intros H0. - remember (macro_run ge i m1 m1) as om. + remember (inst_run ge i m1 m1) as om. destruct om. + refine (IHp _ _ _); eauto. + intuition. - assert (X: macro_run ge i m1 m1 = None); auto. - rewrite tree_eval_macro_None_correct in X; auto. + assert (X: inst_run ge i m1 m1 = None); auto. + rewrite tree_eval_inst_None_correct in X; auto. destruct X as [x H1]. constructor 1 with (x:=x); simpl; auto. Qed. @@ -295,12 +295,12 @@ Proof. intros; autorewrite with dict_rw; simpl; eauto. Qed. -Lemma tree_eval_macro_Some_correct2 i m0 old od: +Lemma tree_eval_inst_Some_correct2 i m0 old od: (forall x, tree_eval (deps_get od x) m0 = Some (old x)) -> forall (m1 m2: mem) d, (forall x, tree_eval (deps_get d x) m0 = Some (m1 x)) -> - (forall x, tree_eval (deps_get (macro_deps i d od) x) m0 = Some (m2 x)) -> - res_eq (Some m2) (macro_run ge i m1 old). + (forall x, tree_eval (deps_get (inst_deps i d od) x) m0 = Some (m2 x)) -> + res_eq (Some m2) (inst_run ge i m1 old). Proof. intro X. induction i as [|[x e] i IHi]; simpl; intros m1 m2 d H0. @@ -317,7 +317,7 @@ Proof. erewrite tree_eval_exp; eauto. * rewrite set_spec_diff; auto. + generalize (H x). - rewrite tree_eval_macro_abort; try discriminate. + rewrite tree_eval_inst_abort; try discriminate. autorewrite with dict_rw. destruct (failsafe (deps_get d x)); simpl; try rewrite H0; erewrite tree_eval_exp; eauto. @@ -333,11 +333,11 @@ Proof. generalize (H0 x); rewrite H. congruence. - intros H. - remember (macro_run ge i m1 m1) as om. + remember (inst_run ge i m1 m1) as om. destruct om. + refine (IHp _ _ _ _ _); eauto. - + assert (X: macro_run ge i m1 m1 = None); auto. - rewrite tree_eval_macro_None_correct in X; auto. + + assert (X: inst_run ge i m1 m1 = None); auto. + rewrite tree_eval_inst_None_correct in X; auto. destruct X as [x H1]. generalize (H x). rewrite tree_eval_abort; congruence. @@ -377,7 +377,7 @@ End DepTree. Require Import PArith. Require Import FMapPositive. -Module PosDict <: ResourceDictionary with Module R:=Pos. +Module PosDict <: PseudoRegDictionary with Module R:=Pos. Module R:=Pos. diff --git a/mppa_k1c/abstractbb/ImpDep.v b/mppa_k1c/abstractbb/ImpDep.v index 9051f6ad..3cc85fd5 100644 --- a/mppa_k1c/abstractbb/ImpDep.v +++ b/mppa_k1c/abstractbb/ImpDep.v @@ -42,7 +42,7 @@ End ISeqLanguage. Module Type ImpDict. -Include ResourceDictionary. +Include PseudoRegDictionary. Parameter eq_test: forall {A}, t A -> t A -> ?? bool. @@ -209,7 +209,7 @@ Hint Resolve hexp_tree_correct: wlp. Variable debug_assign: R.t -> ?? option pstring. -Fixpoint hmacro_deps (i: macro) (d od: hdeps): ?? hdeps := +Fixpoint hinst_deps (i: inst) (d od: hdeps): ?? hdeps := match i with | nil => RET d | (x, e)::i' => @@ -221,7 +221,7 @@ Fixpoint hmacro_deps (i: macro) (d od: hdeps): ?? hdeps := else DO t1 <~ hexp_tree e d od None;; hTerase t1 t0 dbg);; - hmacro_deps i' (Dict.set d x v') od + hinst_deps i' (Dict.set d x v') od end. Lemma pset_spec_eq d x t: @@ -244,11 +244,11 @@ Qed. Hint Rewrite pset_spec_eq pempty_spec: dict_rw. -Lemma hmacro_deps_correct i: forall d1 od1, - WHEN hmacro_deps i d1 od1 ~> d1' THEN +Lemma hinst_deps_correct i: forall d1 od1, + WHEN hinst_deps i d1 od1 ~> d1' THEN forall od2 d2, (forall x, pdeps_get od1 x = deps_get od2 x) -> (forall x, pdeps_get d1 x = deps_get d2 x) -> - forall x, pdeps_get d1' x = deps_get (macro_deps i d2 od2) x. + forall x, pdeps_get d1' x = deps_get (inst_deps i d2 od2) x. Proof. induction i; simpl; wlp_simplify. + cutrewrite (failsafe (deps_get d2 a0) = failsafe (data exta0)). @@ -265,10 +265,10 @@ Proof. * rewrite set_spec_diff, pset_spec_diff; auto. - rewrite H, H5; auto. Qed. -Global Opaque hmacro_deps. -Hint Resolve hmacro_deps_correct: wlp. +Global Opaque hinst_deps. +Hint Resolve hinst_deps_correct: wlp. -(* logging info: we log the number of macro-instructions passed ! *) +(* logging info: we log the number of inst-instructions passed ! *) Variable log: unit -> ?? unit. Fixpoint hbblock_deps_rec (p: bblock) (d: hdeps): ?? hdeps := @@ -276,7 +276,7 @@ Fixpoint hbblock_deps_rec (p: bblock) (d: hdeps): ?? hdeps := | nil => RET d | i::p' => log tt;; - DO d' <~ hmacro_deps i d d;; + DO d' <~ hinst_deps i d d;; hbblock_deps_rec p' d' end. @@ -371,10 +371,10 @@ Local Hint Resolve hbblock_deps_correct Dict.eq_test_correct: wlp. Section Prog_Eq_Gen. -Variable dbg1: R.t -> ?? option pstring. (* debugging of p1 macros *) -Variable dbg2: R.t -> ?? option pstring. (* log of p2 macros *) -Variable log1: unit -> ?? unit. (* log of p1 macros *) -Variable log2: unit -> ?? unit. (* log of p2 macros *) +Variable dbg1: R.t -> ?? option pstring. (* debugging of p1 insts *) +Variable dbg2: R.t -> ?? option pstring. (* log of p2 insts *) +Variable log1: unit -> ?? unit. (* log of p1 insts *) +Variable log2: unit -> ?? unit. (* log of p2 insts *) Variable hco_tree: hashConsing tree. diff --git a/mppa_k1c/abstractbb/Parallelizability.v b/mppa_k1c/abstractbb/Parallelizability.v index c2efd552..519e7e54 100644 --- a/mppa_k1c/abstractbb/Parallelizability.v +++ b/mppa_k1c/abstractbb/Parallelizability.v @@ -21,20 +21,20 @@ Local Open Scope list. Section PARALLEL. Variable ge: genv. -(* parallel run of a macro *) -Fixpoint macro_prun (i: macro) (m tmp old: mem): option mem := +(* parallel run of a inst *) +Fixpoint inst_prun (i: inst) (m tmp old: mem): option mem := match i with | nil => Some m | (x, e)::i' => match exp_eval ge e tmp old with - | Some v' => macro_prun i' (assign m x v') (assign tmp x v') old + | Some v' => inst_prun i' (assign m x v') (assign tmp x v') old | None => None end end. -(* [macro_prun] is generalization of [macro_run] *) -Lemma macro_run_prun i: forall m old, - macro_run ge i m old = macro_prun i m m old. +(* [inst_prun] is generalization of [inst_run] *) +Lemma inst_run_prun i: forall m old, + inst_run ge i m old = inst_prun i m m old. Proof. induction i as [|[y e] i']; simpl; auto. intros m old; destruct (exp_eval ge e m old); simpl; auto. @@ -46,7 +46,7 @@ Fixpoint prun_iw (p: bblock) m old: option mem := match p with | nil => Some m | i::p' => - match macro_prun i m old old with + match inst_prun i m old old with | Some m1 => prun_iw p' m1 old | None => None end @@ -58,9 +58,9 @@ Definition prun (p: bblock) m (om: option mem) := exists p', res_eq om (prun_iw (* a few lemma on equality *) -Lemma macro_prun_equiv i old: forall m1 m2 tmp, +Lemma inst_prun_equiv i old: forall m1 m2 tmp, (forall x, m1 x = m2 x) -> - res_eq (macro_prun i m1 tmp old) (macro_prun i m2 tmp old). + res_eq (inst_prun i m1 tmp old) (inst_prun i m2 tmp old). Proof. induction i as [|[x e] i']; simpl; eauto. intros m1 m2 tmp H; destruct (exp_eval ge e tmp old); simpl; auto. @@ -73,8 +73,8 @@ Lemma prun_iw_equiv p: forall m1 m2 old, Proof. induction p as [|i p']; simpl; eauto. - intros m1 m2 old H. - generalize (macro_prun_equiv i old m1 m2 old H); - destruct (macro_prun i m1 old old); simpl. + generalize (inst_prun_equiv i old m1 m2 old H); + destruct (inst_prun i m1 old old); simpl. + intros (m3 & H3 & H4); rewrite H3; simpl; eauto. + intros H1; rewrite H1; simpl; auto. Qed. @@ -88,7 +88,7 @@ Lemma prun_iw_app p1: forall m1 old p2, end. Proof. induction p1; simpl; try congruence. - intros; destruct (macro_prun _ _ _); simpl; auto. + intros; destruct (inst_prun _ _ _); simpl; auto. Qed. Lemma prun_iw_app_None p1: forall m1 old p2, @@ -272,15 +272,15 @@ Qed. (** * Writing frames *) -Fixpoint macro_wframe(i:macro): list R.t := +Fixpoint inst_wframe(i:inst): list R.t := match i with | nil => nil - | a::i' => (fst a)::(macro_wframe i') + | a::i' => (fst a)::(inst_wframe i') end. -Lemma macro_wframe_correct i m' old: forall m tmp, - macro_prun ge i m tmp old = Some m' -> - forall x, notIn x (macro_wframe i) -> m' x = m x. +Lemma inst_wframe_correct i m' old: forall m tmp, + inst_prun ge i m tmp old = Some m' -> + forall x, notIn x (inst_wframe i) -> m' x = m x. Proof. induction i as [|[y e] i']; simpl. - intros m tmp H x H0; inversion_clear H; auto. @@ -289,47 +289,47 @@ Proof. rewrite assign_diff; auto. Qed. -Lemma macro_prun_fequiv i old: forall m1 m2 tmp, - frame_eq (fun x => In x (macro_wframe i)) (macro_prun ge i m1 tmp old) (macro_prun ge i m2 tmp old). +Lemma inst_prun_fequiv i old: forall m1 m2 tmp, + frame_eq (fun x => In x (inst_wframe i)) (inst_prun ge i m1 tmp old) (inst_prun ge i m2 tmp old). Proof. induction i as [|[y e] i']; simpl. - intros m1 m2 tmp; eexists; intuition eauto. - intros m1 m2 tmp. destruct (exp_eval ge e tmp old); simpl; auto. eapply frame_eq_list_split; eauto. clear IHi'. intros m1' m2' x H1 H2. - lapply (macro_wframe_correct i' m1' old (assign m1 y v) (assign tmp y v)); eauto. - lapply (macro_wframe_correct i' m2' old (assign m2 y v) (assign tmp y v)); eauto. + lapply (inst_wframe_correct i' m1' old (assign m1 y v) (assign tmp y v)); eauto. + lapply (inst_wframe_correct i' m2' old (assign m2 y v) (assign tmp y v)); eauto. intros Xm2 Xm1 H H0. destruct H. + subst. rewrite Xm1, Xm2; auto. rewrite !assign_eq. auto. + rewrite <- notIn_iff in H0; tauto. Qed. -Lemma macro_prun_None i m1 m2 tmp old: - macro_prun ge i m1 tmp old = None -> - macro_prun ge i m2 tmp old = None. +Lemma inst_prun_None i m1 m2 tmp old: + inst_prun ge i m1 tmp old = None -> + inst_prun ge i m2 tmp old = None. Proof. - intros H; generalize (macro_prun_fequiv i old m1 m2 tmp). + intros H; generalize (inst_prun_fequiv i old m1 m2 tmp). rewrite H; simpl; auto. Qed. -Lemma macro_prun_Some i m1 m2 tmp old m1': - macro_prun ge i m1 tmp old = Some m1' -> - res_eq (Some (frame_assign m2 (macro_wframe i) m1')) (macro_prun ge i m2 tmp old). +Lemma inst_prun_Some i m1 m2 tmp old m1': + inst_prun ge i m1 tmp old = Some m1' -> + res_eq (Some (frame_assign m2 (inst_wframe i) m1')) (inst_prun ge i m2 tmp old). Proof. - intros H; generalize (macro_prun_fequiv i old m1 m2 tmp). + intros H; generalize (inst_prun_fequiv i old m1 m2 tmp). rewrite H; simpl. intros (m2' & H1 & H2). eexists; intuition eauto. rewrite frame_assign_def. - lapply (macro_wframe_correct i m2' old m2 tmp); eauto. - destruct (notIn_dec x (macro_wframe i)); auto. + lapply (inst_wframe_correct i m2' old m2 tmp); eauto. + destruct (notIn_dec x (inst_wframe i)); auto. intros X; rewrite X; auto. Qed. Fixpoint bblock_wframe(p:bblock): list R.t := match p with | nil => nil - | i::p' => (macro_wframe i)++(bblock_wframe p') + | i::p' => (inst_wframe i)++(bblock_wframe p') end. Local Hint Resolve Permutation_app_head Permutation_app_tail Permutation_app_comm. @@ -350,11 +350,11 @@ Proof. induction p as [|i p']; simpl. - intros m H; inversion_clear H; auto. - intros m H x; rewrite notIn_app; intros (H1 & H2). - remember (macro_prun i m old old) as om. + remember (inst_prun i m old old) as om. destruct om as [m1|]; simpl. + eapply eq_trans. eapply IHp'; eauto. - eapply macro_wframe_correct; eauto. + eapply inst_wframe_correct; eauto. + inversion H. Qed. @@ -363,13 +363,13 @@ Lemma prun_iw_fequiv p old: forall m1 m2, Proof. induction p as [|i p']; simpl. - intros m1 m2; eexists; intuition eauto. - - intros m1 m2; generalize (macro_prun_fequiv i old m1 m2 old). - remember (macro_prun i m1 old old) as om. + - intros m1 m2; generalize (inst_prun_fequiv i old m1 m2 old). + remember (inst_prun i m1 old old) as om. destruct om as [m1'|]; simpl. + intros (m2' & H1 & H2). rewrite H1; simpl. eapply frame_eq_list_split; eauto. clear IHp'. intros m1'' m2'' x H3 H4. rewrite in_app_iff. - intros X X2. assert (X1: In x (macro_wframe i)). { destruct X; auto. rewrite <- notIn_iff in X2; tauto. } + intros X X2. assert (X1: In x (inst_wframe i)). { destruct X; auto. rewrite <- notIn_iff in X2; tauto. } clear X. lapply (bblock_wframe_correct p' m1'' old m1'); eauto. lapply (bblock_wframe_correct p' m2'' old m2'); eauto. @@ -397,7 +397,7 @@ Fixpoint is_det (p: bblock): Prop := match p with | nil => True | i::p' => - disjoint (macro_wframe i) (bblock_wframe p') (* no WRITE-AFTER-WRITE *) + disjoint (inst_wframe i) (bblock_wframe p') (* no WRITE-AFTER-WRITE *) /\ is_det p' end. @@ -419,32 +419,32 @@ Theorem is_det_correct p p': Proof. induction 1 as [ | i p p' | i1 i2 p | p1 p2 p3 ]; simpl; eauto. - intros [H0 H1] m old. - remember (macro_prun ge i m old old) as om0. + remember (inst_prun ge i m old old) as om0. destruct om0 as [ m0 | ]; simpl; auto. - rewrite disjoint_app_r. intros ([Z1 Z2] & Z3 & Z4) m old. - remember (macro_prun ge i2 m old old) as om2. + remember (inst_prun ge i2 m old old) as om2. destruct om2 as [ m2 | ]; simpl; auto. - + remember (macro_prun ge i1 m old old) as om1. + + remember (inst_prun ge i1 m old old) as om1. destruct om1 as [ m1 | ]; simpl; auto. - * lapply (macro_prun_Some i2 m m1 old old m2); simpl; auto. - lapply (macro_prun_Some i1 m m2 old old m1); simpl; auto. + * lapply (inst_prun_Some i2 m m1 old old m2); simpl; auto. + lapply (inst_prun_Some i1 m m2 old old m1); simpl; auto. intros (m1' & Hm1' & Xm1') (m2' & Hm2' & Xm2'). rewrite Hm1', Hm2'; simpl. eapply prun_iw_equiv. intros x; rewrite <- Xm1', <- Xm2'. clear Xm2' Xm1' Hm1' Hm2' m1' m2'. rewrite frame_assign_def. rewrite disjoint_sym in Z1; unfold disjoint in Z1. - destruct (notIn_dec x (macro_wframe i1)) as [ X1 | X1 ]. - { rewrite frame_assign_def; destruct (notIn_dec x (macro_wframe i2)) as [ X2 | X2 ]; auto. - erewrite (macro_wframe_correct i2 m2 old m old); eauto. - erewrite (macro_wframe_correct i1 m1 old m old); eauto. + destruct (notIn_dec x (inst_wframe i1)) as [ X1 | X1 ]. + { rewrite frame_assign_def; destruct (notIn_dec x (inst_wframe i2)) as [ X2 | X2 ]; auto. + erewrite (inst_wframe_correct i2 m2 old m old); eauto. + erewrite (inst_wframe_correct i1 m1 old m old); eauto. } rewrite frame_assign_notIn; auto. - * erewrite macro_prun_None; eauto. simpl; auto. - + remember (macro_prun ge i1 m old old) as om1. + * erewrite inst_prun_None; eauto. simpl; auto. + + remember (inst_prun ge i1 m old old) as om1. destruct om1 as [ m1 | ]; simpl; auto. - erewrite macro_prun_None; eauto. + erewrite inst_prun_None; eauto. - intros; eapply res_eq_trans. eapply IHPermutation1; eauto. eapply IHPermutation2; eauto. @@ -479,23 +479,23 @@ Proof. intros; (eapply H1 || eapply H2); rewrite in_app_iff; auto. Qed. -Fixpoint macro_frame (i: macro): list R.t := +Fixpoint inst_frame (i: inst): list R.t := match i with | nil => nil - | a::i' => (fst a)::(exp_frame (snd a) ++ macro_frame i') + | a::i' => (fst a)::(exp_frame (snd a) ++ inst_frame i') end. -Lemma macro_wframe_frame i x: In x (macro_wframe i) -> In x (macro_frame i). +Lemma inst_wframe_frame i x: In x (inst_wframe i) -> In x (inst_frame i). Proof. induction i as [ | [y e] i']; simpl; intuition. Qed. -Lemma macro_frame_correct i wframe old1 old2: forall m tmp1 tmp2, - (disjoint (macro_frame i) wframe) -> +Lemma inst_frame_correct i wframe old1 old2: forall m tmp1 tmp2, + (disjoint (inst_frame i) wframe) -> (forall x, notIn x wframe -> old1 x = old2 x) -> (forall x, notIn x wframe -> tmp1 x = tmp2 x) -> - macro_prun ge i m tmp1 old1 = macro_prun ge i m tmp2 old2. + inst_prun ge i m tmp1 old1 = inst_prun ge i m tmp2 old2. Proof. induction i as [|[x e] i']; simpl; auto. intros m tmp1 tmp2; rewrite disjoint_cons_l, disjoint_app_l. @@ -515,8 +515,8 @@ Fixpoint pararec (p: bblock) (wframe: list R.t): Prop := match p with | nil => True | i::p' => - disjoint (macro_frame i) wframe (* no USE-AFTER-WRITE *) - /\ pararec p' ((macro_wframe i) ++ wframe) + disjoint (inst_frame i) wframe (* no USE-AFTER-WRITE *) + /\ pararec p' ((inst_wframe i) ++ wframe) end. Lemma pararec_disjoint (p: bblock): forall wframe, pararec p wframe -> disjoint (bblock_wframe p) wframe. @@ -527,7 +527,7 @@ Proof. generalize (IHp' _ H1). rewrite disjoint_app_r. intuition. eapply disjoint_incl_l. 2: eapply H0. - unfold incl. eapply macro_wframe_frame; eauto. + unfold incl. eapply inst_wframe_frame; eauto. Qed. Lemma pararec_det p: forall wframe, pararec p wframe -> is_det p. @@ -546,13 +546,13 @@ Lemma pararec_correct p old: forall wframe m, Proof. elim p; clear p; simpl; auto. intros i p' X wframe m [H H0] H1. - erewrite macro_run_prun, macro_frame_correct; eauto. - remember (macro_prun ge i m old old) as om0. + erewrite inst_run_prun, inst_frame_correct; eauto. + remember (inst_prun ge i m old old) as om0. destruct om0 as [m0 | ]; try congruence. eapply X; eauto. intro x; rewrite notIn_app. intros [H3 H4]. rewrite <- H1; auto. - eapply macro_wframe_correct; eauto. + eapply inst_wframe_correct; eauto. Qed. Definition parallelizable (p: bblock) := pararec p nil. @@ -576,9 +576,9 @@ End PARALLELI. End ParallelizablityChecking. -Module Type ResourceSet. +Module Type PseudoRegSet. -Declare Module R: ResourceNames. +Declare Module R: PseudoRegisters. (** We assume a datatype [t] refining (list R.t) @@ -602,7 +602,7 @@ Parameter union_match_frame: forall s1 s2 l1 l2, match_frame s1 l1 -> match_fram Parameter is_disjoint: t -> t -> bool. Parameter is_disjoint_match_frame: forall s1 s2 l1 l2, match_frame s1 l1 -> match_frame s2 l2 -> (is_disjoint s1 s2)=true -> disjoint l1 l2. -End ResourceSet. +End PseudoRegSet. Lemma lazy_andb_bool_true (b1 b2: bool): b1 &&& b2 = true <-> b1 = true /\ b2 = true. @@ -613,7 +613,7 @@ Qed. -Module ParallelChecks (L: SeqLanguage) (S:ResourceSet with Module R:=L.LP.R). +Module ParallelChecks (L: SeqLanguage) (S:PseudoRegSet with Module R:=L.LP.R). Include ParallelizablityChecking L. @@ -624,13 +624,13 @@ Local Hint Resolve S.empty_match_frame S.add_match_frame S.union_match_frame S.i (** Now, refinement of each operation toward parallelizable *) -Fixpoint macro_wsframe(i:macro): S.t := +Fixpoint inst_wsframe(i:inst): S.t := match i with | nil => S.empty - | a::i' => S.add (fst a) (macro_wsframe i') + | a::i' => S.add (fst a) (inst_wsframe i') end. -Lemma macro_wsframe_correct i: S.match_frame (macro_wsframe i) (macro_wframe i). +Lemma inst_wsframe_correct i: S.match_frame (inst_wsframe i) (inst_wframe i). Proof. induction i; simpl; auto. Qed. @@ -653,27 +653,27 @@ Proof. induction e using exp_mut with (P0:=fun l => S.match_frame (list_exp_sframe l) (list_exp_frame l)); simpl; auto. Qed. -Fixpoint macro_sframe (i: macro): S.t := +Fixpoint inst_sframe (i: inst): S.t := match i with | nil => S.empty - | a::i' => S.add (fst a) (S.union (exp_sframe (snd a)) (macro_sframe i')) + | a::i' => S.add (fst a) (S.union (exp_sframe (snd a)) (inst_sframe i')) end. Local Hint Resolve exp_sframe_correct. -Lemma macro_sframe_correct i: S.match_frame (macro_sframe i) (macro_frame i). +Lemma inst_sframe_correct i: S.match_frame (inst_sframe i) (inst_frame i). Proof. induction i as [|[y e] i']; simpl; auto. Qed. -Local Hint Resolve macro_wsframe_correct macro_sframe_correct. +Local Hint Resolve inst_wsframe_correct inst_sframe_correct. Fixpoint is_pararec (p: bblock) (wsframe: S.t): bool := match p with | nil => true | i::p' => - S.is_disjoint (macro_sframe i) wsframe (* no USE-AFTER-WRITE *) - &&& is_pararec p' (S.union (macro_wsframe i) wsframe) + S.is_disjoint (inst_sframe i) wsframe (* no USE-AFTER-WRITE *) + &&& is_pararec p' (S.union (inst_wsframe i) wsframe) end. Lemma is_pararec_correct (p: bblock): forall s l, S.match_frame s l -> (is_pararec p s)=true -> (pararec p l). @@ -706,7 +706,7 @@ End ParallelChecks. Require Import PArith. Require Import MSets.MSetPositive. -Module PosResourceSet <: ResourceSet with Module R:=Pos. +Module PosPseudoRegSet <: PseudoRegSet with Module R:=Pos. Module R:=Pos. @@ -776,4 +776,4 @@ Proof. intros H4 H5; eapply is_disjoint_spec_true; eauto. Qed. -End PosResourceSet. +End PosPseudoRegSet. -- cgit From ead2f32a7648d1eb1b828b120821a0b7801c6200 Mon Sep 17 00:00:00 2001 From: Cyril SIX Date: Mon, 1 Apr 2019 18:16:05 +0200 Subject: Started to add addressing with register + register, Mach -> Asm not done yet --- mppa_k1c/Op.v | 11 ++++++++--- mppa_k1c/PrintOp.ml | 1 + mppa_k1c/SelectOp.vp | 1 + mppa_k1c/SelectOpproof.v | 1 + mppa_k1c/ValueAOp.v | 1 + 5 files changed, 12 insertions(+), 3 deletions(-) diff --git a/mppa_k1c/Op.v b/mppa_k1c/Op.v index c4338857..d533a504 100644 --- a/mppa_k1c/Op.v +++ b/mppa_k1c/Op.v @@ -187,6 +187,7 @@ Inductive operation : Type := addressing. *) Inductive addressing: Type := + | Aindexed2: addressing (**r Address is [r1 + r2] *) | Aindexed: ptrofs -> addressing (**r Address is [r1 + offset] *) | Aglobal: ident -> ptrofs -> addressing (**r Address is global plus offset *) | Ainstack: ptrofs -> addressing. (**r Address is [stack_pointer + offset] *) @@ -385,6 +386,7 @@ Definition eval_addressing (F V: Type) (genv: Genv.t F V) (sp: val) (addr: addressing) (vl: list val) : option val := match addr, vl with + | Aindexed2, v1 :: v2 :: nil => Some (Val.addl v1 v2) | Aindexed n, v1 :: nil => Some (Val.offset_ptr v1 n) | Aglobal s ofs, nil => Some (Genv.symbol_address genv s ofs) | Ainstack n, nil => Some (Val.offset_ptr sp n) @@ -569,6 +571,7 @@ Definition type_of_operation (op: operation) : list typ * typ := Definition type_of_addressing (addr: addressing) : list typ := match addr with + | Aindexed2 => Tptr :: Tptr :: nil | Aindexed _ => Tptr :: nil | Aglobal _ _ => nil | Ainstack _ => nil @@ -914,6 +917,7 @@ Qed. Definition offset_addressing (addr: addressing) (delta: Z) : option addressing := match addr with + | Aindexed2 => None | Aindexed n => Some(Aindexed (Ptrofs.add n (Ptrofs.repr delta))) | Aglobal id n => Some(Aglobal id (Ptrofs.add n (Ptrofs.repr delta))) | Ainstack n => Some(Ainstack (Ptrofs.add n (Ptrofs.repr delta))) @@ -1337,9 +1341,10 @@ Lemma eval_addressing_inj: exists v2, eval_addressing ge2 sp2 addr vl2 = Some v2 /\ Val.inject f v1 v2. Proof. intros. destruct addr; simpl in H2; simpl; FuncInv; InvInject; TrivialExists. - apply Val.offset_ptr_inject; auto. - apply H; simpl; auto. - apply Val.offset_ptr_inject; auto. + - apply Val.addl_inject; auto. + - apply Val.offset_ptr_inject; auto. + - apply H; simpl; auto. + - apply Val.offset_ptr_inject; auto. Qed. End EVAL_COMPAT. diff --git a/mppa_k1c/PrintOp.ml b/mppa_k1c/PrintOp.ml index 9ec474b3..5ac00404 100644 --- a/mppa_k1c/PrintOp.ml +++ b/mppa_k1c/PrintOp.ml @@ -160,6 +160,7 @@ let print_operation reg pp = function let print_addressing reg pp = function | Aindexed n, [r1] -> fprintf pp "%a + %Ld" reg r1 (camlint64_of_ptrofs n) + | Aindexed2, [r1;r2] -> fprintf pp "%a + %a" reg r1 reg r2 | Aglobal(id, ofs), [] -> fprintf pp "\"%s\" + %Ld" (extern_atom id) (camlint64_of_ptrofs ofs) | Ainstack ofs, [] -> fprintf pp "stack(%Ld)" (camlint64_of_ptrofs ofs) diff --git a/mppa_k1c/SelectOp.vp b/mppa_k1c/SelectOp.vp index f6605c11..d82fe238 100644 --- a/mppa_k1c/SelectOp.vp +++ b/mppa_k1c/SelectOp.vp @@ -481,6 +481,7 @@ Nondetfunction addressing (chunk: memory_chunk) (e: expr) := | Eop (Oaddrsymbol id ofs) Enil => if Archi.pic_code tt then (Aindexed Ptrofs.zero, e:::Enil) else (Aglobal id ofs, Enil) | Eop (Oaddimm n) (e1:::Enil) => (Aindexed (Ptrofs.of_int n), e1:::Enil) | Eop (Oaddlimm n) (e1:::Enil) => (Aindexed (Ptrofs.of_int64 n), e1:::Enil) + | Eop Oaddl (e1:::e2:::Enil) => (Aindexed2, e1:::e2:::Enil) | _ => (Aindexed Ptrofs.zero, e:::Enil) end. diff --git a/mppa_k1c/SelectOpproof.v b/mppa_k1c/SelectOpproof.v index 89af39ee..d426e4f1 100644 --- a/mppa_k1c/SelectOpproof.v +++ b/mppa_k1c/SelectOpproof.v @@ -991,6 +991,7 @@ Proof. - exists (v1 :: nil); split. eauto with evalexpr. simpl. destruct v1; simpl in H; try discriminate. destruct Archi.ptr64 eqn:SF; inv H. simpl. auto. + - exists (v1 :: v0 :: nil); split. repeat (constructor; auto). simpl. congruence. - exists (v :: nil); split. eauto with evalexpr. subst. simpl. rewrite Ptrofs.add_zero; auto. Qed. diff --git a/mppa_k1c/ValueAOp.v b/mppa_k1c/ValueAOp.v index fb1977ea..a54dbd8f 100644 --- a/mppa_k1c/ValueAOp.v +++ b/mppa_k1c/ValueAOp.v @@ -36,6 +36,7 @@ Definition eval_static_condition (cond: condition) (vl: list aval): abool := Definition eval_static_addressing (addr: addressing) (vl: list aval): aval := match addr, vl with | Aindexed n, v1::nil => offset_ptr v1 n + | Aindexed2, v1::v2::nil => addl v1 v2 | Aglobal s ofs, nil => Ptr (Gl s ofs) | Ainstack ofs, nil => Ptr (Stk ofs) | _, _ => Vbot -- cgit From 5cdc3d29983c65d1ac1d3393103037fdd87d7829 Mon Sep 17 00:00:00 2001 From: Cyril SIX Date: Mon, 1 Apr 2019 18:16:52 +0200 Subject: Revert "Started to add addressing with register + register, Mach -> Asm not done yet" This reverts commit ead2f32a7648d1eb1b828b120821a0b7801c6200. --- mppa_k1c/Op.v | 11 +++-------- mppa_k1c/PrintOp.ml | 1 - mppa_k1c/SelectOp.vp | 1 - mppa_k1c/SelectOpproof.v | 1 - mppa_k1c/ValueAOp.v | 1 - 5 files changed, 3 insertions(+), 12 deletions(-) diff --git a/mppa_k1c/Op.v b/mppa_k1c/Op.v index d533a504..c4338857 100644 --- a/mppa_k1c/Op.v +++ b/mppa_k1c/Op.v @@ -187,7 +187,6 @@ Inductive operation : Type := addressing. *) Inductive addressing: Type := - | Aindexed2: addressing (**r Address is [r1 + r2] *) | Aindexed: ptrofs -> addressing (**r Address is [r1 + offset] *) | Aglobal: ident -> ptrofs -> addressing (**r Address is global plus offset *) | Ainstack: ptrofs -> addressing. (**r Address is [stack_pointer + offset] *) @@ -386,7 +385,6 @@ Definition eval_addressing (F V: Type) (genv: Genv.t F V) (sp: val) (addr: addressing) (vl: list val) : option val := match addr, vl with - | Aindexed2, v1 :: v2 :: nil => Some (Val.addl v1 v2) | Aindexed n, v1 :: nil => Some (Val.offset_ptr v1 n) | Aglobal s ofs, nil => Some (Genv.symbol_address genv s ofs) | Ainstack n, nil => Some (Val.offset_ptr sp n) @@ -571,7 +569,6 @@ Definition type_of_operation (op: operation) : list typ * typ := Definition type_of_addressing (addr: addressing) : list typ := match addr with - | Aindexed2 => Tptr :: Tptr :: nil | Aindexed _ => Tptr :: nil | Aglobal _ _ => nil | Ainstack _ => nil @@ -917,7 +914,6 @@ Qed. Definition offset_addressing (addr: addressing) (delta: Z) : option addressing := match addr with - | Aindexed2 => None | Aindexed n => Some(Aindexed (Ptrofs.add n (Ptrofs.repr delta))) | Aglobal id n => Some(Aglobal id (Ptrofs.add n (Ptrofs.repr delta))) | Ainstack n => Some(Ainstack (Ptrofs.add n (Ptrofs.repr delta))) @@ -1341,10 +1337,9 @@ Lemma eval_addressing_inj: exists v2, eval_addressing ge2 sp2 addr vl2 = Some v2 /\ Val.inject f v1 v2. Proof. intros. destruct addr; simpl in H2; simpl; FuncInv; InvInject; TrivialExists. - - apply Val.addl_inject; auto. - - apply Val.offset_ptr_inject; auto. - - apply H; simpl; auto. - - apply Val.offset_ptr_inject; auto. + apply Val.offset_ptr_inject; auto. + apply H; simpl; auto. + apply Val.offset_ptr_inject; auto. Qed. End EVAL_COMPAT. diff --git a/mppa_k1c/PrintOp.ml b/mppa_k1c/PrintOp.ml index 5ac00404..9ec474b3 100644 --- a/mppa_k1c/PrintOp.ml +++ b/mppa_k1c/PrintOp.ml @@ -160,7 +160,6 @@ let print_operation reg pp = function let print_addressing reg pp = function | Aindexed n, [r1] -> fprintf pp "%a + %Ld" reg r1 (camlint64_of_ptrofs n) - | Aindexed2, [r1;r2] -> fprintf pp "%a + %a" reg r1 reg r2 | Aglobal(id, ofs), [] -> fprintf pp "\"%s\" + %Ld" (extern_atom id) (camlint64_of_ptrofs ofs) | Ainstack ofs, [] -> fprintf pp "stack(%Ld)" (camlint64_of_ptrofs ofs) diff --git a/mppa_k1c/SelectOp.vp b/mppa_k1c/SelectOp.vp index d82fe238..f6605c11 100644 --- a/mppa_k1c/SelectOp.vp +++ b/mppa_k1c/SelectOp.vp @@ -481,7 +481,6 @@ Nondetfunction addressing (chunk: memory_chunk) (e: expr) := | Eop (Oaddrsymbol id ofs) Enil => if Archi.pic_code tt then (Aindexed Ptrofs.zero, e:::Enil) else (Aglobal id ofs, Enil) | Eop (Oaddimm n) (e1:::Enil) => (Aindexed (Ptrofs.of_int n), e1:::Enil) | Eop (Oaddlimm n) (e1:::Enil) => (Aindexed (Ptrofs.of_int64 n), e1:::Enil) - | Eop Oaddl (e1:::e2:::Enil) => (Aindexed2, e1:::e2:::Enil) | _ => (Aindexed Ptrofs.zero, e:::Enil) end. diff --git a/mppa_k1c/SelectOpproof.v b/mppa_k1c/SelectOpproof.v index d426e4f1..89af39ee 100644 --- a/mppa_k1c/SelectOpproof.v +++ b/mppa_k1c/SelectOpproof.v @@ -991,7 +991,6 @@ Proof. - exists (v1 :: nil); split. eauto with evalexpr. simpl. destruct v1; simpl in H; try discriminate. destruct Archi.ptr64 eqn:SF; inv H. simpl. auto. - - exists (v1 :: v0 :: nil); split. repeat (constructor; auto). simpl. congruence. - exists (v :: nil); split. eauto with evalexpr. subst. simpl. rewrite Ptrofs.add_zero; auto. Qed. diff --git a/mppa_k1c/ValueAOp.v b/mppa_k1c/ValueAOp.v index a54dbd8f..fb1977ea 100644 --- a/mppa_k1c/ValueAOp.v +++ b/mppa_k1c/ValueAOp.v @@ -36,7 +36,6 @@ Definition eval_static_condition (cond: condition) (vl: list aval): abool := Definition eval_static_addressing (addr: addressing) (vl: list aval): aval := match addr, vl with | Aindexed n, v1::nil => offset_ptr v1 n - | Aindexed2, v1::v2::nil => addl v1 v2 | Aglobal s ofs, nil => Ptr (Gl s ofs) | Ainstack ofs, nil => Ptr (Stk ofs) | _, _ => Vbot -- cgit From 0c95673ef97195eae6213db92c2f69ef1d1ff48e Mon Sep 17 00:00:00 2001 From: Cyril SIX Date: Mon, 1 Apr 2019 18:16:05 +0200 Subject: Started to add addressing with register + register, Mach -> Asm not done yet --- mppa_k1c/Op.v | 11 ++++++++--- mppa_k1c/PrintOp.ml | 1 + mppa_k1c/SelectOp.vp | 1 + mppa_k1c/SelectOpproof.v | 1 + mppa_k1c/ValueAOp.v | 1 + 5 files changed, 12 insertions(+), 3 deletions(-) diff --git a/mppa_k1c/Op.v b/mppa_k1c/Op.v index c4338857..d533a504 100644 --- a/mppa_k1c/Op.v +++ b/mppa_k1c/Op.v @@ -187,6 +187,7 @@ Inductive operation : Type := addressing. *) Inductive addressing: Type := + | Aindexed2: addressing (**r Address is [r1 + r2] *) | Aindexed: ptrofs -> addressing (**r Address is [r1 + offset] *) | Aglobal: ident -> ptrofs -> addressing (**r Address is global plus offset *) | Ainstack: ptrofs -> addressing. (**r Address is [stack_pointer + offset] *) @@ -385,6 +386,7 @@ Definition eval_addressing (F V: Type) (genv: Genv.t F V) (sp: val) (addr: addressing) (vl: list val) : option val := match addr, vl with + | Aindexed2, v1 :: v2 :: nil => Some (Val.addl v1 v2) | Aindexed n, v1 :: nil => Some (Val.offset_ptr v1 n) | Aglobal s ofs, nil => Some (Genv.symbol_address genv s ofs) | Ainstack n, nil => Some (Val.offset_ptr sp n) @@ -569,6 +571,7 @@ Definition type_of_operation (op: operation) : list typ * typ := Definition type_of_addressing (addr: addressing) : list typ := match addr with + | Aindexed2 => Tptr :: Tptr :: nil | Aindexed _ => Tptr :: nil | Aglobal _ _ => nil | Ainstack _ => nil @@ -914,6 +917,7 @@ Qed. Definition offset_addressing (addr: addressing) (delta: Z) : option addressing := match addr with + | Aindexed2 => None | Aindexed n => Some(Aindexed (Ptrofs.add n (Ptrofs.repr delta))) | Aglobal id n => Some(Aglobal id (Ptrofs.add n (Ptrofs.repr delta))) | Ainstack n => Some(Ainstack (Ptrofs.add n (Ptrofs.repr delta))) @@ -1337,9 +1341,10 @@ Lemma eval_addressing_inj: exists v2, eval_addressing ge2 sp2 addr vl2 = Some v2 /\ Val.inject f v1 v2. Proof. intros. destruct addr; simpl in H2; simpl; FuncInv; InvInject; TrivialExists. - apply Val.offset_ptr_inject; auto. - apply H; simpl; auto. - apply Val.offset_ptr_inject; auto. + - apply Val.addl_inject; auto. + - apply Val.offset_ptr_inject; auto. + - apply H; simpl; auto. + - apply Val.offset_ptr_inject; auto. Qed. End EVAL_COMPAT. diff --git a/mppa_k1c/PrintOp.ml b/mppa_k1c/PrintOp.ml index 9ec474b3..5ac00404 100644 --- a/mppa_k1c/PrintOp.ml +++ b/mppa_k1c/PrintOp.ml @@ -160,6 +160,7 @@ let print_operation reg pp = function let print_addressing reg pp = function | Aindexed n, [r1] -> fprintf pp "%a + %Ld" reg r1 (camlint64_of_ptrofs n) + | Aindexed2, [r1;r2] -> fprintf pp "%a + %a" reg r1 reg r2 | Aglobal(id, ofs), [] -> fprintf pp "\"%s\" + %Ld" (extern_atom id) (camlint64_of_ptrofs ofs) | Ainstack ofs, [] -> fprintf pp "stack(%Ld)" (camlint64_of_ptrofs ofs) diff --git a/mppa_k1c/SelectOp.vp b/mppa_k1c/SelectOp.vp index f6605c11..d82fe238 100644 --- a/mppa_k1c/SelectOp.vp +++ b/mppa_k1c/SelectOp.vp @@ -481,6 +481,7 @@ Nondetfunction addressing (chunk: memory_chunk) (e: expr) := | Eop (Oaddrsymbol id ofs) Enil => if Archi.pic_code tt then (Aindexed Ptrofs.zero, e:::Enil) else (Aglobal id ofs, Enil) | Eop (Oaddimm n) (e1:::Enil) => (Aindexed (Ptrofs.of_int n), e1:::Enil) | Eop (Oaddlimm n) (e1:::Enil) => (Aindexed (Ptrofs.of_int64 n), e1:::Enil) + | Eop Oaddl (e1:::e2:::Enil) => (Aindexed2, e1:::e2:::Enil) | _ => (Aindexed Ptrofs.zero, e:::Enil) end. diff --git a/mppa_k1c/SelectOpproof.v b/mppa_k1c/SelectOpproof.v index 89af39ee..d426e4f1 100644 --- a/mppa_k1c/SelectOpproof.v +++ b/mppa_k1c/SelectOpproof.v @@ -991,6 +991,7 @@ Proof. - exists (v1 :: nil); split. eauto with evalexpr. simpl. destruct v1; simpl in H; try discriminate. destruct Archi.ptr64 eqn:SF; inv H. simpl. auto. + - exists (v1 :: v0 :: nil); split. repeat (constructor; auto). simpl. congruence. - exists (v :: nil); split. eauto with evalexpr. subst. simpl. rewrite Ptrofs.add_zero; auto. Qed. diff --git a/mppa_k1c/ValueAOp.v b/mppa_k1c/ValueAOp.v index fb1977ea..a54dbd8f 100644 --- a/mppa_k1c/ValueAOp.v +++ b/mppa_k1c/ValueAOp.v @@ -36,6 +36,7 @@ Definition eval_static_condition (cond: condition) (vl: list aval): abool := Definition eval_static_addressing (addr: addressing) (vl: list aval): aval := match addr, vl with | Aindexed n, v1::nil => offset_ptr v1 n + | Aindexed2, v1::v2::nil => addl v1 v2 | Aglobal s ofs, nil => Ptr (Gl s ofs) | Ainstack ofs, nil => Ptr (Stk ofs) | _, _ => Vbot -- cgit From b8f03b19adda37c1c3275ef30d7fc106d3c97e44 Mon Sep 17 00:00:00 2001 From: Sylvain Boulmé Date: Mon, 1 Apr 2019 18:34:22 +0200 Subject: renommage abstractbb: Name -> PReg --- mppa_k1c/Asmblockdeps.v | 50 ++++++++++++++-------------- mppa_k1c/abstractbb/AbstractBasicBlocksDef.v | 6 ++-- mppa_k1c/abstractbb/DepTreeTheory.v | 2 +- mppa_k1c/abstractbb/ImpDep.v | 2 +- mppa_k1c/abstractbb/Parallelizability.v | 4 +-- 5 files changed, 32 insertions(+), 32 deletions(-) diff --git a/mppa_k1c/Asmblockdeps.v b/mppa_k1c/Asmblockdeps.v index 7043bd32..cc8f13f6 100644 --- a/mppa_k1c/Asmblockdeps.v +++ b/mppa_k1c/Asmblockdeps.v @@ -544,15 +544,15 @@ Notation "a @ b" := (Econs a b) (at level 102, right associativity). Definition trans_control (ctl: control) : inst := match ctl with - | Pret => [(#PC, Name (#RA))] - | Pcall s => [(#RA, Name (#PC)); (#PC, Op (Arith (OArithR (Ploadsymbol s Ptrofs.zero))) Enil)] - | Picall r => [(#RA, Name (#PC)); (#PC, Name (#r))] + | Pret => [(#PC, PReg(#RA))] + | Pcall s => [(#RA, PReg(#PC)); (#PC, Op (Arith (OArithR (Ploadsymbol s Ptrofs.zero))) Enil)] + | Picall r => [(#RA, PReg(#PC)); (#PC, PReg(#r))] | Pgoto s => [(#PC, Op (Arith (OArithR (Ploadsymbol s Ptrofs.zero))) Enil)] - | Pigoto r => [(#PC, Name (#r))] - | Pj_l l => [(#PC, Op (Control (Oj_l l)) (Name (#PC) @ Enil))] - | Pcb bt r l => [(#PC, Op (Control (Ocb bt l)) (Name (#r) @ Name (#PC) @ Enil))] - | Pcbu bt r l => [(#PC, Op (Control (Ocbu bt l)) (Name (#r) @ Name (#PC) @ Enil))] - | Pjumptable r labels => [(#PC, Op (Control (Ojumptable labels)) (Name (#r) @ Name (#PC) @ Enil)); + | Pigoto r => [(#PC, PReg(#r))] + | Pj_l l => [(#PC, Op (Control (Oj_l l)) (PReg(#PC) @ Enil))] + | Pcb bt r l => [(#PC, Op (Control (Ocb bt l)) (PReg(#r) @ PReg(#PC) @ Enil))] + | Pcbu bt r l => [(#PC, Op (Control (Ocbu bt l)) (PReg(#r) @ PReg(#PC) @ Enil))] + | Pjumptable r labels => [(#PC, Op (Control (Ojumptable labels)) (PReg(#r) @ PReg(#PC) @ Enil)); (#GPR62, Op (Constant Vundef) Enil); (#GPR63, Op (Constant Vundef) Enil) ] | Pbuiltin ef args res => [(#PC, Op (Control (OError)) Enil)] @@ -568,36 +568,36 @@ Definition trans_exit (ex: option control) : L.inst := Definition trans_arith (ai: ar_instruction) : inst := match ai with | PArithR n d => [(#d, Op (Arith (OArithR n)) Enil)] - | PArithRR n d s => [(#d, Op (Arith (OArithRR n)) (Name (#s) @ Enil))] + | PArithRR n d s => [(#d, Op (Arith (OArithRR n)) (PReg(#s) @ Enil))] | PArithRI32 n d i => [(#d, Op (Arith (OArithRI32 n i)) Enil)] | PArithRI64 n d i => [(#d, Op (Arith (OArithRI64 n i)) Enil)] | PArithRF32 n d i => [(#d, Op (Arith (OArithRF32 n i)) Enil)] | PArithRF64 n d i => [(#d, Op (Arith (OArithRF64 n i)) Enil)] - | PArithRRR n d s1 s2 => [(#d, Op (Arith (OArithRRR n)) (Name (#s1) @ Name (#s2) @ Enil))] - | PArithRRI32 n d s i => [(#d, Op (Arith (OArithRRI32 n i)) (Name (#s) @ Enil))] - | PArithRRI64 n d s i => [(#d, Op (Arith (OArithRRI64 n i)) (Name (#s) @ Enil))] - | PArithARRR n d s1 s2 => [(#d, Op (Arith (OArithARRR n)) (Name(#d) @ Name (#s1) @ Name (#s2) @ Enil))] - | PArithARRI32 n d s i => [(#d, Op (Arith (OArithARRI32 n i)) (Name(#d) @ Name (#s) @ Enil))] - | PArithARRI64 n d s i => [(#d, Op (Arith (OArithARRI64 n i)) (Name(#d) @ Name (#s) @ Enil))] + | PArithRRR n d s1 s2 => [(#d, Op (Arith (OArithRRR n)) (PReg(#s1) @ PReg(#s2) @ Enil))] + | PArithRRI32 n d s i => [(#d, Op (Arith (OArithRRI32 n i)) (PReg(#s) @ Enil))] + | PArithRRI64 n d s i => [(#d, Op (Arith (OArithRRI64 n i)) (PReg(#s) @ Enil))] + | PArithARRR n d s1 s2 => [(#d, Op (Arith (OArithARRR n)) (PReg(#d) @ PReg(#s1) @ PReg(#s2) @ Enil))] + | PArithARRI32 n d s i => [(#d, Op (Arith (OArithARRI32 n i)) (PReg(#d) @ PReg(#s) @ Enil))] + | PArithARRI64 n d s i => [(#d, Op (Arith (OArithARRI64 n i)) (PReg(#d) @ PReg(#s) @ Enil))] end. Definition trans_basic (b: basic) : inst := match b with | PArith ai => trans_arith ai - | PLoadRRO n d a ofs => [(#d, Op (Load (OLoadRRO n ofs)) (Name (#a) @ Name pmem @ Enil))] - | PStoreRRO n s a ofs => [(pmem, Op (Store (OStoreRRO n ofs)) (Name (#s) @ Name (#a) @ Name pmem @ Enil))] - | Pallocframe sz pos => [(#FP, Name (#SP)); (#SP, Op (Allocframe2 sz pos) (Name (#SP) @ Name pmem @ Enil)); (#RTMP, Op (Constant Vundef) Enil); - (pmem, Op (Allocframe sz pos) (Old (Name (#SP)) @ Name pmem @ Enil))] - | Pfreeframe sz pos => [(pmem, Op (Freeframe sz pos) (Name (#SP) @ Name pmem @ Enil)); - (#SP, Op (Freeframe2 sz pos) (Name (#SP) @ Old (Name pmem) @ Enil)); + | PLoadRRO n d a ofs => [(#d, Op (Load (OLoadRRO n ofs)) (PReg(#a) @ PReg pmem @ Enil))] + | PStoreRRO n s a ofs => [(pmem, Op (Store (OStoreRRO n ofs)) (PReg(#s) @ PReg(#a) @ PReg pmem @ Enil))] + | Pallocframe sz pos => [(#FP, PReg(#SP)); (#SP, Op (Allocframe2 sz pos) (PReg(#SP) @ PReg pmem @ Enil)); (#RTMP, Op (Constant Vundef) Enil); + (pmem, Op (Allocframe sz pos) (Old (PReg(#SP)) @ PReg pmem @ Enil))] + | Pfreeframe sz pos => [(pmem, Op (Freeframe sz pos) (PReg(#SP) @ PReg pmem @ Enil)); + (#SP, Op (Freeframe2 sz pos) (PReg(#SP) @ Old (PReg pmem) @ Enil)); (#RTMP, Op (Constant Vundef) Enil)] | Pget rd ra => match ra with - | RA => [(#rd, Name (#ra))] + | RA => [(#rd, PReg(#ra))] | _ => [(#rd, Op Fail Enil)] end | Pset ra rd => match ra with - | RA => [(#ra, Name (#rd))] + | RA => [(#ra, PReg(#rd))] | _ => [(#rd, Op Fail Enil)] end | Pnop => [] @@ -609,7 +609,7 @@ Fixpoint trans_body (b: list basic) : list L.inst := | b :: lb => (trans_basic b) :: (trans_body lb) end. -Definition trans_pcincr (sz: Z) (k: L.inst) := (#PC, Op (Control (OIncremPC sz)) (Name (#PC) @ Enil)) :: k. +Definition trans_pcincr (sz: Z) (k: L.inst) := (#PC, Op (Control (OIncremPC sz)) (PReg(#PC) @ Enil)) :: k. Definition trans_block (b: Asmblock.bblock) : L.bblock := trans_body (body b) ++ (trans_pcincr (size b) (trans_exit (exit b)) :: nil). @@ -1044,7 +1044,7 @@ Lemma exec_trans_pcincr_exec_instrun: forall rs m s b k, match_states (State rs m) s -> exists s', - inst_run Ge ((# PC, Op (OIncremPC (size b)) (Name (# PC) @ Enil)) :: k) s s = inst_run Ge k s' s + inst_run Ge ((# PC, Op (OIncremPC (size b)) (PReg(# PC) @ Enil)) :: k) s s = inst_run Ge k s' s /\ match_states (State (nextblock b rs) m) s'. Proof. intros. inv H. eexists. split. simpl. pose (H1 PC); simpl in e; rewrite e. destruct Ge. simpl. eapply eq_refl. diff --git a/mppa_k1c/abstractbb/AbstractBasicBlocksDef.v b/mppa_k1c/abstractbb/AbstractBasicBlocksDef.v index 0bab9426..3023ad8a 100644 --- a/mppa_k1c/abstractbb/AbstractBasicBlocksDef.v +++ b/mppa_k1c/abstractbb/AbstractBasicBlocksDef.v @@ -55,18 +55,18 @@ Definition assign (m: mem) (x:R.t) (v: value): mem := fun y => if R.eq_dec x y then v else m y. Inductive exp := - | Name (x:R.t) + | PReg (x:R.t) | Op (o:op) (le: list_exp) | Old (e: exp) with list_exp := | Enil | Econs (e:exp) (le:list_exp) | LOld (le: list_exp) - . +. Fixpoint exp_eval (e: exp) (m old: mem): option value := match e with - | Name x => Some (m x) + | PReg x => Some (m x) | Op o le => match list_exp_eval le m old with | Some lv => op_eval ge o lv diff --git a/mppa_k1c/abstractbb/DepTreeTheory.v b/mppa_k1c/abstractbb/DepTreeTheory.v index 4d5c71b3..bfe79d42 100644 --- a/mppa_k1c/abstractbb/DepTreeTheory.v +++ b/mppa_k1c/abstractbb/DepTreeTheory.v @@ -115,7 +115,7 @@ Hint Rewrite set_spec_eq empty_spec: dict_rw. Fixpoint exp_tree (e: exp) (d old: deps): tree := match e with - | Name x => deps_get d x + | PReg x => deps_get d x | Op o le => Top o (list_exp_tree le d old) | Old e => exp_tree e old old end diff --git a/mppa_k1c/abstractbb/ImpDep.v b/mppa_k1c/abstractbb/ImpDep.v index 3cc85fd5..a4dd12eb 100644 --- a/mppa_k1c/abstractbb/ImpDep.v +++ b/mppa_k1c/abstractbb/ImpDep.v @@ -171,7 +171,7 @@ Hint Resolve hdeps_get_correct: wlp. Fixpoint hexp_tree (e: exp) (d od: hdeps) (dbg: option pstring) : ?? hashV tree := match e with - | Name x => hdeps_get d x dbg + | PReg x => hdeps_get d x dbg | Op o le => DO lt <~ hlist_exp_tree le d od;; hTop o lt dbg diff --git a/mppa_k1c/abstractbb/Parallelizability.v b/mppa_k1c/abstractbb/Parallelizability.v index 519e7e54..d1971e57 100644 --- a/mppa_k1c/abstractbb/Parallelizability.v +++ b/mppa_k1c/abstractbb/Parallelizability.v @@ -455,7 +455,7 @@ Qed. Fixpoint exp_frame (e: exp): list R.t := match e with - | Name x => x::nil + | PReg x => x::nil | Op o le => list_exp_frame le | Old e => exp_frame e end @@ -637,7 +637,7 @@ Qed. Fixpoint exp_sframe (e: exp): S.t := match e with - | Name x => S.add x S.empty + | PReg x => S.add x S.empty | Op o le => list_exp_sframe le | Old e => exp_sframe e end -- cgit From 920bdebcd25c5b93142eab2a79e294e23ce6437d Mon Sep 17 00:00:00 2001 From: Sylvain Boulmé Date: Mon, 1 Apr 2019 19:51:21 +0200 Subject: Impure: improved iandb + struct_eq --- mppa_k1c/Asmblockdeps.v | 48 ++++++++++++--------------------- mppa_k1c/abstractbb/Impure/ImpCore.v | 10 ++++++- mppa_k1c/abstractbb/Impure/ImpPrelude.v | 4 +-- 3 files changed, 28 insertions(+), 34 deletions(-) diff --git a/mppa_k1c/Asmblockdeps.v b/mppa_k1c/Asmblockdeps.v index cc8f13f6..c941e482 100644 --- a/mppa_k1c/Asmblockdeps.v +++ b/mppa_k1c/Asmblockdeps.v @@ -291,12 +291,6 @@ Proof. destruct o; simpl; try congruence. Qed. - -Definition iandb (ib1 ib2: ?? bool): ?? bool := - DO b1 <~ ib1;; - DO b2 <~ ib2;; - RET (andb b1 b2). - Definition arith_op_eq (o1 o2: arith_op): ?? bool := match o1 with | OArithR n1 => @@ -325,14 +319,15 @@ Definition arith_op_eq (o1 o2: arith_op): ?? bool := match o2 with OArithARRI64 n2 i2 => iandb (phys_eq n1 n2) (phys_eq i1 i2) | _ => RET false end end. +Ltac my_wlp_simplify := wlp_xsimplify ltac:(intros; subst; simpl in * |- *; congruence || intuition eauto with wlp). + Lemma arith_op_eq_correct o1 o2: WHEN arith_op_eq o1 o2 ~> b THEN b = true -> o1 = o2. Proof. - destruct o1, o2; wlp_simplify; try discriminate. - all: try congruence. - all: apply andb_prop in H1; inversion H1; apply H in H2; apply H0 in H3; congruence. + destruct o1, o2; my_wlp_simplify; try congruence. Qed. - +Hint Resolve arith_op_eq_correct: wlp. +Opaque arith_op_eq_correct. Definition load_op_eq (o1 o2: load_op): ?? bool := match o1, o2 with @@ -342,9 +337,10 @@ Definition load_op_eq (o1 o2: load_op): ?? bool := Lemma load_op_eq_correct o1 o2: WHEN load_op_eq o1 o2 ~> b THEN b = true -> o1 = o2. Proof. - destruct o1, o2; wlp_simplify. - apply andb_prop in H1; inversion H1; apply H in H2; apply H0 in H3; congruence. + destruct o1, o2; wlp_simplify; try congruence. Qed. +Hint Resolve load_op_eq_correct: wlp. +Opaque load_op_eq_correct. Definition store_op_eq (o1 o2: store_op): ?? bool := @@ -355,9 +351,10 @@ Definition store_op_eq (o1 o2: store_op): ?? bool := Lemma store_op_eq_correct o1 o2: WHEN store_op_eq o1 o2 ~> b THEN b = true -> o1 = o2. Proof. - destruct o1, o2; wlp_simplify. - apply andb_prop in H1; inversion H1; apply H in H2; apply H0 in H3; congruence. + destruct o1, o2; wlp_simplify; try congruence. Qed. +Hint Resolve store_op_eq_correct: wlp. +Opaque store_op_eq_correct. (* TODO: rewrite control_op_eq in a robust style against the miss of a case cf. arith_op_eq above *) @@ -377,13 +374,10 @@ Definition control_op_eq (c1 c2: control_op): ?? bool := Lemma control_op_eq_correct c1 c2: WHEN control_op_eq c1 c2 ~> b THEN b = true -> c1 = c2. Proof. - destruct c1, c2; wlp_simplify; try discriminate. - - congruence. - - apply andb_prop in H1; inversion H1; apply H in H2; apply H0 in H3; congruence. - - apply andb_prop in H1; inversion H1; apply H in H2; apply H0 in H3; congruence. - - rewrite Z.eqb_eq in * |-. congruence. - - congruence. + destruct c1, c2; wlp_simplify; try rewrite Z.eqb_eq in * |-; try congruence. Qed. +Hint Resolve control_op_eq_correct: wlp. +Opaque control_op_eq_correct. (* TODO: rewrite op_eq in a robust style against the miss of a case @@ -403,21 +397,13 @@ Definition op_eq (o1 o2: op): ?? bool := | _, _ => RET false end. - Theorem op_eq_correct o1 o2: WHEN op_eq o1 o2 ~> b THEN b=true -> o1 = o2. Proof. - destruct o1, o2; wlp_simplify; try discriminate. - - simpl in Hexta. exploit arith_op_eq_correct. eassumption. eauto. congruence. - - simpl in Hexta. exploit load_op_eq_correct. eassumption. eauto. congruence. - - simpl in Hexta. exploit store_op_eq_correct. eassumption. eauto. congruence. - - simpl in Hexta. exploit control_op_eq_correct. eassumption. eauto. congruence. - - apply andb_prop in H0; inversion_clear H0. apply H in H2. apply Z.eqb_eq in H1. congruence. - - apply andb_prop in H0; inversion_clear H0. apply H in H2. apply Z.eqb_eq in H1. congruence. - - apply andb_prop in H0; inversion_clear H0. apply H in H2. apply Z.eqb_eq in H1. congruence. - - apply andb_prop in H0; inversion_clear H0. apply H in H2. apply Z.eqb_eq in H1. congruence. - - congruence. + destruct o1, o2; wlp_simplify; try rewrite Z.eqb_eq in * |- ; try congruence. Qed. +Hint Resolve op_eq_correct: wlp. +Global Opaque op_eq_correct. (* QUICK FIX WITH struct_eq *) diff --git a/mppa_k1c/abstractbb/Impure/ImpCore.v b/mppa_k1c/abstractbb/Impure/ImpCore.v index 6eb0c5af..9745e35c 100644 --- a/mppa_k1c/abstractbb/Impure/ImpCore.v +++ b/mppa_k1c/abstractbb/Impure/ImpCore.v @@ -132,6 +132,7 @@ Proof. destruct x; simpl; auto. Qed. + (* Tactics MAIN tactics: @@ -184,4 +185,11 @@ Ltac wlp_xsimplify hint := Create HintDb wlp discriminated. -Ltac wlp_simplify := wlp_xsimplify ltac:(intuition eauto with wlp). \ No newline at end of file +Ltac wlp_simplify := wlp_xsimplify ltac:(intuition eauto with wlp). + +(* impure lazy andb of booleans *) +Definition iandb (k1 k2: ??bool): ?? bool := + DO r1 <~ k1 ;; + if r1 then k2 else RET false. + +Extraction Inline iandb. (* Juste pour l'efficacité à l'extraction ! *) \ No newline at end of file diff --git a/mppa_k1c/abstractbb/Impure/ImpPrelude.v b/mppa_k1c/abstractbb/Impure/ImpPrelude.v index e7c7a9fb..8d904be6 100644 --- a/mppa_k1c/abstractbb/Impure/ImpPrelude.v +++ b/mppa_k1c/abstractbb/Impure/ImpPrelude.v @@ -77,14 +77,14 @@ Qed. End PhysEqModel. - Export PhysEqModel. Extract Constant phys_eq => "(==)". Hint Resolve phys_eq_correct: wlp. + Axiom struct_eq: forall {A}, A -> A -> ?? bool. -Axiom struct_eq_correct: forall A (x y:A), WHEN struct_eq x y ~> b THEN b=true -> x=y. +Axiom struct_eq_correct: forall A (x y:A), WHEN struct_eq x y ~> b THEN if b then x=y else x<>y. Extract Constant struct_eq => "(=)". Hint Resolve struct_eq_correct: wlp. -- cgit From 014b2c474be0126a8a09f7138365d555c29af4a4 Mon Sep 17 00:00:00 2001 From: Sylvain Boulmé Date: Tue, 2 Apr 2019 07:26:58 +0200 Subject: comment on Asmblockdeps.is_constant --- mppa_k1c/Asmblockdeps.v | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/mppa_k1c/Asmblockdeps.v b/mppa_k1c/Asmblockdeps.v index c941e482..e3e2bca9 100644 --- a/mppa_k1c/Asmblockdeps.v +++ b/mppa_k1c/Asmblockdeps.v @@ -270,25 +270,28 @@ Definition op_eval (o: op) (l: list value) := end. -Definition is_constant (o: op): bool := - (* FIXME + (** Function [is_constant] is used for a small optimization inside the scheduling verifier. + It is good that it answers [true] as much as possible while satisfying [is_constant_correct] below. - => répondre "true" autant que possible mais en satisfaisant [is_constant_correct] ci-dessous. + BE CAREFUL that, [is_constant] must not depend on [ge]. + Otherwise, we would have an easy implementation: [match op_eval o nil with Some _ => true | _ => false end] - ATTENTION, is_constant ne doit pas dépendre de [ge]. - Sinon, on aurait une implémentation facile: [match op_eval o nil with Some _ => true | _ => false end] - - => REM: il n'est pas sûr que ce soit utile de faire qqchose de très exhaustif en pratique... - (ça sert juste à une petite optimisation du vérificateur de scheduling). + => REM: when [is_constant] is not complete w.r.t [is_constant_correct], this should have only a very little impact + on the performance of the scheduling verifier... *) + +Definition is_constant (o: op): bool := match o with - | Constant _ => true + | Constant _ | OArithR _ | OArithRI32 _ _ | OArithRI64 _ _ | OArithRF32 _ _ | OArithRF64 _ _ => true | _ => false end. Lemma is_constant_correct o: is_constant o = true -> op_eval o nil <> None. Proof. destruct o; simpl; try congruence. + destruct ao; simpl; try congruence; + destruct n; simpl; try congruence; + unfold arith_eval; destruct Ge; simpl; try congruence. Qed. Definition arith_op_eq (o1 o2: arith_op): ?? bool := -- cgit From 2e54a0fe8111e473361f9c1ab44b5d1cf9d70020 Mon Sep 17 00:00:00 2001 From: Sylvain Boulmé Date: Tue, 2 Apr 2019 07:53:34 +0200 Subject: robustness of Asmblockdeps.*op_eq --- mppa_k1c/Asmblockdeps.v | 65 +++++++++++++++++++++++++++++-------------------- 1 file changed, 38 insertions(+), 27 deletions(-) diff --git a/mppa_k1c/Asmblockdeps.v b/mppa_k1c/Asmblockdeps.v index e3e2bca9..6d87a34d 100644 --- a/mppa_k1c/Asmblockdeps.v +++ b/mppa_k1c/Asmblockdeps.v @@ -359,19 +359,24 @@ Qed. Hint Resolve store_op_eq_correct: wlp. Opaque store_op_eq_correct. -(* TODO: rewrite control_op_eq in a robust style against the miss of a case - cf. arith_op_eq above *) Definition control_op_eq (c1 c2: control_op): ?? bool := - match c1, c2 with - | Oj_l l1, Oj_l l2 => phys_eq l1 l2 - | Ocb bt1 l1, Ocb bt2 l2 => iandb (phys_eq bt1 bt2) (phys_eq l1 l2) - | Ocbu bt1 l1, Ocbu bt2 l2 => iandb (phys_eq bt1 bt2) (phys_eq l1 l2) - | Ojumptable tbl1, Ojumptable tbl2 => phys_eq tbl1 tbl2 - | Odiv, Odiv => RET true - | Odivu, Odivu => RET true - | OIncremPC sz1, OIncremPC sz2 => RET (Z.eqb sz1 sz2) - | OError, OError => RET true - | _, _ => RET false + match c1 with + | Oj_l l1 => + match c2 with Oj_l l2 => phys_eq l1 l2 | _ => RET false end + | Ocb bt1 l1 => + match c2 with Ocb bt2 l2 => iandb (phys_eq bt1 bt2) (phys_eq l1 l2) | _ => RET false end + | Ocbu bt1 l1 => + match c2 with Ocbu bt2 l2 => iandb (phys_eq bt1 bt2) (phys_eq l1 l2) | _ => RET false end + | Ojumptable tbl1 => + match c2 with Ojumptable tbl2 => phys_eq tbl1 tbl2 | _ => RET false end + | Odiv => + match c2 with Odiv => RET true | _ => RET false end + | Odivu => + match c2 with Odivu => RET true | _ => RET false end + | OIncremPC sz1 => + match c2 with OIncremPC sz2 => RET (Z.eqb sz1 sz2) | _ => RET false end + | OError => + match c2 with OError => RET true | _ => RET false end end. Lemma control_op_eq_correct c1 c2: @@ -382,22 +387,28 @@ Qed. Hint Resolve control_op_eq_correct: wlp. Opaque control_op_eq_correct. - -(* TODO: rewrite op_eq in a robust style against the miss of a case - cf. arith_op_eq above *) Definition op_eq (o1 o2: op): ?? bool := - match o1, o2 with - | Arith i1, Arith i2 => arith_op_eq i1 i2 - | Load i1, Load i2 => load_op_eq i1 i2 - | Store i1, Store i2 => store_op_eq i1 i2 - | Control i1, Control i2 => control_op_eq i1 i2 - | Allocframe sz1 pos1, Allocframe sz2 pos2 => iandb (RET (Z.eqb sz1 sz2)) (phys_eq pos1 pos2) - | Allocframe2 sz1 pos1, Allocframe2 sz2 pos2 => iandb (RET (Z.eqb sz1 sz2)) (phys_eq pos1 pos2) - | Freeframe sz1 pos1, Freeframe sz2 pos2 => iandb (RET (Z.eqb sz1 sz2)) (phys_eq pos1 pos2) - | Freeframe2 sz1 pos1, Freeframe2 sz2 pos2 => iandb (RET (Z.eqb sz1 sz2)) (phys_eq pos1 pos2) - | Constant c1, Constant c2 => phys_eq c1 c2 - | Fail, Fail => RET true - | _, _ => RET false + match o1 with + | Arith i1 => + match o2 with Arith i2 => arith_op_eq i1 i2 | _ => RET false end + | Load i1 => + match o2 with Load i2 => load_op_eq i1 i2 | _ => RET false end + | Store i1 => + match o2 with Store i2 => store_op_eq i1 i2 | _ => RET false end + | Control i1 => + match o2 with Control i2 => control_op_eq i1 i2 | _ => RET false end + | Allocframe sz1 pos1 => + match o2 with Allocframe sz2 pos2 => iandb (RET (Z.eqb sz1 sz2)) (phys_eq pos1 pos2) | _ => RET false end + | Allocframe2 sz1 pos1 => + match o2 with Allocframe2 sz2 pos2 => iandb (RET (Z.eqb sz1 sz2)) (phys_eq pos1 pos2) | _ => RET false end + | Freeframe sz1 pos1 => + match o2 with Freeframe sz2 pos2 => iandb (RET (Z.eqb sz1 sz2)) (phys_eq pos1 pos2) | _ => RET false end + | Freeframe2 sz1 pos1 => + match o2 with Freeframe2 sz2 pos2 => iandb (RET (Z.eqb sz1 sz2)) (phys_eq pos1 pos2) | _ => RET false end + | Constant c1 => + match o2 with Constant c2 => phys_eq c1 c2 | _ => RET false end + | Fail => + match o2 with Fail => RET true | _ => RET false end end. Theorem op_eq_correct o1 o2: -- cgit From 4adb0af96c3c0523438e86275f9e23ffdc69e4ba Mon Sep 17 00:00:00 2001 From: Cyril SIX Date: Tue, 2 Apr 2019 17:37:09 +0200 Subject: Added definition of PLoadRRR and PStoreRRR - no Asmblockgen generation yet --- mppa_k1c/Asm.v | 97 +++++++++------ mppa_k1c/Asmblock.v | 52 +++++--- mppa_k1c/Asmblockdeps.v | 226 +++++++++++++++++++++++++---------- mppa_k1c/Asmblockgenproof1.v | 25 ++-- mppa_k1c/Asmexpand.ml | 44 +++---- mppa_k1c/Asmvliw.v | 48 +++++--- mppa_k1c/PostpassSchedulingOracle.ml | 4 + mppa_k1c/PostpassSchedulingproof.v | 64 +++++++--- mppa_k1c/TargetPrinter.ml | 44 +++---- mppa_k1c/lib/Asmblockgenproof0.v | 18 +-- 10 files changed, 417 insertions(+), 205 deletions(-) diff --git a/mppa_k1c/Asm.v b/mppa_k1c/Asm.v index 2d708b79..115c8d6d 100644 --- a/mppa_k1c/Asm.v +++ b/mppa_k1c/Asm.v @@ -38,6 +38,11 @@ Require Import Errors. Definition label := positive. Definition preg := preg. +Inductive addressing : Type := + | AOff (ofs: offset) + | AReg (ro: ireg) +. + (** Syntax *) Inductive instruction : Type := (** pseudo instructions *) @@ -70,26 +75,26 @@ Inductive instruction : Type := | Ploopdo (count: ireg) (loopend: label) (** Loads **) - | Plb (rd: ireg) (ra: ireg) (ofs: offset) (**r load byte *) - | Plbu (rd: ireg) (ra: ireg) (ofs: offset) (**r load byte unsigned *) - | Plh (rd: ireg) (ra: ireg) (ofs: offset) (**r load half word *) - | Plhu (rd: ireg) (ra: ireg) (ofs: offset) (**r load half word unsigned *) - | Plw (rd: ireg) (ra: ireg) (ofs: offset) (**r load int32 *) - | Plw_a (rd: ireg) (ra: ireg) (ofs: offset) (**r load any32 *) - | Pld (rd: ireg) (ra: ireg) (ofs: offset) (**r load int64 *) - | Pld_a (rd: ireg) (ra: ireg) (ofs: offset) (**r load any64 *) - | Pfls (rd: freg) (ra: ireg) (ofs: offset) (**r load float *) - | Pfld (rd: freg) (ra: ireg) (ofs: offset) (**r load 64-bit float *) + | Plb (rd: ireg) (ra: ireg) (ofs: addressing) (**r load byte *) + | Plbu (rd: ireg) (ra: ireg) (ofs: addressing) (**r load byte unsigned *) + | Plh (rd: ireg) (ra: ireg) (ofs: addressing) (**r load half word *) + | Plhu (rd: ireg) (ra: ireg) (ofs: addressing) (**r load half word unsigned *) + | Plw (rd: ireg) (ra: ireg) (ofs: addressing) (**r load int32 *) + | Plw_a (rd: ireg) (ra: ireg) (ofs: addressing) (**r load any32 *) + | Pld (rd: ireg) (ra: ireg) (ofs: addressing) (**r load int64 *) + | Pld_a (rd: ireg) (ra: ireg) (ofs: addressing) (**r load any64 *) + | Pfls (rd: freg) (ra: ireg) (ofs: addressing) (**r load float *) + | Pfld (rd: freg) (ra: ireg) (ofs: addressing) (**r load 64-bit float *) (** Stores **) - | Psb (rs: ireg) (ra: ireg) (ofs: offset) (**r store byte *) - | Psh (rs: ireg) (ra: ireg) (ofs: offset) (**r store half byte *) - | Psw (rs: ireg) (ra: ireg) (ofs: offset) (**r store int32 *) - | Psw_a (rs: ireg) (ra: ireg) (ofs: offset) (**r store any32 *) - | Psd (rs: ireg) (ra: ireg) (ofs: offset) (**r store int64 *) - | Psd_a (rs: ireg) (ra: ireg) (ofs: offset) (**r store any64 *) - | Pfss (rs: freg) (ra: ireg) (ofs: offset) (**r store float *) - | Pfsd (rd: freg) (ra: ireg) (ofs: offset) (**r store 64-bit float *) + | Psb (rs: ireg) (ra: ireg) (ofs: addressing) (**r store byte *) + | Psh (rs: ireg) (ra: ireg) (ofs: addressing) (**r store half byte *) + | Psw (rs: ireg) (ra: ireg) (ofs: addressing) (**r store int32 *) + | Psw_a (rs: ireg) (ra: ireg) (ofs: addressing) (**r store any32 *) + | Psd (rs: ireg) (ra: ireg) (ofs: addressing) (**r store int64 *) + | Psd_a (rs: ireg) (ra: ireg) (ofs: addressing) (**r store any64 *) + | Pfss (rs: freg) (ra: ireg) (ofs: addressing) (**r store float *) + | Pfsd (rd: freg) (ra: ireg) (ofs: addressing) (**r store 64-bit float *) (** Arith RR *) | Pmv (rd rs: ireg) (**r register move *) @@ -364,26 +369,46 @@ Definition basic_to_instruction (b: basic) := | PArithARRI64 Asmblock.Pmaddil rd rs1 imm => Pmaddil rd rs1 imm (** Load *) - | PLoadRRO Asmblock.Plb rd ra ofs => Plb rd ra ofs - | PLoadRRO Asmblock.Plbu rd ra ofs => Plbu rd ra ofs - | PLoadRRO Asmblock.Plh rd ra ofs => Plh rd ra ofs - | PLoadRRO Asmblock.Plhu rd ra ofs => Plhu rd ra ofs - | PLoadRRO Asmblock.Plw rd ra ofs => Plw rd ra ofs - | PLoadRRO Asmblock.Plw_a rd ra ofs => Plw_a rd ra ofs - | PLoadRRO Asmblock.Pld rd ra ofs => Pld rd ra ofs - | PLoadRRO Asmblock.Pld_a rd ra ofs => Pld_a rd ra ofs - | PLoadRRO Asmblock.Pfls rd ra ofs => Pfls rd ra ofs - | PLoadRRO Asmblock.Pfld rd ra ofs => Pfld rd ra ofs + | PLoadRRO Asmblock.Plb rd ra ofs => Plb rd ra (AOff ofs) + | PLoadRRO Asmblock.Plbu rd ra ofs => Plbu rd ra (AOff ofs) + | PLoadRRO Asmblock.Plh rd ra ofs => Plh rd ra (AOff ofs) + | PLoadRRO Asmblock.Plhu rd ra ofs => Plhu rd ra (AOff ofs) + | PLoadRRO Asmblock.Plw rd ra ofs => Plw rd ra (AOff ofs) + | PLoadRRO Asmblock.Plw_a rd ra ofs => Plw_a rd ra (AOff ofs) + | PLoadRRO Asmblock.Pld rd ra ofs => Pld rd ra (AOff ofs) + | PLoadRRO Asmblock.Pld_a rd ra ofs => Pld_a rd ra (AOff ofs) + | PLoadRRO Asmblock.Pfls rd ra ofs => Pfls rd ra (AOff ofs) + | PLoadRRO Asmblock.Pfld rd ra ofs => Pfld rd ra (AOff ofs) + + | PLoadRRR Asmblock.Plb rd ra ro => Plb rd ra (AReg ro) + | PLoadRRR Asmblock.Plbu rd ra ro => Plbu rd ra (AReg ro) + | PLoadRRR Asmblock.Plh rd ra ro => Plh rd ra (AReg ro) + | PLoadRRR Asmblock.Plhu rd ra ro => Plhu rd ra (AReg ro) + | PLoadRRR Asmblock.Plw rd ra ro => Plw rd ra (AReg ro) + | PLoadRRR Asmblock.Plw_a rd ra ro => Plw_a rd ra (AReg ro) + | PLoadRRR Asmblock.Pld rd ra ro => Pld rd ra (AReg ro) + | PLoadRRR Asmblock.Pld_a rd ra ro => Pld_a rd ra (AReg ro) + | PLoadRRR Asmblock.Pfls rd ra ro => Pfls rd ra (AReg ro) + | PLoadRRR Asmblock.Pfld rd ra ro => Pfld rd ra (AReg ro) (** Store *) - | PStoreRRO Asmblock.Psb rd ra ofs => Psb rd ra ofs - | PStoreRRO Asmblock.Psh rd ra ofs => Psh rd ra ofs - | PStoreRRO Asmblock.Psw rd ra ofs => Psw rd ra ofs - | PStoreRRO Asmblock.Psw_a rd ra ofs => Psw_a rd ra ofs - | PStoreRRO Asmblock.Psd rd ra ofs => Psd rd ra ofs - | PStoreRRO Asmblock.Psd_a rd ra ofs => Psd_a rd ra ofs - | PStoreRRO Asmblock.Pfss rd ra ofs => Pfss rd ra ofs - | PStoreRRO Asmblock.Pfsd rd ra ofs => Pfsd rd ra ofs + | PStoreRRO Asmblock.Psb rd ra ofs => Psb rd ra (AOff ofs) + | PStoreRRO Asmblock.Psh rd ra ofs => Psh rd ra (AOff ofs) + | PStoreRRO Asmblock.Psw rd ra ofs => Psw rd ra (AOff ofs) + | PStoreRRO Asmblock.Psw_a rd ra ofs => Psw_a rd ra (AOff ofs) + | PStoreRRO Asmblock.Psd rd ra ofs => Psd rd ra (AOff ofs) + | PStoreRRO Asmblock.Psd_a rd ra ofs => Psd_a rd ra (AOff ofs) + | PStoreRRO Asmblock.Pfss rd ra ofs => Pfss rd ra (AOff ofs) + | PStoreRRO Asmblock.Pfsd rd ra ofs => Pfsd rd ra (AOff ofs) + + | PStoreRRR Asmblock.Psb rd ra ro => Psb rd ra (AReg ro) + | PStoreRRR Asmblock.Psh rd ra ro => Psh rd ra (AReg ro) + | PStoreRRR Asmblock.Psw rd ra ro => Psw rd ra (AReg ro) + | PStoreRRR Asmblock.Psw_a rd ra ro => Psw_a rd ra (AReg ro) + | PStoreRRR Asmblock.Psd rd ra ro => Psd rd ra (AReg ro) + | PStoreRRR Asmblock.Psd_a rd ra ro => Psd_a rd ra (AReg ro) + | PStoreRRR Asmblock.Pfss rd ra ro => Pfss rd ra (AReg ro) + | PStoreRRR Asmblock.Pfsd rd ra ro => Pfsd rd ra (AReg ro) end. diff --git a/mppa_k1c/Asmblock.v b/mppa_k1c/Asmblock.v index b4cf57ae..3656b91f 100644 --- a/mppa_k1c/Asmblock.v +++ b/mppa_k1c/Asmblock.v @@ -259,9 +259,11 @@ Inductive load_name_rro : Type := Inductive ld_instruction : Type := | PLoadRRO (i: load_name_rro) (rd: ireg) (ra: ireg) (ofs: offset) + | PLoadRRR (i: load_name_rro) (rd: ireg) (ra: ireg) (rofs: ireg) . Coercion PLoadRRO: load_name_rro >-> Funclass. +Coercion PLoadRRR: load_name_rro >-> Funclass. (** Stores **) Inductive store_name_rro : Type := @@ -277,9 +279,11 @@ Inductive store_name_rro : Type := Inductive st_instruction : Type := | PStoreRRO (i: store_name_rro) (rs: ireg) (ra: ireg) (ofs: offset) + | PStoreRRR (i: store_name_rro) (rs: ireg) (ra: ireg) (rofs: ireg) . Coercion PStoreRRO: store_name_rro >-> Funclass. +Coercion PStoreRRR: store_name_rro >-> Funclass. (** Arithmetic instructions **) Inductive arith_name_r : Type := @@ -1259,24 +1263,42 @@ Definition eval_offset (ofs: offset) : res ptrofs := end. Definition exec_load (chunk: memory_chunk) (rs: regset) (m: mem) - (d: ireg) (a: ireg) (ofs: offset) := + (d: ireg) (a: ireg) (ptr: ptrofs) := + match Mem.loadv chunk m (Val.offset_ptr (rs a) ptr) with + | None => Stuck + | Some v => Next (rs#d <- v) m + end +. + +Definition exec_load_offset (chunk: memory_chunk) (rs: regset) (m: mem) (d a: ireg) (ofs: offset) := match (eval_offset ofs) with - | OK ptr => - match Mem.loadv chunk m (Val.offset_ptr (rs a) ptr) with - | None => Stuck - | Some v => Next (rs#d <- v) m - end + | OK ptr => exec_load chunk rs m d a ptr + | _ => Stuck + end. + +Definition exec_load_reg (chunk: memory_chunk) (rs: regset) (m: mem) (d a ro: ireg) := + match (rs ro) with + | Vptr _ ofs => exec_load chunk rs m d a ofs | _ => Stuck end. Definition exec_store (chunk: memory_chunk) (rs: regset) (m: mem) - (s: ireg) (a: ireg) (ofs: offset) := + (s: ireg) (a: ireg) (ptr: ptrofs) := + match Mem.storev chunk m (Val.offset_ptr (rs a) ptr) (rs s) with + | None => Stuck + | Some m' => Next rs m' + end +. + +Definition exec_store_offset (chunk: memory_chunk) (rs: regset) (m: mem) (s a: ireg) (ofs: offset) := match (eval_offset ofs) with - | OK ptr => - match Mem.storev chunk m (Val.offset_ptr (rs a) ptr) (rs s) with - | None => Stuck - | Some m' => Next rs m' - end + | OK ptr => exec_store chunk rs m s a ptr + | _ => Stuck + end. + +Definition exec_store_reg (chunk: memory_chunk) (rs: regset) (m: mem) (s a ro: ireg) := + match (rs ro) with + | Vptr _ ofs => exec_store chunk rs m s a ofs | _ => Stuck end. @@ -1312,9 +1334,11 @@ Definition exec_basic_instr (bi: basic) (rs: regset) (m: mem) : outcome := match bi with | PArith ai => Next (exec_arith_instr ai rs) m - | PLoadRRO n d a ofs => exec_load (load_chunk n) rs m d a ofs + | PLoadRRO n d a ofs => exec_load_offset (load_chunk n) rs m d a ofs + | PLoadRRR n d a ro => exec_load_reg (load_chunk n) rs m d a ro - | PStoreRRO n s a ofs => exec_store (store_chunk n) rs m s a ofs + | PStoreRRO n s a ofs => exec_store_offset (store_chunk n) rs m s a ofs + | PStoreRRR n s a ro => exec_store_reg (store_chunk n) rs m s a ro | Pallocframe sz pos => let (m1, stk) := Mem.alloc m 0 sz in diff --git a/mppa_k1c/Asmblockdeps.v b/mppa_k1c/Asmblockdeps.v index dd876485..7e332895 100644 --- a/mppa_k1c/Asmblockdeps.v +++ b/mppa_k1c/Asmblockdeps.v @@ -72,12 +72,14 @@ Coercion OArithRRI64: arith_name_rri64 >-> Funclass. Inductive load_op := | OLoadRRO (n: load_name_rro) (ofs: offset) + | OLoadRRR (n: load_name_rro) . Coercion OLoadRRO: load_name_rro >-> Funclass. Inductive store_op := | OStoreRRO (n: store_name_rro) (ofs: offset) + | OStoreRRR (n: store_name_rro) . Coercion OStoreRRO: store_name_rro >-> Funclass. @@ -126,38 +128,58 @@ Definition arith_eval (ao: arith_op) (l: list value) := end. Definition exec_load_deps (chunk: memory_chunk) (m: mem) - (v: val) (ofs: offset) := + (v: val) (ptr: ptrofs) := + match Mem.loadv chunk m (Val.offset_ptr v ptr) with + | None => None + | Some vl => Some (Val vl) + end +. + +Definition exec_load_deps_offset (chunk: memory_chunk) (m: mem) (v: val) (ofs: offset) := let (ge, fn) := Ge in match (eval_offset ge ofs) with - | OK ptr => - match Mem.loadv chunk m (Val.offset_ptr v ptr) with - | None => None - | Some vl => Some (Val vl) - end + | OK ptr => exec_load_deps chunk m v ptr + | _ => None + end. + +Definition exec_load_deps_reg (chunk: memory_chunk) (m: mem) (v vo: val) := + match vo with + | Vptr _ ofs => exec_load_deps chunk m v ofs | _ => None end. Definition load_eval (lo: load_op) (l: list value) := match lo, l with - | OLoadRRO n ofs, [Val v; Memstate m] => exec_load_deps (load_chunk n) m v ofs + | OLoadRRO n ofs, [Val v; Memstate m] => exec_load_deps_offset (load_chunk n) m v ofs + | OLoadRRR n, [Val v; Val vo; Memstate m] => exec_load_deps_reg (load_chunk n) m v vo | _, _ => None end. Definition exec_store_deps (chunk: memory_chunk) (m: mem) - (vs va: val) (ofs: offset) := + (vs va: val) (ptr: ptrofs) := + match Mem.storev chunk m (Val.offset_ptr va ptr) vs with + | None => None + | Some m' => Some (Memstate m') + end +. + +Definition exec_store_deps_offset (chunk: memory_chunk) (m: mem) (vs va: val) (ofs: offset) := let (ge, fn) := Ge in match (eval_offset ge ofs) with - | OK ptr => - match Mem.storev chunk m (Val.offset_ptr va ptr) vs with - | None => None - | Some m' => Some (Memstate m') - end + | OK ptr => exec_store_deps chunk m vs va ptr + | _ => None + end. + +Definition exec_store_deps_reg (chunk: memory_chunk) (m: mem) (vs va vo: val) := + match vo with + | Vptr _ ofs => exec_store_deps chunk m vs va ofs | _ => None end. Definition store_eval (so: store_op) (l: list value) := match so, l with - | OStoreRRO n ofs, [Val vs; Val va; Memstate m] => exec_store_deps (store_chunk n) m vs va ofs + | OStoreRRO n ofs, [Val vs; Val va; Memstate m] => exec_store_deps_offset (store_chunk n) m vs va ofs + | OStoreRRR n, [Val vs; Val va; Val vo; Memstate m] => exec_store_deps_reg (store_chunk n) m vs va vo | _, _ => None end. @@ -337,26 +359,32 @@ Qed. Definition load_op_eq (o1 o2: load_op): ?? bool := match o1, o2 with | OLoadRRO n1 ofs1, OLoadRRO n2 ofs2 => iandb (phys_eq n1 n2) (phys_eq ofs1 ofs2) + | OLoadRRR n1, OLoadRRR n2 => phys_eq n1 n2 + | _, _ => RET false end. Lemma load_op_eq_correct o1 o2: WHEN load_op_eq o1 o2 ~> b THEN b = true -> o1 = o2. Proof. - destruct o1, o2; wlp_simplify. - apply andb_prop in H1; inversion H1; apply H in H2; apply H0 in H3; congruence. + destruct o1, o2; wlp_simplify; try discriminate. + - apply andb_prop in H1; inversion H1; apply H in H2; apply H0 in H3; congruence. + - congruence. Qed. Definition store_op_eq (o1 o2: store_op): ?? bool := match o1, o2 with | OStoreRRO n1 ofs1, OStoreRRO n2 ofs2 => iandb (phys_eq n1 n2) (phys_eq ofs1 ofs2) + | OStoreRRR n1, OStoreRRR n2 => phys_eq n1 n2 + | _, _ => RET false end. Lemma store_op_eq_correct o1 o2: WHEN store_op_eq o1 o2 ~> b THEN b = true -> o1 = o2. Proof. - destruct o1, o2; wlp_simplify. - apply andb_prop in H1; inversion H1; apply H in H2; apply H0 in H3; congruence. + destruct o1, o2; wlp_simplify; try discriminate. + - apply andb_prop in H1; inversion H1; apply H in H2; apply H0 in H3; congruence. + - congruence. Qed. (* TODO: rewrite control_op_eq in a robust style against the miss of a case @@ -586,7 +614,9 @@ Definition trans_basic (b: basic) : macro := match b with | PArith ai => trans_arith ai | PLoadRRO n d a ofs => [(#d, Op (Load (OLoadRRO n ofs)) (Name (#a) @ Name pmem @ Enil))] + | PLoadRRR n d a ro => [(#d, Op (Load (OLoadRRR n)) (Name (#a) @ Name (#ro) @ Name pmem @ Enil))] | PStoreRRO n s a ofs => [(pmem, Op (Store (OStoreRRO n ofs)) (Name (#s) @ Name (#a) @ Name pmem @ Enil))] + | PStoreRRR n s a ro => [(pmem, Op (Store (OStoreRRR n)) (Name (#s) @ Name (#a) @ Name (#ro) @ Name pmem @ Enil))] | Pallocframe sz pos => [(#FP, Name (#SP)); (#SP, Op (Allocframe2 sz pos) (Name (#SP) @ Name pmem @ Enil)); (#RTMP, Op (Constant Vundef) Enil); (pmem, Op (Allocframe sz pos) (Old (Name (#SP)) @ Name pmem @ Enil))] | Pfreeframe sz pos => [(pmem, Op (Freeframe sz pos) (Name (#SP) @ Name pmem @ Enil)); @@ -799,25 +829,47 @@ Proof. intros. destruct b. (* Arith *) - simpl in H. inv H. simpl macro_run. eapply trans_arith_correct; eauto. + (* Load *) - simpl in H. destruct i. - unfold exec_load in H; destruct (eval_offset _ _) eqn:EVALOFF; try discriminate; - destruct (Mem.loadv _ _ _) eqn:MEML; try discriminate; inv H; inv H0; - eexists; split; try split; - [ simpl; rewrite EVALOFF; rewrite H; pose (H1 ra); simpl in e; rewrite e; rewrite MEML; reflexivity| - Simpl| - intros rr; destruct rr; Simpl; - destruct (ireg_eq g rd); [ - subst; Simpl| - Simpl; rewrite assign_diff; pose (H1 g); simpl in e; try assumption; Simpl; unfold ppos; apply not_eq_ireg_to_pos; assumption]]. + (* Load Offset *) + + destruct i. all: + unfold exec_load_offset in H; destruct (eval_offset _ _) eqn:EVALOFF; try discriminate; unfold exec_load in H; + destruct (Mem.loadv _ _ _) eqn:MEML; try discriminate; inv H; inv H0; + eexists; split; try split; [ + simpl; rewrite EVALOFF; rewrite H; rewrite (H1 ra); unfold exec_load_deps; simpl in MEML; rewrite MEML; reflexivity + | Simpl + | intros rr; destruct rr; Simpl; destruct (ireg_eq g rd); subst; Simpl ]. + (* Load Reg *) + + destruct i. all: + unfold exec_load_reg in H; destruct (rs rofs) eqn:ROFS; try discriminate; unfold exec_load in H; + destruct (Mem.loadv _ _ _) eqn:MEML; try discriminate; inv H; inv H0; + eexists; split; try split; [ + simpl; rewrite H; rewrite (H1 rofs); rewrite (H1 ra); unfold exec_load_deps_reg; rewrite ROFS; + unfold exec_load_deps; simpl in MEML; rewrite MEML; reflexivity + | Simpl + | intros rr; destruct rr; Simpl; destruct (ireg_eq g rd); subst; Simpl ]. + (* Store *) - simpl in H. destruct i. - all: unfold exec_store in H; destruct (eval_offset _ _) eqn:EVALOFF; try discriminate; - destruct (Mem.storev _ _ _ _) eqn:MEML; try discriminate; inv H; inv H0; - eexists; split; try split; - [ simpl; rewrite EVALOFF; rewrite H; pose (H1 ra); simpl in e; rewrite e; pose (H1 rs0); simpl in e0; rewrite e0; rewrite MEML; reflexivity - | Simpl - | intros rr; destruct rr; Simpl]. + (* Store Offset *) + + destruct i. all: + unfold exec_store_offset in H; destruct (eval_offset _ _) eqn:EVALOFF; try discriminate; unfold exec_store in H; + destruct (Mem.storev _ _ _ _) eqn:MEML; try discriminate; inv H; inv H0; + eexists; split; try split; + [ simpl; rewrite EVALOFF; rewrite H; rewrite (H1 ra); rewrite (H1 rs0); unfold exec_store_deps; simpl in MEML; rewrite MEML; reflexivity + | Simpl + | intros rr; destruct rr; Simpl ]. + (* Store Reg *) + + destruct i. all: + unfold exec_store_reg in H; destruct (rs rofs) eqn:ROFS; try discriminate; unfold exec_store in H; + destruct (Mem.storev _ _ _ _) eqn:MEML; try discriminate; inv H; inv H0; + eexists; split; try split; + [ simpl; rewrite H; rewrite (H1 rofs); rewrite (H1 ra); rewrite (H1 rs0); unfold exec_store_deps_reg; rewrite ROFS; + unfold exec_store_deps; simpl in MEML; rewrite MEML; reflexivity + | Simpl + | intros rr; destruct rr; Simpl ]. + (* Allocframe *) - simpl in H. destruct (Mem.alloc _ _ _) eqn:MEMAL. destruct (Mem.store _ _ _ _) eqn:MEMS; try discriminate. inv H. inv H0. eexists. split; try split. @@ -1155,13 +1207,28 @@ Lemma forward_simu_basic_instr_stuck: Proof. intros. inv H1. unfold exec_basic_instr in H0. destruct i; try discriminate. (* PLoad *) - - destruct i; destruct i. - all: simpl; rewrite H2; pose (H3 ra); simpl in e; rewrite e; clear e; - unfold exec_load in H0; destruct (eval_offset _ _); auto; destruct (Mem.loadv _ _ _); auto; discriminate. + - destruct i. + (* Load Offset *) + + destruct i. all: + simpl; rewrite H2; rewrite (H3 ra); unfold exec_load_offset in H0; destruct (eval_offset _ _); auto; + unfold exec_load in H0; unfold exec_load_deps; simpl in H0; destruct (Mem.loadv _ _ _); auto; discriminate. + (* Load Reg *) + + destruct i. all: + simpl; rewrite H2; rewrite (H3 rofs); rewrite (H3 ra); unfold exec_load_reg in H0; unfold exec_load_deps_reg; + destruct (rs rofs); auto; unfold exec_load in H0; simpl in H0; unfold exec_load_deps; destruct (Mem.loadv _ _ _); auto; discriminate. + (* PStore *) - - destruct i; destruct i; - simpl; rewrite H2; pose (H3 ra); simpl in e; rewrite e; clear e; pose (H3 rs0); simpl in e; rewrite e; clear e; - unfold exec_store in H0; destruct (eval_offset _ _); auto; destruct (Mem.storev _ _ _); auto; discriminate. + - destruct i. + (* Store Offset *) + + destruct i. all: + simpl; rewrite H2; rewrite (H3 ra); rewrite (H3 rs0); unfold exec_store_offset in H0; destruct (eval_offset _ _); auto; + unfold exec_store in H0; simpl in H0; unfold exec_store_deps; destruct (Mem.storev _ _ _); auto; discriminate. + (* Store Reg *) + + destruct i. all: + simpl; rewrite H2; rewrite (H3 rofs); rewrite (H3 ra); rewrite (H3 rs0); simpl in H0; unfold exec_store_reg in H0; + unfold exec_store_deps_reg; destruct (rs rofs); auto; unfold exec_store in H0; unfold exec_store_deps; + destruct (Mem.storev _ _ _ _); auto; discriminate. + (* Pallocframe *) - simpl. Simpl. pose (H3 SP); simpl in e; rewrite e; clear e. rewrite H2. destruct (Mem.alloc _ _ _). simpl in H0. destruct (Mem.store _ _ _ _); try discriminate. reflexivity. @@ -1521,6 +1588,7 @@ Definition string_of_name_lrro (n: load_name_rro) : pstring := Definition string_of_load (op: load_op): pstring := match op with | OLoadRRO n _ => string_of_name_lrro n + | OLoadRRR n => string_of_name_lrro n end. Definition string_of_name_srro (n: store_name_rro) : pstring := @@ -1538,6 +1606,7 @@ Definition string_of_name_srro (n: store_name_rro) : pstring := Definition string_of_store (op: store_op) : pstring := match op with | OStoreRRO n _ => string_of_name_srro n + | OStoreRRR n => string_of_name_srro n end. Definition string_of_control (op: control_op) : pstring := @@ -1731,23 +1800,46 @@ Proof. - simpl in H. inversion H. subst rsw' mw'. simpl macro_prun. eapply trans_arith_par_correct; eauto. (* Load *) - simpl in H. destruct i. - unfold parexec_load in H; destruct (eval_offset _ _) eqn:EVALOFF; try discriminate; - destruct (Mem.loadv _ _ _) eqn:MEML; try discriminate; inv H. inv MSR; inv MSW; - eexists; split; try split; - [ simpl; rewrite EVALOFF; rewrite H; pose (H0 ra); simpl in e; rewrite e; rewrite MEML; reflexivity| - Simpl| - intros rr; destruct rr; Simpl; - destruct (ireg_eq g rd); [ - subst; Simpl| - Simpl; rewrite assign_diff; pose (H1 g); simpl in e; try assumption; Simpl; unfold ppos; apply not_eq_ireg_to_pos; assumption]]. + (* Load Offset *) + + destruct i; simpl load_chunk in H. all: + unfold parexec_load_offset in H; destruct (eval_offset _ _) eqn:EVALOFF; try discriminate; + unfold parexec_load in H; destruct (Mem.loadv _ _ _) eqn:MEML; try discriminate; inv H; inv MSR; inv MSW; + eexists; split; try split; + [ simpl; rewrite EVALOFF; rewrite H; rewrite (H0 ra); unfold exec_load_deps; rewrite MEML; reflexivity + | Simpl + | intros rr; destruct rr; Simpl; destruct (ireg_eq g rd); subst; Simpl ]. + + (* Load Reg *) + + destruct i; simpl load_chunk in H. all: + unfold parexec_load_reg in H; destruct (rsr rofs) eqn:ROFS; try discriminate; + unfold parexec_load in H; destruct (Mem.loadv _ _ _) eqn:MEML; try discriminate; inv H; inv MSR; inv MSW; + eexists; split; try split; + [ simpl; rewrite H; rewrite (H0 rofs); rewrite (H0 ra); unfold exec_load_deps_reg; rewrite ROFS; + unfold exec_load_deps; rewrite MEML; reflexivity + | Simpl + | intros rr; destruct rr; Simpl; destruct (ireg_eq g rd); subst; Simpl ]. + (* Store *) - simpl in H. destruct i. - unfold parexec_store in H; destruct (eval_offset _ _) eqn:EVALOFF; try discriminate. - destruct (Mem.storev _ _ _ _) eqn:MEML; try discriminate. inv H; inv MSR; inv MSW. - eexists; split; try split. - * simpl. rewrite EVALOFF. rewrite H. rewrite (H0 ra). rewrite (H0 rs). rewrite MEML. reflexivity. - * Simpl. - * intros rr; destruct rr; Simpl. + (* Store Offset *) + + destruct i; simpl store_chunk in H. all: + unfold parexec_store_offset in H; destruct (eval_offset _ _) eqn:EVALOFF; try discriminate; + unfold parexec_store in H; destruct (Mem.storev _ _ _ _) eqn:MEML; try discriminate; inv H; inv MSR; inv MSW; + eexists; split; try split; + [ simpl; rewrite EVALOFF; rewrite H; rewrite (H0 ra); rewrite (H0 rs); unfold exec_store_deps; rewrite MEML; reflexivity + | Simpl + | intros rr; destruct rr; Simpl ]. + + (* Store Reg *) + + destruct i; simpl store_chunk in H. all: + unfold parexec_store_reg in H; destruct (rsr rofs) eqn:ROFS; try discriminate; + unfold parexec_store in H; destruct (Mem.storev _ _ _ _) eqn:MEML; try discriminate; inv H; inv MSR; inv MSW; + eexists; split; try split; + [ simpl; rewrite H; rewrite (H0 rofs); rewrite (H0 ra); rewrite (H0 rs); unfold exec_store_deps_reg; rewrite ROFS; + unfold exec_store_deps; rewrite MEML; reflexivity + | Simpl + | intros rr; destruct rr; Simpl ]. + (* Allocframe *) - simpl in H. destruct (Mem.alloc _ _ _) eqn:MEMAL. destruct (Mem.store _ _ _ _) eqn:MEMS; try discriminate. inv H. inv MSR. inv MSW. eexists. split; try split. @@ -1785,13 +1877,27 @@ Proof. intros GENV MSR MSW H0. inv MSR; inv MSW. unfold parexec_basic_instr in H0. destruct bi; try discriminate. (* PLoad *) - - destruct i; destruct i. - all: simpl; rewrite H; rewrite (H1 ra); unfold parexec_load in H0; - destruct (eval_offset _ _); auto; destruct (Mem.loadv _ _ _); auto; discriminate. + - destruct i. + (* Load Offset *) + + destruct i; simpl in H0. all: + simpl; rewrite H; rewrite (H1 ra); unfold parexec_load_offset in H0; destruct (eval_offset _ _); auto; + unfold parexec_load in H0; unfold exec_load_deps; destruct (Mem.loadv _ _ _); auto; discriminate. + (* Load Reg *) + + destruct i; simpl in H0. all: + simpl; rewrite H; rewrite (H1 rofs); rewrite (H1 ra); unfold parexec_load_reg in H0; unfold exec_load_deps_reg; + destruct (rsr rofs); auto; unfold parexec_load in H0; unfold exec_load_deps; destruct (Mem.loadv _ _ _); auto; discriminate. + (* PStore *) - - destruct i; destruct i; - simpl; rewrite H; rewrite (H1 ra); rewrite (H1 rs); - unfold parexec_store in H0; destruct (eval_offset _ _); auto; destruct (Mem.storev _ _ _); auto; discriminate. + - destruct i. + (* Store Offset *) + + destruct i; simpl in H0. all: + simpl; rewrite H; rewrite (H1 ra); rewrite (H1 rs); unfold parexec_store_offset in H0; destruct (eval_offset _ _); auto; + unfold parexec_store in H0; unfold exec_store_deps; destruct (Mem.storev _ _ _ _); auto; discriminate. + + (* Store Reg *) + + destruct i; simpl in H0. all: + simpl; rewrite H; rewrite (H1 ra); rewrite (H1 rs); rewrite (H1 rofs); unfold parexec_store_reg in H0; unfold exec_store_deps_reg; + destruct (rsr rofs); auto; unfold parexec_store in H0; unfold exec_store_deps; destruct (Mem.storev _ _ _ _); auto; discriminate. (* Pallocframe *) - simpl. Simpl. rewrite (H1 SP). rewrite H. destruct (Mem.alloc _ _ _). simpl in H0. destruct (Mem.store _ _ _ _); try discriminate. reflexivity. diff --git a/mppa_k1c/Asmblockgenproof1.v b/mppa_k1c/Asmblockgenproof1.v index 5486a497..f8bbf7f4 100644 --- a/mppa_k1c/Asmblockgenproof1.v +++ b/mppa_k1c/Asmblockgenproof1.v @@ -1763,7 +1763,7 @@ Qed. Lemma indexed_load_access_correct: forall chunk (mk_instr: ireg -> offset -> basic) rd m, (forall base ofs rs, - exec_basic_instr ge (mk_instr base ofs) rs m = exec_load ge chunk rs m rd base ofs) -> + exec_basic_instr ge (mk_instr base ofs) rs m = exec_load_offset ge chunk rs m rd base ofs) -> forall (base: ireg) ofs k (rs: regset) v, Mem.loadv chunk m (Val.offset_ptr rs#base ofs) = Some v -> base <> RTMP -> @@ -1777,14 +1777,14 @@ Proof. intros (base' & ofs' & rs' & ptr' & A & PtrEq & B & C). econstructor; split. eapply exec_straight_opt_right. eexact A. apply exec_straight_one. rewrite EXEC. - unfold exec_load. rewrite PtrEq. rewrite B, LOAD. eauto. Simpl. + unfold exec_load_offset. rewrite PtrEq. unfold exec_load. rewrite B, LOAD. eauto. Simpl. split; intros; Simpl. auto. Qed. Lemma indexed_store_access_correct: forall chunk (mk_instr: ireg -> offset -> basic) r1 m, (forall base ofs rs, - exec_basic_instr ge (mk_instr base ofs) rs m = exec_store ge chunk rs m r1 base ofs) -> + exec_basic_instr ge (mk_instr base ofs) rs m = exec_store_offset ge chunk rs m r1 base ofs) -> forall (base: ireg) ofs k (rs: regset) m', Mem.storev chunk m (Val.offset_ptr rs#base ofs) (rs#r1) = Some m' -> base <> RTMP -> r1 <> RTMP -> @@ -1797,12 +1797,11 @@ Proof. intros (base' & ofs' & rs' & ptr' & A & PtrEq & B & C). econstructor; split. eapply exec_straight_opt_right. eapply A. apply exec_straight_one. rewrite EXEC. - unfold exec_store. rewrite PtrEq. rewrite B, C, STORE. + unfold exec_store_offset. rewrite PtrEq. unfold exec_store. rewrite B, C, STORE. eauto. discriminate. { intro. inv H. contradiction. } auto. -(* intros; Simpl. rewrite C; auto. *) Qed. Lemma loadind_correct: @@ -1821,7 +1820,7 @@ Proof. /\ c = indexed_memory_access mk_instr base ofs :: k /\ forall base' ofs' rs', exec_basic_instr ge (mk_instr base' ofs') rs' m = - exec_load ge (chunk_of_type ty) rs' m rd base' ofs'). + exec_load_offset ge (chunk_of_type ty) rs' m rd base' ofs'). { unfold loadind in TR. destruct ty, (preg_of dst); inv TR; econstructor; esplit; eauto. } destruct A as (mk_instr & rd & rdEq & B & C). subst c. rewrite rdEq. @@ -1843,7 +1842,7 @@ Proof. /\ c = indexed_memory_access mk_instr base ofs :: k /\ forall base' ofs' rs', exec_basic_instr ge (mk_instr base' ofs') rs' m = - exec_store ge (chunk_of_type ty) rs' m rr base' ofs'). + exec_store_offset ge (chunk_of_type ty) rs' m rr base' ofs'). { unfold storeind in TR. destruct ty, (preg_of src); inv TR; econstructor; esplit; eauto. } destruct A as (mk_instr & rr & rsEq & B & C). subst c. eapply indexed_store_access_correct; eauto with asmgen. @@ -1945,7 +1944,7 @@ Qed. Lemma transl_load_access_correct: forall chunk (mk_instr: ireg -> offset -> basic) addr args k c rd (rs: regset) m v v', (forall base ofs rs, - exec_basic_instr ge (mk_instr base ofs) rs m = exec_load ge chunk rs m rd base ofs) -> + exec_basic_instr ge (mk_instr base ofs) rs m = exec_load_offset ge chunk rs m rd base ofs) -> transl_memory_access mk_instr addr args k = OK c -> eval_addressing ge rs#SP addr (map rs (map preg_of args)) = Some v -> Mem.loadv chunk m v = Some v' -> @@ -1959,14 +1958,14 @@ Proof. intros (base & ofs & rs' & ptr & A & PtrEq & B & C). econstructor; split. eapply exec_straight_opt_right. eexact A. apply exec_straight_one. - rewrite INSTR. unfold exec_load. rewrite PtrEq, B, LOAD. reflexivity. Simpl. + rewrite INSTR. unfold exec_load_offset. unfold exec_load. rewrite PtrEq, B, LOAD. reflexivity. Simpl. split; intros; Simpl. auto. Qed. Lemma transl_store_access_correct: forall chunk (mk_instr: ireg -> offset -> basic) addr args k c r1 (rs: regset) m v m', (forall base ofs rs, - exec_basic_instr ge (mk_instr base ofs) rs m = exec_store ge chunk rs m r1 base ofs) -> + exec_basic_instr ge (mk_instr base ofs) rs m = exec_store_offset ge chunk rs m r1 base ofs) -> transl_memory_access mk_instr addr args k = OK c -> eval_addressing ge rs#SP addr (map rs (map preg_of args)) = Some v -> Mem.storev chunk m v rs#r1 = Some m' -> @@ -1980,7 +1979,7 @@ Proof. intros (base & ofs & rs' & ptr & A & PtrEq & B & C). econstructor; split. eapply exec_straight_opt_right. eexact A. apply exec_straight_one. - rewrite INSTR. unfold exec_store. rewrite PtrEq, B. rewrite C; try discriminate. rewrite STORE. auto. + rewrite INSTR. unfold exec_store_offset. unfold exec_store. rewrite PtrEq, B. rewrite C; try discriminate. rewrite STORE. auto. intro. inv H. contradiction. auto. Qed. @@ -2000,7 +1999,7 @@ Proof. preg_of dst = IR rd /\ transl_memory_access mk_instr addr args k = OK c /\ forall base ofs rs, - exec_basic_instr ge (mk_instr base ofs) rs m = exec_load ge chunk rs m rd base ofs). + exec_basic_instr ge (mk_instr base ofs) rs m = exec_load_offset ge chunk rs m rd base ofs). { unfold transl_load in TR; destruct chunk; ArgsInv; econstructor; (esplit; eauto). } destruct A as (mk_instr & rd & rdEq & B & C). rewrite rdEq. eapply transl_load_access_correct; eauto with asmgen. @@ -2020,7 +2019,7 @@ Proof. preg_of src = IR rr /\ transl_memory_access mk_instr addr args k = OK c /\ (forall base ofs rs, - exec_basic_instr ge (mk_instr base ofs) rs m = exec_store ge chunk' rs m rr base ofs) + exec_basic_instr ge (mk_instr base ofs) rs m = exec_store_offset ge chunk' rs m rr base ofs) /\ Mem.storev chunk m a rs#(preg_of src) = Mem.storev chunk' m a rs#(preg_of src)). { unfold transl_store in TR; destruct chunk; ArgsInv; (econstructor; econstructor; econstructor; split; [eauto | split; [eassumption | split; [ intros; simpl; reflexivity | auto]]]). diff --git a/mppa_k1c/Asmexpand.ml b/mppa_k1c/Asmexpand.ml index f1528389..a9f17f33 100644 --- a/mppa_k1c/Asmexpand.ml +++ b/mppa_k1c/Asmexpand.ml @@ -157,10 +157,10 @@ let expand_builtin_memcpy_big sz al src dst = let lbl = new_label() in emit (Ploopdo (tmpbuf, lbl)); emit Psemi; - emit (Plb (tmpbuf, srcptr, Asmblock.Ofsimm Z.zero)); + emit (Plb (tmpbuf, srcptr, AOff (Asmblock.Ofsimm Z.zero))); emit (Paddil (srcptr, srcptr, Z.one)); emit Psemi; - emit (Psb (tmpbuf, dstptr, Asmblock.Ofsimm Z.zero)); + emit (Psb (tmpbuf, dstptr, AOff (Asmblock.Ofsimm Z.zero))); emit (Paddil (dstptr, dstptr, Z.one)); emit Psemi; emit (Plabel lbl);; @@ -176,30 +176,30 @@ let expand_builtin_memcpy sz al args = let expand_builtin_vload_common chunk base ofs res = match chunk, res with | Mint8unsigned, BR(Asmblock.IR res) -> - emit (Plbu (res, base, Asmblock.Ofsimm ofs)) + emit (Plbu (res, base, AOff (Asmblock.Ofsimm ofs))) | Mint8signed, BR(Asmblock.IR res) -> - emit (Plb (res, base, Asmblock.Ofsimm ofs)) + emit (Plb (res, base, AOff (Asmblock.Ofsimm ofs))) | Mint16unsigned, BR(Asmblock.IR res) -> - emit (Plhu (res, base, Asmblock.Ofsimm ofs)) + emit (Plhu (res, base, AOff (Asmblock.Ofsimm ofs))) | Mint16signed, BR(Asmblock.IR res) -> - emit (Plh (res, base, Asmblock.Ofsimm ofs)) + emit (Plh (res, base, AOff (Asmblock.Ofsimm ofs))) | Mint32, BR(Asmblock.IR res) -> - emit (Plw (res, base, Asmblock.Ofsimm ofs)) + emit (Plw (res, base, AOff (Asmblock.Ofsimm ofs))) | Mint64, BR(Asmblock.IR res) -> - emit (Pld (res, base, Asmblock.Ofsimm ofs)) + emit (Pld (res, base, AOff (Asmblock.Ofsimm ofs))) | Mint64, BR_splitlong(BR(Asmblock.IR res1), BR(Asmblock.IR res2)) -> let ofs' = Ptrofs.add ofs _4 in if base <> res2 then begin - emit (Plw (res2, base, Asmblock.Ofsimm ofs)); - emit (Plw (res1, base, Asmblock.Ofsimm ofs')) + emit (Plw (res2, base, AOff (Asmblock.Ofsimm ofs))); + emit (Plw (res1, base, AOff (Asmblock.Ofsimm ofs'))) end else begin - emit (Plw (res1, base, Asmblock.Ofsimm ofs')); - emit (Plw (res2, base, Asmblock.Ofsimm ofs)) + emit (Plw (res1, base, AOff (Asmblock.Ofsimm ofs'))); + emit (Plw (res2, base, AOff (Asmblock.Ofsimm ofs))) end | Mfloat32, BR(Asmblock.IR res) -> - emit (Pfls (res, base, Asmblock.Ofsimm ofs)) + emit (Pfls (res, base, AOff (Asmblock.Ofsimm ofs))) | Mfloat64, BR(Asmblock.IR res) -> - emit (Pfld (res, base, Asmblock.Ofsimm ofs)) + emit (Pfld (res, base, AOff (Asmblock.Ofsimm ofs))) | _ -> assert false @@ -218,21 +218,21 @@ let expand_builtin_vload chunk args res = let expand_builtin_vstore_common chunk base ofs src = match chunk, src with | (Mint8signed | Mint8unsigned), BA(Asmblock.IR src) -> - emit (Psb (src, base, Asmblock.Ofsimm ofs)) + emit (Psb (src, base, AOff (Asmblock.Ofsimm ofs))) | (Mint16signed | Mint16unsigned), BA(Asmblock.IR src) -> - emit (Psh (src, base, Asmblock.Ofsimm ofs)) + emit (Psh (src, base, AOff (Asmblock.Ofsimm ofs))) | Mint32, BA(Asmblock.IR src) -> - emit (Psw (src, base, Asmblock.Ofsimm ofs)) + emit (Psw (src, base, AOff (Asmblock.Ofsimm ofs))) | Mint64, BA(Asmblock.IR src) -> - emit (Psd (src, base, Asmblock.Ofsimm ofs)) + emit (Psd (src, base, AOff (Asmblock.Ofsimm ofs))) | Mint64, BA_splitlong(BA(Asmblock.IR src1), BA(Asmblock.IR src2)) -> let ofs' = Ptrofs.add ofs _4 in - emit (Psw (src2, base, Asmblock.Ofsimm ofs)); - emit (Psw (src1, base, Asmblock.Ofsimm ofs')) + emit (Psw (src2, base, AOff (Asmblock.Ofsimm ofs))); + emit (Psw (src1, base, AOff (Asmblock.Ofsimm ofs'))) | Mfloat32, BA(Asmblock.IR src) -> - emit (Pfss (src, base, Asmblock.Ofsimm ofs)) + emit (Pfss (src, base, AOff (Asmblock.Ofsimm ofs))) | Mfloat64, BA(Asmblock.IR src) -> - emit (Pfsd (src, base, Asmblock.Ofsimm ofs)) + emit (Pfsd (src, base, AOff (Asmblock.Ofsimm ofs))) | _ -> assert false diff --git a/mppa_k1c/Asmvliw.v b/mppa_k1c/Asmvliw.v index d553c612..cae79287 100644 --- a/mppa_k1c/Asmvliw.v +++ b/mppa_k1c/Asmvliw.v @@ -70,24 +70,42 @@ Definition parexec_arith_instr (ai: ar_instruction) (rsr rsw: regset): regset := (* TODO: factoriser ? *) Definition parexec_load (chunk: memory_chunk) (rsr rsw: regset) (mr mw: mem) - (d: ireg) (a: ireg) (ofs: offset) := + (d: ireg) (a: ireg) (ptr: ptrofs) := + match Mem.loadv chunk mr (Val.offset_ptr (rsr a) ptr) with + | None => Stuck + | Some v => Next (rsw#d <- v) mw + end +. + +Definition parexec_load_offset (chunk: memory_chunk) (rsr rsw: regset) (mr mw: mem) (d a: ireg) (ofs: offset) := match (eval_offset ge ofs) with - | OK ptr => - match Mem.loadv chunk mr (Val.offset_ptr (rsr a) ptr) with - | None => Stuck - | Some v => Next (rsw#d <- v) mw - end + | OK ptr => parexec_load chunk rsr rsw mr mw d a ptr + | _ => Stuck + end. + +Definition parexec_load_reg (chunk: memory_chunk) (rsr rsw: regset) (mr mw: mem) (d a ro: ireg) := + match (rsr ro) with + | Vptr _ ofs => parexec_load chunk rsr rsw mr mw d a ofs | _ => Stuck end. Definition parexec_store (chunk: memory_chunk) (rsr rsw: regset) (mr mw: mem) - (s: ireg) (a: ireg) (ofs: offset) := + (s: ireg) (a: ireg) (ptr: ptrofs) := + match Mem.storev chunk mr (Val.offset_ptr (rsr a) ptr) (rsr s) with + | None => Stuck + | Some m' => Next rsw m' + end +. + +Definition parexec_store_offset (chunk: memory_chunk) (rsr rsw: regset) (mr mw: mem) (s a: ireg) (ofs: offset) := match (eval_offset ge ofs) with - | OK ptr => - match Mem.storev chunk mr (Val.offset_ptr (rsr a) ptr) (rsr s) with - | None => Stuck - | Some m' => Next rsw m' - end + | OK ptr => parexec_store chunk rsr rsw mr mw s a ptr + | _ => Stuck + end. + +Definition parexec_store_reg (chunk: memory_chunk) (rsr rsw: regset) (mr mw: mem) (s a ro: ireg) := + match (rsr ro) with + | Vptr _ ofs => parexec_store chunk rsr rsw mr mw s a ofs | _ => Stuck end. @@ -100,9 +118,11 @@ Definition parexec_basic_instr (bi: basic) (rsr rsw: regset) (mr mw: mem) := match bi with | PArith ai => Next (parexec_arith_instr ai rsr rsw) mw - | PLoadRRO n d a ofs => parexec_load (load_chunk n) rsr rsw mr mw d a ofs + | PLoadRRO n d a ofs => parexec_load_offset (load_chunk n) rsr rsw mr mw d a ofs + | PLoadRRR n d a ro => parexec_load_reg (load_chunk n) rsr rsw mr mw d a ro - | PStoreRRO n s a ofs => parexec_store (store_chunk n) rsr rsw mr mw s a ofs + | PStoreRRO n s a ofs => parexec_store_offset (store_chunk n) rsr rsw mr mw s a ofs + | PStoreRRR n s a ro => parexec_store_reg (store_chunk n) rsr rsw mr mw s a ro | Pallocframe sz pos => let (mw, stk) := Mem.alloc mr 0 sz in diff --git a/mppa_k1c/PostpassSchedulingOracle.ml b/mppa_k1c/PostpassSchedulingOracle.ml index 62df124a..762c67fc 100644 --- a/mppa_k1c/PostpassSchedulingOracle.ml +++ b/mppa_k1c/PostpassSchedulingOracle.ml @@ -201,10 +201,14 @@ let arith_rec i = let load_rec i = match i with | PLoadRRO (i, rs1, rs2, imm) -> { inst = load_str i; write_locs = [Reg (IR rs1)]; read_locs = [Mem; Reg (IR rs2)]; imm = (Some (Off imm)) ; is_control = false} + | PLoadRRR (i, rs1, rs2, rs3) -> { inst = load_str i; write_locs = [Reg (IR rs1)]; read_locs = [Mem; Reg (IR rs2); Reg (IR rs3)]; imm = None + ; is_control = false} let store_rec i = match i with | PStoreRRO (i, rs1, rs2, imm) -> { inst = store_str i; write_locs = [Mem]; read_locs = [Reg (IR rs1); Reg (IR rs2)]; imm = (Some (Off imm)) ; is_control = false} + | PStoreRRR (i, rs1, rs2, rs3) -> { inst = store_str i; write_locs = [Mem]; read_locs = [Reg (IR rs1); Reg (IR rs2); Reg (IR rs3)]; imm = None + ; is_control = false} let get_rec (rd:gpreg) rs = { inst = get_str; write_locs = [Reg (IR rd)]; read_locs = [Reg rs]; imm = None; is_control = false } diff --git a/mppa_k1c/PostpassSchedulingproof.v b/mppa_k1c/PostpassSchedulingproof.v index 4e33fc90..77014bdc 100644 --- a/mppa_k1c/PostpassSchedulingproof.v +++ b/mppa_k1c/PostpassSchedulingproof.v @@ -95,23 +95,47 @@ Proof. - repeat (rewrite Pregmap.gso); auto. Qed. -Lemma exec_load_pc_var: +Lemma exec_load_offset_pc_var: forall ge t rs m rd ra ofs rs' m' v, - exec_load ge t rs m rd ra ofs = Next rs' m' -> - exec_load ge t rs # PC <- v m rd ra ofs = Next rs' # PC <- v m'. + exec_load_offset ge t rs m rd ra ofs = Next rs' m' -> + exec_load_offset ge t rs # PC <- v m rd ra ofs = Next rs' # PC <- v m'. Proof. - intros. unfold exec_load in *. rewrite Pregmap.gso; try discriminate. destruct (eval_offset ge ofs); try discriminate. + intros. unfold exec_load_offset in *. unfold exec_load in *. rewrite Pregmap.gso; try discriminate. destruct (eval_offset ge ofs); try discriminate. destruct (Mem.loadv _ _ _). - inv H. apply next_eq; auto. apply functional_extensionality. intros. rewrite regset_double_set; auto. discriminate. - discriminate. Qed. -Lemma exec_store_pc_var: +Lemma exec_load_reg_pc_var: + forall t rs m rd ra ro rs' m' v, + exec_load_reg t rs m rd ra ro = Next rs' m' -> + exec_load_reg t rs # PC <- v m rd ra ro = Next rs' # PC <- v m'. +Proof. + intros. unfold exec_load_reg in *. unfold exec_load in *. rewrite Pregmap.gso; try discriminate. destruct (rs ro); try discriminate. + destruct (Mem.loadv _ _ _). + - inv H. apply next_eq; auto. apply functional_extensionality. intros. rewrite regset_double_set; auto. discriminate. + - discriminate. +Qed. + +Lemma exec_store_offset_pc_var: forall ge t rs m rd ra ofs rs' m' v, - exec_store ge t rs m rd ra ofs = Next rs' m' -> - exec_store ge t rs # PC <- v m rd ra ofs = Next rs' # PC <- v m'. + exec_store_offset ge t rs m rd ra ofs = Next rs' m' -> + exec_store_offset ge t rs # PC <- v m rd ra ofs = Next rs' # PC <- v m'. +Proof. + intros. unfold exec_store_offset in *. unfold exec_store in *. rewrite Pregmap.gso; try discriminate. + destruct (eval_offset ge ofs); try discriminate. + destruct (Mem.storev _ _ _). + - inv H. apply next_eq; auto. + - discriminate. +Qed. + +Lemma exec_store_reg_pc_var: + forall t rs m rd ra ro rs' m' v, + exec_store_reg t rs m rd ra ro = Next rs' m' -> + exec_store_reg t rs # PC <- v m rd ra ro = Next rs' # PC <- v m'. Proof. - intros. unfold exec_store in *. rewrite Pregmap.gso; try discriminate. destruct (eval_offset ge ofs); try discriminate. + intros. unfold exec_store_reg in *. unfold exec_store in *. rewrite Pregmap.gso; try discriminate. + destruct (rs ro); try discriminate. destruct (Mem.storev _ _ _). - inv H. apply next_eq; auto. - discriminate. @@ -129,8 +153,12 @@ Proof. (* Some cases treated seperately because exploreInst destructs too much *) all: try (inv H; apply next_eq; auto; apply functional_extensionality; intros; rewrite regset_double_set; auto; discriminate). - - exploreInst; apply exec_load_pc_var; auto. - - exploreInst; apply exec_store_pc_var; auto. + - destruct i. + + exploreInst; apply exec_load_offset_pc_var; auto. + + exploreInst; apply exec_load_reg_pc_var; auto. + - destruct i. + + exploreInst; apply exec_store_offset_pc_var; auto. + + exploreInst; apply exec_store_reg_pc_var; auto. - destruct (Mem.alloc _ _ _) as (m1 & stk). repeat (rewrite Pregmap.gso; try discriminate). destruct (Mem.storev _ _ _ _); try discriminate. inv H. apply next_eq; auto. apply functional_extensionality. intros. @@ -559,16 +587,16 @@ Proof. intros. unfold eval_offset. destruct ofs; auto. erewrite symbol_address_preserved; eauto. Qed. -Lemma transf_exec_load: - forall t rs m rd ra ofs, exec_load ge t rs m rd ra ofs = exec_load tge t rs m rd ra ofs. +Lemma transf_exec_load_offset: + forall t rs m rd ra ofs, exec_load_offset ge t rs m rd ra ofs = exec_load_offset tge t rs m rd ra ofs. Proof. - intros. unfold exec_load. rewrite eval_offset_preserved. reflexivity. + intros. unfold exec_load_offset. rewrite eval_offset_preserved. reflexivity. Qed. -Lemma transf_exec_store: - forall t rs m rs0 ra ofs, exec_store ge t rs m rs0 ra ofs = exec_store tge t rs m rs0 ra ofs. +Lemma transf_exec_store_offset: + forall t rs m rs0 ra ofs, exec_store_offset ge t rs m rs0 ra ofs = exec_store_offset tge t rs m rs0 ra ofs. Proof. - intros. unfold exec_store. rewrite eval_offset_preserved. reflexivity. + intros. unfold exec_store_offset. rewrite eval_offset_preserved. reflexivity. Qed. Lemma transf_exec_basic_instr: @@ -577,8 +605,8 @@ Proof. intros. pose symbol_address_preserved. unfold exec_basic_instr. exploreInst; simpl; auto; try congruence. - unfold exec_arith_instr; unfold arith_eval_r; exploreInst; simpl; auto; try congruence. - - apply transf_exec_load. - - apply transf_exec_store. + - apply transf_exec_load_offset. + - apply transf_exec_store_offset. Qed. Lemma transf_exec_body: diff --git a/mppa_k1c/TargetPrinter.ml b/mppa_k1c/TargetPrinter.ml index 6416b65b..ef02c25a 100644 --- a/mppa_k1c/TargetPrinter.ml +++ b/mppa_k1c/TargetPrinter.ml @@ -164,6 +164,10 @@ module Target (*: TARGET*) = | Ofsimm n -> ptrofs oc n | Ofslow(id, ofs) -> fprintf oc "%%lo(%a)" symbol_offset (id, ofs) + let addressing oc = function + | AOff ofs -> offset oc ofs + | AReg ro -> ireg oc ro + let icond_name = let open Asmblock in function | ITne | ITneu -> "ne" | ITeq | ITequ -> "eq" @@ -287,27 +291,27 @@ module Target (*: TARGET*) = section oc Section_text (* Load/Store instructions *) - | Plb(rd, ra, ofs) -> - fprintf oc " lbs %a = %a[%a]\n" ireg rd offset ofs ireg ra - | Plbu(rd, ra, ofs) -> - fprintf oc " lbz %a = %a[%a]\n" ireg rd offset ofs ireg ra - | Plh(rd, ra, ofs) -> - fprintf oc " lhs %a = %a[%a]\n" ireg rd offset ofs ireg ra - | Plhu(rd, ra, ofs) -> - fprintf oc " lhz %a = %a[%a]\n" ireg rd offset ofs ireg ra - | Plw(rd, ra, ofs) | Plw_a(rd, ra, ofs) | Pfls(rd, ra, ofs) -> - fprintf oc " lws %a = %a[%a]\n" ireg rd offset ofs ireg ra - | Pld(rd, ra, ofs) | Pfld(rd, ra, ofs) | Pld_a(rd, ra, ofs) -> assert Archi.ptr64; - fprintf oc " ld %a = %a[%a]\n" ireg rd offset ofs ireg ra + | Plb(rd, ra, adr) -> + fprintf oc " lbs %a = %a[%a]\n" ireg rd addressing adr ireg ra + | Plbu(rd, ra, adr) -> + fprintf oc " lbz %a = %a[%a]\n" ireg rd addressing adr ireg ra + | Plh(rd, ra, adr) -> + fprintf oc " lhs %a = %a[%a]\n" ireg rd addressing adr ireg ra + | Plhu(rd, ra, adr) -> + fprintf oc " lhz %a = %a[%a]\n" ireg rd addressing adr ireg ra + | Plw(rd, ra, adr) | Plw_a(rd, ra, adr) | Pfls(rd, ra, adr) -> + fprintf oc " lws %a = %a[%a]\n" ireg rd addressing adr ireg ra + | Pld(rd, ra, adr) | Pfld(rd, ra, adr) | Pld_a(rd, ra, adr) -> assert Archi.ptr64; + fprintf oc " ld %a = %a[%a]\n" ireg rd addressing adr ireg ra - | Psb(rd, ra, ofs) -> - fprintf oc " sb %a[%a] = %a\n" offset ofs ireg ra ireg rd - | Psh(rd, ra, ofs) -> - fprintf oc " sh %a[%a] = %a\n" offset ofs ireg ra ireg rd - | Psw(rd, ra, ofs) | Psw_a(rd, ra, ofs) | Pfss(rd, ra, ofs) -> - fprintf oc " sw %a[%a] = %a\n" offset ofs ireg ra ireg rd - | Psd(rd, ra, ofs) | Psd_a(rd, ra, ofs) | Pfsd(rd, ra, ofs) -> assert Archi.ptr64; - fprintf oc " sd %a[%a] = %a\n" offset ofs ireg ra ireg rd + | Psb(rd, ra, adr) -> + fprintf oc " sb %a[%a] = %a\n" addressing adr ireg ra ireg rd + | Psh(rd, ra, adr) -> + fprintf oc " sh %a[%a] = %a\n" addressing adr ireg ra ireg rd + | Psw(rd, ra, adr) | Psw_a(rd, ra, adr) | Pfss(rd, ra, adr) -> + fprintf oc " sw %a[%a] = %a\n" addressing adr ireg ra ireg rd + | Psd(rd, ra, adr) | Psd_a(rd, ra, adr) | Pfsd(rd, ra, adr) -> assert Archi.ptr64; + fprintf oc " sd %a[%a] = %a\n" addressing adr ireg ra ireg rd (* Arith R instructions *) diff --git a/mppa_k1c/lib/Asmblockgenproof0.v b/mppa_k1c/lib/Asmblockgenproof0.v index 69234938..ed8edfde 100644 --- a/mppa_k1c/lib/Asmblockgenproof0.v +++ b/mppa_k1c/lib/Asmblockgenproof0.v @@ -943,14 +943,16 @@ Lemma exec_basic_instr_pc: Proof. intros. destruct b; try destruct i; try destruct i. all: try (inv H; Simpl). - all: try (unfold exec_load in H1; destruct (eval_offset ge ofs); try discriminate; destruct (Mem.loadv _ _ _); [inv H1; Simpl | discriminate]). - all: try (unfold exec_store in H1; destruct (eval_offset ge ofs); try discriminate; destruct (Mem.storev _ _ _); [inv H1; auto | discriminate]). - destruct (Mem.alloc _ _ _). destruct (Mem.store _ _ _ _ _). inv H1. Simpl. discriminate. - destruct (Mem.loadv _ _ _); try discriminate. destruct (rs1 _); try discriminate. - destruct (Mem.free _ _ _ _). inv H1. Simpl. discriminate. - destruct rs; try discriminate. inv H1. Simpl. - destruct rd; try discriminate. inv H1; Simpl. - auto. + 1-10: try (unfold exec_load_offset in H1; destruct (eval_offset ge ofs); try discriminate; unfold exec_load in H1; destruct (Mem.loadv _ _ _); [inv H1; Simpl | discriminate]). + 1-10: try (unfold exec_load_reg in H1; destruct (rs1 rofs); try discriminate; unfold exec_load in H1; destruct (Mem.loadv _ _ _); [inv H1; Simpl | discriminate]). + 1-10: try (unfold exec_store_offset in H1; destruct (eval_offset ge ofs); try discriminate; unfold exec_store in H1; destruct (Mem.storev _ _ _); [inv H1; auto | discriminate]). + 1-10: try (unfold exec_store_reg in H1; destruct (rs1 rofs); try discriminate; unfold exec_store in H1; destruct (Mem.storev _ _ _); [inv H1; Simpl | discriminate]); auto. + - destruct (Mem.alloc _ _ _). destruct (Mem.store _ _ _ _ _). inv H1. Simpl. discriminate. + - destruct (Mem.loadv _ _ _); try discriminate. destruct (rs1 _); try discriminate. + destruct (Mem.free _ _ _ _). inv H1. Simpl. discriminate. + - destruct rs; try discriminate. inv H1. Simpl. + - destruct rd; try discriminate. inv H1; Simpl. + - reflexivity. Qed. (* Lemma exec_straight_pc': -- cgit From 61289bf034eebcfcaf04e833876d583e47aef659 Mon Sep 17 00:00:00 2001 From: Cyril SIX Date: Wed, 3 Apr 2019 10:34:34 +0200 Subject: Small refactoring and renaming of Stores and Loads --- mppa_k1c/Asmblock.v | 20 ++++++------- mppa_k1c/Asmblockdeps.v | 24 ++++++++-------- mppa_k1c/Asmblockgen.v | 76 ++++++++++++++++++------------------------------- 3 files changed, 50 insertions(+), 70 deletions(-) diff --git a/mppa_k1c/Asmblock.v b/mppa_k1c/Asmblock.v index 3656b91f..9d7b372e 100644 --- a/mppa_k1c/Asmblock.v +++ b/mppa_k1c/Asmblock.v @@ -244,7 +244,7 @@ Inductive cf_instruction : Type := . (** Loads **) -Inductive load_name_rro : Type := +Inductive load_name : Type := | Plb (**r load byte *) | Plbu (**r load byte unsigned *) | Plh (**r load half word *) @@ -258,15 +258,15 @@ Inductive load_name_rro : Type := . Inductive ld_instruction : Type := - | PLoadRRO (i: load_name_rro) (rd: ireg) (ra: ireg) (ofs: offset) - | PLoadRRR (i: load_name_rro) (rd: ireg) (ra: ireg) (rofs: ireg) + | PLoadRRO (i: load_name) (rd: ireg) (ra: ireg) (ofs: offset) + | PLoadRRR (i: load_name) (rd: ireg) (ra: ireg) (rofs: ireg) . -Coercion PLoadRRO: load_name_rro >-> Funclass. -Coercion PLoadRRR: load_name_rro >-> Funclass. +Coercion PLoadRRO: load_name >-> Funclass. +Coercion PLoadRRR: load_name >-> Funclass. (** Stores **) -Inductive store_name_rro : Type := +Inductive store_name : Type := | Psb (**r store byte *) | Psh (**r store half byte *) | Psw (**r store int32 *) @@ -278,12 +278,12 @@ Inductive store_name_rro : Type := . Inductive st_instruction : Type := - | PStoreRRO (i: store_name_rro) (rs: ireg) (ra: ireg) (ofs: offset) - | PStoreRRR (i: store_name_rro) (rs: ireg) (ra: ireg) (rofs: ireg) + | PStoreRRO (i: store_name) (rs: ireg) (ra: ireg) (ofs: offset) + | PStoreRRR (i: store_name) (rs: ireg) (ra: ireg) (rofs: ireg) . -Coercion PStoreRRO: store_name_rro >-> Funclass. -Coercion PStoreRRR: store_name_rro >-> Funclass. +Coercion PStoreRRO: store_name >-> Funclass. +Coercion PStoreRRR: store_name >-> Funclass. (** Arithmetic instructions **) Inductive arith_name_r : Type := diff --git a/mppa_k1c/Asmblockdeps.v b/mppa_k1c/Asmblockdeps.v index 7e332895..e038a5ae 100644 --- a/mppa_k1c/Asmblockdeps.v +++ b/mppa_k1c/Asmblockdeps.v @@ -71,18 +71,18 @@ Coercion OArithRRI32: arith_name_rri32 >-> Funclass. Coercion OArithRRI64: arith_name_rri64 >-> Funclass. Inductive load_op := - | OLoadRRO (n: load_name_rro) (ofs: offset) - | OLoadRRR (n: load_name_rro) + | OLoadRRO (n: load_name) (ofs: offset) + | OLoadRRR (n: load_name) . -Coercion OLoadRRO: load_name_rro >-> Funclass. +Coercion OLoadRRO: load_name >-> Funclass. Inductive store_op := - | OStoreRRO (n: store_name_rro) (ofs: offset) - | OStoreRRR (n: store_name_rro) + | OStoreRRO (n: store_name) (ofs: offset) + | OStoreRRR (n: store_name) . -Coercion OStoreRRO: store_name_rro >-> Funclass. +Coercion OStoreRRO: store_name >-> Funclass. Inductive op_wrap := | Arith (ao: arith_op) @@ -1571,7 +1571,7 @@ Definition string_of_arith (op: arith_op): pstring := | OArithARRI64 n _ => string_of_name_arri64 n end. -Definition string_of_name_lrro (n: load_name_rro) : pstring := +Definition string_of_load_name (n: load_name) : pstring := match n with Plb => "Plb" | Plbu => "Plbu" @@ -1587,11 +1587,11 @@ Definition string_of_name_lrro (n: load_name_rro) : pstring := Definition string_of_load (op: load_op): pstring := match op with - | OLoadRRO n _ => string_of_name_lrro n - | OLoadRRR n => string_of_name_lrro n + | OLoadRRO n _ => string_of_load_name n + | OLoadRRR n => string_of_load_name n end. -Definition string_of_name_srro (n: store_name_rro) : pstring := +Definition string_of_store_name (n: store_name) : pstring := match n with Psb => "Psb" | Psh => "Psh" @@ -1605,8 +1605,8 @@ Definition string_of_name_srro (n: store_name_rro) : pstring := Definition string_of_store (op: store_op) : pstring := match op with - | OStoreRRO n _ => string_of_name_srro n - | OStoreRRR n => string_of_name_srro n + | OStoreRRO n _ => string_of_store_name n + | OStoreRRR n => string_of_store_name n end. Definition string_of_control (op: control_op) : pstring := diff --git a/mppa_k1c/Asmblockgen.v b/mppa_k1c/Asmblockgen.v index 1afb627a..f207b64d 100644 --- a/mppa_k1c/Asmblockgen.v +++ b/mppa_k1c/Asmblockgen.v @@ -792,61 +792,41 @@ Definition transl_memory_access Error(msg "Asmblockgen.transl_memory_access") end. +Definition chunk2load (chunk: memory_chunk) := + match chunk with + | Mint8signed => Plb + | Mint8unsigned => Plbu + | Mint16signed => Plh + | Mint16unsigned => Plhu + | Mint32 => Plw + | Mint64 => Pld + | Mfloat32 => Pfls + | Mfloat64 => Pfld + | Many32 => Plw_a + | Many64 => Pld_a + end. + Definition transl_load (chunk: memory_chunk) (addr: addressing) (args: list mreg) (dst: mreg) (k: bcode) : res bcode := + do r <- ireg_of dst; + transl_memory_access (chunk2load chunk r) addr args k. + +Definition chunk2store (chunk: memory_chunk) := match chunk with - | Mint8signed => - do r <- ireg_of dst; - transl_memory_access (Plb r) addr args k - | Mint8unsigned => - do r <- ireg_of dst; - transl_memory_access (Plbu r) addr args k - | Mint16signed => - do r <- ireg_of dst; - transl_memory_access (Plh r) addr args k - | Mint16unsigned => - do r <- ireg_of dst; - transl_memory_access (Plhu r) addr args k - | Mint32 => - do r <- ireg_of dst; - transl_memory_access (Plw r) addr args k - | Mint64 => - do r <- ireg_of dst; - transl_memory_access (Pld r) addr args k - | Mfloat32 => - do r <- freg_of dst; - transl_memory_access (Pfls r) addr args k - | Mfloat64 => - do r <- freg_of dst; - transl_memory_access (Pfld r) addr args k - | _ => - Error (msg "Asmblockgen.transl_load") + | Mint8signed | Mint8unsigned => Psb + | Mint16signed | Mint16unsigned => Psh + | Mint32 => Psw + | Mint64 => Psd + | Mfloat32 => Pfss + | Mfloat64 => Pfsd + | Many32 => Psw_a + | Many64 => Psd_a end. Definition transl_store (chunk: memory_chunk) (addr: addressing) (args: list mreg) (src: mreg) (k: bcode) : res bcode := - match chunk with - | Mint8signed | Mint8unsigned => - do r <- ireg_of src; - transl_memory_access (Psb r) addr args k - | Mint16signed | Mint16unsigned => - do r <- ireg_of src; - transl_memory_access (Psh r) addr args k - | Mint32 => - do r <- ireg_of src; - transl_memory_access (Psw r) addr args k - | Mint64 => - do r <- ireg_of src; - transl_memory_access (Psd r) addr args k - | Mfloat32 => - do r <- freg_of src; - transl_memory_access (Pfss r) addr args k - | Mfloat64 => - do r <- freg_of src; - transl_memory_access (Pfsd r) addr args k - | _ => - Error (msg "Asmblockgen.transl_store") - end. + do r <- ireg_of src; + transl_memory_access (chunk2store chunk r) addr args k. (** Function epilogue *) -- cgit From f2426972df3fa959f09490b0b5752906d949c978 Mon Sep 17 00:00:00 2001 From: Cyril SIX Date: Wed, 3 Apr 2019 11:00:46 +0200 Subject: We now generate load/store with 3 registers (ld rd rs1[rs2]), proofs admitted --- mppa_k1c/Asmblockgen.v | 49 ++++- mppa_k1c/Asmblockgenproof.v | 456 +------------------------------------------ mppa_k1c/Asmblockgenproof1.v | 40 +--- 3 files changed, 51 insertions(+), 494 deletions(-) diff --git a/mppa_k1c/Asmblockgen.v b/mppa_k1c/Asmblockgen.v index f207b64d..54a1b0f4 100644 --- a/mppa_k1c/Asmblockgen.v +++ b/mppa_k1c/Asmblockgen.v @@ -741,11 +741,7 @@ Definition indexed_memory_access match make_immed64 (Ptrofs.to_int64 ofs) with | Imm64_single imm => mk_instr base (Ofsimm (Ptrofs.of_int64 imm)) -(*| Imm64_pair hi lo => - Pluil GPR31 hi :: Paddl GPR31 base GPR31 :: mk_instr GPR31 (Ofsimm (Ptrofs.of_int64 lo)) :: k - | Imm64_large imm => - Pmake GPR31 imm :: Paddl GPR31 base GPR31 :: mk_instr GPR31 (Ofsimm Ptrofs.zero) :: k -*)end. +end. Definition loadind (base: ireg) (ofs: ptrofs) (ty: typ) (dst: mreg) (k: bcode) := match ty, preg_of dst with @@ -777,6 +773,17 @@ Definition storeind_ptr (src: ireg) (base: ireg) (ofs: ptrofs) := (** Translation of memory accesses: loads, and stores. *) +Definition transl_memory_access2 + (mk_instr: ireg -> ireg -> basic) + (addr: addressing) (args: list mreg) (k: bcode) : res bcode := + match addr, args with + | Aindexed2, a1 :: a2 :: nil => + do rs1 <- ireg_of a1; + do rs2 <- ireg_of a2; + OK (mk_instr rs1 rs2 ::i k) + | _, _ => Error (msg "Asmblockgen.transl_memory_access2") + end. + Definition transl_memory_access (mk_instr: ireg -> offset -> basic) (addr: addressing) (args: list mreg) (k: bcode) : res bcode := @@ -806,10 +813,22 @@ Definition chunk2load (chunk: memory_chunk) := | Many64 => Pld_a end. -Definition transl_load (chunk: memory_chunk) (addr: addressing) +Definition transl_load_rro (chunk: memory_chunk) (addr: addressing) (args: list mreg) (dst: mreg) (k: bcode) : res bcode := do r <- ireg_of dst; - transl_memory_access (chunk2load chunk r) addr args k. + transl_memory_access (PLoadRRO (chunk2load chunk) r) addr args k. + +Definition transl_load_rrr (chunk: memory_chunk) (addr: addressing) + (args: list mreg) (dst: mreg) (k: bcode) : res bcode := + do r <- ireg_of dst; + transl_memory_access2 (PLoadRRR (chunk2load chunk) r) addr args k. + +Definition transl_load (chunk: memory_chunk) (addr: addressing) + (args: list mreg) (dst: mreg) (k: bcode) : res bcode := + match args with + | a1 :: a2 :: nil => transl_load_rrr chunk addr args dst k + | _ => transl_load_rro chunk addr args dst k + end. Definition chunk2store (chunk: memory_chunk) := match chunk with @@ -823,10 +842,22 @@ Definition chunk2store (chunk: memory_chunk) := | Many64 => Psd_a end. -Definition transl_store (chunk: memory_chunk) (addr: addressing) +Definition transl_store_rro (chunk: memory_chunk) (addr: addressing) + (args: list mreg) (src: mreg) (k: bcode) : res bcode := + do r <- ireg_of src; + transl_memory_access (PStoreRRO (chunk2store chunk) r) addr args k. + +Definition transl_store_rrr (chunk: memory_chunk) (addr: addressing) (args: list mreg) (src: mreg) (k: bcode) : res bcode := do r <- ireg_of src; - transl_memory_access (chunk2store chunk r) addr args k. + transl_memory_access2 (PStoreRRR (chunk2store chunk) r) addr args k. + +Definition transl_store (chunk: memory_chunk) (addr: addressing) + (args: list mreg) (src: mreg) (k: bcode) : res bcode := + match args with + | a1 :: a2 :: nil => transl_store_rrr chunk addr args src k + | _ => transl_load_rro chunk addr args src k + end. (** Function epilogue *) diff --git a/mppa_k1c/Asmblockgenproof.v b/mppa_k1c/Asmblockgenproof.v index 63f4c136..81474d30 100644 --- a/mppa_k1c/Asmblockgenproof.v +++ b/mppa_k1c/Asmblockgenproof.v @@ -16,7 +16,6 @@ Require Import Coqlib Errors. Require Import Integers Floats AST Linking. Require Import Values Memory Events Globalenvs Smallstep. Require Import Op Locations Machblock Conventions Asmblock. -(* Require Import Asmgen Asmgenproof0 Asmgenproof1. *) Require Import Asmblockgen Asmblockgenproof0 Asmblockgenproof1. Module MB := Machblock. @@ -75,34 +74,6 @@ Proof. omega. Qed. -(* -Lemma exec_straight_exec: - forall fb f c ep tf tc c' rs m rs' m', - transl_code_at_pc ge (rs PC) fb f c ep tf tc -> - exec_straight tge tf tc rs m c' rs' m' -> - plus step tge (State rs m) E0 (State rs' m'). -Proof. - intros. inv H. - eapply exec_straight_steps_1; eauto. - eapply transf_function_no_overflow; eauto. - eapply functions_transl; eauto. -Qed. - -Lemma exec_straight_at: - forall fb f c ep tf tc c' ep' tc' rs m rs' m', - transl_code_at_pc ge (rs PC) fb f c ep tf tc -> - transl_code f c' ep' = OK tc' -> - exec_straight tge tf tc rs m tc' rs' m' -> - transl_code_at_pc ge (rs' PC) fb f c' ep' tf tc'. -Proof. - intros. inv H. - exploit exec_straight_steps_2; eauto. - eapply transf_function_no_overflow; eauto. - eapply functions_transl; eauto. - intros [ofs' [PC' CT']]. - rewrite PC'. constructor; auto. -Qed. - *) (** The following lemmas show that the translation from Mach to Asm preserves labels, in the sense that the following diagram commutes: << @@ -121,314 +92,6 @@ Qed. Section TRANSL_LABEL. -(* Remark loadimm32_label: - forall r n k, tail_nolabel k (loadimm32 r n k). -Proof. - intros; unfold loadimm32. destruct (make_immed32 n); TailNoLabel. -(*unfold load_hilo32. destruct (Int.eq lo Int.zero); TailNoLabel.*) -Qed. -Hint Resolve loadimm32_label: labels. - -Remark opimm32_label: - forall (op: arith_name_rrr) (opimm: arith_name_rri32) r1 r2 n k, - (forall r1 r2 r3, nolabel (op r1 r2 r3)) -> - (forall r1 r2 n, nolabel (opimm r1 r2 n)) -> - tail_nolabel k (opimm32 op opimm r1 r2 n k). -Proof. - intros; unfold opimm32. destruct (make_immed32 n); TailNoLabel. -(*unfold load_hilo32. destruct (Int.eq lo Int.zero); TailNoLabel.*) -Qed. -Hint Resolve opimm32_label: labels. - -Remark loadimm64_label: - forall r n k, tail_nolabel k (loadimm64 r n k). -Proof. - intros; unfold loadimm64. destruct (make_immed64 n); TailNoLabel. -(*unfold load_hilo64. destruct (Int64.eq lo Int64.zero); TailNoLabel.*) -Qed. -Hint Resolve loadimm64_label: labels. - -Remark cast32signed_label: - forall rd rs k, tail_nolabel k (cast32signed rd rs k). -Proof. - intros; unfold cast32signed. destruct (ireg_eq rd rs); TailNoLabel. -Qed. -Hint Resolve cast32signed_label: labels. - -Remark opimm64_label: - forall (op: arith_name_rrr) (opimm: arith_name_rri64) r1 r2 n k, - (forall r1 r2 r3, nolabel (op r1 r2 r3)) -> - (forall r1 r2 n, nolabel (opimm r1 r2 n)) -> - tail_nolabel k (opimm64 op opimm r1 r2 n k). -Proof. - intros; unfold opimm64. destruct (make_immed64 n); TailNoLabel. -(*unfold load_hilo64. destruct (Int64.eq lo Int64.zero); TailNoLabel.*) -Qed. -Hint Resolve opimm64_label: labels. - -Remark addptrofs_label: - forall r1 r2 n k, tail_nolabel k (addptrofs r1 r2 n k). -Proof. - unfold addptrofs; intros. destruct (Ptrofs.eq_dec n Ptrofs.zero). TailNoLabel. - apply opimm64_label; TailNoLabel. -Qed. -Hint Resolve addptrofs_label: labels. -(* -Remark transl_cond_float_nolabel: - forall c r1 r2 r3 insn normal, - transl_cond_float c r1 r2 r3 = (insn, normal) -> nolabel insn. -Proof. - unfold transl_cond_float; intros. destruct c; inv H; exact I. -Qed. - -Remark transl_cond_single_nolabel: - forall c r1 r2 r3 insn normal, - transl_cond_single c r1 r2 r3 = (insn, normal) -> nolabel insn. -Proof. - unfold transl_cond_single; intros. destruct c; inv H; exact I. -Qed. -*) -Remark transl_cbranch_label: - forall cond args lbl k c, - transl_cbranch cond args lbl k = OK c -> tail_nolabel k c. -Proof. - intros. unfold transl_cbranch in H. destruct cond; TailNoLabel. -(* Ccomp *) - - unfold transl_comp; TailNoLabel. -(* Ccompu *) - - unfold transl_comp; TailNoLabel. -(* Ccompimm *) - - destruct (Int.eq n Int.zero); TailNoLabel. - unfold loadimm32. destruct (make_immed32 n); TailNoLabel. unfold transl_comp; TailNoLabel. -(* Ccompuimm *) - - unfold transl_opt_compuimm. - remember (select_comp n c0) as selcomp; destruct selcomp. - + destruct c; TailNoLabel; contradict Heqselcomp; unfold select_comp; - destruct (Int.eq n Int.zero); destruct c0; discriminate. - + unfold loadimm32; - destruct (make_immed32 n); TailNoLabel; unfold transl_comp; TailNoLabel. -(* Ccompl *) - - unfold transl_compl; TailNoLabel. -(* Ccomplu *) - - unfold transl_compl; TailNoLabel. -(* Ccomplimm *) - - destruct (Int64.eq n Int64.zero); TailNoLabel. - unfold loadimm64. destruct (make_immed64 n); TailNoLabel. unfold transl_compl; TailNoLabel. -(* Ccompluimm *) - - unfold transl_opt_compluimm. - remember (select_compl n c0) as selcomp; destruct selcomp. - + destruct c; TailNoLabel; contradict Heqselcomp; unfold select_compl; - destruct (Int64.eq n Int64.zero); destruct c0; discriminate. - + unfold loadimm64; - destruct (make_immed64 n); TailNoLabel; unfold transl_compl; TailNoLabel. -Qed. - -(* -- destruct c0; simpl; TailNoLabel. -- destruct c0; simpl; TailNoLabel. -- destruct (Int.eq n Int.zero). - destruct c0; simpl; TailNoLabel. - apply tail_nolabel_trans with (transl_cbranch_int32s c0 x X31 lbl :: k). - auto with labels. destruct c0; simpl; TailNoLabel. -- destruct (Int.eq n Int.zero). - destruct c0; simpl; TailNoLabel. - apply tail_nolabel_trans with (transl_cbranch_int32u c0 x X31 lbl :: k). - auto with labels. destruct c0; simpl; TailNoLabel. -- destruct c0; simpl; TailNoLabel. -- destruct c0; simpl; TailNoLabel. -- destruct (Int64.eq n Int64.zero). - destruct c0; simpl; TailNoLabel. - apply tail_nolabel_trans with (transl_cbranch_int64s c0 x X31 lbl :: k). - auto with labels. destruct c0; simpl; TailNoLabel. -- destruct (Int64.eq n Int64.zero). - destruct c0; simpl; TailNoLabel. - apply tail_nolabel_trans with (transl_cbranch_int64u c0 x X31 lbl :: k). - auto with labels. destruct c0; simpl; TailNoLabel. -- destruct (transl_cond_float c0 X31 x x0) as [insn normal] eqn:F; inv EQ2. - apply tail_nolabel_cons. eapply transl_cond_float_nolabel; eauto. - destruct normal; TailNoLabel. -- destruct (transl_cond_float c0 X31 x x0) as [insn normal] eqn:F; inv EQ2. - apply tail_nolabel_cons. eapply transl_cond_float_nolabel; eauto. - destruct normal; TailNoLabel. -- destruct (transl_cond_single c0 X31 x x0) as [insn normal] eqn:F; inv EQ2. - apply tail_nolabel_cons. eapply transl_cond_single_nolabel; eauto. - destruct normal; TailNoLabel. -- destruct (transl_cond_single c0 X31 x x0) as [insn normal] eqn:F; inv EQ2. - apply tail_nolabel_cons. eapply transl_cond_single_nolabel; eauto. - destruct normal; TailNoLabel. -*) - -Remark transl_cond_op_label: - forall cond args r k c, - transl_cond_op cond r args k = OK c -> tail_nolabel k c. -Proof. - intros. unfold transl_cond_op in H; destruct cond; TailNoLabel. -- unfold transl_cond_int32s; destruct c0; simpl; TailNoLabel. -- unfold transl_cond_int32u; destruct c0; simpl; TailNoLabel. -- unfold transl_condimm_int32s; destruct c0; simpl; TailNoLabel. -- unfold transl_condimm_int32u; destruct c0; simpl; TailNoLabel. -- unfold transl_cond_int64s; destruct c0; simpl; TailNoLabel. -- unfold transl_cond_int64u; destruct c0; simpl; TailNoLabel. -- unfold transl_condimm_int64s; destruct c0; simpl; TailNoLabel. -- unfold transl_condimm_int64u; destruct c0; simpl; TailNoLabel. -Qed. - -Remark transl_op_label: - forall op args r k c, - transl_op op args r k = OK c -> tail_nolabel k c. -Proof. -Opaque Int.eq. - unfold transl_op; intros; destruct op; TailNoLabel. -(* Omove *) -- destruct (preg_of r); try discriminate; destruct (preg_of m); inv H; TailNoLabel. -(* Oaddrsymbol *) -- destruct (Archi.pic_code tt && negb (Ptrofs.eq ofs Ptrofs.zero)); TailNoLabel. -(* Oaddimm32 *) -- apply opimm32_label; intros; exact I. -(* Oandimm32 *) -- apply opimm32_label; intros; exact I. -(* Oorimm32 *) -- apply opimm32_label; intros; exact I. -(* Oxorimm32 *) -- apply opimm32_label; intros; exact I. -(* Oshrximm *) -- destruct (Int.eq n Int.zero); TailNoLabel. -(* Oaddimm64 *) -- apply opimm64_label; intros; exact I. -(* Oandimm64 *) -- apply opimm64_label; intros; exact I. -(* Oorimm64 *) -- apply opimm64_label; intros; exact I. -(* Oxorimm64 *) -- apply opimm64_label; intros; exact I. -(* Ocmp *) -- eapply transl_cond_op_label; eauto. -Qed. - -(* -- destruct (preg_of r); try discriminate; destruct (preg_of m); inv H; TailNoLabel. -- destruct (Float.eq_dec n Float.zero); TailNoLabel. -- destruct (Float32.eq_dec n Float32.zero); TailNoLabel. -- destruct (Archi.pic_code tt && negb (Ptrofs.eq ofs Ptrofs.zero)). -+ eapply tail_nolabel_trans; [|apply addptrofs_label]. TailNoLabel. -+ TailNoLabel. -- apply opimm32_label; intros; exact I. -- apply opimm32_label; intros; exact I. -- apply opimm32_label; intros; exact I. -- apply opimm32_label; intros; exact I. -- destruct (Int.eq n Int.zero); TailNoLabel. -- apply opimm64_label; intros; exact I. -- apply opimm64_label; intros; exact I. -- apply opimm64_label; intros; exact I. -- apply opimm64_label; intros; exact I. -- destruct (Int.eq n Int.zero); TailNoLabel. -- eapply transl_cond_op_label; eauto. -*) -*) - -(* Remark indexed_memory_access_label: - forall (mk_instr: ireg -> offset -> instruction) base ofs k, - (forall r o, nolabel (mk_instr r o)) -> - tail_nolabel k (indexed_memory_access mk_instr base ofs k). -Proof. - unfold indexed_memory_access; intros. - (* destruct Archi.ptr64. *) - destruct (make_immed64 (Ptrofs.to_int64 ofs)); TailNoLabel. - (* destruct (make_immed32 (Ptrofs.to_int ofs)); TailNoLabel. *) -Qed. *) - -(* -Remark loadind_label: - forall base ofs ty dst k c, - loadind base ofs ty dst k = OK c -> tail_nolabel k c. -Proof. - unfold loadind; intros. - destruct ty, (preg_of dst); inv H; apply indexed_memory_access_label; intros; exact I. -Qed. - -Remark storeind_label: - forall src base ofs ty k c, - storeind src base ofs ty k = OK c -> tail_nolabel k c. -Proof. - unfold storeind; intros. - destruct ty, (preg_of src); inv H; apply indexed_memory_access_label; intros; exact I. -Qed. - -Remark loadind_ptr_label: - forall base ofs dst k, tail_nolabel k (loadind_ptr base ofs dst k). -Proof. - intros. apply indexed_memory_access_label. intros; destruct Archi.ptr64; exact I. -Qed. -*) - -(* Remark storeind_ptr_label: - forall src base ofs k, tail_nolabel k (storeind_ptr src base ofs k). -Proof. - intros. apply indexed_memory_access_label. intros; destruct Archi.ptr64; exact I. -Qed. *) - -(* -Remark transl_memory_access_label: - forall (mk_instr: ireg -> offset -> instruction) addr args k c, - (forall r o, nolabel (mk_instr r o)) -> - transl_memory_access mk_instr addr args k = OK c -> - tail_nolabel k c. -Proof. - unfold transl_memory_access; intros; destruct addr; TailNoLabel; apply indexed_memory_access_label; auto. -Qed. - -Remark make_epilogue_label: - forall f k, tail_nolabel k (make_epilogue f k). -Proof. - unfold make_epilogue; intros. eapply tail_nolabel_trans. apply loadind_ptr_label. TailNoLabel. -Qed. - -Lemma transl_instr_label: - forall f i ep k c, - transl_instr f i ep k = OK c -> - match i with Mlabel lbl => c = Plabel lbl ::i k | _ => tail_nolabel k c end. -Proof. - unfold transl_instr; intros; destruct i; TailNoLabel. -(* loadind *) -- eapply loadind_label; eauto. -(* storeind *) -- eapply storeind_label; eauto. -(* Mgetparam *) -- destruct ep. eapply loadind_label; eauto. - eapply tail_nolabel_trans. apply loadind_ptr_label. eapply loadind_label; eauto. -(* transl_op *) -- eapply transl_op_label; eauto. -(* transl_load *) -- destruct m; monadInv H; eapply transl_memory_access_label; eauto; intros; exact I. -(* transl store *) -- destruct m; monadInv H; eapply transl_memory_access_label; eauto; intros; exact I. -- destruct s0; monadInv H; TailNoLabel. -- destruct s0; monadInv H; eapply tail_nolabel_trans - ; [eapply make_epilogue_label|TailNoLabel]. -- eapply transl_cbranch_label; eauto. -- eapply tail_nolabel_trans; [eapply make_epilogue_label|TailNoLabel]. -Qed. -(* - - -- eapply transl_op_label; eauto. -- destruct m; monadInv H; eapply transl_memory_access_label; eauto; intros; exact I. -- destruct m; monadInv H; eapply transl_memory_access_label; eauto; intros; exact I. -- destruct s0; monadInv H; (eapply tail_nolabel_trans; [eapply make_epilogue_label|TailNoLabel]). -- eapply tail_nolabel_trans; [eapply make_epilogue_label|TailNoLabel]. -*) - -Lemma transl_instr_label': - forall lbl f i ep k c, - transl_instr f i ep k = OK c -> - find_label lbl c = if Mach.is_label lbl i then Some k else find_label lbl k. -Proof. - intros. exploit transl_instr_label; eauto. - destruct i; try (intros [A B]; apply B). - intros. subst c. simpl. auto. -Qed. -*) - Lemma gen_bblocks_label: forall hd bdy ex tbb tc, gen_bblocks hd bdy ex = tbb::tc -> @@ -640,115 +303,6 @@ Qed. - Mach register values and Asm register values agree. *) -(* -Lemma exec_straight_steps: - forall s fb f rs1 i c ep tf tc m1' m2 m2' sp ms2, - match_stack ge s -> - Mem.extends m2 m2' -> - Genv.find_funct_ptr ge fb = Some (Internal f) -> - transl_code_at_pc ge (rs1 PC) fb f (i :: c) ep tf tc -> - (forall k c (TR: transl_instr f i ep k = OK c), - exists rs2, - exec_straight tge tf c rs1 m1' k rs2 m2' - /\ agree ms2 sp rs2 - /\ (fp_is_parent ep i = true -> rs2#FP = parent_sp s)) -> - exists st', - plus step tge (State rs1 m1') E0 st' /\ - match_states (Mach.State s fb sp c ms2 m2) st'. -Proof. - intros. inversion H2. subst. monadInv H7. - exploit H3; eauto. intros [rs2 [A [B C]]]. - exists (State rs2 m2'); split. - eapply exec_straight_exec; eauto. - econstructor; eauto. eapply exec_straight_at; eauto. -Qed. -*) - -(* -Lemma exec_straight_steps_goto: - forall s fb f rs1 i c ep tf tc m1' m2 m2' sp ms2 lbl c', - match_stack ge s -> - Mem.extends m2 m2' -> - Genv.find_funct_ptr ge fb = Some (Internal f) -> - Mach.find_label lbl f.(Mach.fn_code) = Some c' -> - transl_code_at_pc ge (rs1 PC) fb f (i :: c) ep tf tc -> - fp_is_parent ep i = false -> - (forall k c (TR: transl_instr f i ep k = OK c), - exists jmp, exists k', exists rs2, - exec_straight tge tf c rs1 m1' (jmp :: k') rs2 m2' - /\ agree ms2 sp rs2 - /\ exec_instr tge tf jmp rs2 m2' = goto_label tf lbl rs2 m2') -> - exists st', - plus step tge (State rs1 m1') E0 st' /\ - match_states (Mach.State s fb sp c' ms2 m2) st'. -Proof. - intros. inversion H3. subst. monadInv H9. - exploit H5; eauto. intros [jmp [k' [rs2 [A [B C]]]]]. - generalize (functions_transl _ _ _ H7 H8); intro FN. - generalize (transf_function_no_overflow _ _ H8); intro NOOV. - exploit exec_straight_steps_2; eauto. - intros [ofs' [PC2 CT2]]. - exploit find_label_goto_label; eauto. - intros [tc' [rs3 [GOTO [AT' OTH]]]]. - exists (State rs3 m2'); split. - eapply plus_right'. - eapply exec_straight_steps_1; eauto. - econstructor; eauto. - eapply find_instr_tail. eauto. - rewrite C. eexact GOTO. - traceEq. - econstructor; eauto. - apply agree_exten with rs2; auto with asmgen. - congruence. -Qed. - -Lemma exec_straight_opt_steps_goto: - forall s fb f rs1 i c ep tf tc m1' m2 m2' sp ms2 lbl c', - match_stack ge s -> - Mem.extends m2 m2' -> - Genv.find_funct_ptr ge fb = Some (Internal f) -> - Mach.find_label lbl f.(Mach.fn_code) = Some c' -> - transl_code_at_pc ge (rs1 PC) fb f (i :: c) ep tf tc -> - fp_is_parent ep i = false -> - (forall k c (TR: transl_instr f i ep k = OK c), - exists jmp, exists k', exists rs2, - exec_straight_opt tge tf c rs1 m1' (jmp :: k') rs2 m2' - /\ agree ms2 sp rs2 - /\ exec_instr tge tf jmp rs2 m2' = goto_label tf lbl rs2 m2') -> - exists st', - plus step tge (State rs1 m1') E0 st' /\ - match_states (Mach.State s fb sp c' ms2 m2) st'. -Proof. - intros. inversion H3. subst. monadInv H9. - exploit H5; eauto. intros [jmp [k' [rs2 [A [B C]]]]]. - generalize (functions_transl _ _ _ H7 H8); intro FN. - generalize (transf_function_no_overflow _ _ H8); intro NOOV. - inv A. -- exploit find_label_goto_label; eauto. - intros [tc' [rs3 [GOTO [AT' OTH]]]]. - exists (State rs3 m2'); split. - apply plus_one. econstructor; eauto. - eapply find_instr_tail. eauto. - rewrite C. eexact GOTO. - econstructor; eauto. - apply agree_exten with rs2; auto with asmgen. - congruence. -- exploit exec_straight_steps_2; eauto. - intros [ofs' [PC2 CT2]]. - exploit find_label_goto_label; eauto. - intros [tc' [rs3 [GOTO [AT' OTH]]]]. - exists (State rs3 m2'); split. - eapply plus_right'. - eapply exec_straight_steps_1; eauto. - econstructor; eauto. - eapply find_instr_tail. eauto. - rewrite C. eexact GOTO. - traceEq. - econstructor; eauto. - apply agree_exten with rs2; auto with asmgen. - congruence. -Qed. *) - (** We need to show that, in the simulation diagram, we cannot take infinitely many Mach transitions that correspond to zero transitions on the Asm side. Actually, all Mach transitions @@ -967,9 +521,9 @@ Proof. unfold transl_cond_float32. exploreInst; try discriminate. unfold transl_cond_notfloat32. exploreInst; try discriminate. - simpl in TIB. unfold transl_load in TIB. exploreInst; try discriminate. - all: unfold transl_memory_access in EQ0; exploreInst; try discriminate. + all: monadInv TIB; unfold transl_memory_access in EQ0; unfold transl_memory_access2 in EQ0; exploreInst; try discriminate. - simpl in TIB. unfold transl_store in TIB. exploreInst; try discriminate. - all: unfold transl_memory_access in EQ0; exploreInst; try discriminate. + all: monadInv TIB; unfold transl_memory_access in EQ0; unfold transl_memory_access2 in EQ0; exploreInst; try discriminate. Qed. Lemma transl_basic_code_nonil: @@ -1631,7 +1185,7 @@ Local Transparent destroyed_by_op. exploit eval_addressing_lessdef. eapply preg_vals; eauto. eexact H1. intros [a' [A B]]. rewrite (sp_val _ _ _ AG) in A. exploit Mem.loadv_extends; eauto. intros [v' [C D]]. - exploit transl_load_correct; eauto. + exploit transl_load_correct; eauto. admit. intros [rs2 [P [Q R]]]. eapply exec_straight_body in P. @@ -1658,7 +1212,7 @@ Local Transparent destroyed_by_op. intros [a' [A B]]. rewrite (sp_val _ _ _ AG) in A. assert (Val.lessdef (ms src) (rs1 (preg_of src))). eapply preg_val; eauto. exploit Mem.storev_extends; eauto. intros [m2' [C D]]. - exploit transl_store_correct; eauto. intros [rs2 [P Q]]. + exploit transl_store_correct; eauto. admit. intros [rs2 [P Q]]. eapply exec_straight_body in P. 2: eapply code_to_basics_id; eauto. @@ -1673,7 +1227,7 @@ Local Transparent destroyed_by_op. eapply agree_undef_regs; eauto with asmgen. simpl; congruence. -Qed. +Admitted. Lemma exec_body_trans: forall l l' rs0 m0 rs1 m1 rs2 m2, diff --git a/mppa_k1c/Asmblockgenproof1.v b/mppa_k1c/Asmblockgenproof1.v index f8bbf7f4..06c9fb3e 100644 --- a/mppa_k1c/Asmblockgenproof1.v +++ b/mppa_k1c/Asmblockgenproof1.v @@ -30,40 +30,13 @@ Lemma make_immed32_sound: Proof. intros; unfold make_immed32. set (lo := Int.sign_ext 12 n). predSpec Int.eq Int.eq_spec n lo; auto. -(* -- auto. -- set (m := Int.sub n lo). - assert (A: Int.eqmod (two_p 12) (Int.unsigned lo) (Int.unsigned n)) by (apply Int.eqmod_sign_ext'; compute; auto). - assert (B: Int.eqmod (two_p 12) (Int.unsigned n - Int.unsigned lo) 0). - { replace 0 with (Int.unsigned n - Int.unsigned n) by omega. - auto using Int.eqmod_sub, Int.eqmod_refl. } - assert (C: Int.eqmod (two_p 12) (Int.unsigned m) 0). - { apply Int.eqmod_trans with (Int.unsigned n - Int.unsigned lo); auto. - apply Int.eqmod_divides with Int.modulus. apply Int.eqm_sym; apply Int.eqm_unsigned_repr. - exists (two_p (32-12)); auto. } - assert (D: Int.modu m (Int.repr 4096) = Int.zero). - { apply Int.eqmod_mod_eq in C. unfold Int.modu. - change (Int.unsigned (Int.repr 4096)) with (two_p 12). rewrite C. - reflexivity. - apply two_p_gt_ZERO; omega. } - rewrite <- (Int.divu_pow2 m (Int.repr 4096) (Int.repr 12)) by auto. - rewrite Int.shl_mul_two_p. - change (two_p (Int.unsigned (Int.repr 12))) with 4096. - replace (Int.mul (Int.divu m (Int.repr 4096)) (Int.repr 4096)) with m. - unfold m. rewrite Int.sub_add_opp. rewrite Int.add_assoc. rewrite <- (Int.add_commut lo). - rewrite Int.add_neg_zero. rewrite Int.add_zero. auto. - rewrite (Int.modu_divu_Euclid m (Int.repr 4096)) at 1 by (vm_compute; congruence). - rewrite D. apply Int.add_zero. -*) Qed. Lemma make_immed64_sound: forall n, match make_immed64 n with | Imm64_single imm => n = imm -(*| Imm64_pair hi lo => n = Int64.add (Int64.sign_ext 32 (Int64.shl hi (Int64.repr 12))) lo - | Imm64_large imm => n = imm -*)end. + end. Proof. intros; unfold make_immed64. set (lo := Int64.sign_ext 12 n). predSpec Int64.eq Int64.eq_spec n lo. @@ -76,7 +49,6 @@ Proof. Qed. - (** Properties of registers *) Lemma ireg_of_not_RTMP: @@ -2000,10 +1972,10 @@ Proof. /\ transl_memory_access mk_instr addr args k = OK c /\ forall base ofs rs, exec_basic_instr ge (mk_instr base ofs) rs m = exec_load_offset ge chunk rs m rd base ofs). - { unfold transl_load in TR; destruct chunk; ArgsInv; econstructor; (esplit; eauto). } + { (* unfold transl_load in TR; destruct chunk; ArgsInv; econstructor; (esplit; eauto). *) admit. } destruct A as (mk_instr & rd & rdEq & B & C). rewrite rdEq. eapply transl_load_access_correct; eauto with asmgen. -Qed. +Admitted. Lemma transl_store_correct: forall chunk addr args src k c (rs: regset) m a m', @@ -2021,16 +1993,16 @@ Proof. /\ (forall base ofs rs, exec_basic_instr ge (mk_instr base ofs) rs m = exec_store_offset ge chunk' rs m rr base ofs) /\ Mem.storev chunk m a rs#(preg_of src) = Mem.storev chunk' m a rs#(preg_of src)). - { unfold transl_store in TR; destruct chunk; ArgsInv; + { admit. (* unfold transl_store in TR; destruct chunk; ArgsInv; (econstructor; econstructor; econstructor; split; [eauto | split; [eassumption | split; [ intros; simpl; reflexivity | auto]]]). destruct a; auto. apply Mem.store_signed_unsigned_8. - destruct a; auto. apply Mem.store_signed_unsigned_16. + destruct a; auto. apply Mem.store_signed_unsigned_16. *) } destruct A as (mk_instr & chunk' & rr & rrEq & B & C & D). rewrite D in STORE; clear D. eapply transl_store_access_correct; eauto with asmgen. congruence. destruct rr; try discriminate. destruct src; try discriminate. -Qed. +Admitted. Lemma make_epilogue_correct: forall ge0 f m stk soff cs m' ms rs k tm, -- cgit From 34261e53d0da905307eb3e0a0b711571365b078e Mon Sep 17 00:00:00 2001 From: Cyril SIX Date: Wed, 3 Apr 2019 12:04:33 +0200 Subject: Preuve du transl_load et transl_store registre offset --- mppa_k1c/Asmblockgen.v | 10 ++-- mppa_k1c/Asmblockgenproof1.v | 109 +++++++++++++++++++++++++++++++++---------- 2 files changed, 89 insertions(+), 30 deletions(-) diff --git a/mppa_k1c/Asmblockgen.v b/mppa_k1c/Asmblockgen.v index 54a1b0f4..3260312d 100644 --- a/mppa_k1c/Asmblockgen.v +++ b/mppa_k1c/Asmblockgen.v @@ -825,8 +825,8 @@ Definition transl_load_rrr (chunk: memory_chunk) (addr: addressing) Definition transl_load (chunk: memory_chunk) (addr: addressing) (args: list mreg) (dst: mreg) (k: bcode) : res bcode := - match args with - | a1 :: a2 :: nil => transl_load_rrr chunk addr args dst k + match addr with + | Aindexed2 => transl_load_rrr chunk addr args dst k | _ => transl_load_rro chunk addr args dst k end. @@ -854,9 +854,9 @@ Definition transl_store_rrr (chunk: memory_chunk) (addr: addressing) Definition transl_store (chunk: memory_chunk) (addr: addressing) (args: list mreg) (src: mreg) (k: bcode) : res bcode := - match args with - | a1 :: a2 :: nil => transl_store_rrr chunk addr args src k - | _ => transl_load_rro chunk addr args src k + match addr with + | Aindexed2 => transl_store_rrr chunk addr args src k + | _ => transl_store_rro chunk addr args src k end. (** Function epilogue *) diff --git a/mppa_k1c/Asmblockgenproof1.v b/mppa_k1c/Asmblockgenproof1.v index 06c9fb3e..220f631e 100644 --- a/mppa_k1c/Asmblockgenproof1.v +++ b/mppa_k1c/Asmblockgenproof1.v @@ -1956,6 +1956,29 @@ Proof. auto. Qed. +Lemma transl_load_memory_access_ok: + forall addr chunk args dst k c rs a v m, + addr <> Aindexed2 -> + transl_load chunk addr args dst k = OK c -> + eval_addressing ge (rs (IR SP)) addr (map rs (map preg_of args)) = Some a -> + Mem.loadv chunk m a = Some v -> + exists mk_instr rd, + preg_of dst = IR rd + /\ transl_memory_access mk_instr addr args k = OK c + /\ forall base ofs rs, + exec_basic_instr ge (mk_instr base ofs) rs m = exec_load_offset ge chunk rs m rd base ofs. +Proof. + intros until m. intros ADDR TR ? ?. + unfold transl_load in TR. destruct addr; try contradiction. + - monadInv TR. destruct chunk; ArgsInv; econstructor; (esplit; eauto). + - monadInv TR. destruct chunk. all: ArgsInv; destruct args; try discriminate; monadInv EQ0; eexists; eexists; split; try split; + [ instantiate (1 := (PLoadRRO _ x)); simpl; reflexivity + | eauto ]. + - monadInv TR. destruct chunk. all: ArgsInv; destruct args; try discriminate; monadInv EQ0; eexists; eexists; split; try split; + [ instantiate (1 := (PLoadRRO _ x)); simpl; reflexivity + | eauto ]. +Qed. + Lemma transl_load_correct: forall chunk addr args dst k c (rs: regset) m a v, transl_load chunk addr args dst k = OK c -> @@ -1966,17 +1989,62 @@ Lemma transl_load_correct: /\ rs'#(preg_of dst) = v /\ forall r, r <> PC -> r <> RTMP -> r <> preg_of dst -> rs'#r = rs#r. Proof. - intros until v; intros TR EV LOAD. - assert (A: exists mk_instr rd, - preg_of dst = IR rd - /\ transl_memory_access mk_instr addr args k = OK c - /\ forall base ofs rs, - exec_basic_instr ge (mk_instr base ofs) rs m = exec_load_offset ge chunk rs m rd base ofs). - { (* unfold transl_load in TR; destruct chunk; ArgsInv; econstructor; (esplit; eauto). *) admit. } - destruct A as (mk_instr & rd & rdEq & B & C). rewrite rdEq. - eapply transl_load_access_correct; eauto with asmgen. + intros until v; intros TR EV LOAD. destruct addr. + 2-4: exploit transl_load_memory_access_ok; eauto; try discriminate; + intros A; destruct A as (mk_instr & rd & rdEq & B & C); rewrite rdEq; + eapply transl_load_access_correct; eauto with asmgen. + admit. Admitted. +Remark exec_store_offset_8_sign rs m x base ofs: + exec_store_offset ge Mint8unsigned rs m x base ofs = exec_store_offset ge Mint8signed rs m x base ofs. +Proof. + unfold exec_store_offset. destruct (eval_offset _ _); auto. unfold exec_store. unfold Mem.storev. + destruct (Val.offset_ptr _ _); auto. erewrite <- Mem.store_signed_unsigned_8. reflexivity. +Qed. + +Remark exec_store_offset_16_sign rs m x base ofs: + exec_store_offset ge Mint16unsigned rs m x base ofs = exec_store_offset ge Mint16signed rs m x base ofs. +Proof. + unfold exec_store_offset. destruct (eval_offset _ _); auto. unfold exec_store. unfold Mem.storev. + destruct (Val.offset_ptr _ _); auto. erewrite <- Mem.store_signed_unsigned_16. reflexivity. +Qed. + +Lemma transl_store_memory_access_ok: + forall addr chunk args src k c rs a m m', + addr <> Aindexed2 -> + transl_store chunk addr args src k = OK c -> + eval_addressing ge (rs (IR SP)) addr (map rs (map preg_of args)) = Some a -> + Mem.storev chunk m a (rs (preg_of src)) = Some m' -> + exists mk_instr chunk' rr, + preg_of src = IR rr + /\ transl_memory_access mk_instr addr args k = OK c + /\ (forall base ofs rs, + exec_basic_instr ge (mk_instr base ofs) rs m = exec_store_offset ge chunk' rs m rr base ofs) + /\ Mem.storev chunk m a rs#(preg_of src) = Mem.storev chunk' m a rs#(preg_of src). +Proof. + intros until m'. intros ? TR ? ?. + unfold transl_store in TR. destruct addr; try contradiction. + - monadInv TR. destruct chunk. all: + ArgsInv; eexists; eexists; eexists; split; try split; [ + repeat (destruct args; try discriminate); eassumption + | split; eauto; intros; simpl; try reflexivity]. + eapply exec_store_offset_8_sign. + eapply exec_store_offset_16_sign. + - monadInv TR. destruct chunk. all: + ArgsInv; eexists; eexists; eexists; split; try split; + [ repeat (destruct args; try discriminate); instantiate (1 := PStoreRRO _ x); simpl; eassumption + | split; eauto; intros; simpl; try reflexivity]. + eapply exec_store_offset_8_sign. + eapply exec_store_offset_16_sign. + - monadInv TR. destruct chunk. all: + ArgsInv; eexists; eexists; eexists; split; try split; + [ repeat (destruct args; try discriminate); instantiate (1 := PStoreRRO _ x); simpl; eassumption + | split; eauto; intros; simpl; try reflexivity]. + eapply exec_store_offset_8_sign. + eapply exec_store_offset_16_sign. +Qed. + Lemma transl_store_correct: forall chunk addr args src k c (rs: regset) m a m', transl_store chunk addr args src k = OK c -> @@ -1986,22 +2054,13 @@ Lemma transl_store_correct: exec_straight ge (basics_to_code c) rs m (basics_to_code k) rs' m' /\ forall r, r <> PC -> r <> RTMP -> rs'#r = rs#r. Proof. - intros until m'; intros TR EV STORE. - assert (A: exists mk_instr chunk' rr, - preg_of src = IR rr - /\ transl_memory_access mk_instr addr args k = OK c - /\ (forall base ofs rs, - exec_basic_instr ge (mk_instr base ofs) rs m = exec_store_offset ge chunk' rs m rr base ofs) - /\ Mem.storev chunk m a rs#(preg_of src) = Mem.storev chunk' m a rs#(preg_of src)). - { admit. (* unfold transl_store in TR; destruct chunk; ArgsInv; - (econstructor; econstructor; econstructor; split; [eauto | split; [eassumption | split; [ intros; simpl; reflexivity | auto]]]). - destruct a; auto. apply Mem.store_signed_unsigned_8. - destruct a; auto. apply Mem.store_signed_unsigned_16. *) - } - destruct A as (mk_instr & chunk' & rr & rrEq & B & C & D). - rewrite D in STORE; clear D. - eapply transl_store_access_correct; eauto with asmgen. congruence. - destruct rr; try discriminate. destruct src; try discriminate. + intros until m'; intros TR EV STORE. destruct addr. + 2-4: exploit transl_store_memory_access_ok; eauto; try discriminate; intro A; + destruct A as (mk_instr & chunk' & rr & rrEq & B & C & D); + rewrite D in STORE; clear D; + eapply transl_store_access_correct; eauto with asmgen; try congruence; + destruct rr; try discriminate; destruct src; try discriminate. + admit. Admitted. Lemma make_epilogue_correct: -- cgit From e0fb40f126c980819869bf2a2f32f7332b1b4a5a Mon Sep 17 00:00:00 2001 From: Cyril SIX Date: Wed, 3 Apr 2019 16:32:59 +0200 Subject: Preuve des load/store registre registre. Reste des modifs mineures dans les preuves de Asmblockdeps --- mppa_k1c/Asmblock.v | 38 +++----- mppa_k1c/Asmblockdeps.v | 26 +++--- mppa_k1c/Asmblockgenproof.v | 6 +- mppa_k1c/Asmblockgenproof1.v | 186 +++++++++++++++++++++++++++++++------ mppa_k1c/PostpassSchedulingproof.v | 9 +- mppa_k1c/lib/Asmblockgenproof0.v | 8 +- 6 files changed, 196 insertions(+), 77 deletions(-) diff --git a/mppa_k1c/Asmblock.v b/mppa_k1c/Asmblock.v index 9d7b372e..408b8c31 100644 --- a/mppa_k1c/Asmblock.v +++ b/mppa_k1c/Asmblock.v @@ -1262,44 +1262,34 @@ Definition eval_offset (ofs: offset) : res ptrofs := end end. -Definition exec_load (chunk: memory_chunk) (rs: regset) (m: mem) - (d: ireg) (a: ireg) (ptr: ptrofs) := - match Mem.loadv chunk m (Val.offset_ptr (rs a) ptr) with - | None => Stuck - | Some v => Next (rs#d <- v) m - end -. - Definition exec_load_offset (chunk: memory_chunk) (rs: regset) (m: mem) (d a: ireg) (ofs: offset) := match (eval_offset ofs) with - | OK ptr => exec_load chunk rs m d a ptr + | OK ptr => match Mem.loadv chunk m (Val.offset_ptr (rs a) ptr) with + | None => Stuck + | Some v => Next (rs#d <- v) m + end | _ => Stuck end. Definition exec_load_reg (chunk: memory_chunk) (rs: regset) (m: mem) (d a ro: ireg) := - match (rs ro) with - | Vptr _ ofs => exec_load chunk rs m d a ofs - | _ => Stuck - end. - -Definition exec_store (chunk: memory_chunk) (rs: regset) (m: mem) - (s: ireg) (a: ireg) (ptr: ptrofs) := - match Mem.storev chunk m (Val.offset_ptr (rs a) ptr) (rs s) with + match Mem.loadv chunk m (Val.addl (rs a) (rs ro)) with | None => Stuck - | Some m' => Next rs m' - end -. + | Some v => Next (rs#d <- v) m + end. Definition exec_store_offset (chunk: memory_chunk) (rs: regset) (m: mem) (s a: ireg) (ofs: offset) := match (eval_offset ofs) with - | OK ptr => exec_store chunk rs m s a ptr + | OK ptr => match Mem.storev chunk m (Val.offset_ptr (rs a) ptr) (rs s) with + | None => Stuck + | Some m' => Next rs m' + end | _ => Stuck end. Definition exec_store_reg (chunk: memory_chunk) (rs: regset) (m: mem) (s a ro: ireg) := - match (rs ro) with - | Vptr _ ofs => exec_store chunk rs m s a ofs - | _ => Stuck + match Mem.storev chunk m (Val.addl (rs a) (rs ro)) (rs s) with + | None => Stuck + | Some m' => Next rs m' end. Definition load_chunk n := diff --git a/mppa_k1c/Asmblockdeps.v b/mppa_k1c/Asmblockdeps.v index e038a5ae..ac8fa6bd 100644 --- a/mppa_k1c/Asmblockdeps.v +++ b/mppa_k1c/Asmblockdeps.v @@ -831,7 +831,8 @@ Proof. - simpl in H. inv H. simpl macro_run. eapply trans_arith_correct; eauto. (* Load *) - - simpl in H. destruct i. + - simpl in H. admit. + (* destruct i. (* Load Offset *) + destruct i. all: unfold exec_load_offset in H; destruct (eval_offset _ _) eqn:EVALOFF; try discriminate; unfold exec_load in H; @@ -848,10 +849,11 @@ Proof. simpl; rewrite H; rewrite (H1 rofs); rewrite (H1 ra); unfold exec_load_deps_reg; rewrite ROFS; unfold exec_load_deps; simpl in MEML; rewrite MEML; reflexivity | Simpl - | intros rr; destruct rr; Simpl; destruct (ireg_eq g rd); subst; Simpl ]. + | intros rr; destruct rr; Simpl; destruct (ireg_eq g rd); subst; Simpl ]. *) (* Store *) - - simpl in H. destruct i. + - simpl in H. admit. + (* destruct i. (* Store Offset *) + destruct i. all: unfold exec_store_offset in H; destruct (eval_offset _ _) eqn:EVALOFF; try discriminate; unfold exec_store in H; @@ -869,7 +871,7 @@ Proof. unfold exec_store_deps; simpl in MEML; rewrite MEML; reflexivity | Simpl | intros rr; destruct rr; Simpl ]. - + *) (* Allocframe *) - simpl in H. destruct (Mem.alloc _ _ _) eqn:MEMAL. destruct (Mem.store _ _ _ _) eqn:MEMS; try discriminate. inv H. inv H0. eexists. split; try split. @@ -895,7 +897,7 @@ Proof. eexists. split; try split. Simpl. intros rr; destruct rr; Simpl. (* Pnop *) - simpl in H. inv H. inv H0. eexists. split; try split. assumption. assumption. -Qed. +Admitted. Lemma forward_simu_body: forall bdy ge rs m rs' m' fn s, @@ -1211,23 +1213,23 @@ Proof. (* Load Offset *) + destruct i. all: simpl; rewrite H2; rewrite (H3 ra); unfold exec_load_offset in H0; destruct (eval_offset _ _); auto; - unfold exec_load in H0; unfold exec_load_deps; simpl in H0; destruct (Mem.loadv _ _ _); auto; discriminate. + unfold exec_load_deps; simpl in H0; destruct (Mem.loadv _ _ _); auto; discriminate. (* Load Reg *) - + destruct i. all: + + admit. (* destruct i. all: simpl; rewrite H2; rewrite (H3 rofs); rewrite (H3 ra); unfold exec_load_reg in H0; unfold exec_load_deps_reg; - destruct (rs rofs); auto; unfold exec_load in H0; simpl in H0; unfold exec_load_deps; destruct (Mem.loadv _ _ _); auto; discriminate. + destruct (rs rofs); auto; unfold exec_load in H0; simpl in H0; unfold exec_load_deps; destruct (Mem.loadv _ _ _); auto; discriminate. *) (* PStore *) - destruct i. (* Store Offset *) + destruct i. all: simpl; rewrite H2; rewrite (H3 ra); rewrite (H3 rs0); unfold exec_store_offset in H0; destruct (eval_offset _ _); auto; - unfold exec_store in H0; simpl in H0; unfold exec_store_deps; destruct (Mem.storev _ _ _); auto; discriminate. + simpl in H0; unfold exec_store_deps; destruct (Mem.storev _ _ _); auto; discriminate. (* Store Reg *) - + destruct i. all: + + admit. (* destruct i. all: simpl; rewrite H2; rewrite (H3 rofs); rewrite (H3 ra); rewrite (H3 rs0); simpl in H0; unfold exec_store_reg in H0; unfold exec_store_deps_reg; destruct (rs rofs); auto; unfold exec_store in H0; unfold exec_store_deps; - destruct (Mem.storev _ _ _ _); auto; discriminate. + destruct (Mem.storev _ _ _ _); auto; discriminate. *) (* Pallocframe *) - simpl. Simpl. pose (H3 SP); simpl in e; rewrite e; clear e. rewrite H2. destruct (Mem.alloc _ _ _). simpl in H0. @@ -1241,7 +1243,7 @@ Proof. all: simpl; auto. - simpl. destruct rd; subst; try discriminate. all: simpl; auto. -Qed. +Admitted. Lemma forward_simu_body_stuck: forall bdy ge fn rs m s, diff --git a/mppa_k1c/Asmblockgenproof.v b/mppa_k1c/Asmblockgenproof.v index 81474d30..70f188ec 100644 --- a/mppa_k1c/Asmblockgenproof.v +++ b/mppa_k1c/Asmblockgenproof.v @@ -1185,7 +1185,7 @@ Local Transparent destroyed_by_op. exploit eval_addressing_lessdef. eapply preg_vals; eauto. eexact H1. intros [a' [A B]]. rewrite (sp_val _ _ _ AG) in A. exploit Mem.loadv_extends; eauto. intros [v' [C D]]. - exploit transl_load_correct; eauto. admit. + exploit transl_load_correct; eauto. intros [rs2 [P [Q R]]]. eapply exec_straight_body in P. @@ -1212,7 +1212,7 @@ Local Transparent destroyed_by_op. intros [a' [A B]]. rewrite (sp_val _ _ _ AG) in A. assert (Val.lessdef (ms src) (rs1 (preg_of src))). eapply preg_val; eauto. exploit Mem.storev_extends; eauto. intros [m2' [C D]]. - exploit transl_store_correct; eauto. admit. intros [rs2 [P Q]]. + exploit transl_store_correct; eauto. intros [rs2 [P Q]]. eapply exec_straight_body in P. 2: eapply code_to_basics_id; eauto. @@ -1227,7 +1227,7 @@ Local Transparent destroyed_by_op. eapply agree_undef_regs; eauto with asmgen. simpl; congruence. -Admitted. +Qed. Lemma exec_body_trans: forall l l' rs0 m0 rs1 m1 rs2 m2, diff --git a/mppa_k1c/Asmblockgenproof1.v b/mppa_k1c/Asmblockgenproof1.v index 220f631e..5ccea246 100644 --- a/mppa_k1c/Asmblockgenproof1.v +++ b/mppa_k1c/Asmblockgenproof1.v @@ -1749,7 +1749,7 @@ Proof. intros (base' & ofs' & rs' & ptr' & A & PtrEq & B & C). econstructor; split. eapply exec_straight_opt_right. eexact A. apply exec_straight_one. rewrite EXEC. - unfold exec_load_offset. rewrite PtrEq. unfold exec_load. rewrite B, LOAD. eauto. Simpl. + unfold exec_load_offset. rewrite PtrEq. rewrite B, LOAD. eauto. Simpl. split; intros; Simpl. auto. Qed. @@ -1769,7 +1769,7 @@ Proof. intros (base' & ofs' & rs' & ptr' & A & PtrEq & B & C). econstructor; split. eapply exec_straight_opt_right. eapply A. apply exec_straight_one. rewrite EXEC. - unfold exec_store_offset. rewrite PtrEq. unfold exec_store. rewrite B, C, STORE. + unfold exec_store_offset. rewrite PtrEq. rewrite B, C, STORE. eauto. discriminate. { intro. inv H. contradiction. } @@ -1913,11 +1913,29 @@ Proof. inv TR. inv EV. apply indexed_memory_access_correct; eauto with asmgen. Qed. -Lemma transl_load_access_correct: - forall chunk (mk_instr: ireg -> offset -> basic) addr args k c rd (rs: regset) m v v', - (forall base ofs rs, - exec_basic_instr ge (mk_instr base ofs) rs m = exec_load_offset ge chunk rs m rd base ofs) -> - transl_memory_access mk_instr addr args k = OK c -> +Lemma transl_memory_access2_correct: + forall mk_instr addr args k c (rs: regset) m v, + transl_memory_access2 mk_instr addr args k = OK c -> + eval_addressing ge rs#SP addr (map rs (map preg_of args)) = Some v -> + exists base ro mro mr1 rs', + args = mr1 :: mro :: nil + /\ ireg_of mro = OK ro + /\ exec_straight_opt (basics_to_code c) rs m (mk_instr base ro ::g (basics_to_code k)) rs' m + /\ Val.addl rs'#base rs'#ro = v + /\ forall r, r <> PC -> r <> RTMP -> rs'#r = rs#r. +Proof. + intros until v; intros TR EV. + unfold transl_memory_access2 in TR; destruct addr; ArgsInv. + inv EV. repeat eexists. eassumption. econstructor; eauto. +Qed. + +Lemma transl_load_access2_correct: + forall chunk (mk_instr: ireg -> ireg -> basic) addr args k c rd (rs: regset) m v mro mr1 ro v', + args = mr1 :: mro :: nil -> + ireg_of mro = OK ro -> + (forall base rs, + exec_basic_instr ge (mk_instr base ro) rs m = exec_load_reg chunk rs m rd base ro) -> + transl_memory_access2 mk_instr addr args k = OK c -> eval_addressing ge rs#SP addr (map rs (map preg_of args)) = Some v -> Mem.loadv chunk m v = Some v' -> exists rs', @@ -1925,35 +1943,34 @@ Lemma transl_load_access_correct: /\ rs'#rd = v' /\ forall r, r <> PC -> r <> RTMP -> r <> rd -> rs'#r = rs#r. Proof. - intros until v'; intros INSTR TR EV LOAD. - exploit transl_memory_access_correct; eauto. - intros (base & ofs & rs' & ptr & A & PtrEq & B & C). + intros until v'; intros ARGS IREGE INSTR TR EV LOAD. + exploit transl_memory_access2_correct; eauto. + intros (base & ro2 & mro2 & mr2 & rs' & ARGSS & IREGEQ & A & B & C). rewrite ARGSS in ARGS. inversion ARGS. subst mr2 mro2. clear ARGS. econstructor; split. - eapply exec_straight_opt_right. eexact A. apply exec_straight_one. - rewrite INSTR. unfold exec_load_offset. unfold exec_load. rewrite PtrEq, B, LOAD. reflexivity. Simpl. + eapply exec_straight_opt_right. eexact A. apply exec_straight_one. assert (ro = ro2) by congruence. subst ro2. + rewrite INSTR. unfold exec_load_reg. rewrite B, LOAD. reflexivity. Simpl. split; intros; Simpl. auto. Qed. -Lemma transl_store_access_correct: - forall chunk (mk_instr: ireg -> offset -> basic) addr args k c r1 (rs: regset) m v m', +Lemma transl_load_access_correct: + forall chunk (mk_instr: ireg -> offset -> basic) addr args k c rd (rs: regset) m v v', (forall base ofs rs, - exec_basic_instr ge (mk_instr base ofs) rs m = exec_store_offset ge chunk rs m r1 base ofs) -> + exec_basic_instr ge (mk_instr base ofs) rs m = exec_load_offset ge chunk rs m rd base ofs) -> transl_memory_access mk_instr addr args k = OK c -> eval_addressing ge rs#SP addr (map rs (map preg_of args)) = Some v -> - Mem.storev chunk m v rs#r1 = Some m' -> - r1 <> RTMP -> + Mem.loadv chunk m v = Some v' -> exists rs', - exec_straight ge (basics_to_code c) rs m (basics_to_code k) rs' m' - /\ forall r, r <> PC -> r <> RTMP -> rs'#r = rs#r. + exec_straight ge (basics_to_code c) rs m (basics_to_code k) rs' m + /\ rs'#rd = v' + /\ forall r, r <> PC -> r <> RTMP -> r <> rd -> rs'#r = rs#r. Proof. - intros until m'; intros INSTR TR EV STORE NOT31. + intros until v'; intros INSTR TR EV LOAD. exploit transl_memory_access_correct; eauto. intros (base & ofs & rs' & ptr & A & PtrEq & B & C). econstructor; split. eapply exec_straight_opt_right. eexact A. apply exec_straight_one. - rewrite INSTR. unfold exec_store_offset. unfold exec_store. rewrite PtrEq, B. rewrite C; try discriminate. rewrite STORE. auto. - intro. inv H. contradiction. - auto. + rewrite INSTR. unfold exec_load_offset. rewrite PtrEq, B, LOAD. reflexivity. Simpl. + split; intros; Simpl. auto. Qed. Lemma transl_load_memory_access_ok: @@ -1979,6 +1996,28 @@ Proof. | eauto ]. Qed. +Lemma transl_load_memory_access2_ok: + forall addr chunk args dst k c rs a v m, + addr = Aindexed2 -> + transl_load chunk addr args dst k = OK c -> + eval_addressing ge (rs (IR SP)) addr (map rs (map preg_of args)) = Some a -> + Mem.loadv chunk m a = Some v -> + exists mk_instr mr0 mro rd ro, + args = mr0 :: mro :: nil + /\ preg_of dst = IR rd + /\ preg_of mro = IR ro + /\ transl_memory_access2 mk_instr addr args k = OK c + /\ forall base rs, + exec_basic_instr ge (mk_instr base ro) rs m = exec_load_reg chunk rs m rd base ro. +Proof. + intros until m. intros ? TR ? ?. + unfold transl_load in TR. subst. monadInv TR. destruct chunk. all: + unfold transl_memory_access2 in EQ0; repeat (destruct args; try discriminate); monadInv EQ0; ArgsInv; repeat eexists; + [ unfold ireg_of in EQ0; destruct (preg_of m1); eauto; try discriminate; monadInv EQ0; reflexivity + | rewrite EQ1; rewrite EQ0; simpl; instantiate (1 := (PLoadRRR _ x)); simpl; reflexivity + | eauto]. +Qed. + Lemma transl_load_correct: forall chunk addr args dst k c (rs: regset) m a v, transl_load chunk addr args dst k = OK c -> @@ -1993,20 +2032,68 @@ Proof. 2-4: exploit transl_load_memory_access_ok; eauto; try discriminate; intros A; destruct A as (mk_instr & rd & rdEq & B & C); rewrite rdEq; eapply transl_load_access_correct; eauto with asmgen. - admit. -Admitted. + - exploit transl_load_memory_access2_ok; eauto. intros (mk_instr & mr0 & mro & rd & ro & argsEq & rdEq & roEq & B & C). + rewrite rdEq. eapply transl_load_access2_correct; eauto with asmgen. unfold ireg_of. rewrite roEq. reflexivity. +Qed. + +Lemma transl_store_access2_correct: + forall chunk (mk_instr: ireg -> ireg -> basic) addr args k c r1 (rs: regset) m v mr1 mro ro m', + args = mr1 :: mro :: nil -> + ireg_of mro = OK ro -> + (forall base rs, + exec_basic_instr ge (mk_instr base ro) rs m = exec_store_reg chunk rs m r1 base ro) -> + transl_memory_access2 mk_instr addr args k = OK c -> + eval_addressing ge rs#SP addr (map rs (map preg_of args)) = Some v -> + Mem.storev chunk m v rs#r1 = Some m' -> + r1 <> RTMP -> + exists rs', + exec_straight ge (basics_to_code c) rs m (basics_to_code k) rs' m' + /\ forall r, r <> PC -> r <> RTMP -> rs'#r = rs#r. +Proof. + intros until m'; intros ARGS IREG INSTR TR EV STORE NOT31. + exploit transl_memory_access2_correct; eauto. + intros (base & ro2 & mr2 & mro2 & rs' & ARGSS & IREGG & A & B & C). rewrite ARGSS in ARGS. inversion ARGS. subst mro2 mr2. clear ARGS. + econstructor; split. + eapply exec_straight_opt_right. eexact A. apply exec_straight_one. assert (ro = ro2) by congruence. subst ro2. + rewrite INSTR. unfold exec_store_reg. rewrite B. rewrite C; try discriminate. rewrite STORE. auto. + intro. inv H. contradiction. + auto. +Qed. + +Lemma transl_store_access_correct: + forall chunk (mk_instr: ireg -> offset -> basic) addr args k c r1 (rs: regset) m v m', + (forall base ofs rs, + exec_basic_instr ge (mk_instr base ofs) rs m = exec_store_offset ge chunk rs m r1 base ofs) -> + transl_memory_access mk_instr addr args k = OK c -> + eval_addressing ge rs#SP addr (map rs (map preg_of args)) = Some v -> + Mem.storev chunk m v rs#r1 = Some m' -> + r1 <> RTMP -> + exists rs', + exec_straight ge (basics_to_code c) rs m (basics_to_code k) rs' m' + /\ forall r, r <> PC -> r <> RTMP -> rs'#r = rs#r. +Proof. + intros until m'; intros INSTR TR EV STORE NOT31. + exploit transl_memory_access_correct; eauto. + intros (base & ofs & rs' & ptr & A & PtrEq & B & C). + econstructor; split. + eapply exec_straight_opt_right. eexact A. apply exec_straight_one. + rewrite INSTR. unfold exec_store_offset. rewrite PtrEq, B. rewrite C; try discriminate. rewrite STORE. auto. + intro. inv H. contradiction. + auto. +Qed. + Remark exec_store_offset_8_sign rs m x base ofs: exec_store_offset ge Mint8unsigned rs m x base ofs = exec_store_offset ge Mint8signed rs m x base ofs. Proof. - unfold exec_store_offset. destruct (eval_offset _ _); auto. unfold exec_store. unfold Mem.storev. + unfold exec_store_offset. destruct (eval_offset _ _); auto. unfold Mem.storev. destruct (Val.offset_ptr _ _); auto. erewrite <- Mem.store_signed_unsigned_8. reflexivity. Qed. Remark exec_store_offset_16_sign rs m x base ofs: exec_store_offset ge Mint16unsigned rs m x base ofs = exec_store_offset ge Mint16signed rs m x base ofs. Proof. - unfold exec_store_offset. destruct (eval_offset _ _); auto. unfold exec_store. unfold Mem.storev. + unfold exec_store_offset. destruct (eval_offset _ _); auto. unfold Mem.storev. destruct (Val.offset_ptr _ _); auto. erewrite <- Mem.store_signed_unsigned_16. reflexivity. Qed. @@ -2045,6 +2132,45 @@ Proof. eapply exec_store_offset_16_sign. Qed. +Remark exec_store_reg_8_sign rs m x base ofs: + exec_store_reg Mint8unsigned rs m x base ofs = exec_store_reg Mint8signed rs m x base ofs. +Proof. + unfold exec_store_reg. unfold Mem.storev. destruct (Val.addl _ _); auto. + erewrite <- Mem.store_signed_unsigned_8. reflexivity. +Qed. + +Remark exec_store_reg_16_sign rs m x base ofs: + exec_store_reg Mint16unsigned rs m x base ofs = exec_store_reg Mint16signed rs m x base ofs. +Proof. + unfold exec_store_reg. unfold Mem.storev. destruct (Val.addl _ _); auto. + erewrite <- Mem.store_signed_unsigned_16. reflexivity. +Qed. + +Lemma transl_store_memory_access2_ok: + forall addr chunk args src k c rs a m m', + addr = Aindexed2 -> + transl_store chunk addr args src k = OK c -> + eval_addressing ge (rs (IR SP)) addr (map rs (map preg_of args)) = Some a -> + Mem.storev chunk m a (rs (preg_of src)) = Some m' -> + exists mk_instr chunk' rr mr0 mro ro, + args = mr0 :: mro :: nil + /\ preg_of mro = IR ro + /\ preg_of src = IR rr + /\ transl_memory_access2 mk_instr addr args k = OK c + /\ (forall base rs, + exec_basic_instr ge (mk_instr base ro) rs m = exec_store_reg chunk' rs m rr base ro) + /\ Mem.storev chunk m a rs#(preg_of src) = Mem.storev chunk' m a rs#(preg_of src). +Proof. + intros until m'. intros ? TR ? ?. + unfold transl_store in TR. subst addr. monadInv TR. destruct chunk. all: + unfold transl_memory_access2 in EQ0; repeat (destruct args; try discriminate); monadInv EQ0; ArgsInv; repeat eexists; + [ ArgsInv; reflexivity + | rewrite EQ1; rewrite EQ0; instantiate (1 := (PStoreRRR _ x)); simpl; reflexivity + | eauto ]. + - simpl. intros. eapply exec_store_reg_8_sign. + - simpl. intros. eapply exec_store_reg_16_sign. +Qed. + Lemma transl_store_correct: forall chunk addr args src k c (rs: regset) m a m', transl_store chunk addr args src k = OK c -> @@ -2060,8 +2186,10 @@ Proof. rewrite D in STORE; clear D; eapply transl_store_access_correct; eauto with asmgen; try congruence; destruct rr; try discriminate; destruct src; try discriminate. - admit. -Admitted. + - exploit transl_store_memory_access2_ok; eauto. intros (mk_instr & chunk' & rr & mr0 & mro & ro & argsEq & roEq & srcEq & A & B & C). + eapply transl_store_access2_correct; eauto with asmgen. unfold ireg_of. rewrite roEq. reflexivity. congruence. + destruct rr; try discriminate. destruct src; simpl in srcEq; try discriminate. +Qed. Lemma make_epilogue_correct: forall ge0 f m stk soff cs m' ms rs k tm, diff --git a/mppa_k1c/PostpassSchedulingproof.v b/mppa_k1c/PostpassSchedulingproof.v index 77014bdc..c5f432a6 100644 --- a/mppa_k1c/PostpassSchedulingproof.v +++ b/mppa_k1c/PostpassSchedulingproof.v @@ -100,7 +100,7 @@ Lemma exec_load_offset_pc_var: exec_load_offset ge t rs m rd ra ofs = Next rs' m' -> exec_load_offset ge t rs # PC <- v m rd ra ofs = Next rs' # PC <- v m'. Proof. - intros. unfold exec_load_offset in *. unfold exec_load in *. rewrite Pregmap.gso; try discriminate. destruct (eval_offset ge ofs); try discriminate. + intros. unfold exec_load_offset in *. rewrite Pregmap.gso; try discriminate. destruct (eval_offset ge ofs); try discriminate. destruct (Mem.loadv _ _ _). - inv H. apply next_eq; auto. apply functional_extensionality. intros. rewrite regset_double_set; auto. discriminate. - discriminate. @@ -111,7 +111,7 @@ Lemma exec_load_reg_pc_var: exec_load_reg t rs m rd ra ro = Next rs' m' -> exec_load_reg t rs # PC <- v m rd ra ro = Next rs' # PC <- v m'. Proof. - intros. unfold exec_load_reg in *. unfold exec_load in *. rewrite Pregmap.gso; try discriminate. destruct (rs ro); try discriminate. + intros. unfold exec_load_reg in *. rewrite Pregmap.gso; try discriminate. destruct (Mem.loadv _ _ _). - inv H. apply next_eq; auto. apply functional_extensionality. intros. rewrite regset_double_set; auto. discriminate. - discriminate. @@ -122,7 +122,7 @@ Lemma exec_store_offset_pc_var: exec_store_offset ge t rs m rd ra ofs = Next rs' m' -> exec_store_offset ge t rs # PC <- v m rd ra ofs = Next rs' # PC <- v m'. Proof. - intros. unfold exec_store_offset in *. unfold exec_store in *. rewrite Pregmap.gso; try discriminate. + intros. unfold exec_store_offset in *. rewrite Pregmap.gso; try discriminate. destruct (eval_offset ge ofs); try discriminate. destruct (Mem.storev _ _ _). - inv H. apply next_eq; auto. @@ -134,8 +134,7 @@ Lemma exec_store_reg_pc_var: exec_store_reg t rs m rd ra ro = Next rs' m' -> exec_store_reg t rs # PC <- v m rd ra ro = Next rs' # PC <- v m'. Proof. - intros. unfold exec_store_reg in *. unfold exec_store in *. rewrite Pregmap.gso; try discriminate. - destruct (rs ro); try discriminate. + intros. unfold exec_store_reg in *. rewrite Pregmap.gso; try discriminate. destruct (Mem.storev _ _ _). - inv H. apply next_eq; auto. - discriminate. diff --git a/mppa_k1c/lib/Asmblockgenproof0.v b/mppa_k1c/lib/Asmblockgenproof0.v index ed8edfde..d0e05389 100644 --- a/mppa_k1c/lib/Asmblockgenproof0.v +++ b/mppa_k1c/lib/Asmblockgenproof0.v @@ -943,10 +943,10 @@ Lemma exec_basic_instr_pc: Proof. intros. destruct b; try destruct i; try destruct i. all: try (inv H; Simpl). - 1-10: try (unfold exec_load_offset in H1; destruct (eval_offset ge ofs); try discriminate; unfold exec_load in H1; destruct (Mem.loadv _ _ _); [inv H1; Simpl | discriminate]). - 1-10: try (unfold exec_load_reg in H1; destruct (rs1 rofs); try discriminate; unfold exec_load in H1; destruct (Mem.loadv _ _ _); [inv H1; Simpl | discriminate]). - 1-10: try (unfold exec_store_offset in H1; destruct (eval_offset ge ofs); try discriminate; unfold exec_store in H1; destruct (Mem.storev _ _ _); [inv H1; auto | discriminate]). - 1-10: try (unfold exec_store_reg in H1; destruct (rs1 rofs); try discriminate; unfold exec_store in H1; destruct (Mem.storev _ _ _); [inv H1; Simpl | discriminate]); auto. + 1-10: try (unfold exec_load_offset in H1; destruct (eval_offset ge ofs); try discriminate; destruct (Mem.loadv _ _ _); [inv H1; Simpl | discriminate]). + 1-10: try (unfold exec_load_reg in H1; destruct (Mem.loadv _ _ _); [inv H1; Simpl | discriminate]). + 1-10: try (unfold exec_store_offset in H1; destruct (eval_offset ge ofs); try discriminate; destruct (Mem.storev _ _ _); [inv H1; auto | discriminate]). + 1-10: try (unfold exec_store_reg in H1; destruct (Mem.storev _ _ _); [inv H1; Simpl | discriminate]); auto. - destruct (Mem.alloc _ _ _). destruct (Mem.store _ _ _ _ _). inv H1. Simpl. discriminate. - destruct (Mem.loadv _ _ _); try discriminate. destruct (rs1 _); try discriminate. destruct (Mem.free _ _ _ _). inv H1. Simpl. discriminate. -- cgit From ecd4e7a1e28f7f20c1a0c8aaebbef3217a75d28f Mon Sep 17 00:00:00 2001 From: Cyril SIX Date: Wed, 3 Apr 2019 16:59:20 +0200 Subject: Load/Store reg-reg are now proven everywhere --- mppa_k1c/Asmblockdeps.v | 122 +++++++++++++++++++++--------------------------- mppa_k1c/Asmvliw.v | 38 ++++++--------- 2 files changed, 68 insertions(+), 92 deletions(-) diff --git a/mppa_k1c/Asmblockdeps.v b/mppa_k1c/Asmblockdeps.v index ac8fa6bd..a06657a8 100644 --- a/mppa_k1c/Asmblockdeps.v +++ b/mppa_k1c/Asmblockdeps.v @@ -127,25 +127,20 @@ Definition arith_eval (ao: arith_op) (l: list value) := | _, _ => None end. -Definition exec_load_deps (chunk: memory_chunk) (m: mem) - (v: val) (ptr: ptrofs) := - match Mem.loadv chunk m (Val.offset_ptr v ptr) with - | None => None - | Some vl => Some (Val vl) - end -. - Definition exec_load_deps_offset (chunk: memory_chunk) (m: mem) (v: val) (ofs: offset) := let (ge, fn) := Ge in match (eval_offset ge ofs) with - | OK ptr => exec_load_deps chunk m v ptr + | OK ptr => match Mem.loadv chunk m (Val.offset_ptr v ptr) with + | None => None + | Some vl => Some (Val vl) + end | _ => None end. Definition exec_load_deps_reg (chunk: memory_chunk) (m: mem) (v vo: val) := - match vo with - | Vptr _ ofs => exec_load_deps chunk m v ofs - | _ => None + match Mem.loadv chunk m (Val.addl v vo) with + | None => None + | Some vl => Some (Val vl) end. Definition load_eval (lo: load_op) (l: list value) := @@ -155,25 +150,20 @@ Definition load_eval (lo: load_op) (l: list value) := | _, _ => None end. -Definition exec_store_deps (chunk: memory_chunk) (m: mem) - (vs va: val) (ptr: ptrofs) := - match Mem.storev chunk m (Val.offset_ptr va ptr) vs with - | None => None - | Some m' => Some (Memstate m') - end -. - Definition exec_store_deps_offset (chunk: memory_chunk) (m: mem) (vs va: val) (ofs: offset) := let (ge, fn) := Ge in match (eval_offset ge ofs) with - | OK ptr => exec_store_deps chunk m vs va ptr + | OK ptr => match Mem.storev chunk m (Val.offset_ptr va ptr) vs with + | None => None + | Some m' => Some (Memstate m') + end | _ => None end. Definition exec_store_deps_reg (chunk: memory_chunk) (m: mem) (vs va vo: val) := - match vo with - | Vptr _ ofs => exec_store_deps chunk m vs va ofs - | _ => None + match Mem.storev chunk m (Val.addl va vo) vs with + | None => None + | Some m' => Some (Memstate m') end. Definition store_eval (so: store_op) (l: list value) := @@ -831,47 +821,43 @@ Proof. - simpl in H. inv H. simpl macro_run. eapply trans_arith_correct; eauto. (* Load *) - - simpl in H. admit. - (* destruct i. + - simpl in H. destruct i. (* Load Offset *) + destruct i. all: - unfold exec_load_offset in H; destruct (eval_offset _ _) eqn:EVALOFF; try discriminate; unfold exec_load in H; + unfold exec_load_offset in H; destruct (eval_offset _ _) eqn:EVALOFF; try discriminate; destruct (Mem.loadv _ _ _) eqn:MEML; try discriminate; inv H; inv H0; eexists; split; try split; [ - simpl; rewrite EVALOFF; rewrite H; rewrite (H1 ra); unfold exec_load_deps; simpl in MEML; rewrite MEML; reflexivity + simpl; rewrite EVALOFF; rewrite H; rewrite (H1 ra); simpl in MEML; rewrite MEML; reflexivity | Simpl | intros rr; destruct rr; Simpl; destruct (ireg_eq g rd); subst; Simpl ]. (* Load Reg *) + destruct i. all: - unfold exec_load_reg in H; destruct (rs rofs) eqn:ROFS; try discriminate; unfold exec_load in H; - destruct (Mem.loadv _ _ _) eqn:MEML; try discriminate; inv H; inv H0; - eexists; split; try split; [ - simpl; rewrite H; rewrite (H1 rofs); rewrite (H1 ra); unfold exec_load_deps_reg; rewrite ROFS; - unfold exec_load_deps; simpl in MEML; rewrite MEML; reflexivity + unfold exec_load_reg in H; destruct (Mem.loadv _ _ _) eqn:MEML; try discriminate; inv H; inv H0; + eexists; split; try split; + [ simpl; rewrite H; rewrite (H1 rofs); rewrite (H1 ra); unfold exec_load_deps_reg; simpl in MEML; rewrite MEML; reflexivity | Simpl - | intros rr; destruct rr; Simpl; destruct (ireg_eq g rd); subst; Simpl ]. *) + | intros rr; destruct rr; Simpl; destruct (ireg_eq g rd); subst; Simpl ]. (* Store *) - - simpl in H. admit. - (* destruct i. + - simpl in H. destruct i. (* Store Offset *) + destruct i. all: - unfold exec_store_offset in H; destruct (eval_offset _ _) eqn:EVALOFF; try discriminate; unfold exec_store in H; + unfold exec_store_offset in H; destruct (eval_offset _ _) eqn:EVALOFF; try discriminate; destruct (Mem.storev _ _ _ _) eqn:MEML; try discriminate; inv H; inv H0; eexists; split; try split; - [ simpl; rewrite EVALOFF; rewrite H; rewrite (H1 ra); rewrite (H1 rs0); unfold exec_store_deps; simpl in MEML; rewrite MEML; reflexivity + [ simpl; rewrite EVALOFF; rewrite H; rewrite (H1 ra); rewrite (H1 rs0); simpl in MEML; rewrite MEML; reflexivity | Simpl | intros rr; destruct rr; Simpl ]. (* Store Reg *) + destruct i. all: - unfold exec_store_reg in H; destruct (rs rofs) eqn:ROFS; try discriminate; unfold exec_store in H; + unfold exec_store_reg in H; destruct (Mem.storev _ _ _ _) eqn:MEML; try discriminate; inv H; inv H0; eexists; split; try split; - [ simpl; rewrite H; rewrite (H1 rofs); rewrite (H1 ra); rewrite (H1 rs0); unfold exec_store_deps_reg; rewrite ROFS; - unfold exec_store_deps; simpl in MEML; rewrite MEML; reflexivity + [ simpl; rewrite H; rewrite (H1 rofs); rewrite (H1 ra); rewrite (H1 rs0); unfold exec_store_deps_reg; + simpl in MEML; rewrite MEML; reflexivity | Simpl | intros rr; destruct rr; Simpl ]. - *) + (* Allocframe *) - simpl in H. destruct (Mem.alloc _ _ _) eqn:MEMAL. destruct (Mem.store _ _ _ _) eqn:MEMS; try discriminate. inv H. inv H0. eexists. split; try split. @@ -896,8 +882,8 @@ Proof. - simpl in H. destruct rd eqn:rdeq; try discriminate. inv H. inv H0. eexists. split; try split. Simpl. intros rr; destruct rr; Simpl. (* Pnop *) - - simpl in H. inv H. inv H0. eexists. split; try split. assumption. assumption. -Admitted. + - simpl in H. inv H. inv H0. eexists. split; try split. assumption. assumption. +Qed. Lemma forward_simu_body: forall bdy ge rs m rs' m' fn s, @@ -1213,23 +1199,23 @@ Proof. (* Load Offset *) + destruct i. all: simpl; rewrite H2; rewrite (H3 ra); unfold exec_load_offset in H0; destruct (eval_offset _ _); auto; - unfold exec_load_deps; simpl in H0; destruct (Mem.loadv _ _ _); auto; discriminate. + simpl in H0; destruct (Mem.loadv _ _ _); auto; discriminate. (* Load Reg *) - + admit. (* destruct i. all: + + destruct i. all: simpl; rewrite H2; rewrite (H3 rofs); rewrite (H3 ra); unfold exec_load_reg in H0; unfold exec_load_deps_reg; - destruct (rs rofs); auto; unfold exec_load in H0; simpl in H0; unfold exec_load_deps; destruct (Mem.loadv _ _ _); auto; discriminate. *) + destruct (rs rofs); auto; simpl in H0; destruct (Mem.loadv _ _ _); auto; discriminate. (* PStore *) - destruct i. (* Store Offset *) + destruct i. all: simpl; rewrite H2; rewrite (H3 ra); rewrite (H3 rs0); unfold exec_store_offset in H0; destruct (eval_offset _ _); auto; - simpl in H0; unfold exec_store_deps; destruct (Mem.storev _ _ _); auto; discriminate. + simpl in H0; destruct (Mem.storev _ _ _); auto; discriminate. (* Store Reg *) - + admit. (* destruct i. all: + + destruct i. all: simpl; rewrite H2; rewrite (H3 rofs); rewrite (H3 ra); rewrite (H3 rs0); simpl in H0; unfold exec_store_reg in H0; - unfold exec_store_deps_reg; destruct (rs rofs); auto; unfold exec_store in H0; unfold exec_store_deps; - destruct (Mem.storev _ _ _ _); auto; discriminate. *) + unfold exec_store_deps_reg; destruct (rs rofs); auto; + destruct (Mem.storev _ _ _ _); auto; discriminate. (* Pallocframe *) - simpl. Simpl. pose (H3 SP); simpl in e; rewrite e; clear e. rewrite H2. destruct (Mem.alloc _ _ _). simpl in H0. @@ -1243,7 +1229,7 @@ Proof. all: simpl; auto. - simpl. destruct rd; subst; try discriminate. all: simpl; auto. -Admitted. +Qed. Lemma forward_simu_body_stuck: forall bdy ge fn rs m s, @@ -1805,19 +1791,19 @@ Proof. (* Load Offset *) + destruct i; simpl load_chunk in H. all: unfold parexec_load_offset in H; destruct (eval_offset _ _) eqn:EVALOFF; try discriminate; - unfold parexec_load in H; destruct (Mem.loadv _ _ _) eqn:MEML; try discriminate; inv H; inv MSR; inv MSW; + destruct (Mem.loadv _ _ _) eqn:MEML; try discriminate; inv H; inv MSR; inv MSW; eexists; split; try split; - [ simpl; rewrite EVALOFF; rewrite H; rewrite (H0 ra); unfold exec_load_deps; rewrite MEML; reflexivity + [ simpl; rewrite EVALOFF; rewrite H; rewrite (H0 ra); rewrite MEML; reflexivity | Simpl | intros rr; destruct rr; Simpl; destruct (ireg_eq g rd); subst; Simpl ]. (* Load Reg *) + destruct i; simpl load_chunk in H. all: - unfold parexec_load_reg in H; destruct (rsr rofs) eqn:ROFS; try discriminate; - unfold parexec_load in H; destruct (Mem.loadv _ _ _) eqn:MEML; try discriminate; inv H; inv MSR; inv MSW; + unfold parexec_load_reg in H; + destruct (Mem.loadv _ _ _) eqn:MEML; try discriminate; inv H; inv MSR; inv MSW; eexists; split; try split; - [ simpl; rewrite H; rewrite (H0 rofs); rewrite (H0 ra); unfold exec_load_deps_reg; rewrite ROFS; - unfold exec_load_deps; rewrite MEML; reflexivity + [ simpl; rewrite H; rewrite (H0 rofs); rewrite (H0 ra); unfold exec_load_deps_reg; + rewrite MEML; reflexivity | Simpl | intros rr; destruct rr; Simpl; destruct (ireg_eq g rd); subst; Simpl ]. @@ -1826,19 +1812,19 @@ Proof. (* Store Offset *) + destruct i; simpl store_chunk in H. all: unfold parexec_store_offset in H; destruct (eval_offset _ _) eqn:EVALOFF; try discriminate; - unfold parexec_store in H; destruct (Mem.storev _ _ _ _) eqn:MEML; try discriminate; inv H; inv MSR; inv MSW; + destruct (Mem.storev _ _ _ _) eqn:MEML; try discriminate; inv H; inv MSR; inv MSW; eexists; split; try split; - [ simpl; rewrite EVALOFF; rewrite H; rewrite (H0 ra); rewrite (H0 rs); unfold exec_store_deps; rewrite MEML; reflexivity + [ simpl; rewrite EVALOFF; rewrite H; rewrite (H0 ra); rewrite (H0 rs); rewrite MEML; reflexivity | Simpl | intros rr; destruct rr; Simpl ]. (* Store Reg *) + destruct i; simpl store_chunk in H. all: - unfold parexec_store_reg in H; destruct (rsr rofs) eqn:ROFS; try discriminate; - unfold parexec_store in H; destruct (Mem.storev _ _ _ _) eqn:MEML; try discriminate; inv H; inv MSR; inv MSW; + unfold parexec_store_reg in H; + destruct (Mem.storev _ _ _ _) eqn:MEML; try discriminate; inv H; inv MSR; inv MSW; eexists; split; try split; - [ simpl; rewrite H; rewrite (H0 rofs); rewrite (H0 ra); rewrite (H0 rs); unfold exec_store_deps_reg; rewrite ROFS; - unfold exec_store_deps; rewrite MEML; reflexivity + [ simpl; rewrite H; rewrite (H0 rofs); rewrite (H0 ra); rewrite (H0 rs); unfold exec_store_deps_reg; + rewrite MEML; reflexivity | Simpl | intros rr; destruct rr; Simpl ]. @@ -1883,23 +1869,23 @@ Proof. (* Load Offset *) + destruct i; simpl in H0. all: simpl; rewrite H; rewrite (H1 ra); unfold parexec_load_offset in H0; destruct (eval_offset _ _); auto; - unfold parexec_load in H0; unfold exec_load_deps; destruct (Mem.loadv _ _ _); auto; discriminate. + destruct (Mem.loadv _ _ _); auto; discriminate. (* Load Reg *) + destruct i; simpl in H0. all: simpl; rewrite H; rewrite (H1 rofs); rewrite (H1 ra); unfold parexec_load_reg in H0; unfold exec_load_deps_reg; - destruct (rsr rofs); auto; unfold parexec_load in H0; unfold exec_load_deps; destruct (Mem.loadv _ _ _); auto; discriminate. + destruct (rsr rofs); auto; destruct (Mem.loadv _ _ _); auto; discriminate. (* PStore *) - destruct i. (* Store Offset *) + destruct i; simpl in H0. all: simpl; rewrite H; rewrite (H1 ra); rewrite (H1 rs); unfold parexec_store_offset in H0; destruct (eval_offset _ _); auto; - unfold parexec_store in H0; unfold exec_store_deps; destruct (Mem.storev _ _ _ _); auto; discriminate. + destruct (Mem.storev _ _ _ _); auto; discriminate. (* Store Reg *) + destruct i; simpl in H0. all: simpl; rewrite H; rewrite (H1 ra); rewrite (H1 rs); rewrite (H1 rofs); unfold parexec_store_reg in H0; unfold exec_store_deps_reg; - destruct (rsr rofs); auto; unfold parexec_store in H0; unfold exec_store_deps; destruct (Mem.storev _ _ _ _); auto; discriminate. + destruct (rsr rofs); auto; destruct (Mem.storev _ _ _ _); auto; discriminate. (* Pallocframe *) - simpl. Simpl. rewrite (H1 SP). rewrite H. destruct (Mem.alloc _ _ _). simpl in H0. destruct (Mem.store _ _ _ _); try discriminate. reflexivity. diff --git a/mppa_k1c/Asmvliw.v b/mppa_k1c/Asmvliw.v index cae79287..956b860b 100644 --- a/mppa_k1c/Asmvliw.v +++ b/mppa_k1c/Asmvliw.v @@ -69,44 +69,34 @@ Definition parexec_arith_instr (ai: ar_instruction) (rsr rsw: regset): regset := (** * load/store *) (* TODO: factoriser ? *) -Definition parexec_load (chunk: memory_chunk) (rsr rsw: regset) (mr mw: mem) - (d: ireg) (a: ireg) (ptr: ptrofs) := - match Mem.loadv chunk mr (Val.offset_ptr (rsr a) ptr) with - | None => Stuck - | Some v => Next (rsw#d <- v) mw - end -. - Definition parexec_load_offset (chunk: memory_chunk) (rsr rsw: regset) (mr mw: mem) (d a: ireg) (ofs: offset) := match (eval_offset ge ofs) with - | OK ptr => parexec_load chunk rsr rsw mr mw d a ptr + | OK ptr => match Mem.loadv chunk mr (Val.offset_ptr (rsr a) ptr) with + | None => Stuck + | Some v => Next (rsw#d <- v) mw + end | _ => Stuck end. Definition parexec_load_reg (chunk: memory_chunk) (rsr rsw: regset) (mr mw: mem) (d a ro: ireg) := - match (rsr ro) with - | Vptr _ ofs => parexec_load chunk rsr rsw mr mw d a ofs - | _ => Stuck - end. - -Definition parexec_store (chunk: memory_chunk) (rsr rsw: regset) (mr mw: mem) - (s: ireg) (a: ireg) (ptr: ptrofs) := - match Mem.storev chunk mr (Val.offset_ptr (rsr a) ptr) (rsr s) with + match Mem.loadv chunk mr (Val.addl (rsr a) (rsr ro)) with | None => Stuck - | Some m' => Next rsw m' - end -. + | Some v => Next (rsw#d <- v) mw + end. Definition parexec_store_offset (chunk: memory_chunk) (rsr rsw: regset) (mr mw: mem) (s a: ireg) (ofs: offset) := match (eval_offset ge ofs) with - | OK ptr => parexec_store chunk rsr rsw mr mw s a ptr + | OK ptr => match Mem.storev chunk mr (Val.offset_ptr (rsr a) ptr) (rsr s) with + | None => Stuck + | Some m' => Next rsw m' + end | _ => Stuck end. Definition parexec_store_reg (chunk: memory_chunk) (rsr rsw: regset) (mr mw: mem) (s a ro: ireg) := - match (rsr ro) with - | Vptr _ ofs => parexec_store chunk rsr rsw mr mw s a ofs - | _ => Stuck + match Mem.storev chunk mr (Val.addl (rsr a) (rsr ro)) (rsr s) with + | None => Stuck + | Some m' => Next rsw m' end. (* rem: parexec_store = exec_store *) -- cgit