Proof of type preservation for the RRE pass.
Require Import Coqlib.
Require Import AST.
Require Import Locations.
Require Import Linear.
Require Import Lineartyping.
Require Import Conventions.
Require Import RRE.
Require Import RREproof.
Remark wt_cons:
forall f c i,
wt_instr f i ->
wt_code f c ->
wt_code f (
i::
c).
Proof.
intros; red; intros. simpl in H1; destruct H1. congruence. auto.
Qed.
Hint Constructors wt_instr :
linearty.
Hint Resolve wt_cons:
linearty.
Definition wt_eqs (
eqs:
equations) :=
forall e,
In e eqs ->
slot_type (
e_slot e) =
mreg_type (
e_reg e).
Lemma wt_eqs_nil:
wt_eqs nil.
Proof.
red; simpl; tauto. Qed.
Lemma wt_eqs_cons:
forall r s eqs,
slot_type s =
mreg_type r ->
wt_eqs eqs ->
wt_eqs (
mkeq r s ::
eqs).
Proof.
intros; red; simpl; intros. destruct H1. subst; simpl; auto. auto.
Qed.
Lemma wt_kill_loc:
forall l eqs,
wt_eqs eqs ->
wt_eqs (
kill_loc l eqs).
Proof.
intros;
red;
intros.
exploit In_kill_loc;
eauto.
intros [
A B].
auto.
Qed.
Lemma wt_kill_locs:
forall ll eqs,
wt_eqs eqs ->
wt_eqs (
kill_locs ll eqs).
Proof.
intros;
red;
intros.
exploit In_kill_locs;
eauto.
intros [
A B].
auto.
Qed.
Lemma wt_kill_temps:
forall eqs,
wt_eqs eqs ->
wt_eqs (
kill_temps eqs).
Proof.
Lemma wt_kill_at_move:
forall eqs,
wt_eqs eqs ->
wt_eqs (
kill_at_move eqs).
Proof.
Hint Resolve wt_eqs_nil wt_eqs_cons wt_kill_loc wt_kill_locs
wt_kill_temps wt_kill_at_move:
linearty.
Lemma wt_kill_op:
forall op eqs,
wt_eqs eqs ->
wt_eqs (
kill_op op eqs).
Proof.
Hint Resolve wt_kill_op:
linearty.
Lemma wt_transf_code:
forall f c eqs,
wt_code f c ->
wt_eqs eqs ->
wt_code (
transf_function f) (
transf_code eqs c).
Proof.
Lemma program_typing_preserved:
forall p,
wt_program p ->
wt_program (
transf_program p).
Proof.
intros.
red;
intros.
exploit transform_program_function;
eauto.
intros [
f0 [
A B]].
subst f.
exploit H;
eauto.
intros WTFD.
inv WTFD;
simpl;
constructor.
red;
simpl.
apply wt_transf_code;
auto with linearty.
Qed.