Ignore:
Timestamp:
Oct 11, 2011, 5:42:20 PM (9 years ago)
Author:
tranquil
Message:
  • changed implementation of constant indexings with extensible arrays
  • work on ASM completed
  • next: optimizations!
File:
1 edited

Legend:

Unmodified
Added
Removed
  • Deliverables/D2.2/8051-indexed-labels-branch/src/RTL/RTLInterpret.ml

    r1345 r1357  
    6262
    6363let print_state = function
    64   | State (_, _, lbl, sp, lenv, carry, mem, ind::_, _) ->
     64  | State (_, _, lbl, sp, lenv, carry, mem, ind, _) ->
    6565    Printf.printf "Stack pointer: %s\n\nCarry: %s\n\nLocal environment:\n%s\n\nMemory:%s\nIndexing:"
    6666      (Val.string_of_address sp)
     
    6868      (string_of_local_env lenv)
    6969      (Mem.to_string mem);
    70                         Array.iter (fun a -> Printf.printf "%d, " a) ind;
     70                        let i = CostLabel.curr_const_ind ind in
     71                        CostLabel.const_ind_iter (fun a -> Printf.printf "%d, " a) i;
    7172                        Printf.printf "Regular state: %s\n\n%!"
    7273      lbl
    73         | State (_, _, _, _, _, _, _, [], _) -> assert false (* indexings non-empty *)
    7474  | CallState (_, _, args, mem, _, _) ->
    7575    Printf.printf "Memory:%s\nCall state: %s\n\n%!"
     
    116116  State (sfrs, graph, next_lbl, sp, lenv, carry, mem, inds, trace)
    117117
    118 let curr_ind : indexing list -> indexing = function
    119     | ind :: _ -> ind
    120     | _ -> assert false (* indexing list must be non-empty *)
    121 
    122 let forget_ind : indexing list -> indexing list = function
    123     | _ :: tail -> tail
    124     | _ -> assert false (* indexing list must be non-empty *)
    125 
    126 let max_depth graph =
    127     let f_stmt _ = function
    128         | RTL.St_ind_0(i,_) | RTL.St_ind_inc(i,_) -> max (i + 1)
    129         | _ -> fun x -> x in
    130     Label.Map.fold f_stmt graph 0
     118let curr_ind = CostLabel.curr_const_ind
     119
     120let forget_ind = CostLabel.forget_const_ind
     121
     122let new_ind = CostLabel.new_const_ind
    131123
    132124
     
    149141
    150142      | RTL.St_cost (cost_lbl, lbl) ->
    151         let cost_lbl = CostLabel.apply_const_indexing (curr_ind inds) cost_lbl in
     143        let cost_lbl = CostLabel.ev_indexing (curr_ind inds) cost_lbl in
    152144        State (sfrs, graph, lbl, sp, lenv, carry, mem, inds, cost_lbl :: trace)
    153145
    154146      | RTL.St_ind_0 (i, lbl) ->
    155   CostLabel.enter_loop (Some i) (curr_ind inds);
     147  CostLabel.enter_loop inds i;
    156148  State (sfrs, graph, lbl, sp, lenv, carry, mem, inds, trace)
    157149
    158150      | RTL.St_ind_inc (i, lbl) ->
    159   CostLabel.continue_loop (Some i) (curr_ind inds);
     151  CostLabel.continue_loop inds i;
    160152  State (sfrs, graph, lbl, sp, lenv, carry, mem, inds, trace)
    161153
     
    275267  match f_def with
    276268    | RTL.F_int def ->
    277                         let ind = Array.make (max_depth def.RTL.f_graph) 0 in
     269                        let inds = new_ind inds in
    278270      let (mem', sp) = Mem.alloc mem def.RTL.f_stacksize in
    279271      State (sfrs, def.RTL.f_graph, def.RTL.f_entry, sp,
    280272             init_locals def.RTL.f_locals def.RTL.f_params args,
    281              Val.undef, mem', ind::inds, trace)
     273             Val.undef, mem', inds, trace)
    282274    | RTL.F_ext def ->
    283275      let (mem', vs) = interpret_external mem def.AST.ef_tag args in
Note: See TracChangeset for help on using the changeset viewer.