Home My Page Projects Code Snippets Project Openings SML/NJ
Summary Activity Forums Tracker Lists Tasks Docs Surveys News SCM Files

SCM Repository

[smlnj] Diff of /MLRISC/trunk/amd64/mltree/amd64-gen.sml
ViewVC logotype

Diff of /MLRISC/trunk/amd64/mltree/amd64-gen.sml

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 2788, Sat Sep 29 05:49:51 2007 UTC revision 2789, Tue Oct 2 23:26:36 2007 UTC
# Line 77  Line 77 
77      (* One day, this is going to bite us when precision(LargeInt)>32 *)      (* One day, this is going to bite us when precision(LargeInt)>32 *)
78      fun wToInt32 w = Int32.fromLarge(Word32.toLargeIntX w)      fun wToInt32 w = Int32.fromLarge(Word32.toLargeIntX w)
79    
80        fun move64 (src, dst) = I.move {mvOp=I.MOVABSQ, src=src, dst=dst}
81    
82      (* analyze for power-of-two-ness *)      (* analyze for power-of-two-ness *)
83     fun analyze i' = let     fun analyze i' = let
84         val i = toInt32 i'         val i = toInt32 i'
# Line 165  Line 167 
167              val tmp = newReg ()              val tmp = newReg ()
168              val tmpR = I.Direct (64, tmp)              val tmpR = I.Direct (64, tmp)
169              in              in
170                  emitInstr (I.move {mvOp=I.MOVABSQ, src=src, dst=tmpR});                  emitInstr (move64 (src, tmpR));
171                  mark' (I.move {mvOp=I.MOVQ, src=tmpR, dst=dst}, an)                  mark' (I.move {mvOp=I.MOVQ, src=tmpR, dst=dst}, an)
172              end              end
173            | move' (ty, src, dst, an) =            | move' (ty, src, dst, an) =
# Line 252  Line 254 
254                | doEAImmed(trees, n, b, i, s, I.Immed m) =                | doEAImmed(trees, n, b, i, s, I.Immed m) =
255                  doEA(trees, b, i, s, I.Immed(n+m))                  doEA(trees, b, i, s, I.Immed(n+m))
256                | doEAImmed(trees, n, b, i, s, I.ImmedLabel le) =                | doEAImmed(trees, n, b, i, s, I.ImmedLabel le) =
257                  doEA(trees, b, i, s,                  doEA(trees, b, i, s, I.ImmedLabel (T.ADD(ty,le,T.LI(T.I.fromInt32(ty, n)))))
                      I.ImmedLabel(T.ADD(ty,le,T.LI(T.I.fromInt32(ty, n)))))  
258                | doEAImmed(trees, n, b, i, s, _) = error "doEAImmed"                | doEAImmed(trees, n, b, i, s, _) = error "doEAImmed"
259    
260              (* Add a label expression *)              (* Add a label expression.
261              and doEALabel(trees, le, b, i, s, I.Immed 0) =               * NOTE: Labels in the AMD64 can be 64 bits, but operands can only handle 32 constants.
262                  doEA(trees, b, i, s, I.ImmedLabel le)               * We have to spill label expressions to temporaries to be correct.
263                | doEALabel(trees, le, b, i, s, I.Immed m) =               * TODO: eliminate the extra register-register move from genExpr
264                  doEA(trees, b, i, s,               *)
265                       I.ImmedLabel(T.ADD(ty,le,T.LI(T.I.fromInt32(ty, m))))              and doEALabel (trees, le, b, i, s, d) = let
266                    val le = (case b
267                                of NONE => le
268                                 | SOME base => T.ADD (ty, le, T.REG (ty, base))
269                              (* end case *))
270                    val b' = genExpr le
271                    in
272                      (case d
273                        of I.Immed 0 => doEA(trees, SOME b', i, s, I.Immed 0)
274                         | I.Immed m => (doEA (trees,
275                                  SOME (genExpr (T.ADD (ty, T.REG(ty, b'), T.LI(T.I.fromInt32(ty, m))))),
276                             i, s, I.Immed 0)
277                       handle Overflow => error "doEALabel: constant too large")                       handle Overflow => error "doEALabel: constant too large")
278                | doEALabel(trees, le, b, i, s, I.ImmedLabel le') =                       | I.ImmedLabel le' => doEA (trees,
279                  doEA(trees, b, i, s, I.ImmedLabel(T.ADD(ty,le,le')))                                SOME (genExpr (T.ADD (ty, T.REG(ty, b'), le'))),
280                | doEALabel(trees, le, b, i, s, _) = error "doEALabel"                           i, s, I.Immed 0)
281                         | _ => error "doEALabel"
282                      (* end case *))
283                    end
284    
285              (* generate code for tree and ensure that it is not in %rsp *)              (* generate code for tree and ensure that it is not in %rsp *)
286              and exprNotRsp tree = let              and exprNotRsp tree = let
# Line 317  Line 332 
332            in            in
333              case doEA ([ea], NONE, NONE, 0, I.Immed 0)              case doEA ([ea], NONE, NONE, 0, I.Immed 0)
334               of I.Immed _ => raise EA               of I.Immed _ => raise EA
335                | I.ImmedLabel le => I.LabelEA le                | I.ImmedLabel le => I.Displace {base=genExpr le, disp=I.Immed 0, mem=mem}
336                | ea => ea                | ea => ea
337            end (* address' *)            end (* address' *)
338    

Legend:
Removed from v.2788  
changed lines
  Added in v.2789

root@smlnj-gforge.cs.uchicago.edu
ViewVC Help
Powered by ViewVC 1.0.0