(** * Neededness for memory locations *)

Inductive nmem : Type :=
  | NMemDead
  | NMem (stk: ISet.t) (gl: PTree.t ISet.t).(** * Neededness for memory locations *)

Inductive nmem : Type :=
  | NMemDead
  | NMem (stk: ISet.t) (gl: PTree.t ISet.t).(** * Neededness for memory locations *)

Inductive nmem : Type :=
  | NMemDead
  | NMem (stk: ISet.t) (gl: PTree.t ISet.t).(** All locations are live *)

Definition nmem_all := NMem ISet.empty (PTree.empty _).

(* Specifications: *)
Lemma nlive_all: forall b ofs, nlive nmem_all b ofs.
Lemma nlive_add: forall bc b ofs p nm sz i, genv_match bc ge -> bc sp = BCstack -> pmatch bc b ofs p -> Ptrofs.unsigned ofs <= i < Ptrofs.unsigned ofs + sz -> nlive (nmem_add nm p sz) b i.
Lemma incl_nmem_add: forall nm b i p sz, nlive nm b i -> nlive (nmem_add nm p sz) b i.
Lemma nlive_remove: forall bc b ofs p nm sz b' i, genv_match bc ge -> bc sp = BCstack -> pmatch bc b ofs p -> nlive nm b' i -> b' <> b \/ i < Ptrofs.unsigned ofs \/ Ptrofs.unsigned ofs + sz <= i -> nlive (nmem_remove nm p sz) b' i.
Lemma nlive_contains: forall bc b ofs p nm sz i, genv_match bc ge -> bc sp = BCstack -> pmatch bc b ofs p -> nmem_contains nm p sz = false -> Ptrofs.unsigned ofs <= i < Ptrofs.unsigned ofs + sz -> ~(nlive nm b i).