Instance Finite_mreg : Finite mreg := {
Finite_elements := all_mregs;
Finite_elements_spec := all_mregs_complete
}.
Definition mreg_type (r: mreg): typ :=
match r with
| R5  | R6  | R7  | R8  | R9  | R10 | R11
| R12 | R13 | R14 | R15 | R16 | R17 | R18 | R19
| R20 | R21 | R22 | R23 | R24 | R25 | R26 | R27
| R28 | R29 | R30 => if Archi.ptr64 then Tany64 else Tany32
| F0  | F1  | F2  | F3  | F4  | F5  | F6  | F7
| F8  | F9  | F10 | F11 | F12 | F13 | F14 | F15
| F16 | F17 | F18 | F19 | F20 | F21 | F22 | F23
| F24 | F25 | F26 | F27 | F28 | F29 | F30 | F31 => Tany64
end.
Open Scope positive_scope.
Module IndexedMreg <: INDEXED_TYPE.
Definition t := mreg.
Definition eq := mreg_eq.
Definition index (r: mreg): positive :=
match r with
| R5  =>  1 | R6  =>  2 | R7  =>  3
| R8  =>  4 | R9  =>  5 | R10 =>  6 | R11 =>  7
| R12 =>  8 | R13 =>  9 | R14 => 10 | R15 => 11
| R16 => 12 | R17 => 13 | R18 => 14 | R19 => 15
| R20 => 16 | R21 => 17 | R22 => 18 | R23 => 19
| R24 => 20 | R25 => 21 | R26 => 22 | R27 => 23
| R28 => 24 | R29 => 25 | R30 => 26
| F0  => 28 | F1  => 29 | F2  => 30 | F3  => 31
| F4  => 32 | F5  => 33 | F6  => 34 | F7  => 35
| F8  => 36 | F9  => 37 | F10 => 38 | F11 => 39
| F12 => 40 | F13 => 41 | F14 => 42 | F15 => 43
| F16 => 44 | F17 => 45 | F18 => 46 | F19 => 47
| F20 => 48 | F21 => 49 | F22 => 50 | F23 => 51
| F24 => 52 | F25 => 53 | F26 => 54 | F27 => 55
| F28 => 56 | F29 => 57 | F30 => 58 | F31 => 59
end.

Lemma index_inj:
forall r1 r2, index r1 = index r2 -> r1 = r2.