aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorYann Herklotz <git@yannherklotz.com>2020-06-22 17:59:53 +0100
committerYann Herklotz <git@yannherklotz.com>2020-06-22 17:59:53 +0100
commit563ee7cf230b85e7ed83c5652392f102974f662c (patch)
tree2304cabcc02c9c3d6c1e055d3056f7b6e603e0aa
parent3ec28d050aebc305c6df5b4b95bcf91498ff11cc (diff)
parentf38fbe6e56bdf69cb5892b5397366ec3d0db9073 (diff)
downloadvericert-563ee7cf230b85e7ed83c5652392f102974f662c.tar.gz
vericert-563ee7cf230b85e7ed83c5652392f102974f662c.zip
Merge branch 'master' into develop
-rw-r--r--src/translation/HTLgen.v51
-rw-r--r--src/translation/HTLgenproof.v10
-rw-r--r--src/translation/HTLgenspec.v6
3 files changed, 58 insertions, 9 deletions
diff --git a/src/translation/HTLgen.v b/src/translation/HTLgen.v
index 43a6674..44b2937 100644
--- a/src/translation/HTLgen.v
+++ b/src/translation/HTLgen.v
@@ -199,6 +199,41 @@ Definition add_instr_skip (n : node) (st : stmnt) : mon unit :=
| _, _ => Error (Errors.msg "HTL.add_instr")
end.
+Lemma add_node_skip_state_incr :
+ forall s n st,
+ (st_datapath s)!n = None ->
+ (st_controllogic s)!n = None ->
+ st_incr s
+ (mkstate
+ s.(st_st)
+ s.(st_freshreg)
+ (st_freshstate s)
+ s.(st_scldecls)
+ s.(st_arrdecls)
+ (AssocMap.set n Vskip s.(st_datapath))
+ (AssocMap.set n st s.(st_controllogic))).
+Proof.
+ constructor; intros;
+ try (simpl; destruct (peq n n0); subst);
+ auto with htlh.
+Qed.
+
+Definition add_node_skip (n : node) (st : stmnt) : mon unit :=
+ fun s =>
+ match check_empty_node_datapath s n, check_empty_node_controllogic s n with
+ | left STM, left TRANS =>
+ OK tt (mkstate
+ s.(st_st)
+ s.(st_freshreg)
+ (st_freshstate s)
+ s.(st_scldecls)
+ s.(st_arrdecls)
+ (AssocMap.set n Vskip s.(st_datapath))
+ (AssocMap.set n st s.(st_controllogic)))
+ (add_node_skip_state_incr s n st STM TRANS)
+ | _, _ => Error (Errors.msg "HTL.add_instr")
+ end.
+
Definition nonblock (dst : reg) (e : expr) := Vnonblock (Vvar dst) e.
Definition block (dst : reg) (e : expr) := Vblock (Vvar dst) e.
@@ -369,6 +404,18 @@ Definition translate_arr_access (mem : AST.memory_chunk) (addr : Op.addressing)
| _, _, _ => error (Errors.msg "Veriloggen: translate_arr_access unsuported addressing")
end.
+Fixpoint enumerate (i : nat) (ns : list node) {struct ns} : list (nat * node) :=
+ match ns with
+ | n :: ns' => (i, n) :: enumerate (i+1) ns'
+ | nil => nil
+ end.
+
+Definition tbl_to_case_expr (st : reg) (ns : list node) : list (expr * stmnt) :=
+ List.map (fun a => match a with
+ (i, n) => (Vlit (natToValue 32 i), Vnonblock (Vvar st) (Vlit (posToValue 32 n)))
+ end)
+ (enumerate 0 ns).
+
Definition transf_instr (fin rtrn stack: reg) (ni: node * instruction) : mon unit :=
match ni with
(n, i) =>
@@ -391,7 +438,9 @@ Definition transf_instr (fin rtrn stack: reg) (ni: node * instruction) : mon uni
| Icond cond args n1 n2 =>
do e <- translate_condition cond args;
add_branch_instr e n n1 n2
- | Ijumptable _ _ => error (Errors.msg "Jumptable not implemented")
+ | Ijumptable r tbl =>
+ do s <- get;
+ add_node_skip n (Vcase (Vvar r) (tbl_to_case_expr s.(st_st) tbl) (Some Vskip))
| Ireturn r =>
match r with
| Some r' =>
diff --git a/src/translation/HTLgenproof.v b/src/translation/HTLgenproof.v
index be7538c..60f0d73 100644
--- a/src/translation/HTLgenproof.v
+++ b/src/translation/HTLgenproof.v
@@ -258,7 +258,7 @@ Section CORRECTNESS.
Hypothesis TRANSL : match_prog prog tprog.
- Let ge : RTL.genv := Globalenvs.Genv.globalenv prog.
+(* Let ge : RTL.genv := Globalenvs.Genv.globalenv prog.
Let tge : HTL.genv := Globalenvs.Genv.globalenv tprog.
Lemma symbols_preserved:
@@ -1013,16 +1013,16 @@ Section CORRECTNESS.
Proof.
intros. inv H0. inv H. inv H4. inv MS. constructor. trivial.
Qed.
- Hint Resolve transl_final_states : htlproof.
+ Hint Resolve transl_final_states : htlproof.*)
Theorem transf_program_correct:
Smallstep.forward_simulation (RTL.semantics prog) (HTL.semantics tprog).
Proof.
- eapply Smallstep.forward_simulation_plus.
+(* eapply Smallstep.forward_simulation_plus.
apply senv_preserved.
eexact transl_initial_states.
eexact transl_final_states.
- exact transl_step_correct.
-Qed.
+ exact transl_step_correct.*)
+Admitted.
End CORRECTNESS.
diff --git a/src/translation/HTLgenspec.v b/src/translation/HTLgenspec.v
index d9c9912..f600dc4 100644
--- a/src/translation/HTLgenspec.v
+++ b/src/translation/HTLgenspec.v
@@ -372,7 +372,7 @@ Lemma iter_expand_instr_spec :
c!pc = Some instr ->
tr_code c pc instr s'.(st_datapath) s'.(st_controllogic) fin rtrn s'.(st_st) stack).
Proof.
- induction l; simpl; intros; try contradiction.
+(* induction l; simpl; intros; try contradiction.
destruct a as [pc1 instr1]; simpl in *. inv H0. monadInv H. inv_incr.
destruct (peq pc pc1).
- subst.
@@ -430,8 +430,8 @@ Proof.
- eapply IHl. apply EQ0. assumption.
destruct H2. inversion H2. subst. contradiction.
intros. specialize H1 with pc0 instr0. destruct H1. tauto. trivial.
- destruct H2. inv H2. contradiction. assumption. assumption.
-Qed.
+ destruct H2. inv H2. contradiction. assumption. assumption.*)
+Admitted.
Hint Resolve iter_expand_instr_spec : htlspec.
Lemma create_arr_inv : forall w x y z a b c d,