Ignore:
Timestamp:
Dec 6, 2011, 5:04:13 PM (9 years ago)
Author:
tranquil
Message:
  • turned to argument-less return statements for RTLabs and RTL (there was a hidden invariant, for which the arguments of return statements where equal to the f_result field of the function definition: they were useless and an optimization was breaking the compilation)
  • corrected a bug in liveness analysis I had introduced
File:
1 edited

Legend:

Unmodified
Added
Removed
  • Deliverables/D2.2/8051/src/RTLabs/RTLabsToRTL.ml

    r1585 r1589  
    1111let error_shift () = error "Shift operations not supported."
    1212
     13let dummy = Label.dummy
    1314
    1415let add_graph lbl stmt def =
     
    174175  translate_cst (AST.Cst_int 0) destrs start_lbl dest_lbl def
    175176
    176 let translate_cast_signed destrs srcr start_lbl dest_lbl def =
    177   let (def, tmpr) = fresh_reg def in
    178   let insts =
     177let sign_mask destr srcr =
    179178    (* this sets tmpr to 0xFF if s is neg, 0x00 o.w. Done like that:
    180179       byte in tmpr if srcr is: neg   |  pos
     
    185184
    186185     *)
    187     [RTL.St_op2 (I8051.Or, tmpr, srcr, RTL.Imm 127, start_lbl) ;
    188      RTL.St_op1 (I8051.Rl, tmpr, tmpr, start_lbl) ;
    189      RTL.St_op1 (I8051.Inc, tmpr, tmpr, start_lbl) ;
    190      RTL.St_op1 (I8051.Cmpl, tmpr, tmpr, start_lbl) ] in
     186  [RTL.St_op2 (I8051.Or, destr, srcr, RTL.Imm 127, dummy) ;
     187   RTL.St_op1 (I8051.Rl, destr, destr, dummy) ;
     188   RTL.St_op1 (I8051.Inc, destr, destr, dummy) ;
     189   RTL.St_op1 (I8051.Cmpl, destr, destr, dummy) ]
     190
     191
     192let translate_cast_signed destrs srcr start_lbl dest_lbl def =
     193  let (def, tmpr) = fresh_reg def in
    191194  let srcrs = MiscPottier.make (RTL.Reg tmpr) (List.length destrs) in
    192   add_translates [adds_graph insts ; translate_move destrs srcrs]
     195  add_translates [adds_graph (sign_mask tmpr srcr); translate_move destrs srcrs]
    193196    start_lbl dest_lbl def
    194197
     
    477480
    478481    | AST.Op_add | AST.Op_addp ->
    479       translate_op I8051.Addc destrs srcrs1 srcrs2 start_lbl dest_lbl def
     482      translate_op I8051.Add destrs srcrs1 srcrs2 start_lbl dest_lbl def
    480483
    481484    | AST.Op_sub | AST.Op_subp | AST.Op_subpp ->
     
    666669    error "Jump tables not supported yet."
    667670
    668   | RTLabs.St_return None ->
    669     add_graph lbl (RTL.St_return []) def
    670 
    671   | RTLabs.St_return (Some r) ->
    672     add_graph lbl (RTL.St_return (find_local_env r lenv)) def
     671  | RTLabs.St_return ->
     672    add_graph lbl RTL.St_return def
     673
     674open BList.Notation
    673675
    674676open BList.Notation
     
    708710      load_args args (fun args ->
    709711        RTLabs.St_tailcall_ptr (f, args, s) ^:: bnil)
    710     | RTLabs.St_return (Some a) ->
    711       load_arg a (fun a ->
    712         RTLabs.St_return (Some a) ^:: bnil)
    713712    | stmt -> stmt ^:: bnil in
    714713  let module T = GraphUtilities.Trans(RTLabsGraph)(RTLabsGraph) in
Note: See TracChangeset for help on using the changeset viewer.