Section LOCATIONS.
Variable ge: genv.
Variable sp: block.
Inductive nlive: nmem -> block -> Z -> Prop :=
| nlive_intro: forall stk gl b ofs
(STK: b = sp -> ~ISet.In ofs stk)
(GL: forall id iv,
Genv.find_symbol ge id = Some b ->
gl!id = Some iv ->
~ISet.In ofs iv),
nlive (NMem stk gl) b ofs.
(** All locations are live *)
Definition nmem_all := NMem ISet.empty (PTree.empty _).
(** Add a range of live locations to [nm].  The range starts at the abstract pointer [p] and has length [sz]. *)
Definition nmem_add (nm: nmem) (p: aptr) (sz: Z) : nmem :=
match nm with
| NMemDead => nmem_all       (**r very conservative, should never happen *)
| NMem stk gl =>
match p with
| Gl id ofs =>
match gl!id with
| Some iv => NMem stk (PTree.set id (ISet.remove (Ptrofs.unsigned ofs) (Ptrofs.unsigned ofs + sz) iv) gl)
| None => nm
end
| Glo id =>
NMem stk (PTree.remove id gl)
| Stk ofs =>
NMem (ISet.remove (Ptrofs.unsigned ofs) (Ptrofs.unsigned ofs + sz) stk) gl
| Stack =>
NMem ISet.empty gl
| _ => nmem_all
end
end.

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.