aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--aarch64/Asmgenproof.v55
-rw-r--r--aarch64/Asmgenproof1.v73
2 files changed, 92 insertions, 36 deletions
diff --git a/aarch64/Asmgenproof.v b/aarch64/Asmgenproof.v
index 5353d1ab..0dc37f36 100644
--- a/aarch64/Asmgenproof.v
+++ b/aarch64/Asmgenproof.v
@@ -473,7 +473,7 @@ Inductive match_states: Mach.state -> Asm.state -> Prop :=
(AT: transl_code_at_pc ge (rs PC) fb f c ep tf tc)
(AG: agree ms sp rs)
(DXP: ep = true -> rs#X29 = parent_sp s)
- (LEAF: is_leaf_function f = true -> rs#X30 = parent_ra s),
+ (LEAF: is_leaf_function f = true -> rs#RA = parent_ra s),
match_states (Mach.State s fb sp c ms m)
(Asm.State rs m')
| match_states_call:
@@ -505,7 +505,7 @@ Lemma exec_straight_steps:
exec_straight tge tf c rs1 m1' k rs2 m2'
/\ agree ms2 sp rs2
/\ (it1_is_parent ep i = true -> rs2#X29 = parent_sp s)
- /\ (is_leaf_function f = true -> rs2#X30 = parent_ra s)) ->
+ /\ (is_leaf_function f = true -> rs2#RA = parent_ra s)) ->
exists st',
plus step tge (State rs1 m1') E0 st' /\
match_states (Mach.State s fb sp c ms2 m2) st'.
@@ -529,13 +529,14 @@ Lemma exec_straight_steps_goto:
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') ->
+ /\ exec_instr tge tf jmp rs2 m2' = goto_label tf lbl rs2 m2'
+ /\ (is_leaf_function f = true -> rs2#RA = parent_ra 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 H3. subst. monadInv H9.
- exploit H5; eauto. intros [jmp [k' [rs2 [A [B C]]]]].
+ exploit H5; eauto. intros [jmp [k' [rs2 [A [B [C D]]]]]].
generalize (functions_transl _ _ _ H7 H8); intro FN.
generalize (transf_function_no_overflow _ _ H8); intro NOOV.
exploit exec_straight_steps_2; eauto.
@@ -552,6 +553,7 @@ Proof.
econstructor; eauto.
apply agree_exten with rs2; auto with asmgen.
congruence.
+ rewrite OTH by congruence; auto.
Qed.
Lemma exec_straight_opt_steps_goto:
@@ -566,13 +568,14 @@ Lemma exec_straight_opt_steps_goto:
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') ->
+ /\ exec_instr tge tf jmp rs2 m2' = goto_label tf lbl rs2 m2'
+ /\ (is_leaf_function f = true -> rs2#RA = parent_ra 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 H3. subst. monadInv H9.
- exploit H5; eauto. intros [jmp [k' [rs2 [A [B C]]]]].
+ exploit H5; eauto. intros [jmp [k' [rs2 [A [B [C D]]]]]].
generalize (functions_transl _ _ _ H7 H8); intro FN.
generalize (transf_function_no_overflow _ _ H8); intro NOOV.
inv A.
@@ -585,6 +588,7 @@ Proof.
econstructor; eauto.
apply agree_exten with rs2; auto with asmgen.
congruence.
+ rewrite OTH by congruence; auto.
- exploit exec_straight_steps_2; eauto.
intros [ofs' [PC2 CT2]].
exploit find_label_goto_label; eauto.
@@ -599,6 +603,7 @@ Proof.
econstructor; eauto.
apply agree_exten with rs2; auto with asmgen.
congruence.
+ rewrite OTH by congruence; auto.
Qed.
(** We need to show that, in the simulation diagram, we cannot
@@ -640,17 +645,20 @@ Proof.
- (* Mlabel *)
left; eapply exec_straight_steps; eauto; intros.
monadInv TR. econstructor; split. apply exec_straight_one. simpl; eauto. auto.
- split. apply agree_nextinstr; auto. simpl; congruence.
+ split. { apply agree_nextinstr; auto. }
+ split. { simpl; congruence. }
+ rewrite nextinstr_inv by congruence; assumption.
- (* Mgetstack *)
unfold load_stack in H.
exploit Mem.loadv_extends; eauto. intros [v' [A B]].
rewrite (sp_val _ _ _ AG) in A.
left; eapply exec_straight_steps; eauto. intros. simpl in TR.
- exploit loadind_correct; eauto with asmgen. intros [rs' [P [Q R]]].
+ exploit loadind_correct; eauto with asmgen. intros [rs' [P [Q [R S]]]].
exists rs'; split. eauto.
- split. eapply agree_set_mreg; eauto with asmgen. congruence.
- simpl; congruence.
+ split. { eapply agree_set_mreg; eauto with asmgen. congruence. }
+ split. { simpl; congruence. }
+ rewrite S. assumption.
- (* Msetstack *)
unfold store_stack in H.
@@ -658,10 +666,12 @@ Proof.
exploit Mem.storev_extends; eauto. intros [m2' [A B]].
left; eapply exec_straight_steps; eauto.
rewrite (sp_val _ _ _ AG) in A. intros. simpl in TR.
- exploit storeind_correct; eauto with asmgen. intros [rs' [P Q]].
+ exploit storeind_correct; eauto with asmgen. intros [rs' [P [Q R]]].
exists rs'; split. eauto.
split. eapply agree_undef_regs; eauto with asmgen.
- simpl; intros. rewrite Q; auto with asmgen.
+ simpl; intros.
+ split. rewrite Q; auto with asmgen.
+ rewrite R. assumption.
- (* Mgetparam *)
assert (f0 = f) by congruence; subst f0.
@@ -677,24 +687,29 @@ Opaque loadind.
(* X30 contains parent *)
exploit loadind_correct. eexact EQ.
instantiate (2 := rs0). simpl; rewrite DXP; eauto. simpl; congruence.
- intros [rs1 [P [Q R]]].
+ intros [rs1 [P [Q [R S]]]].
exists rs1; split. eauto.
split. eapply agree_set_mreg. eapply agree_set_mreg; eauto. congruence. auto with asmgen.
- simpl; intros. rewrite R; auto with asmgen.
- apply preg_of_not_X29; auto.
+ simpl; split; intros.
+ { rewrite R; auto with asmgen.
+ apply preg_of_not_X29; auto.
+ }
+ { rewrite S; auto. }
+
(* X30 does not contain parent *)
exploit loadptr_correct. eexact A. simpl; congruence. intros [rs1 [P [Q R]]].
exploit loadind_correct. eexact EQ. instantiate (2 := rs1). simpl; rewrite Q. eauto. simpl; congruence.
- intros [rs2 [S [T U]]].
+ intros [rs2 [S [T [U V]]]].
exists rs2; split. eapply exec_straight_trans; eauto.
split. eapply agree_set_mreg. eapply agree_set_mreg. eauto. eauto.
instantiate (1 := rs1#X29 <- (rs2#X29)). intros.
rewrite Pregmap.gso; auto with asmgen.
congruence.
intros. unfold Pregmap.set. destruct (PregEq.eq r' X29). congruence. auto with asmgen.
- simpl; intros. rewrite U; auto with asmgen.
+ split; simpl; intros. rewrite U; auto with asmgen.
apply preg_of_not_X29; auto.
-
+ rewrite V. rewrite R by congruence. auto.
+
- (* Mop *)
assert (eval_operation tge sp op (map rs args) m = Some v).
{ rewrite <- H. apply eval_operation_preserved. exact symbols_preserved. }
@@ -705,11 +720,11 @@ Opaque loadind.
exists rs2; split. eauto. split.
apply agree_set_undef_mreg with rs0; auto.
apply Val.lessdef_trans with v'; auto.
- simpl; intros. InvBooleans.
+ split; simpl; intros. InvBooleans.
rewrite R; auto. apply preg_of_not_X29; auto.
Local Transparent destroyed_by_op.
destruct op; try exact I; simpl; congruence.
-
+
- (* Mload *)
assert (Op.eval_addressing tge sp addr (map rs args) = Some a).
{ rewrite <- H. apply eval_addressing_preserved. exact symbols_preserved. }
diff --git a/aarch64/Asmgenproof1.v b/aarch64/Asmgenproof1.v
index 6d44bcc8..c85543f3 100644
--- a/aarch64/Asmgenproof1.v
+++ b/aarch64/Asmgenproof1.v
@@ -22,6 +22,37 @@ Local Transparent Archi.ptr64.
(** Properties of registers *)
+Lemma preg_of_not_RA:
+ forall r, (preg_of r) <> RA.
+Proof.
+ destruct r; discriminate.
+Qed.
+
+Lemma RA_not_written:
+ forall (rs : regset) dst v,
+ rs # (preg_of dst) <- v RA = rs RA.
+Proof.
+ intros.
+ apply Pregmap.gso.
+ intro.
+ symmetry in H.
+ exact (preg_of_not_RA dst H).
+Qed.
+
+Hint Resolve RA_not_written : asmgen.
+
+Lemma RA_not_written2:
+ forall (rs : regset) dst v i,
+ preg_of dst = i ->
+ rs # i <- v RA = rs RA.
+Proof.
+ intros.
+ subst i.
+ apply RA_not_written.
+Qed.
+
+Hint Resolve RA_not_written2 : asmgen.
+
Lemma preg_of_iregsp_not_PC: forall r, preg_of_iregsp r <> PC.
Proof.
destruct r; simpl; congruence.
@@ -1347,13 +1378,15 @@ Ltac TranslOpSimpl :=
[ apply exec_straight_one; [simpl; eauto | reflexivity]
| split; [ rewrite ? transl_eval_shift, ? transl_eval_shiftl;
apply Val.lessdef_same; Simpl; fail
- | intros; Simpl; fail ] ].
+ | split; [ intros; Simpl; fail
+ | intros; Simpl; eapply RA_not_written2; eauto] ]].
Ltac TranslOpBase :=
econstructor; split;
[ apply exec_straight_one; [simpl; eauto | reflexivity]
| split; [ rewrite ? transl_eval_shift, ? transl_eval_shiftl; Simpl
- | intros; Simpl; fail ] ].
+ | split; [ intros; Simpl; fail
+ | intros; Simpl; eapply RA_not_written2; eauto] ]].
Lemma transl_op_correct:
forall op args res k (rs: regset) m v c,
@@ -1362,15 +1395,15 @@ Lemma transl_op_correct:
exists rs',
exec_straight ge fn c rs m k rs' m
/\ Val.lessdef v rs'#(preg_of res)
- /\ forall r, data_preg r = true -> r <> preg_of res -> preg_notin r (destroyed_by_op op) -> rs' r = rs r.
+ /\ (forall r, data_preg r = true -> r <> preg_of res -> preg_notin r (destroyed_by_op op) -> rs' r = rs r)
+ /\ rs' RA = rs RA.
Proof.
Local Opaque Int.eq Int64.eq Val.add Val.addl Int.zwordsize Int64.zwordsize.
intros until c; intros TR EV.
unfold transl_op in TR; destruct op; ArgsInv; simpl in EV; SimplEval EV; try TranslOpSimpl.
- (* move *)
destruct (preg_of res) eqn:RR; try discriminate; destruct (preg_of m0) eqn:R1; inv TR.
-+ TranslOpSimpl.
-+ TranslOpSimpl.
+ all: TranslOpSimpl.
- (* intconst *)
exploit exec_loadimm32. intros (rs' & A & B & C).
exists rs'; split. eexact A. split. rewrite B; auto. intros; auto with asmgen.
@@ -1712,7 +1745,7 @@ Lemma loadptr_correct: forall (base: iregsp) ofs dst k m v (rs: regset),
exists rs',
exec_straight ge fn (loadptr base ofs dst k) rs m k rs' m
/\ rs'#dst = v
- /\ forall r, r <> PC -> r <> X16 -> r <> dst -> rs' r = rs r.
+ /\ (forall r, r <> PC -> r <> X16 -> r <> dst -> rs' r = rs r).
Proof.
intros.
destruct (Val.offset_ptr rs#base ofs) eqn:V; try discriminate.
@@ -1720,7 +1753,8 @@ Proof.
econstructor; split.
eapply exec_straight_opt_right. eexact A.
apply exec_straight_one. simpl. unfold exec_load. rewrite B, H. eauto. auto.
- split. Simpl. intros; Simpl.
+ split. Simpl.
+ intros; Simpl.
Qed.
Lemma storeptr_correct: forall (base: iregsp) ofs (src: ireg) k m m' (rs: regset),
@@ -1729,7 +1763,8 @@ Lemma storeptr_correct: forall (base: iregsp) ofs (src: ireg) k m m' (rs: regset
src <> X16 ->
exists rs',
exec_straight ge fn (storeptr src base ofs k) rs m k rs' m'
- /\ forall r, r <> PC -> r <> X16 -> rs' r = rs r.
+ /\ (forall r, r <> PC -> r <> X16 -> rs' r = rs r)
+ /\ rs' RA = rs RA.
Proof.
intros.
destruct (Val.offset_ptr rs#base ofs) eqn:V; try discriminate.
@@ -1737,7 +1772,7 @@ Proof.
econstructor; split.
eapply exec_straight_opt_right. eexact A.
apply exec_straight_one. simpl. unfold exec_store. rewrite B, C, H by eauto with asmgen. eauto. auto.
- intros; Simpl.
+ split; intros; Simpl.
Qed.
Lemma loadind_correct: forall (base: iregsp) ofs ty dst k c (rs: regset) m v,
@@ -1747,7 +1782,8 @@ Lemma loadind_correct: forall (base: iregsp) ofs ty dst k c (rs: regset) m v,
exists rs',
exec_straight ge fn c rs m k rs' m
/\ rs'#(preg_of dst) = v
- /\ forall r, data_preg r = true -> r <> preg_of dst -> rs' r = rs r.
+ /\ (forall r, data_preg r = true -> r <> preg_of dst -> rs' r = rs r)
+ /\ rs' RA = rs RA.
Proof.
intros.
destruct (Val.offset_ptr rs#base ofs) eqn:V; try discriminate.
@@ -1763,7 +1799,10 @@ Proof.
econstructor; split.
eapply exec_straight_opt_right. eexact A.
apply exec_straight_one. rewrite SEM. unfold exec_load. rewrite B, H0. eauto. Simpl.
- split. Simpl. intros; Simpl.
+ split. Simpl.
+ split. intros; Simpl.
+ Simpl. rewrite RA_not_written.
+ apply C; congruence.
Qed.
Lemma storeind_correct: forall (base: iregsp) ofs ty src k c (rs: regset) m m',
@@ -1772,7 +1811,8 @@ Lemma storeind_correct: forall (base: iregsp) ofs ty src k c (rs: regset) m m',
preg_of_iregsp base <> IR X16 ->
exists rs',
exec_straight ge fn c rs m k rs' m'
- /\ forall r, data_preg r = true -> rs' r = rs r.
+ /\ (forall r, data_preg r = true -> rs' r = rs r)
+ /\ rs' RA = rs RA.
Proof.
intros.
destruct (Val.offset_ptr rs#base ofs) eqn:V; try discriminate.
@@ -1790,7 +1830,8 @@ Proof.
apply exec_straight_one. rewrite SEM.
unfold exec_store. rewrite B, C, H0 by eauto with asmgen. eauto.
Simpl.
- intros; Simpl.
+ split. intros; Simpl.
+ Simpl.
Qed.
Lemma make_epilogue_correct:
@@ -1807,7 +1848,7 @@ Lemma make_epilogue_correct:
/\ Mem.extends m' tm'
/\ rs'#RA = parent_ra cs
/\ rs'#SP = parent_sp cs
- /\ (forall r, r <> PC -> r <> SP -> r <> X30 -> r <> X16 -> rs'#r = rs#r).
+ /\ (forall r, r <> PC -> r <> SP -> r <> RA -> r <> X16 -> rs'#r = rs#r).
Proof.
intros until tm; intros LP LRA FREE AG MEXT MCS.
exploit Mem.loadv_extends. eauto. eexact LP. auto. simpl. intros (parent' & LP' & LDP').
@@ -1815,7 +1856,7 @@ Proof.
exploit lessdef_parent_sp; eauto. intros EQ; subst parent'; clear LDP'.
exploit lessdef_parent_ra; eauto. intros EQ; subst ra'; clear LDRA'.
exploit Mem.free_parallel_extends; eauto. intros (tm' & FREE' & MEXT').
- unfold make_epilogue.
+ unfold make_epilogue.
exploit (loadptr_correct XSP (fn_retaddr_ofs f)).
instantiate (2 := rs). simpl. rewrite <- (sp_val _ _ _ AG). simpl. eexact LRA'. simpl; congruence.
intros (rs1 & A1 & B1 & C1).
@@ -1833,4 +1874,4 @@ Proof.
intros. Simpl.
Qed.
-End CONSTRUCTORS. \ No newline at end of file
+End CONSTRUCTORS.