1 | open Preamble |
---|
2 | |
---|
3 | open CostLabel |
---|
4 | |
---|
5 | open Proper |
---|
6 | |
---|
7 | open PositiveMap |
---|
8 | |
---|
9 | open Deqsets |
---|
10 | |
---|
11 | open PreIdentifiers |
---|
12 | |
---|
13 | open Errors |
---|
14 | |
---|
15 | open Extralib |
---|
16 | |
---|
17 | open Setoids |
---|
18 | |
---|
19 | open Monad |
---|
20 | |
---|
21 | open Option |
---|
22 | |
---|
23 | open Lists |
---|
24 | |
---|
25 | open Positive |
---|
26 | |
---|
27 | open Identifiers |
---|
28 | |
---|
29 | open Coqlib |
---|
30 | |
---|
31 | open Floats |
---|
32 | |
---|
33 | open Arithmetic |
---|
34 | |
---|
35 | open Char |
---|
36 | |
---|
37 | open String |
---|
38 | |
---|
39 | open Vector |
---|
40 | |
---|
41 | open Div_and_mod |
---|
42 | |
---|
43 | open Jmeq |
---|
44 | |
---|
45 | open Russell |
---|
46 | |
---|
47 | open List |
---|
48 | |
---|
49 | open Util |
---|
50 | |
---|
51 | open FoldStuff |
---|
52 | |
---|
53 | open BitVector |
---|
54 | |
---|
55 | open Extranat |
---|
56 | |
---|
57 | open Bool |
---|
58 | |
---|
59 | open Relations |
---|
60 | |
---|
61 | open Nat |
---|
62 | |
---|
63 | open Integers |
---|
64 | |
---|
65 | open Hints_declaration |
---|
66 | |
---|
67 | open Core_notation |
---|
68 | |
---|
69 | open Pts |
---|
70 | |
---|
71 | open Logic |
---|
72 | |
---|
73 | open Types |
---|
74 | |
---|
75 | open AST |
---|
76 | |
---|
77 | open Csyntax |
---|
78 | |
---|
79 | open Label |
---|
80 | |
---|
81 | open Sets |
---|
82 | |
---|
83 | open Listb |
---|
84 | |
---|
85 | open Star |
---|
86 | |
---|
87 | open Frontend_misc |
---|
88 | |
---|
89 | open CexecInd |
---|
90 | |
---|
91 | open CexecSound |
---|
92 | |
---|
93 | open Casts |
---|
94 | |
---|
95 | open ClassifyOp |
---|
96 | |
---|
97 | open Smallstep |
---|
98 | |
---|
99 | open Extra_bool |
---|
100 | |
---|
101 | open FrontEndVal |
---|
102 | |
---|
103 | open Hide |
---|
104 | |
---|
105 | open ByteValues |
---|
106 | |
---|
107 | open GenMem |
---|
108 | |
---|
109 | open FrontEndMem |
---|
110 | |
---|
111 | open Globalenvs |
---|
112 | |
---|
113 | open Csem |
---|
114 | |
---|
115 | open SmallstepExec |
---|
116 | |
---|
117 | open Division |
---|
118 | |
---|
119 | open Z |
---|
120 | |
---|
121 | open BitVectorZ |
---|
122 | |
---|
123 | open Pointers |
---|
124 | |
---|
125 | open Values |
---|
126 | |
---|
127 | open Events |
---|
128 | |
---|
129 | open IOMonad |
---|
130 | |
---|
131 | open IO |
---|
132 | |
---|
133 | open Cexec |
---|
134 | |
---|
135 | open TypeComparison |
---|
136 | |
---|
137 | open SimplifyCasts |
---|
138 | |
---|
139 | open MemProperties |
---|
140 | |
---|
141 | open MemoryInjections |
---|
142 | |
---|
143 | open Fresh |
---|
144 | |
---|
145 | open SwitchRemoval |
---|
146 | |
---|
147 | open FrontEndOps |
---|
148 | |
---|
149 | open Cminor_syntax |
---|
150 | |
---|
151 | open ToCminor |
---|
152 | |
---|
153 | open Initialisation |
---|
154 | |
---|
155 | open BitVectorTrie |
---|
156 | |
---|
157 | open Graphs |
---|
158 | |
---|
159 | open Order |
---|
160 | |
---|
161 | open Registers |
---|
162 | |
---|
163 | open RTLabs_syntax |
---|
164 | |
---|
165 | open ToRTLabs |
---|
166 | |
---|
167 | (** val front_end : |
---|
168 | Csyntax.clight_program -> ((CostLabel.costlabel, Csyntax.clight_program) |
---|
169 | Types.prod, RTLabs_syntax.rTLabs_program) Types.prod Errors.res **) |
---|
170 | let front_end p = |
---|
171 | let p0 = SwitchRemoval.program_switch_removal p in |
---|
172 | let { Types.fst = p'; Types.snd = init_cost } = Label.clight_label p0 in |
---|
173 | let p3 = SimplifyCasts.simplify_program p' in |
---|
174 | Obj.magic |
---|
175 | (Monad.m_bind0 (Monad.max_def Errors.res0) |
---|
176 | (Obj.magic (ToCminor.clight_to_cminor p3)) (fun p4 -> |
---|
177 | let p5 = ToRTLabs.cminor_to_rtlabs init_cost p4 in |
---|
178 | Monad.m_return0 (Monad.max_def Errors.res0) { Types.fst = { Types.fst = |
---|
179 | init_cost; Types.snd = p' }; Types.snd = p5 })) |
---|
180 | |
---|
181 | open LabelledObjects |
---|
182 | |
---|
183 | open ASM |
---|
184 | |
---|
185 | (** val back_end : |
---|
186 | RTLabs_syntax.rTLabs_program -> ASM.pseudo_assembly_program **) |
---|
187 | let back_end x = |
---|
188 | failwith "AXIOM TO BE REALIZED" |
---|
189 | |
---|
190 | type object_code = BitVector.byte List.list |
---|
191 | |
---|
192 | type costlabel_map = CostLabel.costlabel BitVectorTrie.bitVectorTrie |
---|
193 | |
---|
194 | (** val assembler : |
---|
195 | ASM.pseudo_assembly_program -> (object_code, costlabel_map) Types.prod |
---|
196 | Errors.res **) |
---|
197 | let assembler x = |
---|
198 | failwith "AXIOM TO BE REALIZED" |
---|
199 | |
---|
200 | open StructuredTraces |
---|
201 | |
---|
202 | open AbstractStatus |
---|
203 | |
---|
204 | open Status |
---|
205 | |
---|
206 | open StatusProofs |
---|
207 | |
---|
208 | open Interpret |
---|
209 | |
---|
210 | open Fetch |
---|
211 | |
---|
212 | open ASMCosts |
---|
213 | |
---|
214 | (** val lift_cost_map_back_to_front : |
---|
215 | Csyntax.clight_program -> BitVector.byte BitVectorTrie.bitVectorTrie -> |
---|
216 | CostLabel.costlabel BitVectorTrie.bitVectorTrie -> (CostLabel.costlabel |
---|
217 | -> (__, __) Types.sum) -> StructuredTraces.as_cost_map -> |
---|
218 | Label.clight_cost_map **) |
---|
219 | let lift_cost_map_back_to_front clight code_memory lbls dec k asm_cost_map = |
---|
220 | StructuredTraces.lift_sigma_map_id Nat.O dec k asm_cost_map |
---|
221 | |
---|
222 | open UtilBranch |
---|
223 | |
---|
224 | open ASMCostsSplit |
---|
225 | |
---|
226 | (** val compile : |
---|
227 | Csyntax.clight_program -> ((object_code, costlabel_map) Types.prod, |
---|
228 | (Csyntax.clight_program, Label.clight_cost_map) Types.dPair) Types.prod |
---|
229 | Errors.res **) |
---|
230 | let compile p = |
---|
231 | Obj.magic |
---|
232 | (Monad.m_bind3 (Monad.max_def Errors.res0) (Obj.magic (front_end p)) |
---|
233 | (fun init_cost p' p0 -> |
---|
234 | let p3 = back_end p0 in |
---|
235 | Monad.m_bind0 (Monad.max_def Errors.res0) (Obj.magic (assembler p3)) |
---|
236 | (fun p4 -> |
---|
237 | let k = ASMCostsSplit.aSM_cost_map p4 in |
---|
238 | let k' = |
---|
239 | lift_cost_map_back_to_front p' |
---|
240 | (Fetch.load_code_memory p4.Types.fst) p4.Types.snd (assert false |
---|
241 | (* absurd case *)) k |
---|
242 | in |
---|
243 | Monad.m_return0 (Monad.max_def Errors.res0) { Types.fst = p4; |
---|
244 | Types.snd = { Types.dpi1 = p'; Types.dpi2 = k' } }))) |
---|
245 | |
---|