(* *********************************************************************)
(*                                                                     *)
(*              The Compcert verified compiler                         *)
(*                                                                     *)
(*          Xavier Leroy, INRIA Paris-Rocquencourt                     *)
(*                                                                     *)
(*  Copyright Institut National de Recherche en Informatique et en     *)
(*  Automatique.  All rights reserved.  This file is distributed       *)
(*  under the terms of the GNU General Public License as published by  *)
(*  the Free Software Foundation, either version 2 of the License, or  *)
(*  (at your option) any later version.  This file is also distributed *)
(*  under the terms of the INRIA Non-Commercial License Agreement.     *)
(*                                                                     *)
(* *********************************************************************)
(** This module defines the type of values that is used in the dynamic semantics of all our intermediate languages. *)
Definition block : Type := positive.
Definition eq_block := peq.
(** A value is either: - a machine integer; - a floating-point number; - a pointer: a pair of a memory address and an integer offset with respect to this address; - the [Vundef] value denoting an arbitrary bit pattern, such as the value of an uninitialized variable. *)
Inductive val: Type :=
| Vundef: val
| Vint: int -> val
| Vlong: int64 -> val
| Vfloat: float -> val
| Vsingle: float32 -> val
| Vptr: block -> ptrofs -> val.
Definition Vzero: val := Vint Int.zero.
Definition Vone: val := Vint Int.one.
Definition Vmone: val := Vint Int.mone.
Definition Vtrue: val := Vint Int.one.
Definition Vfalse: val := Vint Int.zero.
Definition Vnullptr :=
if Archi.ptr64 then Vlong Int64.zero else Vint Int.zero.
Definition Vptrofs (n: ptrofs) :=
if Archi.ptr64 then Vlong (Ptrofs.to_int64 n) else Vint (Ptrofs.to_int n).
(** * Operations over values *)
(** The module [Val] defines a number of arithmetic and logical operations over type [val].  Most of these operations are straightforward extensions of the corresponding integer or floating-point operations. *)
Module Val.
Definition eq (x y: val): {x=y} + {x<>y}.

Lemma Vnullptr_has_type:
has_type Vnullptr Tptr.