Ignore:
Timestamp:
Mar 2, 2011, 3:27:41 PM (10 years ago)
Author:
ayache
Message:

Update of D2.2 from Paris.

Location:
Deliverables/D2.2/8051/src/cminor
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • Deliverables/D2.2/8051/src/cminor/cminorAnnotator.ml

    r486 r619  
    137137    (f_name, instrument_function costs_mapping cost_id f_def) in
    138138  let functs = List.map f p.Cminor.functs in
    139   { Cminor.vars   = vars ;
    140     Cminor.functs = functs ;
    141     Cminor.main   = p.Cminor.main }
     139  ({ Cminor.vars   = vars ;
     140     Cminor.functs = functs ;
     141     Cminor.main   = p.Cminor.main },
     142   "" (* TODO *))
    142143
    143144
  • Deliverables/D2.2/8051/src/cminor/cminorAnnotator.mli

    r486 r619  
    55    global variable --- the so-called cost variable --- is added to the program.
    66    Then, each cost label in the program is replaced by an increment of the cost
    7     variable, following the mapping [cost_map]. *)
     7    variable, following the mapping [cost_map]. The returned string is the name
     8    of the cost increment function. *)
    89
    9 val instrument : Cminor.program -> int CostLabel.Map.t -> Cminor.program
     10val instrument : Cminor.program -> int CostLabel.Map.t ->
     11                 Cminor.program * string
    1012
    1113val cost_labels : Cminor.program -> CostLabel.Set.t
  • Deliverables/D2.2/8051/src/cminor/cminorInterpret.ml

    r486 r619  
    128128  | Op_divu             -> Value.divu arg1 arg2
    129129  | Op_mod              -> Value.modulo arg1 arg2
    130   | Op_modu             -> Value.modu arg1 arg2
     130  | Op_modu             -> Value.modulou arg1 arg2
    131131  | Op_and              -> Value.and_op arg1 arg2
    132132  | Op_or               -> Value.or_op arg1 arg2
     
    405405    (m,(g2,f))
    406406
     407let compute_result v =
     408  if Value.is_int v then IntValue.Int8.cast (Value.to_int_repr v)
     409  else IntValue.Int8.zero
     410
    407411let interpret debug prog = match prog.main with
    408   | None -> []
     412  | None -> (IntValue.Int8.zero, [])
    409413  | Some main ->
    410414      let (m,global_env) = initmem_cminor prog in
     
    413417                           [], Ct_stop,m),[]) in
    414418      let rec exec l = function
    415         | (State_return(v,Ct_stop,m),lbl) ->
     419        | (State_return(v,Ct_stop,m),lbl) ->
     420(*
    416421            if debug then (
    417422              print_string ("Result: "^(Value.to_string v));
     
    419424              Mem.print m
    420425            );
    421             lbl@l
     426*)
     427          let (res, cost_labels) as trace = (compute_result v, lbl@l) in
     428          if debug then
     429            Printf.printf "Cminor: %s\n%!" (IntValue.Int8.to_string res) ;
     430          trace
    422431        | (State_regular(_,St_skip,Ct_stop,_,_,m),lbl) ->
     432(*
    423433            if debug then (
    424434              print_string ("Result: (implicit return)\n");
     
    426436              Mem.print m
    427437            );
    428             lbl@l
     438*)
     439          let (res, cost_labels) as trace = (IntValue.Int8.zero, lbl@l) in
     440          if debug then
     441            Printf.printf "Cminor: %s\n%!" (IntValue.Int8.to_string res) ;
     442          trace
    429443        | (state,lbl) ->
     444(*
    430445            if debug then print_string ((string_of_state state)^"\n");
     446*)
    431447            exec (lbl@l) (state_transition state global_env)
    432448      in
     449(*
    433450      if debug then print_string ">------------------- Interpret Cminor -------------------<\n";
     451*)
    434452      (exec [] first_state)
Note: See TracChangeset for help on using the changeset viewer.