Ignore:
Timestamp:
Nov 28, 2011, 3:13:14 PM (8 years ago)
Author:
tranquil
Message:
  • corrected previous bug
  • finished propagating immediates
Location:
Deliverables/D2.2/8051/src/RTL
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • Deliverables/D2.2/8051/src/RTL/RTL.mli

    r1568 r1572  
    5050     statement. *)
    5151  | St_opaccs of I8051.opaccs * Register.t * Register.t *
    52                                 Register.t * Register.t * Label.t
     52                                argument * argument * Label.t
    5353
    5454  (* Apply an unary operation. Parameters are the operation, the destination
     
    5858  (* Apply a binary operation. Parameters are the operation, the destination
    5959     register, the source arguments, and the label of the next statement. *)
    60   | St_op2 of I8051.op2 * Register.t * Register.t * argument * Label.t
     60  | St_op2 of I8051.op2 * Register.t * argument * argument * Label.t
    6161
    6262  (* Set the carry flag to zero. Parameter is the label of the next
     
    7070     address registers (low bytes first), and the label of the next
    7171     statement. *)
    72   | St_load of Register.t * Register.t * Register.t * Label.t
     72  | St_load of Register.t * argument * argument * Label.t
    7373
    7474  (* Store to external memory. Parameters are the address registers (low bytes
    7575     first), the source register, and the label of the next statement. *)
    76   | St_store of Register.t * Register.t * Register.t * Label.t
     76  | St_store of argument * argument * argument * Label.t
    7777
    7878  (* Call to a function given its name. Parameters are the name of the function,
    7979     the arguments of the function, the destination registers, and the label of
    8080     the next statement. *)
    81   | St_call_id of AST.ident * Register.t list * registers * Label.t
     81  | St_call_id of AST.ident * argument list * registers * Label.t
    8282
    8383  (* Call to a function given its address. Parameters are the registers holding
     
    8585     function, the destination registers, and the label of the next
    8686     statement. *)
    87   | St_call_ptr of Register.t * Register.t * Register.t list * registers *
     87  | St_call_ptr of Register.t * Register.t * argument list * registers *
    8888      Label.t
    8989
    9090  (* Tail call to a function given its name. Parameters are the name of the
    9191     function, and the arguments of the function. *)
    92   | St_tailcall_id of AST.ident * Register.t list
     92  | St_tailcall_id of AST.ident * argument list
    9393
    9494  (* Tail call to a function given its address. Parameters are the registers
    9595     holding the address of the function (low bytes first), and the arguments of
    9696     the function. *)
    97   | St_tailcall_ptr of Register.t * Register.t * Register.t list
     97  | St_tailcall_ptr of Register.t * Register.t * argument list
    9898
    9999  (* Branch. Parameters are the register holding the value for the branching,
     
    103103
    104104  (* Return the value of some registers (low bytes first). *)
    105   | St_return of registers
     105  | St_return of argument list
    106106
    107107
  • Deliverables/D2.2/8051/src/RTL/RTLInterpret.ml

    r1568 r1572  
    9494  | RTL.Imm i -> Val.of_int i
    9595
    96 let get_arg_values lenv args = List.map (get_local_value lenv) args
     96let get_arg_values lenv args = List.map (get_local_arg_value lenv) args
    9797
    9898let get_local_addr lenv f1 f2 =
    99   List.map (get_local_value lenv) [f1 ; f2]
     99  List.map (get_local_arg_value lenv) [f1 ; f2]
    100100
    101101
     
    174174        let (v1, v2) =
    175175          Eval.opaccs opaccs
    176             (get_local_value lenv srcr1)
    177             (get_local_value lenv srcr2) in
     176            (get_local_arg_value lenv srcr1)
     177            (get_local_arg_value lenv srcr2) in
    178178        assign_state sfrs graph lbl sp lenv carry mem inds trace
    179179          [destr1 ; destr2] [v1 ; v2]
     
    186186        let (v, carry) =
    187187          Eval.op2 carry op2
    188             (get_local_value lenv srcr1)
     188            (get_local_arg_value lenv srcr1)
    189189            (get_local_arg_value lenv srcr2) in
    190190        assign_state sfrs graph lbl sp lenv carry mem inds trace [destr] [v]
     
    203203      | RTL.St_store (addr1, addr2, srcr, lbl) ->
    204204        let addr = get_local_addr lenv addr1 addr2 in
    205         let mem = Mem.store mem chunk addr (get_local_value lenv srcr) in
     205        let mem = Mem.store mem chunk addr (get_local_arg_value lenv srcr) in
    206206        State (sfrs, graph, lbl, sp, lenv, carry, mem, inds, trace)
    207207
     
    216216
    217217      | RTL.St_call_ptr (f1, f2, args, ret_regs, lbl) ->
    218         let addr = get_local_addr lenv f1 f2 in
     218        let addr = get_local_addr lenv (RTL.Reg f1) (RTL.Reg f2) in
    219219        let f_def = Mem.find_fun_def mem addr in
    220220        let args = get_arg_values lenv args in
     
    230230
    231231      | RTL.St_tailcall_ptr (f1, f2, args) ->
    232         let addr = get_local_addr lenv f1 f2 in
     232        let addr = get_local_addr lenv (RTL.Reg f1) (RTL.Reg f2) in
    233233        let f_def = Mem.find_fun_def mem addr in
    234234        let args = get_arg_values lenv args in
     
    241241
    242242      | RTL.St_return rl ->
    243         let vl = List.map (get_local_value lenv) rl in
     243        let vl = List.map (get_local_arg_value lenv) rl in
    244244        let mem = Mem.free mem sp in
    245245        ReturnState (sfrs, vl, mem, inds, trace)
  • Deliverables/D2.2/8051/src/RTL/RTLPrinter.ml

    r1568 r1572  
    3131let print_ptr rl = print_reg_list "[" "]" " ; " print_reg rl
    3232
    33 let print_args rl = print_reg_list "(" ")" ", " print_reg rl
     33let print_args rl = print_reg_list "(" ")" ", " print_arg rl
    3434
    35 let print_return rl = print_reg_list "[" "]" " ; " print_reg rl
     35let print_returned rl = print_reg_list "[" "]" " ; " print_reg rl
     36
     37let print_return rl = print_reg_list "[" "]" " ; " print_arg rl
    3638
    3739let print_params rl = print_reg_list "(" ")" ", " Register.print rl
     
    6971      (print_reg dstr1)
    7072      (print_reg dstr2)
    71       (print_reg srcr1)
    72       (print_reg srcr2)
     73      (print_arg srcr1)
     74      (print_arg srcr2)
    7375      lbl
    7476  | RTL.St_op1 (op1, dstr, srcr, lbl) ->
     
    7981      (I8051.print_op2 op2)
    8082      (print_reg dstr)
    81       (print_reg srcr1)
     83      (print_arg srcr1)
    8284      (print_arg srcr2)
    8385      lbl
     
    8991    Printf.sprintf "load %s, (%s, %s) --> %s"
    9092      (print_reg dstr)
    91       (print_reg addr1)
    92       (print_reg addr2)
     93      (print_arg addr1)
     94      (print_arg addr2)
    9395      lbl
    9496  | RTL.St_store (addr1, addr2, srcr, lbl) ->
    9597    Printf.sprintf "store (%s, %s), %s --> %s"
    96       (print_reg addr1)
    97       (print_reg addr2)
    98       (print_reg srcr)
     98      (print_arg addr1)
     99      (print_arg addr2)
     100      (print_arg srcr)
    99101      lbl
    100102  | RTL.St_call_id (f, args, dstrs, lbl) ->
     
    102104      f
    103105      (print_args args)
    104       (print_return dstrs)
     106      (print_returned dstrs)
    105107      lbl
    106108  | RTL.St_call_ptr (f1, f2, args, dstrs, lbl) ->
     
    109111      (print_reg f2)
    110112      (print_args args)
    111       (print_return dstrs)
     113      (print_returned dstrs)
    112114      lbl
    113115  | RTL.St_tailcall_id (f, args) ->
  • Deliverables/D2.2/8051/src/RTL/RTLToERTL.ml

    r1568 r1572  
    100100
    101101let restore_hdws l =
    102   let f (destr, srcr) start_lbl =
    103     adds_graph [ERTL.St_set_hdw (destr, RTL.Reg srcr, start_lbl)] start_lbl in
    104   List.map f (List.map (fun (x, y) -> (y, x)) l)
     102  let f (srcr, destr) start_lbl =
     103    adds_graph [ERTL.St_set_hdw (destr, srcr, start_lbl)] start_lbl in
     104  List.map f l
    105105
    106106let get_params_hdw params =
     
    117117  adds_graph
    118118    [ERTL.St_framesize (addr1, start_lbl) ;
    119      ERTL.St_op2 (I8051.Sub, addr1, addr1, RTL.Imm (off+I8051.int_size),
     119     ERTL.St_op2 (I8051.Sub, addr1, RTL.Reg addr1, RTL.Imm (off+I8051.int_size),
    120120                  start_lbl) ;
    121121     ERTL.St_get_hdw (tmpr, I8051.spl, start_lbl) ;
    122      ERTL.St_op2 (I8051.Add, addr1, addr1, RTL.Reg tmpr, start_lbl) ;
     122     ERTL.St_op2 (I8051.Add, addr1, RTL.Reg addr1, RTL.Reg tmpr, start_lbl) ;
    123123     ERTL.St_get_hdw (tmpr, I8051.sph, start_lbl) ;
    124      ERTL.St_op2 (I8051.Addc, addr2, tmpr, RTL.Imm 0, start_lbl) ;
    125      ERTL.St_load (destr, addr1, addr2, start_lbl)]
     124     ERTL.St_op2 (I8051.Addc, addr2, RTL.Reg tmpr, RTL.Imm 0, start_lbl) ;
     125     ERTL.St_load (destr, RTL.Reg addr1, RTL.Reg addr2, start_lbl)]
    126126    start_lbl dest_lbl def
    127127
     
    203203       (* restore the return address *)
    204204       [adds_graph [ERTL.St_comment ("Restore return address", start_lbl) ;
    205                     ERTL.St_push (srah, start_lbl) ;
    206                     ERTL.St_push (sral, start_lbl)]] @
     205                    ERTL.St_push (RTL.Reg srah, start_lbl) ;
     206                    ERTL.St_push (RTL.Reg sral, start_lbl)]] @
    207207       (* delete frame *)
    208208       [adds_graph [ERTL.St_comment ("Delete frame", start_lbl) ;
     
    225225let add_pro_and_epilogue params ret_regs def =
    226226  (* Allocate registers to hold the return address. *)
    227   let (def, sra) = fresh_regs def 2 in
    228   let sral = List.nth sra 0 in
    229   let srah = List.nth sra 1 in
     227  let (def, sral) = fresh_reg def in
     228  let (def, srah) = fresh_reg def in
    230229  (* Allocate registers to save callee-saved registers. *)
    231230  let (def, sregs) = allocate_regs I8051.callee_saved def in
    232231  (* Add a prologue and a epilogue. *)
    233232  let def = add_prologue params sral srah sregs def in
     233  let sregs = List.map (fun (r, r') -> (RTL.Reg r, r')) sregs in
    234234  let def = add_epilogue ret_regs sral srah sregs def in
    235235  def
     
    238238let set_params_hdw params =
    239239  if List.length params = 0 then
    240     [fun start_lbl -> adds_graph [ERTL.St_skip start_lbl] start_lbl]
     240    []
    241241  else
    242242    let l = MiscPottier.combine params I8051.parameters in
     
    250250    [ERTL.St_get_hdw (tmpr, I8051.spl, start_lbl) ;
    251251     ERTL.St_clear_carry start_lbl ;
    252      ERTL.St_op2 (I8051.Sub, addr1, tmpr, RTL.Imm (off+I8051.int_size),
     252     ERTL.St_op2 (I8051.Sub, addr1, RTL.Reg tmpr, RTL.Imm (off+I8051.int_size),
    253253                  start_lbl) ;
    254254     ERTL.St_get_hdw (tmpr, I8051.sph, start_lbl) ;
    255      ERTL.St_op2 (I8051.Sub, addr2, tmpr, RTL.Imm 0, start_lbl) ;
    256      ERTL.St_store (addr1, addr2, srcr, start_lbl)]
     255     ERTL.St_op2 (I8051.Sub, addr2, RTL.Reg tmpr, RTL.Imm 0, start_lbl) ;
     256     ERTL.St_store (RTL.Reg addr1, RTL.Reg addr2, srcr, start_lbl)]
    257257    start_lbl dest_lbl def
    258258
Note: See TracChangeset for help on using the changeset viewer.