aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--backend/CSE2.v19
-rw-r--r--backend/CSE2proof.v23
2 files changed, 37 insertions, 5 deletions
diff --git a/backend/CSE2.v b/backend/CSE2.v
index e2ab9f07..d9fe5799 100644
--- a/backend/CSE2.v
+++ b/backend/CSE2.v
@@ -381,6 +381,23 @@ Fixpoint kill_builtin_res res rel :=
| _ => rel
end.
+Definition apply_external_call ef (rel : RELATION.t) : RELATION.t :=
+ match ef with
+ | EF_builtin name sg
+ | EF_runtime name sg =>
+ match Builtins.lookup_builtin_function name sg with
+ | Some bf => rel
+ | None => kill_mem rel
+ end
+ | EF_malloc (* FIXME *)
+ | EF_external _ _
+ | EF_vstore _
+ | EF_free (* FIXME *)
+ | EF_memcpy _ _ (* FIXME *)
+ | EF_inline_asm _ _ _ => kill_mem rel
+ | _ => rel
+ end.
+
Definition apply_instr instr (rel : RELATION.t) : RB.t :=
match instr with
| Inop _
@@ -390,7 +407,7 @@ Definition apply_instr instr (rel : RELATION.t) : RB.t :=
| Iop op args dst _ => Some (gen_oper op dst args rel)
| Iload trap chunk addr args dst _ => Some (load chunk addr dst args rel)
| Icall _ _ _ dst _ => Some (kill_reg dst (kill_mem rel))
- | Ibuiltin _ _ res _ => Some (kill_builtin_res res (kill_mem rel))
+ | Ibuiltin ef _ res _ => Some (kill_builtin_res res (apply_external_call ef rel))
| Itailcall _ _ _ | Ireturn _ => RB.bot
end.
diff --git a/backend/CSE2proof.v b/backend/CSE2proof.v
index e61cde3d..9e0ad909 100644
--- a/backend/CSE2proof.v
+++ b/backend/CSE2proof.v
@@ -1125,6 +1125,22 @@ Definition is_killed_in_fmap fmap pc res :=
| Some map => is_killed_in_map map pc res
end.
+Lemma external_call_sound:
+ forall ef (rel : RELATION.t) sp (m m' : mem) (rs : regset) vargs t vres
+ (REL : sem_rel fundef unit ge sp m rel rs)
+ (CALL : external_call ef ge vargs m t vres m'),
+ sem_rel fundef unit ge sp m' (apply_external_call ef rel) rs.
+Proof.
+ destruct ef; intros; simpl in *.
+ all: eauto using kill_mem_sound.
+ all: unfold builtin_or_external_sem in *.
+ 1, 2: destruct (Builtins.lookup_builtin_function name sg);
+ eauto using kill_mem_sound;
+ inv CALL; eauto using kill_mem_sound.
+ all: inv CALL.
+ all: eauto using kill_mem_sound.
+Qed.
+
Definition sem_rel_b' := sem_rel_b fundef unit ge.
Definition fmap_sem' := fmap_sem fundef unit ge.
Definition subst_arg_ok' := subst_arg_ok fundef unit ge.
@@ -1587,9 +1603,9 @@ Proof.
destruct (forward_map _) as [map |] eqn:MAP in *; trivial.
destruct (map # pc) as [mpc |] eqn:MPC in *; try contradiction.
- apply sem_rel_b_ge with (rb2 := Some (kill_builtin_res res (kill_mem mpc))).
+ apply sem_rel_b_ge with (rb2 := Some (kill_builtin_res res (apply_external_call ef mpc))).
{
- replace (Some (kill_builtin_res res (kill_mem mpc))) with (apply_instr' (fn_code f) pc (map # pc)).
+ replace (Some (kill_builtin_res res (apply_external_call ef mpc))) with (apply_instr' (fn_code f) pc (map # pc)).
{
eapply DS.fixpoint_solution with (code := fn_code f) (successors := successors_instr); try eassumption.
2: apply apply_instr'_bot.
@@ -1601,8 +1617,7 @@ Proof.
reflexivity.
}
apply kill_builtin_res_sound.
- apply kill_mem_sound with (m := m).
- assumption.
+ eapply external_call_sound with (m := m); eassumption.
(* cond *)
- econstructor; split.