Module Regmap := EMap(RegEq).
Definition regset := Regmap.t val.
Notation "a ## b" := (List.map a b) (at level 1).
Notation "a # b <- c" := (Regmap.set b c a) (at level 1, b at next level).
Fixpoint undef_regs (rl: list mreg) (rs: regset) {struct rl} : regset :=
match rl with
| nil => rs
| r1 :: rl' => Regmap.set r1 Vundef (undef_regs rl' rs)
end.
Definition undef_caller_save_regs (rs: regset) : regset :=
fun r => if is_callee_save r then rs r else Vundef.
Definition set_pair (p: rpair mreg) (v: val) (rs: regset) : regset :=
match p with
| One r => rs#r <- v
| Twolong rhi rlo => rs#rhi <- (Val.hiword v) #rlo <- (Val.loword v)
end.
Fixpoint set_res (res: builtin_res mreg) (v: val) (rs: regset) : regset :=
match res with
| BR r => Regmap.set r v rs
| BR_none => rs
| BR_splitlong hi lo => set_res lo (Val.loword v) (set_res hi (Val.hiword v) rs)
end.
Definition is_label (lbl: label) (instr: instruction) : bool :=
match instr with
| Mlabel lbl' => if peq lbl lbl' then true else false
| _ => false
end.

Lemma is_label_correct:
forall lbl instr,
if is_label lbl instr then instr = Mlabel lbl else instr <> Mlabel lbl.