Changeset 645 for Deliverables/D2.2/8051/src/clight/clightAnnotator.ml
 Timestamp:
 Mar 7, 2011, 4:04:42 PM (9 years ago)
 File:

 1 edited
Legend:
 Unmodified
 Added
 Removed

Deliverables/D2.2/8051/src/clight/clightAnnotator.ml
r640 r645 181 181  Clight.Sskip  Clight.Sbreak  Clight.Scontinue  Clight.Sreturn None 182 182  Clight.Sgoto _ > 183 183 stmt 184 184  Clight.Sassign (e1, e2) > 185 186 187 185 let e1' = instrument_expr cost_mapping cost_incr e1 in 186 let e2' = instrument_expr cost_mapping cost_incr e2 in 187 Clight.Sassign (e1', e2') 188 188  Clight.Scall (eopt, f, args) > 189 190 191 192 193 194 189 let eopt' = match eopt with 190  None > None 191  Some e > Some (instrument_expr cost_mapping cost_incr e) in 192 let f' = instrument_expr cost_mapping cost_incr f in 193 let args' = List.map (instrument_expr cost_mapping cost_incr) args in 194 Clight.Scall (eopt', f', args') 195 195  Clight.Ssequence (s1, s2) > 196 197 196 Clight.Ssequence (instrument_body cost_mapping cost_incr s1, 197 instrument_body cost_mapping cost_incr s2) 198 198  Clight.Sifthenelse (e, s1, s2) > 199 200 201 202 199 let e' = instrument_expr cost_mapping cost_incr e in 200 let s1' = instrument_body cost_mapping cost_incr s1 in 201 let s2' = instrument_body cost_mapping cost_incr s2 in 202 Clight.Sifthenelse (e', s1', s2') 203 203  Clight.Swhile (e, s) > 204 205 206 204 let e' = instrument_expr cost_mapping cost_incr e in 205 let s' = instrument_body cost_mapping cost_incr s in 206 Clight.Swhile (e', s') 207 207  Clight.Sdowhile (e, s) > 208 209 210 208 let e' = instrument_expr cost_mapping cost_incr e in 209 let s' = instrument_body cost_mapping cost_incr s in 210 Clight.Sdowhile (e', s') 211 211  Clight.Sfor (s1, e, s2, s3) > 212 213 214 215 216 212 let s1' = instrument_body cost_mapping cost_incr s1 in 213 let e' = instrument_expr cost_mapping cost_incr e in 214 let s2' = instrument_body cost_mapping cost_incr s2 in 215 let s3' = instrument_body cost_mapping cost_incr s3 in 216 Clight.Sfor (s1', e', s2', s3') 217 217  Clight.Sreturn (Some e) > 218 219 218 let e' = instrument_expr cost_mapping cost_incr e in 219 Clight.Sreturn (Some e') 220 220  Clight.Sswitch (e, ls) > 221 222 223 221 let e' = instrument_expr cost_mapping cost_incr e in 222 let ls' = instrument_ls cost_mapping cost_incr ls in 223 Clight.Sswitch (e', ls') 224 224  Clight.Slabel (lbl, s) > 225 226 225 let s' = instrument_body cost_mapping cost_incr s in 226 Clight.Slabel (lbl, s') 227 227  Clight.Scost (lbl, s) when CostLabel.Map.mem lbl cost_mapping > 228 let s' = instrument_body cost_mapping cost_incr s in 229 let incr = CostLabel.Map.find lbl cost_mapping in 230 if incr = 0 then s' 231 else 232 let fun_typ = Clight.Tfunction ([int_typ], Clight.Tvoid) in 233 let f = Clight.Expr (Clight.Evar cost_incr, fun_typ) in 234 let args = [Clight.Expr (Clight.Econst_int incr, int_typ)] in 235 Clight.Ssequence (Clight.Scall (None, f, args), s') 236  Clight.Scost (_, s) > 237 instrument_body cost_mapping cost_incr s 228 (* Keep the cost label in the code. *) 229 let s' = instrument_body cost_mapping cost_incr s in 230 let incr = CostLabel.Map.find lbl cost_mapping in 231 let fun_typ = Clight.Tfunction ([int_typ], Clight.Tvoid) in 232 let f = Clight.Expr (Clight.Evar cost_incr, fun_typ) in 233 let args = [Clight.Expr (Clight.Econst_int incr, int_typ)] in 234 Clight.Scost (lbl, Clight.Ssequence (Clight.Scall (None, f, args), s')) 235 (* 236 let s' = instrument_body cost_mapping cost_incr s in 237 let incr = CostLabel.Map.find lbl cost_mapping in 238 if incr = 0 then s' 239 else 240 let fun_typ = Clight.Tfunction ([int_typ], Clight.Tvoid) in 241 let f = Clight.Expr (Clight.Evar cost_incr, fun_typ) in 242 let args = [Clight.Expr (Clight.Econst_int incr, int_typ)] in 243 Clight.Ssequence (Clight.Scall (None, f, args), s') 244 *) 245  Clight.Scost (lbl, s) > 246 (* Keep the cost label in the code and show the increment of 0. *) 247 let s' = instrument_body cost_mapping cost_incr s in 248 let fun_typ = Clight.Tfunction ([int_typ], Clight.Tvoid) in 249 let f = Clight.Expr (Clight.Evar cost_incr, fun_typ) in 250 let args = [Clight.Expr (Clight.Econst_int 0, int_typ)] in 251 Clight.Scost (lbl, Clight.Ssequence (Clight.Scall (None, f, args), s')) 252 (* 253 instrument_body cost_mapping cost_incr s 254 *) 238 255 and instrument_ls cost_mapping cost_incr = function 239 256  Clight.LSdefault s > 240 241 257 let s' = instrument_body cost_mapping cost_incr s in 258 Clight.LSdefault s' 242 259  Clight.LScase (i, s, ls) > 243 244 245 260 let s' = instrument_body cost_mapping cost_incr s in 261 let ls' = instrument_ls cost_mapping cost_incr ls in 262 Clight.LScase (i, s', ls') 246 263 247 264 (* Instrument a function. *)
Note: See TracChangeset
for help on using the changeset viewer.