aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Monniaux <david.monniaux@univ-grenoble-alpes.fr>2019-05-11 10:21:59 +0200
committerDavid Monniaux <david.monniaux@univ-grenoble-alpes.fr>2019-05-11 10:21:59 +0200
commit3ef3e6c78026cc1d5793ccb4e905a0232ec7bb4e (patch)
tree2c4e87342b978883fb471559ca0c18e5f7a3cc00
parentae22df3c5ef0a60527ea85b83bb71e8c95a6ab9c (diff)
downloadcompcert-kvx-3ef3e6c78026cc1d5793ccb4e905a0232ec7bb4e.tar.gz
compcert-kvx-3ef3e6c78026cc1d5793ccb4e905a0232ec7bb4e.zip
generate multiply-sub long
-rw-r--r--mppa_k1c/ExtValues.v33
-rw-r--r--mppa_k1c/SelectLong.vp6
-rw-r--r--mppa_k1c/SelectLongproof.v21
3 files changed, 56 insertions, 4 deletions
diff --git a/mppa_k1c/ExtValues.v b/mppa_k1c/ExtValues.v
index 0d56fd1c..735d5c3c 100644
--- a/mppa_k1c/ExtValues.v
+++ b/mppa_k1c/ExtValues.v
@@ -146,4 +146,35 @@ Proof.
destruct x; destruct y; simpl; trivial.
f_equal.
apply Int.neg_mul_distr_r.
-Qed. \ No newline at end of file
+Qed.
+
+(* pointer diff
+Lemma sub_addl_negl :
+ forall x y, Val.subl x y = Val.addl x (Val.negl y).
+Proof.
+ destruct x; destruct y; simpl; trivial.
+ + f_equal. apply Int64.sub_add_opp.
+ + destruct (Archi.ptr64) eqn:ARCHI64; trivial.
+ f_equal. rewrite Ptrofs.sub_add_opp.
+ pose (Ptrofs.agree64_neg ARCHI64 (Ptrofs.of_int64 i0) i0) as Hagree.
+ unfold Ptrofs.agree64 in Hagree.
+ unfold Ptrofs.add.
+ f_equal. f_equal.
+ rewrite Hagree.
+ pose (Ptrofs.agree64_of_int ARCHI64 (Int64.neg i0)) as Hagree2.
+ rewrite Hagree2.
+ reflexivity.
+ exact (Ptrofs.agree64_of_int ARCHI64 i0).
+ + destruct (Archi.ptr64) eqn:ARCHI64; simpl; trivial.
+ destruct (eq_block _ _); simpl; trivial.
+Qed.
+ *)
+
+Lemma negl_mull_distr_r :
+ forall x y, Val.negl (Val.mull x y) = Val.mull x (Val.negl y).
+Proof.
+ destruct x; destruct y; simpl; trivial.
+ f_equal.
+ apply Int64.neg_mul_distr_r.
+Qed.
+
diff --git a/mppa_k1c/SelectLong.vp b/mppa_k1c/SelectLong.vp
index 717b0120..b29b9712 100644
--- a/mppa_k1c/SelectLong.vp
+++ b/mppa_k1c/SelectLong.vp
@@ -118,6 +118,10 @@ Nondetfunction subl (e1: expr) (e2: expr) :=
addlimm n1 (Eop Osubl (t1:::t2:::Enil))
| t1, Eop (Oaddlimm n2) (t2:::Enil) =>
addlimm (Int64.neg n2) (Eop Osubl (t1:::t2:::Enil))
+ | t1, (Eop Omull (t2:::t3:::Enil)) =>
+ Eop Omsubl (t1:::t2:::t3:::Enil)
+ | t1, (Eop (Omullimm n) (t2:::Enil)) =>
+ Eop (Omaddlimm (Int64.neg n)) (t1:::t2:::Enil)
| _, _ => Eop Osubl (e1:::e2:::Enil)
end.
@@ -225,7 +229,7 @@ Definition mullimm_base (n1: int64) (e2: expr) :=
| i :: j :: nil =>
Elet e2 (addl (shllimm (Eletvar 0) i) (shllimm (Eletvar 0) j))
| _ =>
- Eop Omull (e2 ::: longconst n1 ::: Enil)
+ Eop (Omullimm n1) (e2 ::: Enil)
end.
Nondetfunction mullimm (n1: int64) (e2: expr) :=
diff --git a/mppa_k1c/SelectLongproof.v b/mppa_k1c/SelectLongproof.v
index 3b724c01..257c7fd9 100644
--- a/mppa_k1c/SelectLongproof.v
+++ b/mppa_k1c/SelectLongproof.v
@@ -208,6 +208,23 @@ Proof.
- subst. rewrite Val.subl_addl_l. apply eval_addlimm; EvalOp.
- subst. rewrite Val.subl_addl_r.
apply eval_addlimm; EvalOp.
+- TrivialExists. simpl. subst. reflexivity.
+- TrivialExists. simpl. subst.
+ destruct v1; destruct x; simpl; trivial.
+ + f_equal. f_equal.
+ rewrite <- Int64.neg_mul_distr_r.
+ rewrite Int64.sub_add_opp.
+ reflexivity.
+ + destruct (Archi.ptr64) eqn:ARCHI64; simpl; trivial.
+ f_equal. f_equal.
+ rewrite <- Int64.neg_mul_distr_r.
+ rewrite Ptrofs.sub_add_opp.
+ unfold Ptrofs.add.
+ f_equal. f_equal.
+ rewrite (Ptrofs.agree64_neg ARCHI64 (Ptrofs.of_int64 (Int64.mul i n)) (Int64.mul i n)).
+ rewrite (Ptrofs.agree64_of_int ARCHI64 (Int64.neg (Int64.mul i n))).
+ reflexivity.
+ apply (Ptrofs.agree64_of_int ARCHI64).
- TrivialExists.
Qed.
@@ -371,7 +388,7 @@ Proof.
auto. }
generalize (Int64.one_bits'_decomp n); intros D.
destruct (Int64.one_bits' n) as [ | i [ | j [ | ? ? ]]] eqn:B.
-- apply DEFAULT.
+- TrivialExists.
- replace (Val.mull x (Vlong n)) with (Val.shll x (Vint i)).
apply eval_shllimm; auto.
simpl in D. rewrite D, Int64.add_zero. destruct x; simpl; auto.
@@ -389,7 +406,7 @@ Proof.
rewrite (Int64.one_bits'_range n) in B2 by (rewrite B; auto with coqlib).
inv B1; inv B2. simpl in B3; inv B3.
rewrite Int64.mul_add_distr_r. rewrite <- ! Int64.shl'_mul. auto.
-- apply DEFAULT.
+- TrivialExists.
Qed.
Theorem eval_mullimm: forall n, unary_constructor_sound (mullimm n) (fun v => Val.mull v (Vlong n)).