@@ -885,21 +885,12 @@ Qed.
885885
886886(** Properties of the compilation environment produced by [build_compilenv] *)
887887
888- Remark block_alignment_pos:
889- forall sz, block_alignment sz > 0.
890- Proof .
891- unfold block_alignment; intros.
892- destruct (zlt sz 2). lia.
893- destruct (zlt sz 4). lia.
894- destruct (zlt sz 8); lia.
895- Qed .
896-
897888Remark assign_variable_incr:
898889 forall id sz cenv stksz cenv' stksz',
899890 assign_variable (cenv, stksz) (id, sz) = (cenv', stksz') -> stksz <= stksz'.
900891Proof .
901892 simpl; intros. inv H.
902- generalize (align_le stksz (block_alignment sz) (block_alignment_pos sz)).
893+ generalize (align_le stksz (min_safe_alignment sz) (min_safe_alignment_pos sz)).
903894 assert (0 <= Z.max 0 sz). apply Zmax_bound_l. lia.
904895 lia.
905896Qed .
@@ -919,35 +910,22 @@ Qed.
919910
920911Remark inj_offset_aligned_block:
921912 forall stacksize sz,
922- Mem.inj_offset_aligned (align stacksize (block_alignment sz)) sz.
913+ Mem.inj_offset_aligned (align stacksize (min_safe_alignment sz)) sz.
923914Proof .
924- intros; red; intros.
925- apply Z.divide_trans with (block_alignment sz).
926- unfold align_chunk. unfold block_alignment.
927- generalize Z.divide_1_l; intro.
928- generalize Z.divide_refl; intro.
929- assert (2 | 4). exists 2; auto.
930- assert (2 | 8). exists 4; auto.
931- assert (4 | 8). exists 2; auto.
932- destruct (zlt sz 2).
933- destruct chunk; simpl in *; auto; extlia.
934- destruct (zlt sz 4).
935- destruct chunk; simpl in *; auto; extlia.
936- destruct (zlt sz 8).
937- destruct chunk; simpl in *; auto; extlia.
938- destruct chunk; simpl; auto.
939- apply align_divides. apply block_alignment_pos.
915+ intros; red; intros. apply Z.divide_trans with (min_safe_alignment sz).
916+ - apply min_safe_alignment_safe; auto.
917+ - apply align_divides. apply min_safe_alignment_pos.
940918Qed .
941919
942920Remark inj_offset_aligned_block':
943921 forall stacksize sz,
944- Mem.inj_offset_aligned (align stacksize (block_alignment sz)) (Z.max 0 sz).
922+ Mem.inj_offset_aligned (align stacksize (min_safe_alignment sz)) (Z.max 0 sz).
945923Proof .
946924 intros.
947- replace (block_alignment sz) with (block_alignment (Z.max 0 sz)).
925+ replace (min_safe_alignment sz) with (min_safe_alignment (Z.max 0 sz)).
948926 apply inj_offset_aligned_block.
949927 rewrite Zmax_spec. destruct (zlt sz 0); auto.
950- transitivity 1. reflexivity. unfold block_alignment . rewrite zlt_true. auto. lia.
928+ transitivity 1. reflexivity. unfold min_safe_alignment . rewrite zlt_true. auto. lia.
951929Qed .
952930
953931Lemma assign_variable_sound:
@@ -962,21 +940,22 @@ Lemma assign_variable_sound:
962940Proof .
963941 unfold assign_variable; intros until vars; intros ASV NOREPET POS COMPAT SEP.
964942 inv ASV.
965- assert (LE: sz1 <= align sz1 (block_alignment sz)). apply align_le. apply block_alignment_pos.
943+ assert (LE: sz1 <= align sz1 (min_safe_alignment sz)).
944+ { apply align_le. apply min_safe_alignment_pos. }
966945 assert (EITHER: forall id' sz',
967946 In (id', sz') (vars ++ (id, sz) :: nil) ->
968947 In (id', sz') vars /\ id' <> id \/ (id', sz') = (id, sz)).
969- intros. rewrite in_app in H. destruct H.
948+ { intros. rewrite in_app in H. destruct H.
970949 left; split; auto. red; intros; subst id'. elim NOREPET.
971950 change id with (fst (id, sz')). apply in_map; auto.
972- simpl in H. destruct H. auto. contradiction.
951+ simpl in H. destruct H. auto. contradiction. }
973952 split; red; intros.
974953 apply EITHER in H. destruct H as [[P Q] | P].
975954 exploit COMPAT; eauto. intros [ofs [A [B [C D]]]].
976955 exists ofs.
977956 split. rewrite PTree.gso; auto.
978957 split. auto. split. auto. zify; lia.
979- inv P. exists (align sz1 (block_alignment sz)).
958+ inv P. exists (align sz1 (min_safe_alignment sz)).
980959 split. apply PTree.gss.
981960 split. apply inj_offset_aligned_block.
982961 split. lia.
0 commit comments