From 373ad4a6efcb6cd0ecd30e7c131640b9783f1269 Mon Sep 17 00:00:00 2001 From: Léo Gourdin Date: Sun, 20 Dec 2020 14:30:47 +0100 Subject: Fix the Asmblock/Asm proof --- aarch64/Asmblock.v | 4 ++-- aarch64/Asmblockdeps.v | 14 +++++++------- aarch64/Asmgenproof.v | 42 +++++++++++++++++------------------------- 3 files changed, 26 insertions(+), 34 deletions(-) (limited to 'aarch64') diff --git a/aarch64/Asmblock.v b/aarch64/Asmblock.v index a4decae7..58817776 100644 --- a/aarch64/Asmblock.v +++ b/aarch64/Asmblock.v @@ -640,7 +640,7 @@ Definition exec_cfi (f: function) (cfi: cf_instruction) (rs: regset) (m: mem) : match (rs#X16 <- Vundef)#r with | Vint n => SOME lbl <- list_nth_z tbl (Int.unsigned n) IN - goto_label f lbl (rs#X16 <- Vundef #X17 <- Vundef) m + goto_label f lbl (rs#X16 <- Vundef) m | _ => Stuck end end. @@ -951,7 +951,7 @@ Inductive exec_exit (f: function) size_b (rs: regset) (m: mem): (option control) external_call ef ge vargs m t vres m' -> rs' = incrPC size_b (set_res (map_builtin_res DR res) vres - (undef_regs (map preg_of (destroyed_by_builtin ef)) rs)) -> + (undef_regs (DR (IR X16) :: DR (IR X30) :: map preg_of (destroyed_by_builtin ef)) rs)) -> exec_exit f size_b rs m (Some (Pbuiltin ef args res)) t rs' m' . diff --git a/aarch64/Asmblockdeps.v b/aarch64/Asmblockdeps.v index f5dd46ee..670a7d06 100644 --- a/aarch64/Asmblockdeps.v +++ b/aarch64/Asmblockdeps.v @@ -1051,8 +1051,7 @@ Definition trans_control (ctl: control) : inst := | Ptbz sz r n lbl => [(#PC, Op (Control (Otbz sz n lbl)) (PReg(#r) @ PReg(#PC) @ Enil))] | Pbtbl r tbl => [(#X16, Op (Constant Vundef) Enil); (#PC, Op (Control (Obtbl tbl)) (PReg(#r) @ PReg(#PC) @ Enil)); - (#X16, Op (Constant Vundef) Enil); - (#X17, Op (Constant Vundef) Enil)] + (#X16, Op (Constant Vundef) Enil)] | Pbuiltin ef args res => [] end. @@ -1923,10 +1922,9 @@ Proof. try rewrite 2Pregmap.gso, Pregmap.gss; destruct (Val.offset_ptr (rsr PC) (Ptrofs.repr sz)); try reflexivity; discriminate_ppos. Simpl sr. destruct (PregEq.eq X16 rr); [ subst; Simpl_update |]; - destruct (PregEq.eq X17 rr); [ subst; Simpl_update |]; destruct (PregEq.eq PC rr); [ subst; Simpl_update |]. rewrite !Pregmap.gso; auto; - apply ppos_discr in n0; apply ppos_discr in n1; apply ppos_discr in n2; + apply ppos_discr in n0; apply ppos_discr in n1; rewrite !assign_diff; auto. Qed. @@ -2044,11 +2042,11 @@ Proof. Qed. Lemma incrPC_undef_regs_commut l : forall d rs, - incrPC d (undef_regs (map preg_of l) rs) = undef_regs (map preg_of l) (incrPC d rs). + incrPC d (undef_regs l rs) = undef_regs l (incrPC d rs). Proof. induction l; simpl; auto. intros. rewrite IHl. unfold incrPC. - destruct (PregEq.eq (preg_of a) PC). + destruct (PregEq.eq a PC). - rewrite e. rewrite Pregmap.gss. simpl. apply f_equal. unfold Pregmap.set. apply functional_extensionality. intros x. @@ -2056,7 +2054,9 @@ Proof. - rewrite Pregmap.gso; auto. apply f_equal. unfold Pregmap.set. apply functional_extensionality. intros x. - destruct (PregEq.eq x PC); subst; auto. + destruct (PregEq.eq x PC). + + subst. destruct a; simpl; auto. congruence. + + auto. Qed. Lemma bblock_simu_reduce: diff --git a/aarch64/Asmgenproof.v b/aarch64/Asmgenproof.v index 32d1261e..19821509 100644 --- a/aarch64/Asmgenproof.v +++ b/aarch64/Asmgenproof.v @@ -1924,11 +1924,6 @@ Proof. * exploit next_inst_incr_pc_preserved; eauto. * exploit goto_label_preserved; eauto. - (* Pbtbl *) - admit. -(* FIXME, cause commit 0df99dc4 of X. Leroy. -The modifications of 0df99dc4 on Pbtbl semantics must be also ported to Asmblock. -*) -(* assert (rs2 # X16 <- Vundef r1 = (incrPC (Ptrofs.repr (size bb)) rs1) # X16 <- Vundef r1) as EQUNDEFX16. { unfold incrPC, Pregmap.set. @@ -1941,30 +1936,26 @@ The modifications of 0df99dc4 on Pbtbl semantics must be also ported to Asmblock rewrite <- (label_pos_preserved f); auto. inversion MATCHI; subst. destruct label_pos; next_stuck_cong. - destruct (((incrPC (Ptrofs.repr (size bb)) rs1) # X16 <- Vundef) # X17 <- Vundef PC) eqn:INCRPC; next_stuck_cong. + destruct ((incrPC (Ptrofs.repr (size bb)) rs1) # X16 <- Vundef PC) eqn:INCRPC; next_stuck_cong. inversion H0; auto. repeat (econstructor; eauto). rewrite !Pregmap.gso; try congruence. rewrite <- AGPC. unfold incrPC in *. destruct (rs1 PC) eqn:EQRS1; simpl in *; try discriminate. - replace (((rs2 # X16 <- Vundef) # X17 <- Vundef) # PC <- (Vptr b0 (Ptrofs.repr z))) with - ((((rs1 # PC <- (Vptr b0 (Ptrofs.add i1 (Ptrofs.repr (size bb))))) # X16 <- - Vundef) # X17 <- Vundef) # PC <- (Vptr b (Ptrofs.repr z))); auto. + replace ((rs2 # X16 <- Vundef) # PC <- (Vptr b0 (Ptrofs.repr z))) with + (((rs1 # PC <- (Vptr b0 (Ptrofs.add i1 (Ptrofs.repr (size bb))))) # X16 <- + Vundef) # PC <- (Vptr b (Ptrofs.repr z))); auto. eapply functional_extensionality; intros x. destruct (PregEq.eq x PC); subst. + rewrite Pregmap.gso in INCRPC; try congruence. - rewrite Pregmap.gso in INCRPC; try congruence. rewrite Pregmap.gss in INCRPC. rewrite !Pregmap.gss in *; congruence. + rewrite Pregmap.gso; auto. rewrite (Pregmap.gso (i := x) (j := PC)); auto. - destruct (PregEq.eq x X17); subst. + destruct (PregEq.eq x X16); subst. * rewrite !Pregmap.gss; auto. - * rewrite !(Pregmap.gso (i := x) (j:= X17)); auto. destruct (PregEq.eq x X16); subst. - -- rewrite !Pregmap.gss; auto. - -- rewrite !Pregmap.gso; auto. -*) -Admitted. + * rewrite !Pregmap.gso; auto. +Qed. Lemma last_instruction_cannot_be_label bb: list_nth_z (header bb) (size bb - 1) = None. @@ -2168,11 +2159,6 @@ Proof. - eapply pc_ptr_exec_step; eauto. - eapply find_instr_ofs_somei; eauto. * (* builtin *) - admit. -(* FIXME, cause commit 0df99dc4 of X. Leroy. -The modifications of 0df99dc4 on Pbuiltin semantics must be also ported to Asmblock. -*) -(* destruct s2. rewrite H in EXIT. rewrite H in MATCHI. simpl in MATCHI. @@ -2199,11 +2185,17 @@ The modifications of 0df99dc4 on Pbuiltin semantics must be also ported to Asmbl reflexivity. } apply set_builtin_res_dont_move_pc_gen. -- erewrite !set_builtin_map_not_pc. - erewrite !undef_regs_other_2. - rewrite HPC; auto. all: rewrite preg_notin_charact; intros; try discriminate. + erewrite !undef_regs_other. + rewrite HPC; auto. + all: intros; simpl in *; destruct H3 as [HX16 | [HX30 | HDES]]; subst; try discriminate; + exploit list_in_map_inv; eauto; intros [mr [A B]]; subst; discriminate. -- intros. eapply undef_reg_preserved; eauto. -*) -Admitted. + intros. destruct (PregEq.eq X16 r0); destruct (PregEq.eq X30 r0); subst. + rewrite Pregmap.gso, Pregmap.gss; try congruence. + do 2 (rewrite Pregmap.gso, Pregmap.gss; try discriminate; auto). + rewrite 2Pregmap.gss; auto. + rewrite !Pregmap.gso; auto. +Qed. Lemma exec_exit_simulation_star b ofs f bb s2 t rs m rs' m': forall (FINDF: Genv.find_funct_ptr ge b = Some (Internal f)) -- cgit