Module CSSAliverange
Require Import Coqlib.
Require Import Maps.
Require Import AST.
Require Import Op.
Require Import Registers.
Require Import CSSA.
Require Import SSA.
Require Import SSAutils.
Require Import CSSAgen.
Require Import Kildall.
Require Import Utils.
Require Import KildallComp.
Require Import DLib.
Require Import CSSAgenspec.
Require Import CSSAutils.
Require Import CSSAproof.
Require Import Classical.
Require Import Coqlib.
Require Import CSSA.
Require Import CSSAgenwf.
Unset Allow StrictProp.
Section CSSAparDefProp.
Variable tf :
CSSA.function.
Inductive phi_resources (
pc :
node) :
list reg ->
Prop :=
pr_intro:
forall phib dst args ,
forall (
PHICODE: (
CSSA.fn_phicode tf) !
pc =
Some phib)
(
PHI:
In (
Iphi args dst)
phib),
phi_resources pc (
dst::
args).
Lemma cssaliveout_use_def :
forall r pc,
(
forall pc,
use tf r pc ->
def tf r pc) ->
cssaliveout_spec tf r pc ->
False.
Proof.
induction 2 ; go.
Qed.
Lemma ninterlive_spec_sym:
forall r1 r2,
ninterlive_spec tf r1 r2 ->
ninterlive_spec tf r2 r1.
Proof.
induction 1 ; go.
Qed.
End CSSAparDefProp.
Section transl_function_Properties.
Variable f :
SSA.function.
Hypothesis WF:
wf_ssa_function f.
Variable tf :
CSSA.function.
Hypothesis TRANSL:
transl_function f =
Errors.OK tf.
Lemma STRUCT1:
check_parcborparcb'
tf =
true.
Proof.
Hint Resolve STRUCT1:
core.
Lemma NORM:
normalized_jp f.
Proof.
Hint Resolve NORM:
core.
Lemma use_phi_pltmaxreg_r:
forall r pc,
use_phicode tf r pc ->
Plt (
get_maxreg f)
r.
Proof.
Lemma nodups_in_preds_cssa :
forall l preds pc,
preds =
make_predecessors (
fn_code tf)
successors_instr ->
(
fn_phicode tf) !
pc <>
None ->
preds !
pc =
Some (
l:
list node) -> ~
In pc l ->
NoDup (
pc ::
l).
Proof.
Lemma phi_source_use_phicode :
forall pc phib args dst r,
(
fn_phicode tf) !
pc =
Some phib ->
In (
Iphi args dst)
phib ->
In r args ->
exists k,
cfg tf k pc /\
use_phicode tf r k.
Proof.
Lemma phiresources_use_def :
forall pc resources,
phi_resources tf pc resources ->
forall r,
In r resources ->
(
forall pc,
use tf r pc ->
def tf r pc).
Proof.
Lemma phi_resource_def :
forall pc res,
phi_resources tf pc res ->
forall r,
In r res ->
exists d,
def tf r d.
Proof.
Lemma unique_def_spec_def :
forall x d1 d2,
def tf x d1 ->
def tf x d2 ->
d1 <>
d2 ->
False.
Proof.
intros.
edestruct (
p_fn_cssa f WF)
as [
Hssa1 Hssa2];
eauto.
generalize (
p_fn_entry f WF tf TRANSL) ;
intros.
destruct H2 as [
succ Hentry].
generalize (
p_fn_cssa_params f WF tf TRANSL);
intros Hparams.
repeat invh def;
repeat invh ext_params;
try congruence ;
try solve
[
exploit Hparams ;
eauto;
intros (
HH &
HH' &
HH'') ; (
exploit HH ;
eauto)
|
exploit Hparams ;
eauto;
intros (
HH &
HH' &
HH'') ; (
exploit HH' ;
eauto)
|
exploit Hparams ;
eauto;
intros (
HH &
HH' &
HH'') ; (
exploit HH'' ;
eauto)
|
eelim H4;
eauto
|
eelim H5;
eauto
|
eelim H3;
eauto
|
eelim (
Hssa1 x d1 d2) ;
eauto ;
intuition ;
eauto
].
Qed.
Lemma def_def_eq :
forall x d1 d2,
def tf x d1 ->
def tf x d2 ->
d1 =
d2.
Proof.
Lemma phi_src_dst_ninterlive :
forall pc phib r1 r2 args,
(
fn_phicode tf) !
pc =
Some phib ->
In r2 args ->
In (
Iphi args r1)
phib ->
ninterlive_spec tf r2 r1.
Proof.
Lemma phi_unique_uses:
forall pc phib args args'
dst dst'
r,
(
fn_phicode tf) !
pc =
Some phib ->
In (
Iphi args dst)
phib ->
In (
Iphi args'
dst')
phib ->
In r args ->
In r args' ->
dst =
dst' /\
args =
args'.
Proof.
intros until r.
intros PHIB PHI1 PHI2 Hr1 Hr2.
eapply check_phicode_for_dups_in_phib_correct in PHIB;
eauto.
induction PHIB ;
intros;
go.
invh NoDup.
repeat invh In;
auto.
-
split;
go.
-
eelim H with (
x:=
r) (
y:=
r) ;
go.
-
eelim H with (
x:=
r) (
y:=
r) ;
go.
-
unfold transl_function in * ;
flatten TRANSL ;
boolInv ;
go.
Qed.
Lemma phi_unique_uses_pc :
forall pc phib args dst x r1 r2
(
PHICODE : (
fn_phicode tf) !
pc =
Some phib)
(
PHI :
In (
Iphi args dst)
phib)
(
H :
In r2 args)
(
H0 :
In r1 args)
(
CFG :
cfg tf x pc)
(
USE :
use_phicode tf r1 x)
(
USE' :
use_phicode tf r2 x)
(
DEF :
assigned_parcopy_spec (
fn_parcopycode tf)
x r1)
(
DEF' :
assigned_parcopy_spec (
fn_parcopycode tf)
x r2),
r1 =
r2.
Proof.
Theorem cssa_phi_live :
forall pc resources,
phi_resources tf pc resources ->
forall r1 r2,
In r1 resources ->
In r2 resources ->
r1 =
r2 \/
ninterlive_spec tf r1 r2.
Proof.
End transl_function_Properties.
Theorem cssa_phi_live_range :
forall f tf,
wf_ssa_function f ->
transl_function f =
Errors.OK tf ->
forall (
pc :
node) (
resources :
list reg),
phi_resources tf pc resources ->
forall r1 r2 :
reg,
In r1 resources ->
In r2 resources ->
r1 =
r2 \/
ninterlive_spec tf r1 r2.
Proof.