(* *********************************************************************)
(*                                                                     *)
(*              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 INRIA Non-Commercial License Agreement.     *)
(*                                                                     *)
(* *********************************************************************)
(** Correctness proof for RTL generation. *)
Require Export Axioms.
(** * Correspondence between Cminor environments and RTL register sets *)
(** A compilation environment (mapping) is well-formed if the following properties hold: - Two distinct Cminor local variables are mapped to distinct pseudo-registers. - A Cminor local variable and a let-bound variable are mapped to distinct pseudo-registers. *)
Record map_wf (m: mapping) : Prop :=
mk_map_wf {
map_wf_inj:
(forall id1 id2 r,
m.(map_vars)!id1 = Some r -> m.(map_vars)!id2 = Some r -> id1 = id2);
map_wf_disj:
(forall id r,
m.(map_vars)!id = Some r -> In r m.(map_letvars) -> False)
}.

(* Specifications: *)
Lemma init_mapping_wf:
map_wf init_mapping.
Lemma add_var_wf:
forall s1 s2 map name r map' i,
add_var map name s1 = OK (r,map') s2 i ->
map_wf map -> map_valid map s1 -> map_wf map'.
Lemma add_vars_wf:
forall names s1 s2 map map' rl i,
add_vars map names s1 = OK (rl,map') s2 i ->
map_wf map -> map_valid map s1 -> map_wf map'.
Lemma add_letvar_wf:
forall map r,
map_wf map -> ~reg_in_map map r -> map_wf (add_letvar map r).