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

SCM Repository

[smlnj] Annotation of /sml/branches/SMLNJ/src/MLRISC/sparc/sparcDelaySlotProps.sml
ViewVC logotype

Annotation of /sml/branches/SMLNJ/src/MLRISC/sparc/sparcDelaySlotProps.sml

Parent Directory Parent Directory | Revision Log Revision Log


Revision 130 - (view) (download)

1 : monnier 129 functor SparcDelaySlotProps
2 :     (structure I : SPARCINSTR
3 :     structure P : INSN_PROPERTIES
4 :     sharing P.I = I) : DELAY_SLOT_PROPERTIES =
5 :     struct
6 :     structure I = I
7 :     structure SL = SortedList
8 :    
9 :     fun error msg = MLRiscErrorMsg.impossible("SparcDelaySlotProps."^msg)
10 :    
11 :     datatype delay_slot = D_NONE | D_ERROR | D_ALWAYS | D_TAKEN | D_FALLTHRU
12 :    
13 :     val delaySlotSize = 4
14 :    
15 :     fun delaySlot{instr, backward} =
16 :     case instr of
17 :     I.CALL{nop,...} => {n=false,nOn=D_ERROR,nOff=D_ALWAYS,nop=nop}
18 :     | I.JMP{nop,...} => {n=false,nOn=D_ERROR,nOff=D_ALWAYS,nop=nop}
19 :     | I.JMPL{nop,...} => {n=false,nOn=D_ERROR,nOff=D_ALWAYS,nop=nop}
20 :     | I.RET{nop,...} => {n=false,nOn=D_ERROR,nOff=D_ALWAYS,nop=nop}
21 :     | I.Bicc{b=I.BA,a,nop,...} => {n=false,nOn=D_NONE,nOff=D_ALWAYS,nop=nop}
22 :     | I.Bicc{a,nop,...} => {n=a,nOn=D_TAKEN,nOff=D_ALWAYS,nop=nop}
23 :     | I.FBfcc{a,nop,...} => {n=a,nOn=D_TAKEN,nOff=D_ALWAYS,nop=nop}
24 :     | _ => {n=false,nOn=D_ERROR,nOff=D_NONE,nop=false}
25 :    
26 :     fun enableDelaySlot{instr, n, nop} =
27 :     case (instr,n) of
28 :     (I.CALL{defs,uses,label,...},false) =>
29 :     I.CALL{defs=defs,uses=uses,label=label,nop=nop}
30 :     | (I.JMPL{r,i,d,defs,uses,...},false) =>
31 :     I.JMPL{r=r,i=i,d=d,defs=defs,uses=uses,nop=nop}
32 :     | (I.JMP{r,i,labs,...},false) =>
33 :     I.JMP{r=r,i=i,labs=labs,nop=nop}
34 :     | (I.RET{leaf,...},false) => I.RET{leaf=leaf,nop=nop}
35 :     | (I.Bicc{b,a,label,...},_) => I.Bicc{b=b,a=n,nop=nop,label=label}
36 :     | (I.FBfcc{b,a,label,...},_) => I.FBfcc{b=b,a=n,nop=nop,label=label}
37 :     | _ => error "enableDelaySlot"
38 :    
39 :     (* %y = 64
40 :     * %psr = 65
41 :     * %fsr = 66
42 :     *)
43 :     fun conflict{regmap,src=i,dst=j} =
44 :     let fun defUseOther(I.Ticc _) = ([],[65])
45 :     | defUseOther(I.ARITH{cc=true,...}) = ([65],[])
46 :     | defUseOther(I.WRY _) = ([64],[])
47 :     | defUseOther(I.RDY _) = ([],[64])
48 :     | defUseOther(I.FCMP _) = ([66],[])
49 :     | defUseOther(I.Bicc{b=I.BA,...}) = ([],[])
50 :     | defUseOther(I.Bicc _) = ([],[65])
51 :     | defUseOther(I.FBfcc _) = ([],[66])
52 :     | defUseOther _ = ([],[])
53 :     fun clash(defUse) =
54 :     let val (di,ui) = defUse i
55 :     val (dj,uj) = defUse j
56 :     val di = map regmap di
57 :     val ui = map regmap ui
58 :     val dj = map regmap dj
59 :     val uj = map regmap uj
60 :     in case SL.intersect(di,uj) of
61 :     [] => (case SL.intersect(di,dj) of
62 :     [] => (case SL.intersect(ui,dj) of
63 :     [] => false
64 :     | _ => true)
65 :     | _ => true)
66 :     | _ => true
67 :     end
68 :     in clash(P.defUse I.C.GP) orelse
69 :     clash(P.defUse I.C.FP) orelse
70 :     clash(defUseOther)
71 :     end
72 :    
73 :     fun delaySlotCandidate(I.CALL _ | I.Bicc _ | I.FBfcc _ | I.Ticc _
74 :     | I.JMP _ | I.JMPL _ | I.RET _) = false
75 :     | delaySlotCandidate _ = true
76 :    
77 :     fun setTarget(I.Bicc{b,a,nop,...},lab) = I.Bicc{b=b,a=a,nop=nop,label=lab}
78 :     | setTarget(I.FBfcc{b,a,nop,...},lab) = I.FBfcc{b=b,a=a,nop=nop,label=lab}
79 :     | setTarget _ = error "setTarget"
80 :    
81 :     end
82 :    
83 :     (*
84 :     * $Log$
85 :     *)

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