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 167 - (view) (download)

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

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