Ignore:
Timestamp:
Nov 25, 2011, 7:43:39 PM (9 years ago)
Author:
tranquil
Message:
  • Immediates introduced (but not fully used yet in RTLabs to RTL pass)
  • translation streamlined
  • BUGGY: interpretation fails in LTL, trying to fetch a function with incorrect address
Location:
Deliverables/D2.2/8051/src/ERTL
Files:
7 edited

Legend:

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

    r1542 r1568  
    3838type registers = Register.t list
    3939
     40type argument = RTL.argument
     41
    4042type statement =
    4143
     
    6365     are the destination hardware register, the source pseudo register, and the
    6466     label of the next statement. *)
    65   | St_set_hdw of I8051.register * Register.t * Label.t
     67  | St_set_hdw of I8051.register * argument * Label.t
    6668
    6769  (* Assign the content of a hardware register to a hardware
     
    101103  | St_addrL of Register.t * AST.ident * Label.t
    102104
    103   (* Assign an integer constant to a register. Parameters are the destination
    104      register, the integer and the label of the next statement. *)
    105   | St_int of Register.t * int * Label.t
     105  (* (\* Assign an integer constant to a register. Parameters are the destination *)
     106  (*    register, the integer and the label of the next statement. *\) *)
     107  (* | St_int of Register.t * int * Label.t *)
    106108
    107109  (* Move the content of a register to another. Parameters are the destination
    108110     register, the source register, and the label of the next statement. *)
    109   | St_move of Register.t * Register.t * Label.t
     111  | St_move of Register.t * argument * Label.t
    110112
    111113  (* Apply a binary operation that will later be translated in an operation on
     
    127129  (* Apply a binary operation. Parameters are the operation, the destination
    128130     register, the source registers, and the label of the next statement. *)
    129   | St_op2 of I8051.op2 * Register.t * Register.t * Register.t * Label.t
     131  | St_op2 of I8051.op2 * Register.t * Register.t * argument * Label.t
    130132
    131133  (* Set the carry flag to zero. Parameter is the label of the next
  • Deliverables/D2.2/8051/src/ERTL/ERTLInterpret.ml

    r1542 r1568  
    158158    else error ("Unknown local register " ^ (Register.print r) ^ ".")
    159159
     160let get_arg a st = match a with
     161  | RTL.Imm i -> Val.of_int i
     162  | RTL.Reg r -> get_reg (Psd r) st
     163
    160164let push st v =
    161165  let mem = Mem.store st.mem chunk st.isp v in
     
    282286
    283287    | ERTL.St_set_hdw (destr, srcr, lbl) ->
    284       let st = add_reg (Hdw destr) (get_reg (Psd srcr) st) st in
     288      let st = add_reg (Hdw destr) (get_arg srcr st) st in
    285289      next_pc st lbl
    286290
     
    328332      next_pc st lbl
    329333
    330     | ERTL.St_int (r, i, lbl) ->
     334    | ERTL.St_move (r, RTL.Imm i, lbl) ->
    331335      let st = add_reg (Psd r) (Val.of_int i) st in
    332336      next_pc st lbl
    333337
    334     | ERTL.St_move (destr, srcr, lbl) ->
     338    | ERTL.St_move (destr, RTL.Reg srcr, lbl) ->
    335339      let st = add_reg (Psd destr) (get_reg (Psd srcr) st) st in
    336340      next_pc st lbl
     
    361365        Eval.op2 st.carry op2
    362366          (get_reg (Psd srcr1) st)
    363           (get_reg (Psd srcr2) st) in
     367          (get_arg srcr2 st) in
    364368      let st = change_carry st carry in
    365369      let st = add_reg (Psd destr) v st in
  • Deliverables/D2.2/8051/src/ERTL/ERTLPrinter.ml

    r1542 r1568  
    3737let print_result rl = print_reg_list "[" "]" " ; " Register.print rl
    3838
     39let print_arg = function
     40  | RTL.Imm i -> string_of_int i
     41  | RTL.Reg r -> Register.print r
    3942
    4043let print_statement = function
     
    5457  | ERTL.St_set_hdw (r1, r2, lbl) ->
    5558    Printf.sprintf "move %s, %s --> %s"
    56       (I8051.print_register r1) (Register.print r2) lbl
     59      (I8051.print_register r1) (print_arg r2) lbl
    5760  | ERTL.St_hdw_to_hdw (r1, r2, lbl) ->
    5861    Printf.sprintf "move %s, %s --> %s"
     
    7275  | ERTL.St_addrL (dstr, id, lbl) ->
    7376    Printf.sprintf "addrL %s, %s --> %s" (Register.print dstr) id lbl
    74   | ERTL.St_int (dstr, i, lbl) ->
    75     Printf.sprintf "imm %s, %d --> %s" (Register.print dstr) i lbl
     77  (* | ERTL.St_int (dstr, i, lbl) -> *)
     78  (*   Printf.sprintf "imm %s, %d --> %s" (Register.print dstr) i lbl *)
    7679  | ERTL.St_move (dstr, srcr, lbl) ->
    7780    Printf.sprintf "move %s, %s --> %s"
    78       (Register.print dstr) (Register.print srcr) lbl
     81      (Register.print dstr) (print_arg srcr) lbl
    7982  | ERTL.St_opaccsA (opaccs, dstr, srcr1, srcr2, lbl) ->
    8083    Printf.sprintf "%sA %s, %s, %s --> %s"
     
    102105      (Register.print dstr)
    103106      (Register.print srcr1)
    104       (Register.print srcr2)
     107      (print_arg srcr2)
    105108      lbl
    106109  | ERTL.St_clear_carry lbl ->
  • Deliverables/D2.2/8051/src/ERTL/ERTLToLTLI.ml

    r1542 r1568  
    4040    let l = generate (LTL.St_load l) in
    4141    let l = generate (LTL.St_from_acc (I8051.dph, l)) in
    42     let l = generate (LTL.St_op2 (I8051.Addc, I8051.sph, l)) in
     42    let l = generate (LTL.St_op2 (I8051.Addc, LTL.Reg I8051.sph, l)) in
    4343    let l = generate (LTL.St_int (I8051.a, 0, l)) in
    4444    let l = generate (LTL.St_from_acc (I8051.dpl, l)) in
    45     let l = generate (LTL.St_op2 (I8051.Add, I8051.spl, l)) in
     45    let l = generate (LTL.St_op2 (I8051.Add, LTL.Reg I8051.spl, l)) in
    4646    LTL.St_int (I8051.a, off, l)
    4747
     48  let set_stack_preamble off l =
     49    let off = adjust off in
     50    let l = generate (LTL.St_from_acc (I8051.dph, l)) in
     51    let l = generate (LTL.St_op2 (I8051.Addc, LTL.Reg I8051.sph, l)) in
     52    let l = generate (LTL.St_int (I8051.a, 0, l)) in
     53    let l = generate (LTL.St_from_acc (I8051.dpl, l)) in
     54    let l = generate (LTL.St_op2 (I8051.Add, LTL.Reg I8051.spl, l)) in
     55    LTL.St_int (I8051.a, off, l)
     56
    4857  let set_stack off r l =
    49     let off = adjust off in
    5058    let l = generate (LTL.St_store l) in
    5159    let l = generate (LTL.St_to_acc (r, l)) in
    52     let l = generate (LTL.St_from_acc (I8051.dph, l)) in
    53     let l = generate (LTL.St_op2 (I8051.Addc, I8051.sph, l)) in
    54     let l = generate (LTL.St_int (I8051.a, 0, l)) in
    55     let l = generate (LTL.St_from_acc (I8051.dpl, l)) in
    56     let l = generate (LTL.St_op2 (I8051.Add, I8051.spl, l)) in
    57     LTL.St_int (I8051.a, off, l)
    58 
    59 
    60   let write (r : Register.t) (l : Label.t) : (I8051.register * Label.t) =
    61     match lookup r with
    62 
    63       | Color hwr ->
    64         (* Pseudo-register [r] has been mapped to hardware register
    65            [hwr]. Just write into [hwr] and branch to [l]. *)
    66         (hwr, l)
    67 
    68       | Spill off ->
    69         (* Pseudo-register [r] has been mapped to offset [off] in the local zone
    70            of the stack. Then, write into [sst] (never allocated) and transfer
    71            control to an instruction that copies [sst] in the designated
    72            location of the stack before branching to [l]. *)
    73         (I8051.sst, generate (set_stack off I8051.sst l))
    74 
    75 
    76   let read (r : Register.t) (stmt : I8051.register -> LTL.statement) =
    77     match lookup r with
    78       | Color hwr ->
    79         (* Pseudo-register [r] has been mapped to hardware register [hwr]. Just
    80            generate statement [stmt] with a reference to register [hwr]. *)
    81         generate (stmt hwr)
    82 
    83       | Spill off ->
    84         (* Pseudo-register [r] has been mapped to offset [off] in the local zone
    85            of the stack. Issue a statement that copies the designated area in
    86            the stack into the temporary unallocatable hardware register [sst],
    87            then generate statement [stmt] with a reference to register
    88            [sst]. *)
    89         let temphwr = I8051.sst in
    90         let l = generate (stmt temphwr) in
    91         generate (get_stack temphwr off l)
     60    set_stack_preamble off l
     61
     62  let set_stack_int off k l =
     63    let l = generate (LTL.St_store l) in
     64    let l = generate (LTL.St_int (I8051.a, k, l)) in
     65    set_stack_preamble off l
     66
     67  (* let write (r : Register.t) (l : Label.t) : (I8051.register * Label.t) = *)
     68  (*   match lookup r with *)
     69
     70  (*     | Color hwr -> *)
     71  (*       (\* Pseudo-register [r] has been mapped to hardware register *)
     72  (*          [hwr]. Just write into [hwr] and branch to [l]. *\) *)
     73  (*       (hwr, l) *)
     74
     75  (*     | Spill off -> *)
     76  (*       (\* Pseudo-register [r] has been mapped to offset [off] in the local zone *)
     77  (*          of the stack. Then, write into [sst] (never allocated) and transfer *)
     78  (*          control to an instruction that copies [sst] in the designated *)
     79  (*          location of the stack before branching to [l]. *\) *)
     80  (*       (I8051.sst, generate (set_stack off I8051.sst l)) *)
     81
     82
     83  (* let read (r : Register.t) (stmt : I8051.register -> LTL.statement) = *)
     84  (*   match lookup r with *)
     85  (*     | Color hwr -> *)
     86  (*       (\* Pseudo-register [r] has been mapped to hardware register [hwr]. Just *)
     87  (*          generate statement [stmt] with a reference to register [hwr]. *\) *)
     88  (*       generate (stmt hwr) *)
     89
     90  (*     | Spill off -> *)
     91  (*       (\* Pseudo-register [r] has been mapped to offset [off] in the local zone *)
     92  (*          of the stack. Issue a statement that copies the designated area in *)
     93  (*          the stack into the temporary unallocatable hardware register [sst], *)
     94  (*          then generate statement [stmt] with a reference to register *)
     95  (*          [sst]. *\) *)
     96  (*       let temphwr = I8051.sst in *)
     97  (*       let l = generate (stmt temphwr) in *)
     98  (*       generate (get_stack temphwr off l) *)
    9299
    93100
     
    100107      | Color desthwr, Color sourcehwr when I8051.eq_reg desthwr sourcehwr ->
    101108        LTL.St_skip l
     109      | Color desthwr, Color sourcehwr when I8051.eq_reg desthwr I8051.a ->
     110        LTL.St_to_acc (sourcehwr, l)
     111      | Color desthwr, Color sourcehwr when I8051.eq_reg sourcehwr I8051.a ->
     112        LTL.St_from_acc (desthwr, l)
    102113      | Color desthwr, Color sourcehwr ->
    103114        let l = generate (LTL.St_from_acc (desthwr, l)) in
     
    119130        get_stack temphwr off2 l
    120131
     132  let move_int (dest : decision) (k : int) l =
     133    match dest with
     134      | Color desthwr -> LTL.St_int (desthwr, k, l)
     135      | Spill off -> set_stack_int off k l
     136
     137  let op2 op (dest : decision) (src1 : decision) (src2 : decision) l =
     138    let l = generate (move dest (Color I8051.a) l) in
     139    match op, src1, src2 with
     140      | _, _, Color src2hwr ->
     141        let l = generate (LTL.St_op2 (op, LTL.Reg src2hwr, l)) in
     142        move (Color I8051.a) src1 l
     143        (* if op is commutative, we can do as above if first is hwr *)
     144      | (Add | Addc | And | Or | Xor), Color src1hwr, _ ->
     145        let l = generate (LTL.St_op2 (op, LTL.Reg src1hwr, l)) in
     146        move (Color I8051.a) src2 l
     147        (* otherwise we have to use b *)
     148      | _ ->
     149        let l = generate (LTL.St_op2 (op, LTL.Reg I8051.b, l)) in
     150        let l = generate (move (Color I8051.a) src1 l) in
     151        move (Color I8051.b) src2 l
     152
     153  let move_to_dptr (addr1 : decision) (addr2 : decision) l =
     154    match addr1, addr2 with
     155      | Color _, _ ->
     156        (* the following does not change dph, as addr1 is hwr *)
     157        let l = generate (move (Color I8051.dpl) addr1 l) in
     158        move (Color I8051.dph) addr2 l
     159      | _, Color _ ->
     160        (* the following does not change dph, as addr1 is hwr *)
     161        let l = generate (move (Color I8051.dph) addr2 l) in
     162        move (Color I8051.dpl) addr1 l
     163      | _ ->
     164        let l = generate (move (Color I8051.dph) (Color I8051.b) l) in
     165        let l = generate (move (Color I8051.dpl) addr1 l) in
     166        move (Color I8051.b) addr2 l
     167
     168  let store addr1 addr2 srcr l =
     169    let l = generate (LTL.St_store l) in
     170    match srcr with
     171      | Color _ ->
     172        let l = generate (move (Color I8051.a) srcr l) in
     173        move_to_dptr addr1 addr2 l
     174      | _ ->
     175        let l = generate (LTL.St_to_acc (I8051.st0, l)) in
     176        let l = generate (move_to_dptr addr1 addr2 l) in
     177        move (Color I8051.st0) srcr l
    121178
    122179  let newframe l =
     
    124181    else
    125182      let l = generate (LTL.St_from_acc (I8051.sph, l)) in
    126       let l = generate (LTL.St_op2 (I8051.Sub, I8051.dph, l)) in
    127       let l = generate (LTL.St_int (I8051.dph, 0, l)) in
     183      let l = generate (LTL.St_op2 (I8051.Sub, LTL.Imm 0, l)) in
    128184      let l = generate (LTL.St_to_acc (I8051.sph, l)) in
    129185      let l = generate (LTL.St_from_acc (I8051.spl, l)) in
    130       let l = generate (LTL.St_op2 (I8051.Sub, I8051.dpl, l)) in
     186      let l = generate (LTL.St_op2 (I8051.Sub, LTL.Imm stacksize, l)) in
    131187      let l = generate (LTL.St_clear_carry l) in
    132       let l = generate (LTL.St_int (I8051.dpl, stacksize, l)) in
    133188      LTL.St_to_acc (I8051.spl, l)
    134189
     
    137192    else
    138193      let l = generate (LTL.St_from_acc (I8051.sph, l)) in
    139       let l = generate (LTL.St_op2 (I8051.Addc, I8051.sph, l)) in
     194      let l = generate (LTL.St_op2 (I8051.Addc, LTL.Reg I8051.sph, l)) in
    140195      let l = generate (LTL.St_int (I8051.a, 0, l)) in
    141196      let l = generate (LTL.St_from_acc (I8051.spl, l)) in
    142       let l = generate (LTL.St_op2 (I8051.Add, I8051.spl, l)) in
    143       LTL.St_int (I8051.a, stacksize, l)
     197      let l = generate (LTL.St_op2 (I8051.Add, LTL.Imm stacksize, l)) in
     198      LTL.St_to_acc (I8051.spl, l)
    144199
    145200
     
    174229        move (lookup destr) (Color sourcehwr) l
    175230
    176       | ERTL.St_set_hdw (desthwr, sourcer, l) ->
     231      | ERTL.St_set_hdw (desthwr, RTL.Reg sourcer, l) ->
    177232        move (Color desthwr) (lookup sourcer) l
    178233
     234      | ERTL.St_set_hdw (desthwr, RTL.Imm k, l) ->
     235        move_int (Color desthwr) k l
     236
    179237      | ERTL.St_hdw_to_hdw (r1, r2, l) ->
    180         let l = generate (LTL.St_from_acc (r1, l)) in
    181         LTL.St_to_acc (r2, l)
     238        move (Color r1) (Color r2) l
    182239
    183240      | ERTL.St_newframe l ->
     
    188245
    189246      | ERTL.St_framesize (r, l) ->
    190         let (hdw, l) = write r l in
    191         LTL.St_int (hdw, stacksize, l)
     247        move_int (lookup r) stacksize l
    192248
    193249      | ERTL.St_pop (r, l) ->
    194         let (hdw, l) = write r l in
    195         let l = generate (LTL.St_from_acc (hdw, l)) in
     250        let l = generate (move (lookup r) (Color I8051.a) l) in
    196251        LTL.St_pop l
    197252
    198253      | ERTL.St_push (r, l) ->
    199254        let l = generate (LTL.St_push l) in
    200         let l = read r (fun hdw -> LTL.St_to_acc (hdw, l)) in
    201         LTL.St_skip l
     255        move (Color I8051.a) (lookup r) l
    202256
    203257      | ERTL.St_addrH (r, x, l) ->
    204         let (hdw, l) = write r l in
    205         let l = generate (LTL.St_from_acc (hdw, l)) in
    206         let l = generate (LTL.St_to_acc (I8051.dph, l)) in
     258        let l = generate (move (lookup r) (Color I8051.dph) l) in
    207259        LTL.St_addr (x, l)
    208260
    209261      | ERTL.St_addrL (r, x, l) ->
    210         let (hdw, l) = write r l in
    211         let l = generate (LTL.St_from_acc (hdw, l)) in
    212         let l = generate (LTL.St_to_acc (I8051.dpl, l)) in
     262        let l = generate (move (lookup r) (Color I8051.dpl) l) in
    213263        LTL.St_addr (x, l)
    214264
    215       | ERTL.St_int (r, i, l) ->
    216         let (hdw, l) = write r l in
    217         LTL.St_int (hdw, i, l)
    218 
    219       | ERTL.St_move (r1, r2, l) ->
     265      | ERTL.St_move (r, RTL.Imm i, l) ->
     266        move_int (lookup r) i l
     267
     268      | ERTL.St_move (r1, RTL.Reg r2, l) ->
    220269        move (lookup r1) (lookup r2) l
    221270
    222271      | ERTL.St_opaccsA (opaccs, destr, srcr1, srcr2, l) ->
    223         let (hdw, l) = write destr l in
    224         let l = generate (LTL.St_from_acc (hdw, l)) in
     272        let l = generate (move (lookup destr) (Color I8051.a) l) in
    225273        let l = generate (LTL.St_opaccs (opaccs, l)) in
    226         let l = read srcr1 (fun hdw -> LTL.St_to_acc (hdw, l)) in
    227         let l = generate (LTL.St_from_acc (I8051.b, l)) in
    228         let l = read srcr2 (fun hdw -> LTL.St_to_acc (hdw, l)) in
    229         LTL.St_skip l
     274        let l = generate (move (Color I8051.a) (lookup srcr1) l) in
     275        move (Color I8051.b) (lookup srcr2) l
    230276
    231277      | ERTL.St_opaccsB (opaccs, destr, srcr1, srcr2, l) ->
    232         let (hdw, l) = write destr l in
    233         let l = generate (LTL.St_from_acc (hdw, l)) in
    234         let l = generate (LTL.St_to_acc (I8051.b, l)) in
     278        let l = generate (move (lookup destr) (Color I8051.b) l) in
    235279        let l = generate (LTL.St_opaccs (opaccs, l)) in
    236         let l = read srcr1 (fun hdw -> LTL.St_to_acc (hdw, l)) in
    237         let l = generate (LTL.St_from_acc (I8051.b, l)) in
    238         let l = read srcr2 (fun hdw -> LTL.St_to_acc (hdw, l)) in
    239         LTL.St_skip l
     280        let l = generate (move (Color I8051.a) (lookup srcr1) l) in
     281        move (Color I8051.b) (lookup srcr2) l
    240282
    241283      | ERTL.St_op1 (op1, destr, srcr, l) ->
    242         let (hdw, l) = write destr l in
    243         let l = generate (LTL.St_from_acc (hdw, l)) in
     284        let l = generate (move (lookup destr) (Color I8051.a) l) in
    244285        let l = generate (LTL.St_op1 (op1, l)) in
    245         let l = read srcr (fun hdw -> LTL.St_to_acc (hdw, l)) in
    246         LTL.St_skip l
    247 
    248       | ERTL.St_op2 (op2, destr, srcr1, srcr2, l) ->
    249         let (hdw, l) = write destr l in
    250         let l = generate (LTL.St_from_acc (hdw, l)) in
    251         let l = generate (LTL.St_op2 (op2, I8051.b, l)) in
    252         let l = read srcr1 (fun hdw -> LTL.St_to_acc (hdw, l)) in
    253         let l = generate (LTL.St_from_acc (I8051.b, l)) in
    254         let l = read srcr2 (fun hdw -> LTL.St_to_acc (hdw, l)) in
    255         LTL.St_skip l
     286        move (Color I8051.a) (lookup srcr) l
     287
     288      | ERTL.St_op2 (op, destr, srcr1, RTL.Reg srcr2, l) ->
     289        op2 op (lookup destr) (lookup srcr1) (lookup srcr2) l
     290
     291      | ERTL.St_op2 (op2, destr, srcr1, RTL.Imm k, l) ->
     292        let l = generate (move (lookup destr) (Color I8051.a) l) in
     293        let l = generate (LTL.St_op2 (op2, LTL.Imm k, l)) in
     294        move (Color I8051.a) (lookup srcr1) l
    256295
    257296      | ERTL.St_clear_carry l ->
     
    261300        LTL.St_set_carry l
    262301
     302      (* act differently on hardware registers? if at least one of
     303         the address bytes is hdw use of st0 can be avoided. And in
     304         case of non-hdw, the read could actually target a register
     305         directly *)
    263306      | ERTL.St_load (destr, addr1, addr2, l) ->
    264         let (hdw, l) = write destr l in
    265         let l = generate (LTL.St_from_acc (hdw, l)) in
    266         let l = generate (LTL.St_load l) in
    267         let l = generate (LTL.St_from_acc (I8051.dph, l)) in
    268         let l = generate (LTL.St_to_acc (I8051.st0, l)) in
    269         let l = generate (LTL.St_from_acc (I8051.dpl, l)) in
    270         let l = read addr1 (fun hdw -> LTL.St_to_acc (hdw, l)) in
    271         let l = generate (LTL.St_from_acc (I8051.st0, l)) in
    272         let l = read addr2 (fun hdw -> LTL.St_to_acc (hdw, l)) in
    273         LTL.St_skip l
     307        let l = generate (move (lookup destr) (Color I8051.a) l) in
     308        let l = generate (LTL.St_load l) in
     309        move_to_dptr (lookup addr1) (lookup addr2) l
    274310
    275311      | ERTL.St_store (addr1, addr2, srcr, l) ->
    276         let l = generate (LTL.St_store l) in
    277         let l = generate (LTL.St_to_acc (I8051.st1, l)) in
    278         let l = generate (LTL.St_from_acc (I8051.dph, l)) in
    279         let l = generate (LTL.St_to_acc (I8051.st0, l)) in
    280         let l = generate (LTL.St_from_acc (I8051.dpl, l)) in
    281         let l = read addr1 (fun hdw -> LTL.St_to_acc (hdw, l)) in
    282         let l = generate (LTL.St_from_acc (I8051.st0, l)) in
    283         let l = read addr2 (fun hdw -> LTL.St_to_acc (hdw, l)) in
    284         let l = generate (LTL.St_from_acc (I8051.st1, l)) in
    285         let l = read srcr (fun hdw -> LTL.St_to_acc (hdw, l)) in
    286         LTL.St_skip l
     312        store (lookup addr1) (lookup addr2) (lookup srcr) l
    287313
    288314      | ERTL.St_call_id (f, _, l) ->
     
    291317      | ERTL.St_call_ptr (f1, f2, _, l) ->
    292318        let l = generate (LTL.St_call_ptr l) in
    293         let l = generate (LTL.St_from_acc (I8051.dph, l)) in
    294         let l = generate (LTL.St_to_acc (I8051.st0, l)) in
    295         let l = generate (LTL.St_from_acc (I8051.dpl, l)) in
    296         let l = read f1 (fun hdw -> LTL.St_to_acc (hdw, l)) in
    297         let l = generate (LTL.St_from_acc (I8051.st0, l)) in
    298         let l = read f2 (fun hdw -> LTL.St_to_acc (hdw, l)) in
    299         LTL.St_skip l
     319        move_to_dptr (lookup f1) (lookup f2) l
    300320
    301321      | ERTL.St_cond (srcr, lbl_true, lbl_false) ->
    302322        let l = generate (LTL.St_condacc (lbl_true, lbl_false)) in
    303         let l = read srcr (fun hdw -> LTL.St_to_acc (hdw, l)) in
    304         LTL.St_skip l
     323        move (Color I8051.a) (lookup srcr) l
    305324
    306325      | ERTL.St_return _ ->
  • Deliverables/D2.2/8051/src/ERTL/build.ml

    r486 r1568  
    7070          let exceptions =
    7171            match stmt with
    72             | St_move (_, sourcer, _)
    73             | St_set_hdw (_, sourcer, _) ->
     72            | St_move (_, RTL.Reg sourcer, _)
     73            | St_set_hdw (_, RTL.Reg sourcer, _) ->
    7474                 Liveness.L.psingleton sourcer
    7575            | St_get_hdw (_, sourcehwr, _) ->
     
    103103          let graph =
    104104            match stmt with
    105             | St_move (r1, r2, _) ->
     105            | St_move (r1, RTL.Reg r2, _) ->
    106106                mkppp graph r1 r2
    107107            | St_get_hdw (r, hwr, _)
    108             | St_set_hdw (hwr, r, _) ->
     108            | St_set_hdw (hwr, RTL.Reg r, _) ->
    109109                mkpph graph r hwr
    110110            | _ ->
  • Deliverables/D2.2/8051/src/ERTL/liveness.ml

    r1542 r1568  
    3030  | St_addrH (_, _, l)
    3131  | St_addrL (_, _, l)
    32   | St_int (_, _, l)
     32  (* | St_int (_, _, l) *)
    3333  | St_move (_, _, l)
    3434  | St_opaccsA (_, _, _, _, l)
     
    112112  | St_framesize (r, _)
    113113  | St_pop (r, _)
    114   | St_int (r, _, _)
     114  (* | St_int (r, _, _) *)
    115115  | St_addrH (r, _, _)
    116116  | St_addrL (r, _, _)
     
    154154  | St_addrH _
    155155  | St_addrL _
    156   | St_int _
     156  (* | St_int _ *)
    157157  | St_clear_carry _
    158   | St_set_carry _ ->
     158  | St_set_carry _
     159  | St_set_hdw (_, RTL.Imm _, _)
     160  | St_move (_, RTL.Imm _, _) ->
    159161    L.bottom
    160162  | St_call_id (_, nparams, _) ->
     
    169171  | St_hdw_to_hdw (_, r, _) ->
    170172    L.hsingleton r
    171   | St_set_hdw (_, r, _)
     173  | St_op2 (I8051.Addc, _, r1, RTL.Reg r2, _) ->
     174    L.join (L.join (L.psingleton r1) (L.psingleton r2))
     175      (L.hsingleton I8051.carry)
     176  | St_op2 (I8051.Addc, _, r1, RTL.Imm _, _) ->
     177    L.join (L.psingleton r1) (L.hsingleton I8051.carry)
     178  | St_set_hdw (_, RTL.Reg r, _)
    172179  | St_push (r, _)
    173   | St_move (_, r, _)
     180  | St_move (_, RTL.Reg r, _)
    174181  | St_op1 (_, _, r, _)
     182  | St_op2 (_, _, r, RTL.Imm _, _)
    175183  | St_cond (r, _, _) ->
    176184    L.psingleton r
    177   | St_op2 (I8051.Addc, _, r1, r2, _) ->
    178     L.join (L.join (L.psingleton r1) (L.psingleton r2))
    179       (L.hsingleton I8051.carry)
    180185  | St_opaccsA (_, _, r1, r2, _)
    181186  | St_opaccsB (_, _, r1, r2, _)
    182   | St_op2 (_, _, r1, r2, _)
     187  | St_op2 (_, _, r1, RTL.Reg r2, _)
    183188  | St_load (_, r1, r2, _) ->
    184189    L.join (L.psingleton r1) (L.psingleton r2)
     
    187192  | St_newframe _
    188193  | St_delframe _ ->
    189     L.join (L.hsingleton I8051.spl) (L.hsingleton I8051.sph)   
     194    L.join (L.hsingleton I8051.spl) (L.hsingleton I8051.sph)
    190195  | St_return _ ->
    191196    Register.Set.empty, I8051.RegisterSet.union I8051.callee_saved ret_regs
     
    224229  | St_get_hdw (r, _, l)
    225230  | St_framesize (r, l)
    226   | St_int (r, _, l)
     231  (* | St_int (r, _, l) *)
    227232  | St_addrH (r, _, l)
    228233  | St_addrL (r, _, l)
  • Deliverables/D2.2/8051/src/ERTL/uses.ml

    r1542 r1568  
    2323  | St_ind_inc _
    2424  | St_hdw_to_hdw _
     25  | St_set_hdw (_, RTL.Imm _, _)
    2526  | St_newframe _
    2627  | St_delframe _
     
    3132    uses
    3233  | St_get_hdw (r, _, _)
    33   | St_set_hdw (_, r, _)
     34  | St_set_hdw (_, RTL.Reg r, _)
    3435  | St_framesize (r, _)
    3536  | St_pop (r, _)
    3637  | St_push (r, _)
    37   | St_int (r, _, _)
     38  | St_move (r, RTL.Imm _, _)
    3839  | St_addrH (r, _, _)
    3940  | St_addrL (r, _, _)
    4041  | St_cond (r, _, _) ->
    4142    count r uses
    42   | St_move (r1, r2, _)
     43  | St_move (r1, RTL.Reg r2, _)
    4344  | St_op1 (_, r1, r2, _)
     45  | St_op2 (_, r1, r2, RTL.Imm _, _)
    4446  | St_call_ptr (r1, r2, _, _) ->
    4547    count r1 (count r2 uses)
    4648  | St_opaccsA (_, r1, r2, r3, _)
    4749  | St_opaccsB (_, r1, r2, r3, _)
    48   | St_op2 (_, r1, r2, r3, _)
     50  | St_op2 (_, r1, r2, RTL.Reg r3, _)
    4951  | St_load (r1, r2, r3, _)
    5052  | St_store (r1, r2, r3, _) ->
Note: See TracChangeset for help on using the changeset viewer.