(* *********************************************************************)
(*                                                                     *)
(*              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 of instruction selection *)
Local Open Scope cminorsel_scope.
Local Open Scope error_monad_scope.
(** * Relational specification of instruction selection *)
Definition match_fundef (cunit: Cminor.program) (f: Cminor.fundef) (tf: CminorSel.fundef) : Prop :=
exists hf, helper_functions_declared cunit hf /\ sel_fundef (prog_defmap cunit) hf f = OK tf.
Definition match_prog (p: Cminor.program) (tp: CminorSel.program) :=
match_program match_fundef eq p tp.
(** Processing of helper functions *)

(* Specifications: *)
Lemma record_globdefs_sound:
forall dm id gd, (record_globdefs dm)!id = Some gd -> dm!id = Some gd.
Lemma lookup_helper_correct_1:
forall globs name sg id,
lookup_helper globs name sg = OK id ->
globs!id = Some (Gfun (External (EF_runtime name sg))).
Lemma lookup_helper_correct:
forall p name sg id,
lookup_helper (record_globdefs (prog_defmap p)) name sg = OK id ->
helper_declared p id name sg.
Lemma get_helpers_correct:
forall p hf,
get_helpers (prog_defmap p) = OK hf -> helper_functions_declared p hf.
Theorem transf_program_match:
forall p tp, sel_program p = OK tp -> match_prog p tp.
Lemma helper_functions_declared_linkorder:
forall (p p': Cminor.program) hf,
helper_functions_declared p hf -> linkorder p p' -> helper_functions_declared p' hf.