@@ -3829,7 +3829,7 @@ Definition simplify {opts : symbolic_options_computed_opt} (dag : dag) (e : node
3829
3829
Lemma eval_simplify {opts : symbolic_options_computed_opt} G d n v : gensym_dag_ok G d -> eval_node G d n v -> eval G d (simplify d n) v.
3830
3830
Proof using Type . eauto using Rewrite .eval_expr, eval_node_reveal_node_at_least. Qed .
3831
3831
3832
- Definition reg_state := Tuple.tuple (option idx) 16 .
3832
+ Definition reg_state := Tuple.tuple (option idx) (compute! (List.length widest_registers)) .
3833
3833
Definition flag_state := Tuple.tuple (option idx) 6.
3834
3834
Definition mem_state := list (idx * idx).
3835
3835
@@ -3863,16 +3863,16 @@ Definition reverse_lookup_flag (st : flag_state) (i : idx) : option FLAG
3863
3863
(List.find (fun v => option_beq N.eqb (Some i) (fst v))
3864
3864
(Tuple.to_list _ (Tuple.map2 (@pair _ _) st (CF, PF, AF, ZF, SF, OF)))).
3865
3865
3866
- Definition get_reg (st : reg_state) (ri : nat ) : option idx
3867
- := Tuple.nth_default None ri st.
3868
- Definition set_reg (st : reg_state) ri (i : idx) : reg_state
3866
+ Definition get_reg (st : reg_state) (ri : N ) : option idx
3867
+ := Tuple.nth_default None (N.to_nat ri) st.
3868
+ Definition set_reg (st : reg_state) (ri : N) (i : idx) : reg_state
3869
3869
:= Tuple.from_list_default None _ (ListUtil.set_nth
3870
- ri
3870
+ (N.to_nat ri)
3871
3871
(Some i)
3872
3872
(Tuple.to_list _ st)).
3873
3873
Definition reverse_lookup_widest_reg (st : reg_state) (i : idx) : option REG
3874
3874
:= option_map
3875
- (fun v => widest_register_of_index (fst v))
3875
+ (fun v => widest_register_of_index (N.of_nat ( fst v) ))
3876
3876
(List.find (fun v => option_beq N.eqb (Some i) (snd v))
3877
3877
(List.enumerate (Tuple.to_list _ st))).
3878
3878
@@ -3906,7 +3906,7 @@ Definition update_mem_with (st : symbolic_state) (f : mem_state -> mem_state) :
3906
3906
:= {| dag_state := st.(dag_state); symbolic_reg_state := st.(symbolic_reg_state) ; symbolic_flag_state := st.(symbolic_flag_state) ; symbolic_mem_state := f st.(symbolic_mem_state) |}.
3907
3907
3908
3908
Global Instance show_reg_state : Show reg_state := fun st =>
3909
- show (List.map ( fun '(n, v) => (widest_register_of_index n, v)) (ListUtil.List.enumerate ( Option.List.map id (Tuple.to_list _ st) ))).
3909
+ show (List.combine widest_registers ( Option.List.map id (Tuple.to_list _ st))).
3910
3910
3911
3911
Global Instance show_flag_state : Show flag_state :=
3912
3912
fun '(cfv, pfv, afv, zfv, sfv, ofv) => (
@@ -3953,7 +3953,7 @@ Module error.
3953
3953
Local Unset Decidable Equality Schemes.
3954
3954
Variant error :=
3955
3955
| get_flag (f : FLAG) (s : flag_state)
3956
- | get_reg (r : nat + REG) (s : reg_state)
3956
+ | get_reg (r : N + REG) (s : reg_state)
3957
3957
| load (a : idx) (s : symbolic_state)
3958
3958
| remove (a : idx) (s : symbolic_state)
3959
3959
| remove_has_duplicates (a : idx) (vs : list idx) (s : symbolic_state)
@@ -3977,7 +3977,7 @@ Module error.
3977
3977
=> ["In flag state " ++ show_flag_state s;
3978
3978
"Flag " ++ show f ++ " was read without being set."]
3979
3979
| get_reg (inl i) s
3980
- => ["Invalid reg index " ++ show_nat i]
3980
+ => ["Invalid reg index " ++ show i]
3981
3981
| get_reg (inr r) s
3982
3982
=> ["In reg state " ++ show_reg_state s;
3983
3983
"Register " ++ show (r : REG) ++ " read without being set."]
@@ -4042,7 +4042,7 @@ Definition mapM_ {A B} (f: A -> M B) l : M unit := _ <- mapM f l; ret tt.
4042
4042
4043
4043
Definition error_get_reg_of_reg_index ri : symbolic_state -> error
4044
4044
:= error.get_reg (let r := widest_register_of_index ri in
4045
- if (reg_index r =? ri)%nat
4045
+ if (reg_index r =? ri)%N
4046
4046
then inr r
4047
4047
else inl ri).
4048
4048
0 commit comments