Changeset 1392


Ignore:
Timestamp:
Oct 17, 2011, 2:08:27 PM (8 years ago)
Author:
tranquil
Message:

fiddling with Cminor: elimination of loops, blocks and exits

Location:
Deliverables/D2.2/8051-indexed-labels-branch/src
Files:
2 deleted
9 edited

Legend:

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

    r1349 r1392  
    33
    44
    5 let n_spaces n = String.make n ' '
     5let n_spaces ?stmt n =
     6        let n = match stmt with
     7                | Some (LIN.St_label _) | Some (LIN.St_cost _) -> n - 2
     8                | _ -> n in
     9        String.make n ' '
    610
    711
     
    6670let print_code n c =
    6771  let f s stmt =
    68     Printf.sprintf "%s\n%s%s" s (n_spaces n) (print_statement stmt) in
     72    Printf.sprintf "%s\n%s%s" s (n_spaces ~stmt:stmt n) (print_statement stmt) in
    6973  List.fold_left f "" c
    7074
  • Deliverables/D2.2/8051-indexed-labels-branch/src/clight/clightFold.ml

    r1305 r1392  
    170170  let sub_stmts_res = List.map (statement2 f_expr f_statement) sub_stmts in
    171171  f_statement stmt sub_exprs_res sub_stmts_res
     172       
  • Deliverables/D2.2/8051-indexed-labels-branch/src/clight/clightPrinter.ml

    r1328 r1392  
    248248              print_stmt s2
    249249  | Swhile(i, e, s) ->
    250       fprintf p "@[<v 2>%a@ while (%a) {@ %a@;<0 -2>}@]"
     250      fprintf p "@[<v 0>%a@[<v 2>while (%a) {@ %a@;<0 -2>}@]@]"
    251251                                print_loop_depth i
    252252              print_expr e
    253253              print_stmt s
    254254  | Sdowhile(i, e, s) ->
    255       fprintf p "@[<v 2>%a@ do {@ %a@;<0 -2>} while(%a);@]"
     255      fprintf p "@[<v 0>%a@[<v 2>do {@ %a@;<0 -2>} while(%a);@]@]"
    256256                                print_loop_depth i
    257257              print_stmt s
  • Deliverables/D2.2/8051-indexed-labels-branch/src/clight/clightToCminor.ml

    r1334 r1392  
    492492let ind_inc i stmt = match i with
    493493        | None -> stmt
    494         | Some x -> Cminor.St_ind_inc(stmt, x)
    495 
    496 let f_stmt fresh var_locs stmt sub_exprs_res sub_stmts_res =
    497   let (tmps, sub_stmts_res) = List.split sub_stmts_res in
    498   let tmps = List.flatten tmps in
    499 
    500   let (added_tmps, stmt) = match stmt, sub_exprs_res, sub_stmts_res with
    501 
    502     | Clight.Sskip, _, _ -> ([], Cminor.St_skip)
    503 
    504     | Clight.Sassign (e1, _), _ :: e2 :: _, _ ->
     494        | Some x -> Cminor.St_ind_inc(x, stmt)
     495
     496let trans_for =
     497        let f_expr e _ = e in
     498        let f_stmt stmt expr_res stmt_res = match expr_res, stmt_res, stmt with
     499                | e::_, s1::s2::s3::_, Clight.Sfor(i,_,_,_,_) ->
     500                        Clight.Ssequence(s1,Clight.Swhile(i,e,
     501                         Clight.Ssequence(s3, s2)))
     502                | exprs, sub_sts, stm -> ClightFold.statement_fill_subs stm exprs sub_sts in
     503        ClightFold.statement2 f_expr f_stmt
     504
     505let rec translate_stmt fresh var_locs cnt_lbl br_lbl = function
     506
     507    | Clight.Sskip -> ([], Cminor.St_skip)
     508
     509    | Clight.Sassign (e1, e2) ->
     510                        let e2 = translate_expr var_locs e2 in
    505511      ([], assign var_locs e1 e2)
    506512
    507     | Clight.Scall (None, _, _), f :: args, _ ->
     513    | Clight.Scall (None, f, args) ->
     514                        let f = translate_expr var_locs f in
     515                        let args = List.map (translate_expr var_locs) args in
    508516      ([], Cminor.St_call (None, f, args, call_sig AST.Type_void args))
    509517
    510     | Clight.Scall (Some e, _, _), _ :: f :: args, _ ->
     518    | Clight.Scall (Some e, f, args) ->
     519            let f = translate_expr var_locs f in
     520            let args = List.map (translate_expr var_locs) args in
    511521      let t = sig_type_of_ctype (clight_type_of e) in
    512522      let tmp = fresh () in
     
    517527      ([(tmp, t)], Cminor.St_seq (stmt_call, stmt_assign))
    518528
    519     | Clight.Swhile (i,_,_), e :: _, stmt :: _ ->
     529    | Clight.Swhile (i,e,stmt) ->
     530                        let loop_lbl = fresh () in
     531                        let llbl_opt = Some loop_lbl in
     532                        let exit_lbl = fresh () in
     533            let elbl_opt = Some exit_lbl in
     534            let (tmps, stmt) = translate_stmt fresh var_locs llbl_opt elbl_opt stmt in
     535                        let e = translate_expr var_locs e in
     536                        let jmp lbl = Cminor.St_goto lbl in
    520537      let econd =               
    521538        Cminor.Expr (Cminor.Op1 (AST.Op_notbool, e), cminor_type_of e) in
    522539      let scond =
    523         Cminor.St_ifthenelse (econd, Cminor.St_exit 0, Cminor.St_skip) in
    524             let loop_body = Cminor.St_seq (scond, ind_inc i (Cminor.St_block stmt)) in
    525                         let loop = ind_0 i (Cminor.St_loop loop_body) in
    526       ([], Cminor.St_block loop)
     540        Cminor.St_ifthenelse (econd, jmp exit_lbl, Cminor.St_skip) in
     541            let loop =
     542                                Cminor.St_seq(scond,Cminor.St_seq (stmt, ind_inc i (jmp loop_lbl))) in
     543                        let loop = ind_0 i (Cminor.St_label(loop_lbl,loop)) in
     544      (tmps, Cminor.St_seq (loop, Cminor.St_label(exit_lbl,Cminor.St_skip)))
    527545                       
    528     | Clight.Sdowhile (i,_,_), e :: _, stmt :: _ ->
    529       let econd =               
    530         Cminor.Expr (Cminor.Op1 (AST.Op_notbool, e), cminor_type_of e) in
     546    | Clight.Sdowhile (i,e,stmt) ->
     547            let loop_lbl = fresh () in
     548            let llbl_opt = Some loop_lbl in
     549            let exit_lbl = fresh () in
     550            let elbl_opt = Some exit_lbl in
     551      let (tmps, stmt) = translate_stmt fresh var_locs llbl_opt elbl_opt stmt in
     552      let e = translate_expr var_locs e in
     553      let jmp lbl = Cminor.St_goto lbl in
    531554      let scond =
    532               Cminor.St_ifthenelse (econd, Cminor.St_exit 0, Cminor.St_skip) in
    533                         let loop_body = ind_inc i (Cminor.St_seq (Cminor.St_block stmt, scond)) in
    534                         let loop = ind_0 i (Cminor.St_loop loop_body) in
    535       ([], Cminor.St_block loop)
    536 
    537     | Clight.Sfor (i,_,_,_,_), e :: _, stmt1 :: stmt2 :: stmt3 :: _ ->
    538       let econd =                               
    539         Cminor.Expr (Cminor.Op1 (AST.Op_notbool, e), cminor_type_of e) in
    540       let scond =
    541               Cminor.St_ifthenelse (econd, Cminor.St_exit 0, Cminor.St_skip) in
    542       let body = Cminor.St_seq (ind_inc i (Cminor.St_block stmt3), stmt2) in
    543                         let body = Cminor.St_seq (scond, body) in
    544                         let block = Cminor.St_block (ind_0 i (Cminor.St_loop body)) in 
    545       ([], Cminor.St_seq (stmt1, block))
    546 
    547     | Clight.Sifthenelse _, e :: _, stmt1 :: stmt2 :: _ ->
    548       ([], Cminor.St_ifthenelse (e, stmt1, stmt2))
    549 
    550     | Clight.Ssequence _, _, stmt1 :: stmt2 :: _ ->
    551       ([], Cminor.St_seq (stmt1, stmt2))
    552 
    553     | Clight.Sbreak, _, _ -> ([], Cminor.St_exit 1)
    554 
    555     | Clight.Scontinue, _, _ -> ([], Cminor.St_exit 0)
    556 
    557     | Clight.Sswitch _, _, _ ->
     555        Cminor.St_ifthenelse (e, ind_inc i (jmp loop_lbl), Cminor.St_skip) in
     556            let loop =
     557        Cminor.St_seq (stmt, scond) in
     558      let loop = ind_0 i (Cminor.St_label(loop_lbl,loop)) in
     559      (tmps, Cminor.St_seq (loop, Cminor.St_label(exit_lbl,Cminor.St_skip)))
     560                       
     561    | Clight.Sfor _ -> assert false (* transformed *)
     562
     563    | Clight.Sifthenelse (e, stmt1, stmt2) ->
     564      let (tmps1, stmt1) = translate_stmt fresh var_locs cnt_lbl br_lbl stmt1 in
     565      let (tmps2, stmt2) = translate_stmt fresh var_locs cnt_lbl br_lbl stmt2 in
     566      let e = translate_expr var_locs e in
     567      (tmps1 @ tmps2, Cminor.St_ifthenelse (e, stmt1, stmt2))
     568
     569    | Clight.Ssequence(stmt1,stmt2) ->
     570      let (tmps1, stmt1) = translate_stmt fresh var_locs cnt_lbl br_lbl stmt1 in
     571      let (tmps2, stmt2) = translate_stmt fresh var_locs cnt_lbl br_lbl stmt2 in
     572      (tmps1 @ tmps2, Cminor.St_seq (stmt1, stmt2))
     573
     574    | Clight.Sbreak ->
     575                        let br_lbl = match br_lbl with
     576                                | Some x -> x
     577                                | None -> invalid_arg("break without enclosing scope") in
     578                        ([], Cminor.St_goto br_lbl)
     579
     580    | Clight.Scontinue ->
     581            let cnt_lbl = match cnt_lbl with
     582                | Some x -> x
     583                | None -> invalid_arg("continue without enclosing scope") in
     584      ([], Cminor.St_goto cnt_lbl)
     585    | Clight.Sswitch _ ->
    558586      (* Should not appear because of switch transformation performed
    559587         beforehand. *)
    560588      assert false
    561589
    562     | Clight.Sreturn None, _, _ -> ([], Cminor.St_return None)
    563 
    564     | Clight.Sreturn (Some _), e :: _, _ -> ([], Cminor.St_return (Some e))
    565 
    566     | Clight.Slabel (lbl, _), _, stmt :: _ -> ([], Cminor.St_label (lbl, stmt))
    567 
    568     | Clight.Sgoto lbl, _, _ -> ([], Cminor.St_goto lbl)
    569 
    570     | Clight.Scost (lbl, _), _, stmt :: _ -> ([], Cminor.St_cost (lbl, stmt))
    571 
    572     | _ -> assert false (* type error *) in
    573 
    574   (tmps @ added_tmps, stmt)
    575 
    576 let translate_statement fresh var_locs =
    577   ClightFold.statement2 (f_expr var_locs) (f_stmt fresh var_locs)
     590    | Clight.Sreturn None -> ([], Cminor.St_return None)
     591
     592    | Clight.Sreturn (Some e) ->
     593                        let e = translate_expr var_locs e in
     594                        ([], Cminor.St_return (Some e))
     595
     596    | Clight.Slabel (lbl, stmt) ->
     597                        let (tmps, stmt) = translate_stmt fresh var_locs cnt_lbl br_lbl stmt in
     598                        (tmps, Cminor.St_label (lbl, stmt))
     599
     600    | Clight.Sgoto lbl -> ([], Cminor.St_goto lbl)
     601
     602    | Clight.Scost (lbl, stmt) ->
     603                        let (tmps, stmt) = translate_stmt fresh var_locs cnt_lbl br_lbl stmt in
     604                        (tmps, Cminor.St_cost (lbl, stmt))
     605
     606    | _ -> assert false (* type error *)
    578607
    579608
     
    596625  let params =
    597626    List.map (fun (x, t) -> (x, sig_type_of_ctype t)) cfun.Clight.fn_params in
    598   let (tmps, body) = translate_statement fresh var_locs cfun.Clight.fn_body in
     627        let body = cfun.Clight.fn_body in
     628  let (tmps, body) = translate_stmt fresh var_locs None None body in
    599629  let body = add_stack_parameters_initialization var_locs body in
    600630  { Cminor.f_return = type_return_of_ctype cfun.Clight.fn_return ;
  • Deliverables/D2.2/8051-indexed-labels-branch/src/cminor/cminor.mli

    r1334 r1392  
    3434  | St_seq of statement * statement
    3535  | St_ifthenelse of expression * statement * statement
    36   | St_loop of statement
     36(*  | St_loop of statement
    3737  | St_block of statement
    38   | St_exit of int
     38  | St_exit of int *)
    3939
    4040  (* Switch. Parameters are the expression whose value is switch, a
    4141     table of cases and their corresponding number of blocks to exit,
    4242     and the number of block to exit in the default case. *)
    43   | St_switch of expression * (int*int) list * int
     43  | St_switch of expression * (int*Label.t) list * Label.t
    4444
    4545  | St_return of expression option
    4646  | St_label of AST.ident * statement
    47   | St_goto of string
     47  | St_goto of Label.t
    4848  | St_cost of CostLabel.t * statement
    4949        | St_ind_0 of CostLabel.index * statement
    50   | St_ind_inc of statement * CostLabel.index
     50  | St_ind_inc of CostLabel.index * statement
    5151
    5252
  • Deliverables/D2.2/8051-indexed-labels-branch/src/cminor/cminorFold.ml

    r1334 r1392  
    3131
    3232let statement_subs = function
    33   | Cminor.St_skip | Cminor.St_exit _ | Cminor.St_return None
     33  | Cminor.St_skip | (*Cminor.St_exit _ |*) Cminor.St_return None
    3434  | Cminor.St_goto _ -> ([], [])
    3535  | Cminor.St_assign (_, e) | Cminor.St_switch (e, _, _)
     
    4343  | Cminor.St_ifthenelse (e, stmt1, stmt2) ->
    4444    ([e], [stmt1 ; stmt2])
    45   | Cminor.St_loop stmt | Cminor.St_block stmt
     45  (*| Cminor.St_loop stmt | Cminor.St_block stmt *)
    4646  | Cminor.St_label (_, stmt) | Cminor.St_cost (_, stmt)
    47         | Cminor.St_ind_0 (_, stmt) | Cminor.St_ind_inc (stmt, _) ->
     47        | Cminor.St_ind_0 (_, stmt) | Cminor.St_ind_inc (_, stmt) ->
    4848                ([], [stmt])
    4949
    5050let statement_fill_subs stmt sub_es sub_stmts =
    5151  match stmt, sub_es, sub_stmts with
    52     | (  Cminor.St_skip | Cminor.St_exit _ | Cminor.St_return None
     52    | (  Cminor.St_skip | (*Cminor.St_exit _ |*) Cminor.St_return None
    5353       | Cminor.St_goto _), _, _ -> stmt
    5454    | Cminor.St_assign (x, _), e :: _, _ ->
     
    6868    | Cminor.St_ifthenelse _, e :: _, stmt1 :: stmt2 :: _ ->
    6969      Cminor.St_ifthenelse (e, stmt1, stmt2)
    70     | Cminor.St_loop _, _, stmt :: _ ->
     70 (*   | Cminor.St_loop _, _, stmt :: _ ->
    7171      Cminor.St_loop stmt
    7272    | Cminor.St_block _, _, stmt :: _ ->
    73       Cminor.St_block stmt
     73      Cminor.St_block stmt *)
    7474    | Cminor.St_label (lbl, _), _, stmt :: _ ->
    7575      Cminor.St_label (lbl, stmt)
    7676    | Cminor.St_cost (lbl, _), _, stmt :: _ ->
    7777      Cminor.St_cost (lbl, stmt)
     78    | Cminor.St_ind_0 (i, _), _, stmt :: _ ->
     79      Cminor.St_ind_0 (i, stmt)
     80    | Cminor.St_ind_inc (i, _), _, stmt :: _ ->
     81      Cminor.St_ind_inc (i, stmt)
    7882    | _ -> assert false (* do not use on these arguments *)
    7983
  • Deliverables/D2.2/8051-indexed-labels-branch/src/cminor/cminorInterpret.ml

    r1357 r1392  
    2828    Ct_stop
    2929  | Ct_cont of statement*continuation
    30         | Ct_ind_inc of CostLabel.index*continuation
    31   | Ct_endblock of continuation
     30(*  | Ct_endblock of continuation *)
    3231  | Ct_returnto of
    3332      ident option*internal_function*Val.address*local_env*continuation
     
    6261  | St_seq _ -> "sequence"
    6362  | St_ifthenelse (e, _, _) -> "if (" ^ (string_of_expr e) ^ ")"
    64   | St_loop _ -> "loop"
     63(*  | St_loop _ -> "loop"
    6564  | St_block _ -> "block"
    66   | St_exit n -> "exit " ^ (string_of_int n)
     65  | St_exit n -> "exit " ^ (string_of_int n) *)
    6766  | St_switch (e, _, _) -> "switch (" ^ (string_of_expr e) ^ ")"
    6867  | St_return None -> "return"
     
    7473                "cost " ^ lbl
    7574        | St_ind_0 (i, _) -> "reset " ^ string_of_int i ^ " to 0"
    76         | St_ind_inc (_, i) -> "post-increment " ^ string_of_int i
     75        | St_ind_inc (i, _) -> "post-increment " ^ string_of_int i
    7776
    7877let print_state = function
     
    233232
    234233let rec callcont = function
    235   | Ct_cont(_,k) | Ct_endblock k | Ct_ind_inc(_,k) -> callcont k
     234  | Ct_cont(_,k) (*| Ct_endblock k *) -> callcont k
    236235        | (Ct_stop | Ct_returnto _) as k -> k
    237236
     
    245244  | St_seq(s1,s2)               ->
    246245      (match fdlbl (Ct_cont(s2,k)) s1 with
    247            None -> fdlbl k s2
    248         | Some(v) -> Some(v)
     246       None -> fdlbl k s2
     247    | Some(v) -> Some(v)
    249248      )
    250249  | St_ifthenelse(_,s1,s2)      ->
    251250      (match fdlbl k s1 with
    252            None -> fdlbl k s2
    253         | Some(v) -> Some(v)
     251       None -> fdlbl k s2
     252    | Some(v) -> Some(v)
    254253      )
    255   | St_loop(s)                  -> fdlbl (Ct_cont(St_loop(s),k)) s
     254(*  | St_loop(s)                  -> fdlbl (Ct_cont(St_loop(s),k)) s
    256255  | St_block(s)                 -> fdlbl (Ct_endblock(k)) s
    257   | St_exit(_)                  -> None
     256  | St_exit(_)                  -> None *)
    258257  | St_switch(_,_,_)            -> None
    259258  | St_return(_)                -> None
    260   | St_label(l,s)               -> if l=lbl then Some((s,k)) else None
     259  | St_label(l,s) when l = lbl  -> Some((s,k))
    261260  | St_goto(_)                  -> None
    262   | St_cost (_,s) | St_ind_0(_,s) | St_ind_inc(s,_) -> fdlbl k s
     261  | St_cost(_,s)  | St_label(_,s)
     262        | St_ind_0(_,s) | St_ind_inc(_,s) -> fdlbl k s
    263263  in match fdlbl k st with
    264264      None -> assert false (*Wrong label*)
     
    274274let eval_stmt f k sigma e m i s = match s, k with
    275275  | St_skip,Ct_cont(s,k) -> (State_regular(f, s, k, sigma, e, m, i),[])
    276   | St_skip,Ct_endblock(k) -> (State_regular(f, St_skip, k, sigma, e, m, i),[])
     276(*  | St_skip,Ct_endblock(k) -> (State_regular(f, St_skip, k, sigma, e, m, i),[]) *)
    277277  | St_skip, (Ct_returnto _ as k) ->
    278278    (State_return (Val.undef,k,Mem.free m sigma,i),[])
    279   | St_skip,Ct_ind_inc(ind,k) ->
    280                 CostLabel.continue_loop i ind;
    281                 (State_regular(f, s, k, sigma, e, m, i),[])
    282279  | St_skip,Ct_stop ->
    283280    (State_return (Val.undef,Ct_stop,Mem.free m sigma,i),[])
     
    304301        else error "undefined conditional value." in
    305302      (State_regular(f,next_stmt,k,sigma,e,m,i),l)
    306   | St_loop(s),_ -> (State_regular(f,s,Ct_cont((St_loop s),k),sigma,e,m,i),[])
     303(*  | St_loop(s),_ -> (State_regular(f,s,Ct_cont((St_loop s),k),sigma,e,m,i),[])
    307304  | St_block(s),_ -> (State_regular(f,s,(Ct_endblock k),sigma,e,m,i),[])
    308305  | St_exit(n),Ct_cont(s,k) -> (State_regular(f,(St_exit n),k,sigma,e,m,i),[])
    309306  | St_exit(0),Ct_endblock(k) -> (State_regular(f,St_skip,k,sigma,e,m,i),[])
    310307  | St_exit(n),Ct_endblock(k) ->
    311     (State_regular(f,(St_exit (n-1)),k,sigma,e,m,i),[])
     308    (State_regular(f,(St_exit (n-1)),k,sigma,e,m,i),[]) *)
    312309  | St_label(_,s),_ -> (State_regular(f,s,k,sigma,e,m,i),[])
    313   | St_goto(lbl),_ -> 
     310  | St_goto(lbl),_ ->
    314311    let (s2,k2) = findlabel lbl f.f_body (callcont k) in
    315312    (State_regular(f,s2,k2,sigma,e,m,i),[])
     
    318315    if Val.is_int v then
    319316      try
    320         let v = Val.to_int v in
    321         let nb_exit =
    322           if List.mem_assoc v lst then List.assoc v lst
    323           else def in
    324         (State_regular(f, St_exit nb_exit,k, sigma, e, m, i),l)
     317                                let v = Val.to_int v in
     318                                let lbl =
     319                                        try
     320                                                List.assoc v lst
     321                                        with
     322                                                | Not_found -> def in
     323        let (s',k') = findlabel lbl f.f_body (callcont k) in
     324              (State_regular(f, s', k', sigma, e, m, i),l)
    325325      with _ -> error "int value too big."
    326326    else error "undefined switch value."
     
    337337                CostLabel.enter_loop i ind;
    338338                (State_regular(f,s,k,sigma,e,m,i), [])
    339         | St_ind_inc(s,ind),_ ->
    340     (State_regular(f,s,Ct_ind_inc(ind,k),sigma,e,m,i), [])
    341   | _ -> error "state malformation."
     339        | St_ind_inc(ind,s),_ ->
     340                CostLabel.continue_loop i ind;
     341    (State_regular(f,s,k,sigma,e,m,i), [])
     342(*  | _ -> error "state malformation." *)
    342343
    343344
  • Deliverables/D2.2/8051-indexed-labels-branch/src/cminor/cminorPrinter.ml

    r1334 r1392  
    137137let print_table n =
    138138  let f s (case, exit) =
    139     Printf.sprintf "%s%scase %d: exit %d;\n" s (n_spaces n) case exit
     139    Printf.sprintf "%s%scase %d: goto %s;\n" s (n_spaces n) case exit
    140140  in
    141141  List.fold_left f ""
     
    187187        (print_body (n+2) s2)
    188188        (n_spaces n)
    189   | Cminor.St_loop s ->
     189(*  | Cminor.St_loop s ->
    190190      Printf.sprintf "%sloop {\n%s%s}\n"
    191191        (n_spaces n)
     
    198198        (n_spaces n)
    199199  | Cminor.St_exit i ->
    200       Printf.sprintf "%sexit %d;\n" (n_spaces n) i
     200      Printf.sprintf "%sexit %d;\n" (n_spaces n) i *)
    201201  | Cminor.St_switch (e, tbl, dflt) ->
    202       Printf.sprintf "%sswitch (%s) {\n%s%sdefault: exit %d;\n%s}\n"
     202      Printf.sprintf "%sswitch (%s) {\n%s%sdefault: goto %s;\n%s}\n"
    203203        (n_spaces n)
    204204        (print_expression e)
     
    219219        | Cminor.St_ind_0 (i, s) ->
    220220                  Printf.sprintf "%sindex %d:\n%s" (n_spaces n) i (print_body n s)
    221         | Cminor.St_ind_inc (s, i) ->
    222                   Printf.sprintf "%s%sincrement %d;\n" (print_body n s) (n_spaces n) i
     221        | Cminor.St_ind_inc (i,s) ->
     222                  Printf.sprintf "%sincrement %d:\n%s\n" (n_spaces n) i (print_body n s)
    223223
    224224let print_internal f_name f_def =
     
    257257  | Cminor.St_seq(_,_) -> "seq"
    258258  | Cminor.St_ifthenelse(_,_,_) -> "ifthenelse"
    259   | Cminor.St_loop(_) -> "loop"
     259(*  | Cminor.St_loop(_) -> "loop"
    260260  | Cminor.St_block(_) -> "block"
    261   | Cminor.St_exit(_) -> "exit"
     261  | Cminor.St_exit(_) -> "exit" *)
    262262  | Cminor.St_switch(_,_,_) -> "switch"
    263263  | Cminor.St_return(_) -> "return"
  • Deliverables/D2.2/8051-indexed-labels-branch/src/cminor/cminorToRTLabs.ml

    r1340 r1392  
    333333      translate_branch rtlabs_fun lenv e lbl_true lbl_false
    334334
    335     | Cminor.St_loop s ->
     335(*    | Cminor.St_loop s ->
    336336      let loop_start = fresh_label rtlabs_fun in
    337337      let rtlabs_fun = change_entry rtlabs_fun loop_start in
     
    345345
    346346    | Cminor.St_exit n ->
    347       change_entry rtlabs_fun (List.nth exits n)
     347      change_entry rtlabs_fun (List.nth exits n) *)
    348348
    349349    | Cminor.St_return eopt ->
     
    376376      generate rtlabs_fun (RTLabs.St_ind_0 (i, old_entry))
    377377
    378     | Cminor.St_ind_inc (s, i) ->
    379       let old_entry = rtlabs_fun.RTLabs.f_entry in
    380             let rtlabs_fun = generate rtlabs_fun (RTLabs.St_ind_inc(i, old_entry)) in
    381       translate_stmt rtlabs_fun lenv exits s
     378    | Cminor.St_ind_inc (i, s) ->
     379      let rtlabs_fun = translate_stmt rtlabs_fun lenv exits s in
     380      let old_entry = rtlabs_fun.RTLabs.f_entry in
     381      generate rtlabs_fun (RTLabs.St_ind_inc (i, old_entry))
    382382
    383383    | Cminor.St_goto lbl ->
Note: See TracChangeset for help on using the changeset viewer.