Changeset 640 for Deliverables/D2.2/8051/src
- Timestamp:
- Mar 7, 2011, 11:10:57 AM (10 years ago)
- Location:
- Deliverables/D2.2/8051/src
- Files:
-
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
Deliverables/D2.2/8051/src/ASM/ASMPrinter.ml
r619 r640 4 4 let print_program p = 5 5 let code_memory = ASMInterpret.load_code_memory p.ASM.code in 6 let intel_hex = IntelHex.pack_exported_code_memory 16 6553 6code_memory in6 let intel_hex = IntelHex.pack_exported_code_memory 16 65535 code_memory in 7 7 IntelHex.string_of_intel_hex_format intel_hex -
Deliverables/D2.2/8051/src/ASM/Pretty.ml
r627 r640 44 44 `Label l -> l ^ ":" 45 45 | `Cost l -> l ^ ":" 46 | `Jmp j -> " Jmp " ^ j47 | `Call j -> " Call " ^ j46 | `Jmp j -> "ljmp " ^ j 47 | `Call j -> "lcall " ^ j 48 48 | `WithLabel i -> pp_jump i 49 49 | `Begin_fun -> "\n; Begin function" … … 99 99 100 100 let print_program p = 101 let f s i = Printf.sprintf "%s%s\n" s (pp_instruction i) in 102 "Org 0\n\n" ^ (List.fold_left f "" p.ASM.pcode) ^ "\nEND\n" 101 let mem = ASMInterpret.load_code_memory p.ASM.code in 102 let f (s, pc) _ = 103 let (inst, new_pc, _) = ASMInterpret.fetch mem pc in 104 (Printf.sprintf "%s%s: %s%s\n" 105 s 106 (string_of_int (BitVectors.int_of_vect pc)) 107 (pp_instruction inst) 108 (if BitVectors.WordMap.mem pc p.ASM.cost_labels then 109 " ;; (" ^ (BitVectors.WordMap.find pc p.ASM.cost_labels) ^ ")" 110 else ""), 111 new_pc) in 112 fst (List.fold_left f ("", BitVectors.zero `Sixteen) p.ASM.code) -
Deliverables/D2.2/8051/src/ASM/Pretty.mli
r627 r640 21 21 val pp_instruction: [< ASM.labelled_instruction] -> string 22 22 23 val print_program : [< ASM.labelled_instruction] ASM.pretty_program -> string23 val print_program : ASM.program -> string -
Deliverables/D2.2/8051/src/acc.ml
r630 r640 39 39 save final_ast; 40 40 (if Options.annotation_requested () then 41 let (annotated_input_ast, cost_i ncr) =41 let (annotated_input_ast, cost_id, cost_incr) = 42 42 Languages.annotate input_ast final_ast in 43 43 save annotated_input_ast; 44 Languages.save_cost _incr output_filenamecost_incr);44 Languages.save_cost output_filename cost_id cost_incr); 45 45 (if Options.is_debug_enabled () then 46 46 List.iter save intermediate_asts); -
Deliverables/D2.2/8051/src/clight/clightAnnotator.ml
r624 r640 285 285 close_out cout 286 286 287 (** [instrument prog cost_map] instruments the program [prog]. *) 287 (** [instrument prog cost_map] instruments the program [prog]. First a fresh 288 global variable --- the so-called cost variable --- is added to the program. 289 Then, each cost label in the program is replaced by an increment of the cost 290 variable, following the mapping [cost_map]. The function also returns the 291 name of the cost variable and the name of the cost increment function. *) 288 292 289 293 let instrument p cost_mapping = … … 318 322 let res = ClightParser.process tmp_file in 319 323 Misc.SysExt.safe_remove tmp_file ; 320 (res, cost_i ncr)324 (res, cost_id, cost_incr) -
Deliverables/D2.2/8051/src/clight/clightAnnotator.mli
r619 r640 5 5 global variable --- the so-called cost variable --- is added to the program. 6 6 Then, each cost label in the program is replaced by an increment of the cost 7 variable, following the mapping [cost_map]. The returned string is the name8 of the cost increment function. *)7 variable, following the mapping [cost_map]. The function also returns the 8 name of the cost variable and the name of the cost increment function. *) 9 9 10 10 val instrument : Clight.program -> int CostLabel.Map.t -> 11 Clight.program * string 11 Clight.program * string * string 12 12 13 13 val cost_labels : Clight.program -> CostLabel.Set.t -
Deliverables/D2.2/8051/src/cminor/cminorAnnotator.ml
r619 r640 131 131 132 132 133 (** [instrument prog cost_map] instruments the program [prog]. First a fresh 134 global variable --- the so-called cost variable --- is added to the program. 135 Then, each cost label in the program is replaced by an increment of the cost 136 variable, following the mapping [cost_map]. The function also returns the 137 name of the cost variable and the name of the cost increment function. *) 138 133 139 let instrument p costs_mapping = 134 140 let cost_id = fresh_cost_id "_cost" p in … … 140 146 Cminor.functs = functs ; 141 147 Cminor.main = p.Cminor.main }, 148 "" (* TODO *), 142 149 "" (* TODO *)) 143 150 -
Deliverables/D2.2/8051/src/cminor/cminorAnnotator.mli
r619 r640 5 5 global variable --- the so-called cost variable --- is added to the program. 6 6 Then, each cost label in the program is replaced by an increment of the cost 7 variable, following the mapping [cost_map]. The returned string is the name8 of the cost increment function. *)7 variable, following the mapping [cost_map]. The function also returns the 8 name of the cost variable and the name of the cost increment function. *) 9 9 10 10 val instrument : Cminor.program -> int CostLabel.Map.t -> 11 Cminor.program * string 11 Cminor.program * string * string 12 12 13 13 val cost_labels : Cminor.program -> CostLabel.Set.t -
Deliverables/D2.2/8051/src/languages.ml
r619 r640 47 47 48 48 let extension = function 49 | ASM -> "s"50 | Clight -> "c"51 | language -> to_string language49 | ASM -> ["s" ; "hex"] 50 | Clight -> ["c"] 51 | language -> [to_string language] 52 52 53 53 let parse = function … … 200 200 let instrument costs_mapping = function 201 201 | AstClight p -> 202 let (p', cost_i ncr) = ClightAnnotator.instrument p costs_mapping in203 (AstClight p', cost_i ncr)202 let (p', cost_id, cost_incr) = ClightAnnotator.instrument p costs_mapping in 203 (AstClight p', cost_id, cost_incr) 204 204 | AstCminor p -> 205 let (p', cost_i ncr) = CminorAnnotator.instrument p costs_mapping in206 (AstCminor p', cost_i ncr)205 let (p', cost_id, cost_incr) = CminorAnnotator.instrument p costs_mapping in 206 (AstCminor p', cost_id, cost_incr) 207 207 | p -> 208 208 Error.warning "during instrumentation" … … 210 210 "Instrumentation is not implemented for source language `%s'." 211 211 (to_string (language_of_ast p))); 212 (p, "" )212 (p, "", "") 213 213 214 214 let annotate input_ast final = … … 218 218 let string_output = function 219 219 | AstClight p -> 220 ClightPrinter.print_program p220 [ClightPrinter.print_program p] 221 221 | AstCminor p -> 222 CminorPrinter.print_program p222 [CminorPrinter.print_program p] 223 223 | AstRTLabs p -> 224 RTLabsPrinter.print_program p224 [RTLabsPrinter.print_program p] 225 225 | AstRTL p -> 226 RTLPrinter.print_program p226 [RTLPrinter.print_program p] 227 227 | AstERTL p -> 228 ERTLPrinter.print_program p228 [ERTLPrinter.print_program p] 229 229 | AstLTL p -> 230 LTLPrinter.print_program p230 [LTLPrinter.print_program p] 231 231 | AstLIN p -> 232 LINPrinter.print_program p232 [LINPrinter.print_program p] 233 233 | AstASM p -> 234 ASMPrinter.print_program p234 [Pretty.print_program p ; ASMPrinter.print_program p] 235 235 236 236 let save exact_output filename ast = … … 240 240 try Filename.chop_extension filename 241 241 with Invalid_argument ("Filename.chop_extension") -> filename in 242 let ext_filename = 243 ext_chopped_filename ^ "." ^ extension (language_of_ast ast) in 244 let output_filename = 245 if exact_output then ext_filename 246 else Misc.SysExt.alternative ext_filename in 247 let cout = open_out output_filename in 248 output_string cout (string_output ast); 249 flush cout; 250 close_out cout 251 252 let save_cost_incr filename cost_incr = 242 let ext_filenames = 243 List.map (fun ext -> ext_chopped_filename ^ "." ^ ext) 244 (extension (language_of_ast ast)) in 245 let output_filenames = 246 if exact_output then ext_filenames 247 else List.map Misc.SysExt.alternative ext_filenames in 248 let output_strings = string_output ast in 249 let f filename s = 250 let cout = open_out filename in 251 output_string cout s; 252 flush cout; 253 close_out cout in 254 List.iter2 f output_filenames output_strings 255 256 let save_cost filename cost_id cost_incr = 253 257 let cout = open_out (filename ^ ".cerco") in 254 output_string cout cost_incr; 258 output_string cout (cost_id ^ "\n"); 259 output_string cout (cost_incr ^ "\n"); 255 260 flush cout; 256 261 close_out cout -
Deliverables/D2.2/8051/src/languages.mli
r619 r640 62 62 63 63 (** [annotate input_ast target_ast] inserts cost annotations into the input AST 64 from the (final) target AST. It also returns the name of the cost increment65 function*)66 val annotate : ast -> ast -> (ast * string )64 from the (final) target AST. It also returns the name of the cost variable 65 and the name of the cost increment function. *) 66 val annotate : ast -> ast -> (ast * string * string) 67 67 68 68 (** [interpret print_result ast] runs the program [ast] from the default initial … … 80 80 val save : bool -> string -> ast -> unit 81 81 82 (** [save_cost_incr filename cost_incr] prints the name of the cost increment 83 function [cost_incr] in the file prefixed by [filename] and extended with 82 (** [save_cost_incr filename cost_id cost_incr] prints the name [cost_id] of the 83 cost variable and then the name [cost_incr] of the cost increment function 84 in a seperate line in the file prefixed by [filename] and extended with 84 85 ".cost". If the file already exists, it is overwritten. *) 85 val save_cost _incr :string -> string -> unit86 val save_cost : string -> string -> string -> unit 86 87 87 88 (** [from_string s] parses [s] as an intermediate language name. *)
Note: See TracChangeset
for help on using the changeset viewer.