1212
1313(** RTL function inlining: relational specification *)
1414
15- Require Import Coqlib Wfsimpl Maps Errors Integers.
15+ Require Import Coqlib Wfsimpl Maps Errors Integers Memory .
1616Require Import AST Linking.
1717Require Import Op Registers RTL.
1818Require Import Inlining.
@@ -256,7 +256,7 @@ Definition context_stack_call (ctx1 ctx2: context): Prop :=
256256 ctx1.(mstk) >= 0 /\ ctx1.(dstk) + ctx1.(mstk) <= ctx2.(dstk).
257257
258258Definition context_stack_tailcall (ctx1: context) (f: function) (ctx2: context) : Prop :=
259- ctx2.(dstk) = align ctx1.(dstk) (min_alignment f.(fn_stacksize)).
259+ ctx2.(dstk) = align ctx1.(dstk) (min_safe_alignment f.(fn_stacksize)).
260260
261261Section INLINING_BODY_SPEC.
262262
@@ -332,7 +332,7 @@ with tr_funbody: context -> function -> code -> Prop :=
332332 (forall r, In r f.(fn_params) -> Ple r ctx.(mreg)) ->
333333 (forall pc i, f.(fn_code)!pc = Some i -> tr_instr ctx pc i c) ->
334334 ctx.(mstk) = Z.max f.(fn_stacksize) 0 ->
335- (min_alignment f.(fn_stacksize) | ctx.(dstk)) ->
335+ (min_safe_alignment f.(fn_stacksize) | ctx.(dstk)) ->
336336 ctx.(dstk) >= 0 -> ctx.(dstk) + ctx.(mstk) <= stacksize ->
337337 tr_funbody ctx f c.
338338
@@ -454,19 +454,12 @@ Hypothesis rec_spec:
454454 Ple (Pos.add ctx.(dreg) ctx.(mreg)) s.(st_nextreg) ->
455455 ctx.(mstk) >= 0 ->
456456 ctx.(mstk) = Z.max (fn_stacksize f) 0 ->
457- (min_alignment (fn_stacksize f) | ctx.(dstk)) ->
457+ (min_safe_alignment (fn_stacksize f) | ctx.(dstk)) ->
458458 ctx.(dstk) >= 0 ->
459459 s'.(st_stksize) <= stacksize ->
460460 (forall pc, Ple ctx.(dpc) pc -> Plt pc s'.(st_nextnode) -> c!pc = s'.(st_code)!pc) ->
461461 tr_funbody ctx f c.
462462
463- Remark min_alignment_pos:
464- forall sz, min_alignment sz > 0.
465- Proof .
466- intros; unfold min_alignment.
467- destruct (zle sz 1). lia. destruct (zle sz 2). lia. destruct (zle sz 4); lia.
468- Qed .
469-
470463Ltac inv_incr :=
471464 match goal with
472465 | [ H: sincr _ _ |- _ ] => destruct H; inv_incr
@@ -508,14 +501,14 @@ Proof.
508501 simpl. subst s2; simpl in *; extlia.
509502 simpl. subst s3; simpl in *; extlia.
510503 simpl. extlia.
511- simpl. apply align_divides. apply min_alignment_pos .
512- assert (dstk ctx + mstk ctx <= dstk ctx'). simpl. apply align_le. apply min_alignment_pos . lia.
504+ simpl. apply align_divides. apply min_safe_alignment_pos .
505+ assert (dstk ctx + mstk ctx <= dstk ctx'). simpl. apply align_le. apply min_safe_alignment_pos . lia.
513506 lia.
514507 intros. simpl in H. rewrite S1.
515508 transitivity (s1.(st_code)!pc0). eapply set_instr_other; eauto. unfold node in *; extlia.
516509 eapply add_moves_unchanged; eauto. unfold node in *; extlia. extlia.
517510 red; simpl. subst s2; simpl in *. extlia.
518- red; simpl. split. auto. apply align_le. apply min_alignment_pos .
511+ red; simpl. split. auto. apply align_le. apply min_safe_alignment_pos .
519512(* tailcall *)
520513 destruct (can_inline fe s1) as [|id f P Q].
521514 (* not inlined *)
@@ -538,8 +531,8 @@ Proof.
538531 simpl. subst s3; simpl in *. subst s2; simpl in *. extlia.
539532 simpl. subst s3; simpl in *; extlia.
540533 simpl. extlia.
541- simpl. apply align_divides. apply min_alignment_pos .
542- assert (dstk ctx <= dstk ctx'). simpl. apply align_le. apply min_alignment_pos . lia.
534+ simpl. apply align_divides. apply min_safe_alignment_pos .
535+ assert (dstk ctx <= dstk ctx'). simpl. apply align_le. apply min_safe_alignment_pos . lia.
543536 lia.
544537 intros. simpl in H. rewrite S1.
545538 transitivity (s1.(st_code))!pc0. eapply set_instr_other; eauto. unfold node in *; extlia.
@@ -612,7 +605,7 @@ Lemma expand_cfg_rec_spec:
612605 Ple (ctx.(dreg) + ctx.(mreg)) s.(st_nextreg) ->
613606 ctx.(mstk) >= 0 ->
614607 ctx.(mstk) = Z.max (fn_stacksize f) 0 ->
615- (min_alignment (fn_stacksize f) | ctx.(dstk)) ->
608+ (min_safe_alignment (fn_stacksize f) | ctx.(dstk)) ->
616609 ctx.(dstk) >= 0 ->
617610 s'.(st_stksize) <= stacksize ->
618611 (forall pc', Ple ctx.(dpc) pc' -> Plt pc' s'.(st_nextnode) -> c!pc' = s'.(st_code)!pc') ->
@@ -665,7 +658,7 @@ Lemma expand_cfg_spec:
665658 Ple (ctx.(dreg) + ctx.(mreg)) s.(st_nextreg) ->
666659 ctx.(mstk) >= 0 ->
667660 ctx.(mstk) = Z.max (fn_stacksize f) 0 ->
668- (min_alignment (fn_stacksize f) | ctx.(dstk)) ->
661+ (min_safe_alignment (fn_stacksize f) | ctx.(dstk)) ->
669662 ctx.(dstk) >= 0 ->
670663 s'.(st_stksize) <= stacksize ->
671664 (forall pc', Ple ctx.(dpc) pc' -> Plt pc' s'.(st_nextnode) -> c!pc' = s'.(st_code)!pc') ->
0 commit comments