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 /sml/trunk/src/MLRISC/x86/omit-frameptr/x86omit-frameptr.sml
ViewVC logotype

Diff of /sml/trunk/src/MLRISC/x86/omit-frameptr/x86omit-frameptr.sml

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

revision 888, Thu Jul 19 20:24:21 2001 UTC revision 889, Thu Jul 19 20:35:20 2001 UTC
# Line 13  Line 13 
13      structure F : FLOWGRAPH where I = I      structure F : FLOWGRAPH where I = I
14      structure PC : PRINT_CLUSTER where F=F      structure PC : PRINT_CLUSTER where F=F
15      structure MemRegs : MEMORY_REGISTERS where I=I      structure MemRegs : MEMORY_REGISTERS where I=I
16      val memRegBase : I.C.cell option): OMIT_FRAME_POINTER =      val memRegBase : CellsBasis.cell option): OMIT_FRAME_POINTER =
17  struct  struct
18    structure F = F    structure F = F
19    structure I = I    structure I = I
20    structure C = I.C    structure C = I.C
21      structure CB = CellsBasis
22    val sp = C.esp    val sp = C.esp
23    
24    val dumpCfg = MLRiscControl.getFlag "dump-cfg-after-omit-frame-pointer"    val dumpCfg = MLRiscControl.getFlag "dump-cfg-after-omit-frame-pointer"
25    
26    fun error msg = MLRiscErrorMsg.error("X86OmitFramePointer", msg)    fun error msg = MLRiscErrorMsg.error("X86OmitFramePointer", msg)
27    
28    fun omitframeptr{vfp:I.C.cell, idelta:Int32.int option, cl as F.CLUSTER{entry, blkCounter, ...}} = let    fun omitframeptr{vfp:CB.cell, idelta:Int32.int option, cl as F.CLUSTER{entry, blkCounter, ...}} = let
29    
30      (* rewrite a list of instructions where the gap between fp and sp is delta *)      (* rewrite a list of instructions where the gap between fp and sp is delta *)
31      fun rewrite(instrs, idelta) = let      fun rewrite(instrs, idelta) = let
32    
33        (* What kind of register? *)        (* What kind of register? *)
34        datatype which = SP | FP | OTHER        datatype which = SP | FP | OTHER
35        fun isSp cell = C.sameColor(cell, sp)        fun isSp cell = CB.sameColor(cell, sp)
36        fun isVfp cell = C.sameColor(cell, vfp)        fun isVfp cell = CB.sameColor(cell, vfp)
37        fun which(cell) = if isSp(cell) then SP else if isVfp(cell) then FP else OTHER        fun which(cell) = if isSp(cell) then SP else if isVfp(cell) then FP else OTHER
38        fun either(cell) = isSp(cell) orelse isVfp(cell)        fun either(cell) = isSp(cell) orelse isVfp(cell)
39    
# Line 156  Line 157 
157               else unchanged(I.MOVE{mvOp=mvOp, src=operand(src), dst=dst})               else unchanged(I.MOVE{mvOp=mvOp, src=operand(src), dst=dst})
158           | I.MOVE{mvOp, src, dst} =>           | I.MOVE{mvOp, src, dst} =>
159               unchanged(I.MOVE{mvOp=mvOp, src=operand(src), dst=operand(dst)})               unchanged(I.MOVE{mvOp=mvOp, src=operand(src), dst=operand(dst)})
160           | I.LEA{r32:C.cell, addr as I.Displace{base, disp=I.Immed d, mem}} =>           | I.LEA{r32:CB.cell, addr as I.Displace{base, disp=I.Immed d, mem}} =>
161             (case (which r32, which base)             (case (which r32, which base)
162              of (SP, SP) =>              of (SP, SP) =>
163                   (* assumes stack grows from high to low.                   (* assumes stack grows from high to low.
# Line 213  Line 214 
214              unchanged(I.CMPXCHG{lock=lock, sz=sz, src=operand(src), dst=operand(dst)})              unchanged(I.CMPXCHG{lock=lock, sz=sz, src=operand(src), dst=operand(dst)})
215           | I.MULTDIV{multDivOp:I.multDivOp, src:I.operand} =>           | I.MULTDIV{multDivOp:I.multDivOp, src:I.operand} =>
216              unchanged(I.MULTDIV{multDivOp=multDivOp, src=operand(src)})              unchanged(I.MULTDIV{multDivOp=multDivOp, src=operand(src)})
217           | I.MUL3{dst:C.cell, src2:Int32.int, src1:I.operand} =>           | I.MUL3{dst:CB.cell, src2:Int32.int, src1:I.operand} =>
218             if either(dst) then error "MUL3: assignment to FP/SP"             if either(dst) then error "MUL3: assignment to FP/SP"
219             else unchanged(I.MUL3{dst=dst, src2=src2, src1=operand(src1)})             else unchanged(I.MUL3{dst=dst, src2=src2, src1=operand(src1)})
220           | I.UNARY{unOp=I.INCL, opnd as I.Direct(r)} =>           | I.UNARY{unOp=I.INCL, opnd as I.Direct(r)} =>
# Line 231  Line 232 
232           | I.UNARY{unOp, opnd} => unchanged(I.UNARY{unOp=unOp, opnd=operand(opnd)})           | I.UNARY{unOp, opnd} => unchanged(I.UNARY{unOp=unOp, opnd=operand(opnd)})
233           | I.SET{cond:I.cond, opnd:I.operand} =>           | I.SET{cond:I.cond, opnd:I.operand} =>
234               unchanged(I.SET{cond=cond, opnd=operand(opnd)})               unchanged(I.SET{cond=cond, opnd=operand(opnd)})
235           | I.CMOV{cond:I.cond, src as I.Direct(s), dst:C.cell} =>           | I.CMOV{cond:I.cond, src as I.Direct(s), dst:CB.cell} =>
236               if either(s) orelse either(dst) then               if either(s) orelse either(dst) then
237                 error "CMOV: FP/SP in conditional move"                 error "CMOV: FP/SP in conditional move"
238               else unchanged(I.CMOV{cond=cond, src=operand(src), dst=dst})               else unchanged(I.CMOV{cond=cond, src=operand(src), dst=dst})
# Line 239  Line 240 
240           | I.PUSHW opnd => changedto(I.PUSHW(operand(opnd)), addToDelta(2))           | I.PUSHW opnd => changedto(I.PUSHW(operand(opnd)), addToDelta(2))
241           | I.PUSHB opnd => changedto(I.PUSHB(operand(opnd)), addToDelta(1))           | I.PUSHB opnd => changedto(I.PUSHB(operand(opnd)), addToDelta(1))
242           | I.POP opnd => changedto(I.POP(operand(opnd)), addToDelta(~4))           | I.POP opnd => changedto(I.POP(operand(opnd)), addToDelta(~4))
243           | I.COPY{dst:C.cell list, src:C.cell list, tmp:I.operand option} => let           | I.COPY{dst:CB.cell list, src:CB.cell list, tmp:I.operand option} => let
244              (* the situation where SP <- FP is somewhat complicated.              (* the situation where SP <- FP is somewhat complicated.
245               * The copy must be extracted, and a lea generated.               * The copy must be extracted, and a lea generated.
246               * Should it be before or after the parallel copy? Depends on if SP is used.               * Should it be before or after the parallel copy? Depends on if SP is used.
# Line 342  Line 343 
343    
344    
345    
346      val C.CELL{col, ...} = vfp      val CB.CELL{col, ...} = vfp
347    in    in
348      (*      (*
349       * check that virtual frame pointer is a pseudo register or       * check that virtual frame pointer is a pseudo register or
350       * aliased to the stack pointer.       * aliased to the stack pointer.
351       *)       *)
352      case !col      case !col
353       of C.PSEUDO => dfs(entry, idelta)       of CB.PSEUDO => dfs(entry, idelta)
354        | _ => error "virtual frame pointer not a pseudo register"        | _ => error "virtual frame pointer not a pseudo register"
355      (*esac*);      (*esac*);
356    

Legend:
Removed from v.888  
changed lines
  Added in v.889

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