aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCyril SIX <cyril.six@kalray.eu>2019-09-03 17:34:02 +0200
committerCyril SIX <cyril.six@kalray.eu>2019-09-03 17:34:02 +0200
commit863b65cc49fb49ad203694cac36e3cbd4f45dab7 (patch)
tree30a0eaafba7086be2e5eb3cab1038c7b705e11fc
parent2bf7b92601fd6f33f93609c85a79192f821e6637 (diff)
downloadcompcert-kvx-863b65cc49fb49ad203694cac36e3cbd4f45dab7.tar.gz
compcert-kvx-863b65cc49fb49ad203694cac36e3cbd4f45dab7.zip
Stubs for Duplicate pass
-rw-r--r--Makefile1
-rw-r--r--backend/Duplicate.v31
-rw-r--r--backend/Duplicateaux.ml3
-rw-r--r--backend/Duplicateproof.v29
-rw-r--r--driver/Compiler.v64
5 files changed, 100 insertions, 28 deletions
diff --git a/Makefile b/Makefile
index aa99786b..299f5ffe 100644
--- a/Makefile
+++ b/Makefile
@@ -80,6 +80,7 @@ BACKEND=\
Tailcall.v Tailcallproof.v \
Inlining.v Inliningspec.v Inliningproof.v \
Renumber.v Renumberproof.v \
+ Duplicate.v Duplicateproof.v \
RTLtyping.v \
Kildall.v Liveness.v \
ValueDomain.v ValueAOp.v ValueAnalysis.v \
diff --git a/backend/Duplicate.v b/backend/Duplicate.v
new file mode 100644
index 00000000..cb52ec04
--- /dev/null
+++ b/backend/Duplicate.v
@@ -0,0 +1,31 @@
+(** RTL node duplication using external oracle. Used to form superblock
+ structures *)
+
+Require Import AST RTL Maps.
+Require Import Coqlib Errors.
+
+Local Open Scope error_monad_scope.
+
+(** External oracle returning the new RTL function, along with a mapping
+ of new nodes to old nodes *)
+Axiom duplicate_aux: RTL.function -> RTL.function * (PTree.t nat).
+
+Extract Constant duplicate_aux => "Duplicateaux.duplicate_aux".
+
+(** * Verification of node duplications *)
+
+(** Verifies that the mapping [mp] is giving correct information *)
+Definition verify_mapping (f tf: function) (mp: PTree.t nat) : res unit := OK tt. (* TODO *)
+
+(** * Entry points *)
+
+Definition transf_function (f: function) : res function :=
+ let (tf, mp) := duplicate_aux f in
+ do u <- verify_mapping f tf mp;
+ OK tf.
+
+Definition transf_fundef (f: fundef) : res fundef :=
+ transf_partial_fundef transf_function f.
+
+Definition transf_program (p: program) : res program :=
+ transform_partial_program transf_fundef p. \ No newline at end of file
diff --git a/backend/Duplicateaux.ml b/backend/Duplicateaux.ml
new file mode 100644
index 00000000..8a57f364
--- /dev/null
+++ b/backend/Duplicateaux.ml
@@ -0,0 +1,3 @@
+open Maps
+
+let duplicate_aux f = (f, PTree.empty)
diff --git a/backend/Duplicateproof.v b/backend/Duplicateproof.v
new file mode 100644
index 00000000..5cf6b368
--- /dev/null
+++ b/backend/Duplicateproof.v
@@ -0,0 +1,29 @@
+(** Correctness proof for code duplication *)
+Require Import AST Linking Errors.
+Require Import RTL Globalenvs Smallstep.
+Require Import Duplicate.
+
+Definition match_prog (p tp: program) :=
+ match_program (fun _ f tf => transf_fundef f = OK tf) eq p tp.
+
+Lemma transf_program_match:
+ forall prog tprog, transf_program prog = OK tprog -> match_prog prog tprog.
+Proof.
+ intros. eapply match_transform_partial_program_contextual; eauto.
+Qed.
+
+Section PRESERVATION.
+
+Variable prog: program.
+Variable tprog: program.
+Hypothesis TRANSL: match_prog prog tprog.
+Let ge := Genv.globalenv prog.
+Let tge := Genv.globalenv tprog.
+
+Theorem transf_program_correct:
+ forward_simulation (RTL.semantics prog) (RTL.semantics tprog).
+Proof.
+ (* TODO *)
+Admitted.
+
+End PRESERVATION. \ No newline at end of file
diff --git a/driver/Compiler.v b/driver/Compiler.v
index 6d398327..49fa2e86 100644
--- a/driver/Compiler.v
+++ b/driver/Compiler.v
@@ -38,6 +38,7 @@ Require RTLgen.
Require Tailcall.
Require Inlining.
Require Renumber.
+Require Duplicate.
Require Constprop.
Require CSE.
Require Deadcode.
@@ -59,6 +60,7 @@ Require RTLgenproof.
Require Tailcallproof.
Require Inliningproof.
Require Renumberproof.
+Require Duplicateproof.
Require Constpropproof.
Require CSEproof.
Require Deadcodeproof.
@@ -126,16 +128,18 @@ Definition transf_rtl_program (f: RTL.program) : res Asm.program :=
@@ print (print_RTL 2)
@@ time "Renumbering" Renumber.transf_program
@@ print (print_RTL 3)
- @@ total_if Compopts.optim_constprop (time "Constant propagation" Constprop.transf_program)
+ @@@ time "Duplicating" Duplicate.transf_program
@@ print (print_RTL 4)
- @@ total_if Compopts.optim_constprop (time "Renumbering" Renumber.transf_program)
+ @@ total_if Compopts.optim_constprop (time "Constant propagation" Constprop.transf_program)
@@ print (print_RTL 5)
- @@@ partial_if Compopts.optim_CSE (time "CSE" CSE.transf_program)
+ @@ total_if Compopts.optim_constprop (time "Renumbering" Renumber.transf_program)
@@ print (print_RTL 6)
- @@@ partial_if Compopts.optim_redundancy (time "Redundancy elimination" Deadcode.transf_program)
+ @@@ partial_if Compopts.optim_CSE (time "CSE" CSE.transf_program)
@@ print (print_RTL 7)
- @@@ time "Unused globals" Unusedglob.transform_program
+ @@@ partial_if Compopts.optim_redundancy (time "Redundancy elimination" Deadcode.transf_program)
@@ print (print_RTL 8)
+ @@@ time "Unused globals" Unusedglob.transform_program
+ @@ print (print_RTL 9)
@@@ time "Register allocation" Allocation.transf_program
@@ print print_LTL
@@ time "Branch tunneling" Tunneling.tunnel_program
@@ -238,6 +242,7 @@ Definition CompCert's_passes :=
::: mkpass (match_if Compopts.optim_tailcalls Tailcallproof.match_prog)
::: mkpass Inliningproof.match_prog
::: mkpass Renumberproof.match_prog
+ ::: mkpass Duplicateproof.match_prog
::: mkpass (match_if Compopts.optim_constprop Constpropproof.match_prog)
::: mkpass (match_if Compopts.optim_constprop Renumberproof.match_prog)
::: mkpass (match_if Compopts.optim_CSE CSEproof.match_prog)
@@ -281,17 +286,18 @@ Proof.
set (p7 := total_if optim_tailcalls Tailcall.transf_program p6) in *.
destruct (Inlining.transf_program p7) as [p8|e] eqn:P8; simpl in T; try discriminate.
set (p9 := Renumber.transf_program p8) in *.
- set (p10 := total_if optim_constprop Constprop.transf_program p9) in *.
- set (p11 := total_if optim_constprop Renumber.transf_program p10) in *.
- destruct (partial_if optim_CSE CSE.transf_program p11) as [p12|e] eqn:P12; simpl in T; try discriminate.
- destruct (partial_if optim_redundancy Deadcode.transf_program p12) as [p13|e] eqn:P13; simpl in T; try discriminate.
- destruct (Unusedglob.transform_program p13) as [p14|e] eqn:P14; simpl in T; try discriminate.
- destruct (Allocation.transf_program p14) as [p15|e] eqn:P15; simpl in T; try discriminate.
- set (p16 := Tunneling.tunnel_program p15) in *.
- destruct (Linearize.transf_program p16) as [p17|e] eqn:P17; simpl in T; try discriminate.
- set (p18 := CleanupLabels.transf_program p17) in *.
- destruct (partial_if debug Debugvar.transf_program p18) as [p19|e] eqn:P19; simpl in T; try discriminate.
- destruct (Stacking.transf_program p19) as [p20|e] eqn:P20; simpl in T; try discriminate.
+ destruct (Duplicate.transf_program p9) as [p10|e] eqn:P10; simpl in T; try discriminate.
+ set (p11 := total_if optim_constprop Constprop.transf_program p10) in *.
+ set (p12 := total_if optim_constprop Renumber.transf_program p11) in *.
+ destruct (partial_if optim_CSE CSE.transf_program p12) as [p13|e] eqn:P13; simpl in T; try discriminate.
+ destruct (partial_if optim_redundancy Deadcode.transf_program p13) as [p14|e] eqn:P14; simpl in T; try discriminate.
+ destruct (Unusedglob.transform_program p14) as [p15|e] eqn:P15; simpl in T; try discriminate.
+ destruct (Allocation.transf_program p15) as [p16|e] eqn:P16; simpl in T; try discriminate.
+ set (p17 := Tunneling.tunnel_program p16) in *.
+ destruct (Linearize.transf_program p17) as [p18|e] eqn:P18; simpl in T; try discriminate.
+ set (p19 := CleanupLabels.transf_program p18) in *.
+ destruct (partial_if debug Debugvar.transf_program p19) as [p20|e] eqn:P20; simpl in T; try discriminate.
+ destruct (Stacking.transf_program p20) as [p21|e] eqn:P21; simpl in T; try discriminate.
unfold match_prog; simpl.
exists p1; split. apply SimplExprproof.transf_program_match; auto.
exists p2; split. apply SimplLocalsproof.match_transf_program; auto.
@@ -302,17 +308,18 @@ Proof.
exists p7; split. apply total_if_match. apply Tailcallproof.transf_program_match.
exists p8; split. apply Inliningproof.transf_program_match; auto.
exists p9; split. apply Renumberproof.transf_program_match; auto.
- exists p10; split. apply total_if_match. apply Constpropproof.transf_program_match.
- exists p11; split. apply total_if_match. apply Renumberproof.transf_program_match.
- exists p12; split. eapply partial_if_match; eauto. apply CSEproof.transf_program_match.
- exists p13; split. eapply partial_if_match; eauto. apply Deadcodeproof.transf_program_match.
- exists p14; split. apply Unusedglobproof.transf_program_match; auto.
- exists p15; split. apply Allocproof.transf_program_match; auto.
- exists p16; split. apply Tunnelingproof.transf_program_match.
- exists p17; split. apply Linearizeproof.transf_program_match; auto.
- exists p18; split. apply CleanupLabelsproof.transf_program_match; auto.
- exists p19; split. eapply partial_if_match; eauto. apply Debugvarproof.transf_program_match.
- exists p20; split. apply Stackingproof.transf_program_match; auto.
+ exists p10; split. apply Duplicateproof.transf_program_match; auto.
+ exists p11; split. apply total_if_match. apply Constpropproof.transf_program_match.
+ exists p12; split. apply total_if_match. apply Renumberproof.transf_program_match.
+ exists p13; split. eapply partial_if_match; eauto. apply CSEproof.transf_program_match.
+ exists p14; split. eapply partial_if_match; eauto. apply Deadcodeproof.transf_program_match.
+ exists p15; split. apply Unusedglobproof.transf_program_match; auto.
+ exists p16; split. apply Allocproof.transf_program_match; auto.
+ exists p17; split. apply Tunnelingproof.transf_program_match.
+ exists p18; split. apply Linearizeproof.transf_program_match; auto.
+ exists p19; split. apply CleanupLabelsproof.transf_program_match; auto.
+ exists p20; split. eapply partial_if_match; eauto. apply Debugvarproof.transf_program_match.
+ exists p21; split. apply Stackingproof.transf_program_match; auto.
exists tp; split. apply Asmgenproof.transf_program_match; auto.
reflexivity.
Qed.
@@ -364,7 +371,7 @@ Ltac DestructM :=
destruct H as (p & M & MM); clear H
end.
repeat DestructM. subst tp.
- assert (F: forward_simulation (Cstrategy.semantics p) (Asm.semantics p21)).
+ assert (F: forward_simulation (Cstrategy.semantics p) (Asm.semantics p22)).
{
eapply compose_forward_simulations.
eapply SimplExprproof.transl_program_correct; eassumption.
@@ -383,6 +390,7 @@ Ltac DestructM :=
eapply compose_forward_simulations.
eapply Inliningproof.transf_program_correct; eassumption.
eapply compose_forward_simulations. eapply Renumberproof.transf_program_correct; eassumption.
+ eapply compose_forward_simulations. eapply Duplicateproof.transf_program_correct; eassumption.
eapply compose_forward_simulations.
eapply match_if_simulation. eassumption. exact Constpropproof.transf_program_correct.
eapply compose_forward_simulations.