Ignore:
Timestamp:
Nov 28, 2011, 3:13:14 PM (9 years ago)
Author:
tranquil
Message:
  • corrected previous bug
  • finished propagating immediates
File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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.