Debian Codegraph @

src/StandaloneDebuggingExamples.v

raw
1 From Coq Require Import List.
2 From Coq Require Import Ascii.
3 From Coq Require Import String.
4 Require Crypto.Util.Strings.String.
5 Require Import Crypto.CLI.
6 Require Import Crypto.Util.Notations.
7 Require Import Crypto.StandaloneOCamlMain.
8 Import ListNotations. Local Open Scope string_scope.
9
10 Module debugging_no_asm.
11 Import StandaloneOCamlMain.UnsaturatedSolinas.
12 Import Coq.ZArith.ZArith.
13 Open Scope Z_scope.
14 Goal True.
15 pose main as v.
16 cbv beta iota zeta delta [main main_gen] in v.
17 set (k := map _ sys_argv) in (value of v).
18 assert (k = ["./src/ExtractionOCaml/unsaturated_solinas"; "25519"; "64"; "5"; "2^255-19"; "carry_mul"; "--no-primitives"; "--debug"; "-all"; "--hints-file"; "t.asm"]) by admit.
19 clearbody k; subst k.
20 cbv beta iota zeta delta [ForExtraction.UnsaturatedSolinas.PipelineMain ForExtraction.Parameterized.PipelineMain] in v.
21 vm_compute Arg.parse_argv in v.
22 cbv beta iota in v.
23 vm_compute Arg.split_type_of_list' in v.
24 cbv beta iota in v.
25 cbv [ForExtraction.parse_common_optional_options] in v.
26 cbv [ForExtraction.hint_file_names] in v.
27 cbn [map fst snd] in v.
28 vm_compute ParseFlagOptions.parse_flag_opts in v.
29 vm_compute ParseFlagOptions.parse_flag_opts_to_bool_filter in v.
30 cbn [List.app] in v.
31 cbn [ForExtraction.with_read_concat_asm_files_cps] in v.
32 set (k := ForExtraction.with_read_file "t.asm") in (value of v).
33 assert (k = (fun k => k ["SECTION .text"
34 ;" GLOBAL 451_run80000of100000_ratio07298_seed1612328584_mul_curve25519"
35 ;""
36 ;"451_run80000of100000_ratio07298_seed1612328584_mul_curve25519:"
37 ;" sub rsp, 0x70"
38 ;" mov [ rsp + 0x38 ], rbx; saving to stack"
39 ;" mov [ rsp + 0x40 ], rbp; saving to stack"
40 ;" mov [ rsp + 0x48 ], r12; saving to stack"
41 ;" mov [ rsp + 0x50 ], r13; saving to stack"
42 ;" mov [ rsp + 0x58 ], r14; saving to stack"
43 ])) by admit.
44 clearbody k; subst k.
45 set (k := (_ =? _)%string) in (value of v) at 1; vm_compute in k; subst k; cbv beta iota in v.
46 vm_compute ForExtraction.parse_args in v.
47 cbv beta iota zeta in v.
48 vm_compute concat in v.
49 cbv [ForExtraction.output_file_name ForExtraction.asm_output_file_name] in v.
50 cbn [Option.sequence_return nth_error] in v.
51 set (k := (_ =? _)%string) in (value of v).
52 vm_compute in k; subst k.
53 cbv beta iota zeta in v.
54 cbv [ForExtraction.Parameterized.Pipeline] in v.
55 cbv [ForExtraction.Parameterized.ProcessedLines] in v.
56 cbv [ForExtraction.Parameterized.PipelineLines] in v.
57 cbv [ForExtraction.UnsaturatedSolinas.api] in v.
58 cbn [fst snd] in v.
59 repeat (set (x := ((_ ++ _)%string)) in (value of v) at 1; vm_compute in x; subst x).
60 repeat (set (x := (_ =? _)%string) in (value of v) at 1; vm_compute in x; subst x).
61 cbv beta iota zeta in v.
62 repeat (set (x := ((_ ++ _)%list)) in (value of v) at 1; vm_compute in x; subst x).
63 cbv [ForExtraction.Synthesize] in v.
64 cbv [ForExtraction.machine_wordsize ForExtraction.parsed_synthesize_options] in v.
65 cbv [UnsaturatedSolinas.Synthesize] in v.
66 cbv [BoundsPipeline.typedef_info_of_typedef] in v.
67 vm_compute BoundsPipeline.typedef.name in v.
68 vm_compute Language.Compilers.ToString.int.option.interp.to_union in v.
69 cbv [Primitives.parse_asm_hints] in v.
70 cbv [Primitives.Synthesize] in v.
71 cbv beta delta [Primitives.parse_asm_hints Primitives.parse_asm_files_lines] in v.
72 vm_compute Primitives.Options.assembly_hints_lines in v.
73 cbv beta iota in v.
74 vm_compute Parse.parse_validated in v.
75 cbv beta iota in v.
76 vm_compute Parse.split_code_to_global_functions in v.
77 cbv beta iota in v.
78 set (k := map _ _) in (value of v) at 1.
79 cbn [map] in k.
80 cbv [UnsaturatedSolinas.known_functions UnsaturatedSolinas.valid_names Primitives.synthesize_of_name] in k.
81 cbn [fold_right map] in k.
82 set (k' := (_ =? _)%string) in (value of k) at 1; vm_compute in k'; subst k'; cbv beta iota in k.
83 cbn [fold_right map List.app] in k.
84 cbv [UnsaturatedSolinas.extra_special_synthesis UnsaturatedSolinas.scarry_mul] in k.
85 set (cm := BoundsPipeline.Pipeline.BoundsPipelineWithDebug _ _ _ _ _) in (value of k).
86 vm_compute in cm.
87 set (cmv := (fun var => Language.Compilers.expr.Abs _)) in (value of cm).
88 subst cm; cbv beta iota in k.
89 let k' := fresh in rename k into k'; pose (List.map DebugMonad.Debug.eval_result (List.map snd k')) as k; subst k'.
90 cbv [DebugMonad.Debug.eval_result] in k; cbn [List.map snd] in k.
91 unfold DebugMonad.Debug.bind in (value of k) at 1; cbn [snd] in k.
92 unfold DebugMonad.Debug.bind in (value of k) at 1; cbn [snd] in k.
93 set (cml := Language.Compilers.ToString.ToFunctionLines _ _ _ _ _ _ _ _ _ _ _ _ _ _) in (value of k).
94 vm_compute in cml.
95 set (cmlv := _ :: _) in (value of cml) at 1.
96 subst cml.
97 clearbody cmlv cmv.
98 cbv beta iota in k.
99 cbn [ErrorT.bind] in k.
100 vm_compute String.append in k.
101 subst k.
102 cbn [ErrorT.bind] in v.
103 set (k := Primitives.split_to_assembly_functions _ _) in (value of v).
104 clear -k.
105 cbv [Primitives.split_to_assembly_functions] in k.
106 vm_compute in k; clear -k.
107 Abort.
108 End debugging_no_asm.
109
110 Module debugging_typedef_bounds.
111 Import StandaloneOCamlMain.UnsaturatedSolinas.
112 Goal True.
113 pose main as v.
114 cbv beta iota zeta delta [main main_gen] in v.
115 set (k := map _ sys_argv) in (value of v).
116 assert (k = ["./src/ExtractionOCaml/unsaturated_solinas"; "curve25519"; "64"; "5"; "2^255-19"; "add"; "--no-primitives"; "--debug"; "-all"]) by admit.
117 clearbody k; subst k.
118 cbv beta iota zeta delta [ForExtraction.UnsaturatedSolinas.PipelineMain ForExtraction.Parameterized.PipelineMain] in v.
119 vm_compute Arg.parse_argv in v.
120 Import ZArith.
121 Open Scope Z_scope.
122 cbv beta iota in v.
123 vm_compute Arg.split_type_of_list' in v.
124 cbv beta iota in v.
125 cbv [ForExtraction.parse_common_optional_options] in v.
126 cbv [ForExtraction.hint_file_names] in v.
127 cbn [map] in v.
128 vm_compute ParseFlagOptions.parse_flag_opts in v.
129 vm_compute ParseFlagOptions.parse_flag_opts_to_bool_filter in v.
130 cbn [List.app] in v.
131 cbn [ForExtraction.with_read_concat_asm_files_cps] in v.
132 vm_compute ForExtraction.parse_args in v.
133 cbv beta iota zeta in v.
134 vm_compute concat in v.
135 cbv [ForExtraction.output_file_name ForExtraction.asm_output_file_name] in v.
136 cbn [Option.sequence_return nth_error] in v.
137 set (k := (_ =? _)%string) in (value of v).
138 vm_compute in k; subst k.
139 cbv beta iota zeta in v.
140 cbv [ForExtraction.Parameterized.Pipeline] in v.
141 cbv [ForExtraction.Parameterized.ProcessedLines] in v.
142 cbv [ForExtraction.Parameterized.PipelineLines] in v.
143 cbv [ForExtraction.UnsaturatedSolinas.api] in v.
144 cbn [fst snd] in v.
145 repeat (set (x := ((_ ++ _)%string)) in (value of v) at 1; vm_compute in x; subst x).
146 repeat (set (x := (_ =? _)%string) in (value of v) at 1; vm_compute in x; subst x).
147 cbv beta iota zeta in v.
148 repeat (set (x := ((_ ++ _)%list)) in (value of v) at 1; vm_compute in x; subst x).
149 cbv [ForExtraction.Synthesize] in v.
150 cbv [ForExtraction.machine_wordsize ForExtraction.parsed_synthesize_options] in v.
151 cbv [UnsaturatedSolinas.Synthesize] in v.
152 cbv [BoundsPipeline.typedef_info_of_typedef] in v.
153 vm_compute BoundsPipeline.typedef.name in v.
154 vm_compute Language.Compilers.ToString.int.option.interp.to_union in v.
155 cbv [Primitives.parse_asm_hints] in v.
156 cbv [Primitives.Synthesize] in v.
157 cbv [Primitives.parse_asm_hints] in v.
158 vm_compute Primitives.Options.assembly_hints_lines in v.
159 cbv beta iota in v.
160 cbv beta iota delta [Primitives.Synthesize] in v.
161 set (k := ForExtraction.CollectErrors _) in (value of v).
162 clear v; rename k into v.
163 lazymatch (eval cbv [v] in v) with
164 | context[map ?f ["add"] ] => pose (map f ["add"]) as k; change (map f ["add"]) with k in (value of v)
165 end.
166 clear v; rename k into v.
167 cbn [map] in v.
168 cbv [Primitives.synthesize_of_name] in v.
169 set (k' := map _ _) in (value of v).
170 cbv [UnsaturatedSolinas.known_functions] in k'.
171 cbn [map] in k'.
172 repeat (set (k'' := (_ =? _)%string) in (value of k') at 1; vm_compute in k''; subst k''; cbv beta iota zeta in k').
173 set (k'' := UnsaturatedSolinas.sadd _ _ _ _ _) in (value of k').
174 clear -k''; rename k'' into v.
175 cbn -[UnsaturatedSolinas.sadd] in v.
176 cbv [ForExtraction.low_level_rewriter_method] in v.
177 cbn -[UnsaturatedSolinas.sadd] in v.
178 cbv [UnsaturatedSolinas.sadd] in v.
179 vm_compute BoundsPipeline.Pipeline.BoundsPipelineWithDebug in v.
180 cbv beta iota zeta in v.
181 let k' := fresh in rename v into k'; pose (DebugMonad.Debug.eval_result (snd k')) as v; subst k'.
182 cbv [DebugMonad.Debug.eval_result] in v; cbn [List.map snd] in v.
183 unfold DebugMonad.Debug.bind in (value of v) at 1; cbn [snd] in v.
184 cbv [Language.Compilers.ToString.ToFunctionLines] in v.
185 cbv [C.Compilers.ToString.C.OutputCAPI] in v.
186 cbv [C.Compilers.ToString.C.ToFunctionLines] in v.
187 vm_compute IR.Compilers.ToString.IR.OfPHOAS.ExprOfPHOAS in v.
188 cbv beta iota zeta in v.
189 set (k := Language.Compilers.ToString.OfPHOAS.input_bounds_to_string _ _) in (value of v).
190 cbv [Language.Compilers.ToString.OfPHOAS.input_bounds_to_string] in k; clear -k.
191 cbv [Language.Compilers.ToString.OfPHOAS.bound_to_string] in k.
192 Redirect "log" Print Language.Compilers.ToString.OfPHOAS.bound_to_string.
193 vm_compute in k.
194 Abort.
195 End debugging_typedef_bounds.