@@ -19,11 +19,10 @@ Require Import Bounds.
19
19
(** The general shape of activation records is as follows,
20
20
from bottom (lowest offsets) to top:
21
21
- Space for outgoing arguments to function calls.
22
- - Local stack slots.
23
- - Saved values of integer callee-save registers used by the function.
24
- - Saved values of float callee-save registers used by the function.
25
- - Saved return address into caller.
26
22
- Pointer to activation record of the caller.
23
+ - Saved return address into caller.
24
+ - Local stack slots.
25
+ - Saved values of callee-save registers used by the function.
27
26
- Space for the stack-allocated data declared in Cminor.
28
27
29
28
The [frame_env] compilation environment records the positions of
@@ -36,11 +35,11 @@ Definition fe_ofs_arg := 0.
36
35
function. *)
37
36
38
37
Definition make_env (b: bounds) :=
39
- let ol := align (4 * b.(bound_outgoing)) 8 in (* locals *)
38
+ let olink := 4 * b.(bound_outgoing) in (* back link *)
39
+ let ora := olink + 4 in (* return address *)
40
+ let ol := align (ora + 4) 8 in (* locals *)
40
41
let ocs := ol + 4 * b.(bound_local) in (* callee-saves *)
41
- let ora := align (size_callee_save_area b ocs) 4 in (* retaddr *)
42
- let olink := ora + 4 in (* back link *)
43
- let ostkdata := align (olink + 4) 8 in (* stack data *)
42
+ let ostkdata := align (size_callee_save_area b ocs) 8 in (* retaddr *)
44
43
let sz := align (ostkdata + b.(bound_stack_data)) 8 in
45
44
{| fe_size := sz;
46
45
fe_ofs_link := olink;
@@ -67,33 +66,32 @@ Lemma frame_env_separated:
67
66
Proof .
68
67
Local Opaque Z.add Z.mul sepconj range.
69
68
intros; simpl.
70
- set (ol := align (4 * b.(bound_outgoing)) 8);
69
+ set (olink := 4 * b.(bound_outgoing));
70
+ set (ora := olink + 4);
71
+ set (ol := align (ora + 4) 8);
71
72
set (ocs := ol + 4 * b.(bound_local));
72
- set (ora := align (size_callee_save_area b ocs) 4);
73
- set (olink := ora + 4);
74
- set (ostkdata := align (olink + 4) 8).
73
+ set (ostkdata := align (size_callee_save_area b ocs) 8).
75
74
generalize b.(bound_local_pos) b.(bound_outgoing_pos) b.(bound_stack_data_pos); intros.
76
- assert (4 * b.(bound_outgoing) <= ol) by (apply align_le; omega).
75
+ assert (0 <= olink) by (unfold olink; omega).
76
+ assert (olink <= ora) by (unfold ora; omega).
77
+ assert (ora + 4 <= ol) by (apply align_le; omega).
77
78
assert (ol + 4 * b.(bound_local) <= ocs) by (unfold ocs; omega).
78
79
assert (ocs <= size_callee_save_area b ocs) by apply size_callee_save_area_incr.
79
- assert (size_callee_save_area b ocs <= ora) by (apply align_le; omega).
80
- assert (ora <= olink) by (unfold olink; omega).
81
- assert (olink + 4 <= ostkdata) by (apply align_le; omega).
80
+ assert (size_callee_save_area b ocs <= ostkdata) by (apply align_le; omega).
82
81
(* Reorder as:
83
82
outgoing
84
- local
85
- callee-save
83
+ back link
86
84
retaddr
87
- back link *)
85
+ local
86
+ callee-save *)
88
87
rewrite sep_swap12.
89
- rewrite sep_swap45 .
88
+ rewrite sep_swap23 .
90
89
rewrite sep_swap34.
91
- rewrite sep_swap45.
92
90
(* Apply range_split and range_split2 repeatedly *)
93
91
unfold fe_ofs_arg.
94
- apply range_split_2. fold ol; omega. omega.
95
92
apply range_split. omega.
96
- apply range_split_2. fold ora; omega. omega.
93
+ apply range_split. omega.
94
+ apply range_split_2. fold ol; omega. omega.
97
95
apply range_split. omega.
98
96
apply range_drop_right with ostkdata. omega.
99
97
eapply sep_drop2. eexact H.
@@ -105,18 +103,18 @@ Lemma frame_env_range:
105
103
0 <= fe_stack_data fe /\ fe_stack_data fe + bound_stack_data b <= fe_size fe.
106
104
Proof .
107
105
intros; simpl.
108
- set (ol := align (4 * b.(bound_outgoing)) 8);
106
+ set (olink := 4 * b.(bound_outgoing));
107
+ set (ora := olink + 4);
108
+ set (ol := align (ora + 4) 8);
109
109
set (ocs := ol + 4 * b.(bound_local));
110
- set (ora := align (size_callee_save_area b ocs) 4);
111
- set (olink := ora + 4);
112
- set (ostkdata := align (olink + 4) 8).
110
+ set (ostkdata := align (size_callee_save_area b ocs) 8).
113
111
generalize b.(bound_local_pos) b.(bound_outgoing_pos) b.(bound_stack_data_pos); intros.
114
- assert (4 * b.(bound_outgoing) <= ol) by (apply align_le; omega).
112
+ assert (0 <= olink) by (unfold olink; omega).
113
+ assert (olink <= ora) by (unfold ora; omega).
114
+ assert (ora + 4 <= ol) by (apply align_le; omega).
115
115
assert (ol + 4 * b.(bound_local) <= ocs) by (unfold ocs; omega).
116
116
assert (ocs <= size_callee_save_area b ocs) by apply size_callee_save_area_incr.
117
- assert (size_callee_save_area b ocs <= ora) by (apply align_le; omega).
118
- assert (ora <= olink) by (unfold olink; omega).
119
- assert (olink + 4 <= ostkdata) by (apply align_le; omega).
117
+ assert (size_callee_save_area b ocs <= ostkdata) by (apply align_le; omega).
120
118
split. omega. apply align_le; omega.
121
119
Qed .
122
120
@@ -130,14 +128,13 @@ Lemma frame_env_aligned:
130
128
/\ (4 | fe_ofs_retaddr fe).
131
129
Proof .
132
130
intros; simpl.
133
- set (ol := align (4 * b.(bound_outgoing)) 8);
131
+ set (olink := 4 * b.(bound_outgoing));
132
+ set (ora := olink + 4);
133
+ set (ol := align (ora + 4) 8);
134
134
set (ocs := ol + 4 * b.(bound_local));
135
- set (ora := align (size_callee_save_area b ocs) 4);
136
- set (olink := ora + 4);
137
- set (ostkdata := align (olink + 4) 8).
135
+ set (ostkdata := align (size_callee_save_area b ocs) 8).
138
136
split. apply Zdivide_0.
139
137
split. apply align_divides; omega.
140
138
split. apply align_divides; omega.
141
- split. apply Z.divide_add_r. apply align_divides; omega. apply Z.divide_refl.
142
- apply align_divides; omega.
139
+ unfold ora, olink; auto using Z.divide_mul_l, Z.divide_add_r, Z.divide_refl.
143
140
Qed .
0 commit comments