aboutsummaryrefslogtreecommitdiffstats
path: root/riscV/ValueAOp.v
diff options
context:
space:
mode:
authorDavid Monniaux <david.monniaux@univ-grenoble-alpes.fr>2021-02-01 18:53:04 +0100
committerDavid Monniaux <david.monniaux@univ-grenoble-alpes.fr>2021-02-01 18:53:04 +0100
commit21aaf9c53b2bb0c6d376c2ce436d6dd7f5442a47 (patch)
treec1068ba7e0aad0744ecd851050317a1967686f91 /riscV/ValueAOp.v
parent2e635ffa6693be77004e398f7dd3c2ed6bb6bca0 (diff)
downloadcompcert-kvx-21aaf9c53b2bb0c6d376c2ce436d6dd7f5442a47.tar.gz
compcert-kvx-21aaf9c53b2bb0c6d376c2ce436d6dd7f5442a47.zip
bits to float
Diffstat (limited to 'riscV/ValueAOp.v')
-rw-r--r--riscV/ValueAOp.v28
1 files changed, 27 insertions, 1 deletions
diff --git a/riscV/ValueAOp.v b/riscV/ValueAOp.v
index e1ba878e..f94669a2 100644
--- a/riscV/ValueAOp.v
+++ b/riscV/ValueAOp.v
@@ -54,6 +54,18 @@ Definition bits_of_float (v : aval) : aval :=
| _ => ntop1 v
end.
+Definition single_of_bits (v : aval) : aval :=
+ match v with
+ | I f => FS (Float32.of_bits f)
+ | _ => ntop1 v
+ end.
+
+Definition float_of_bits (v : aval) : aval :=
+ match v with
+ | L f => F (Float.of_bits f)
+ | _ => ntop1 v
+ end.
+
Definition eval_static_operation (op: operation) (vl: list aval): aval :=
match op, vl with
| Omove, v1::nil => v1
@@ -151,6 +163,8 @@ Definition eval_static_operation (op: operation) (vl: list aval): aval :=
| Ocmp c, _ => of_optbool (eval_static_condition c vl)
| Obits_of_single, v1::nil => bits_of_single v1
| Obits_of_float, v1::nil => bits_of_float v1
+ | Osingle_of_bits, v1::nil => single_of_bits v1
+ | Ofloat_of_bits, v1::nil => float_of_bits v1
| _, _ => Vbot
end.
@@ -174,7 +188,19 @@ Proof.
unfold ExtValues.bits_of_float; intros. inv H; cbn; constructor.
Qed.
-Hint Resolve bits_of_single_sound bits_of_float_sound : va.
+Lemma single_of_bits_sound:
+ forall v x, vmatch bc v x -> vmatch bc (ExtValues.single_of_bits v) (single_of_bits x).
+Proof.
+ unfold ExtValues.bits_of_single; intros. inv H; cbn; constructor.
+Qed.
+
+Lemma float_of_bits_sound:
+ forall v x, vmatch bc v x -> vmatch bc (ExtValues.float_of_bits v) (float_of_bits x).
+Proof.
+ unfold ExtValues.bits_of_float; intros. inv H; cbn; constructor.
+Qed.
+
+Hint Resolve bits_of_single_sound bits_of_float_sound single_of_bits_sound float_of_bits_sound : va.
Theorem eval_static_condition_sound:
forall cond vargs m aargs,