(* *********************************************************************)
(*                                                                     *)
(*              The Compcert verified compiler                         *)
(*                                                                     *)
(*                 Xavier Leroy, INRIA Paris                           *)
(*                                                                     *)
(*  Copyright Institut National de Recherche en Informatique et en     *)
(*  Automatique.  All rights reserved.  This file is distributed       *)
(*  under the terms of the INRIA Non-Commercial License Agreement.     *)
(*                                                                     *)
(* *********************************************************************)
(** Correctness of instruction selection for 64-bit integer operations *)
Require Archi.
Local Open Scope cminorsel_scope.
Local Open Scope string_scope.
(** * Correctness of the instruction selection functions for 64-bit operators *)
Section CMCONSTR.
Variable prog: program.
Variable hf: helper_functions.
Hypothesis HELPERS: helper_functions_declared prog hf.
Let ge := Genv.globalenv prog.
Variable sp: val.
Variable e: env.
Variable m: mem.
Definition unary_constructor_sound (cstr: expr -> expr) (sem: val -> val) : Prop :=
forall le a x,
eval_expr ge sp e m le a x ->
exists v, eval_expr ge sp e m le (cstr a) v /\ Val.lessdef (sem x) v.
Definition binary_constructor_sound (cstr: expr -> expr -> expr) (sem: val -> val -> val) : Prop :=
forall le a x b y,
eval_expr ge sp e m le a x ->
eval_expr ge sp e m le b y ->
exists v, eval_expr ge sp e m le (cstr a b) v /\ Val.lessdef (sem x y) v.
Definition partial_unary_constructor_sound (cstr: expr -> expr) (sem: val -> option val) : Prop :=
forall le a x y,
eval_expr ge sp e m le a x ->
sem x = Some y ->
exists v, eval_expr ge sp e m le (cstr a) v /\ Val.lessdef y v.
Definition partial_binary_constructor_sound (cstr: expr -> expr -> expr) (sem: val -> val -> option val) : Prop :=
forall le a x b y z,
eval_expr ge sp e m le a x ->
eval_expr ge sp e m le b y ->
sem x y = Some z ->
exists v, eval_expr ge sp e m le (cstr a b) v /\ Val.lessdef z v.

(* Specifications: *)
Theorem eval_longconst:
forall le n, eval_expr ge sp e m le (longconst n) (Vlong n).
Lemma is_longconst_sound:
forall v a n le,
is_longconst a = Some n -> eval_expr ge sp e m le a v -> v = Vlong n.
Theorem eval_longconst:
forall le n, eval_expr ge sp e m le (longconst n) (Vlong n).
Lemma is_longconst_sound:
forall v a n le,
is_longconst a = Some n -> eval_expr ge sp e m le a v -> v = Vlong n.