1 | open Preamble |
---|
2 | |
---|
3 | open BitVectorTrie |
---|
4 | |
---|
5 | open CostLabel |
---|
6 | |
---|
7 | open Coqlib |
---|
8 | |
---|
9 | open Proper |
---|
10 | |
---|
11 | open PositiveMap |
---|
12 | |
---|
13 | open Deqsets |
---|
14 | |
---|
15 | open ErrorMessages |
---|
16 | |
---|
17 | open PreIdentifiers |
---|
18 | |
---|
19 | open Errors |
---|
20 | |
---|
21 | open Extralib |
---|
22 | |
---|
23 | open Setoids |
---|
24 | |
---|
25 | open Monad |
---|
26 | |
---|
27 | open Option |
---|
28 | |
---|
29 | open Lists |
---|
30 | |
---|
31 | open Positive |
---|
32 | |
---|
33 | open Identifiers |
---|
34 | |
---|
35 | open Exp |
---|
36 | |
---|
37 | open Arithmetic |
---|
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 Graphs |
---|
156 | |
---|
157 | open Order |
---|
158 | |
---|
159 | open Registers |
---|
160 | |
---|
161 | open RTLabs_syntax |
---|
162 | |
---|
163 | open ToRTLabs |
---|
164 | |
---|
165 | (** val front_end : |
---|
166 | Csyntax.clight_program -> ((CostLabel.costlabel, Csyntax.clight_program) |
---|
167 | Types.prod, RTLabs_syntax.rTLabs_program) Types.prod Errors.res **) |
---|
168 | let front_end p = |
---|
169 | let p0 = SwitchRemoval.program_switch_removal p in |
---|
170 | let { Types.fst = p'; Types.snd = init_cost } = Label.clight_label p0 in |
---|
171 | let p3 = SimplifyCasts.simplify_program p' in |
---|
172 | Obj.magic |
---|
173 | (Monad.m_bind0 (Monad.max_def Errors.res0) |
---|
174 | (Obj.magic (ToCminor.clight_to_cminor p3)) (fun p4 -> |
---|
175 | let p5 = ToRTLabs.cminor_to_rtlabs init_cost p4 in |
---|
176 | Monad.m_return0 (Monad.max_def Errors.res0) { Types.fst = { Types.fst = |
---|
177 | init_cost; Types.snd = p' }; Types.snd = p5 })) |
---|
178 | |
---|
179 | open Deqsets |
---|
180 | |
---|
181 | open State |
---|
182 | |
---|
183 | open Bind_new |
---|
184 | |
---|
185 | open BindLists |
---|
186 | |
---|
187 | open Blocks |
---|
188 | |
---|
189 | open TranslateUtils |
---|
190 | |
---|
191 | open AssocList |
---|
192 | |
---|
193 | open String |
---|
194 | |
---|
195 | open LabelledObjects |
---|
196 | |
---|
197 | open I8051 |
---|
198 | |
---|
199 | open BackEndOps |
---|
200 | |
---|
201 | open Joint |
---|
202 | |
---|
203 | open RTL |
---|
204 | |
---|
205 | open RTLabsToRTL |
---|
206 | |
---|
207 | open ERTL |
---|
208 | |
---|
209 | open RegisterSet |
---|
210 | |
---|
211 | open RTLToERTL |
---|
212 | |
---|
213 | open ERTLptr |
---|
214 | |
---|
215 | open ERTLToERTLptr |
---|
216 | |
---|
217 | open Fixpoints |
---|
218 | |
---|
219 | open Set_adt |
---|
220 | |
---|
221 | open Liveness |
---|
222 | |
---|
223 | open Interference |
---|
224 | |
---|
225 | open Joint_LTL_LIN |
---|
226 | |
---|
227 | open LTL |
---|
228 | |
---|
229 | open ERTLptrToLTL |
---|
230 | |
---|
231 | open LIN |
---|
232 | |
---|
233 | open Linearise |
---|
234 | |
---|
235 | open LTLToLIN |
---|
236 | |
---|
237 | open ASM |
---|
238 | |
---|
239 | open BitVectorTrieSet |
---|
240 | |
---|
241 | open LINToASM |
---|
242 | |
---|
243 | (** val compute_fixpoint : Fixpoints.fixpoint_computer **) |
---|
244 | let compute_fixpoint _ = |
---|
245 | failwith "AXIOM TO BE REALIZED" |
---|
246 | |
---|
247 | (** val colour_graph : Interference.coloured_graph_computer **) |
---|
248 | let colour_graph _ = |
---|
249 | failwith "AXIOM TO BE REALIZED" |
---|
250 | |
---|
251 | (** val back_end : |
---|
252 | RTLabs_syntax.rTLabs_program -> ASM.pseudo_assembly_program **) |
---|
253 | let back_end p = |
---|
254 | let p0 = RTLabsToRTL.rtlabs_to_rtl p in |
---|
255 | let p3 = RTLToERTL.rtl_to_ertl p0 in |
---|
256 | let p4 = ERTLToERTLptr.ertl_to_ertlptr p3 in |
---|
257 | let p5 = ERTLptrToLTL.ertlptr_to_ltl compute_fixpoint colour_graph p4 in |
---|
258 | let p6 = LTLToLIN.ltl_to_lin p5 in LINToASM.lin_to_asm p6 |
---|
259 | |
---|
260 | type object_code = BitVector.byte List.list |
---|
261 | |
---|
262 | type costlabel_map1 = CostLabel.costlabel BitVectorTrie.bitVectorTrie |
---|
263 | |
---|
264 | open Assembly |
---|
265 | |
---|
266 | open Status |
---|
267 | |
---|
268 | open Fetch |
---|
269 | |
---|
270 | open PolicyFront |
---|
271 | |
---|
272 | open PolicyStep |
---|
273 | |
---|
274 | open Policy |
---|
275 | |
---|
276 | (** val assembler : |
---|
277 | ASM.pseudo_assembly_program -> (object_code, costlabel_map1) Types.prod |
---|
278 | Errors.res **) |
---|
279 | let assembler p = |
---|
280 | let { Types.fst = preamble0; Types.snd = list_instr } = p in |
---|
281 | let p' = { Types.fst = preamble0; Types.snd = list_instr } in |
---|
282 | Obj.magic |
---|
283 | (Monad.m_bind0 (Monad.max_def Errors.res0) |
---|
284 | (Obj.magic |
---|
285 | (Errors.opt_to_res (Errors.msg ErrorMessages.Jump_expansion_failed) |
---|
286 | (Policy.jump_expansion' (Types.coerc_pair_sigma p')))) |
---|
287 | (fun sigma_pol -> |
---|
288 | let sigma0 = fun ppc -> (Types.pi1 sigma_pol).Types.fst ppc in |
---|
289 | let pol = fun ppc -> (Types.pi1 sigma_pol).Types.snd ppc in |
---|
290 | Obj.magic (Errors.OK (Types.pi1 (Assembly.assembly p sigma0 pol))))) |
---|
291 | |
---|
292 | open StructuredTraces |
---|
293 | |
---|
294 | open AbstractStatus |
---|
295 | |
---|
296 | open StatusProofs |
---|
297 | |
---|
298 | open Interpret |
---|
299 | |
---|
300 | open ASMCosts |
---|
301 | |
---|
302 | (** val lift_cost_map_back_to_front : |
---|
303 | Csyntax.clight_program -> BitVector.byte BitVectorTrie.bitVectorTrie -> |
---|
304 | CostLabel.costlabel BitVectorTrie.bitVectorTrie -> (CostLabel.costlabel |
---|
305 | -> (__, __) Types.sum) -> StructuredTraces.as_cost_map -> |
---|
306 | Label.clight_cost_map **) |
---|
307 | let lift_cost_map_back_to_front clight code_memory lbls dec k asm_cost_map = |
---|
308 | StructuredTraces.lift_sigma_map_id Nat.O dec k asm_cost_map |
---|
309 | |
---|
310 | open UtilBranch |
---|
311 | |
---|
312 | open ASMCostsSplit |
---|
313 | |
---|
314 | (** val compile : |
---|
315 | Csyntax.clight_program -> ((object_code, costlabel_map1) Types.prod, |
---|
316 | (Csyntax.clight_program, Label.clight_cost_map) Types.dPair) Types.prod |
---|
317 | Errors.res **) |
---|
318 | let compile p = |
---|
319 | Obj.magic |
---|
320 | (Monad.m_bind3 (Monad.max_def Errors.res0) (Obj.magic (front_end p)) |
---|
321 | (fun init_cost p' p0 -> |
---|
322 | let p3 = back_end p0 in |
---|
323 | Monad.m_bind0 (Monad.max_def Errors.res0) (Obj.magic (assembler p3)) |
---|
324 | (fun p4 -> |
---|
325 | let k = ASMCostsSplit.aSM_cost_map p4 in |
---|
326 | let k' = |
---|
327 | lift_cost_map_back_to_front p' |
---|
328 | (Fetch.load_code_memory p4.Types.fst) p4.Types.snd (assert false |
---|
329 | (* absurd case *)) k |
---|
330 | in |
---|
331 | Monad.m_return0 (Monad.max_def Errors.res0) { Types.fst = p4; |
---|
332 | Types.snd = { Types.dpi1 = p'; Types.dpi2 = k' } }))) |
---|
333 | |
---|