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/hppa/backpatch/hppaJumps.sml
ViewVC logotype

Diff of /sml/trunk/src/MLRISC/hppa/backpatch/hppaJumps.sml

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

revision 1002, Fri Nov 30 17:11:33 2001 UTC revision 1003, Fri Dec 7 02:45:32 2001 UTC
# Line 19  Line 19 
19    
20    val branchDelayedArch = false    val branchDelayedArch = false
21    
22    fun minSize(I.COPY _)    = 0    fun minSize(I.INSTR(I.COPY _))    = 0
23      | minSize(I.FCOPY _)   = 0      | minSize(I.INSTR(I.FCOPY _))   = 0
24      | minSize(I.FBRANCH _) = 12 (* FCMP/FTEST/B *)      | minSize(I.INSTR(I.FBRANCH _)) = 12 (* FCMP/FTEST/B *)
25      | minSize(I.BLR{labs,...}) = 8 + 8 * length labs (* FCMP/FTEST/B *)      | minSize(I.INSTR(I.BLR{labs,...})) = 8 + 8 * length labs (* FCMP/FTEST/B *)
26      | minSize(I.ANNOTATION{i,...}) = minSize i      | minSize(I.ANNOTATION{i,...}) = minSize i
27      | minSize(I.COMCLR_LDO _) = 8      | minSize(I.LIVE _)  = 0
28      | minSize(I.COMICLR_LDO _) = 8      | minSize(I.KILL _)  = 0
29        | minSize(I.INSTR(I.COMCLR_LDO _)) = 8
30        | minSize(I.INSTR(I.COMICLR_LDO _)) = 8
31      | minSize _            = 4      | minSize _            = 4
32    
33    fun maxSize (I.BCOND _)  = 16  (* BCOND+LONGJUMP *)    fun maxSize (I.INSTR(I.BCOND _))  = 16  (* BCOND+LONGJUMP *)
34      | maxSize (I.BCONDI _) = 16  (* BCONDI+LONGJUMP *)      | maxSize (I.INSTR(I.BCONDI _)) = 16  (* BCONDI+LONGJUMP *)
35      | maxSize (I.BB _)     = 16  (* BB+LONGJUMP *)      | maxSize (I.INSTR(I.BB _))     = 16  (* BB+LONGJUMP *)
36      | maxSize (I.B _)      = 12  (* LONGJUMP *)      | maxSize (I.INSTR(I.B _))     = 12  (* LONGJUMP *)
37      | maxSize (I.FBRANCH _)= 20      | maxSize (I.INSTR(I.FBRANCH _))= 20
38      | maxSize (I.COPY _)   = error "maxSize:COPY"      | maxSize (I.INSTR(I.COPY _))   = error "maxSize:COPY"
39      | maxSize (I.FCOPY _)  = error "maxSize:FCOPY"      | maxSize (I.INSTR(I.FCOPY _))  = error "maxSize:FCOPY"
40      | maxSize (I.ANNOTATION{i,...}) = maxSize i      | maxSize (I.ANNOTATION{i,...}) = maxSize i
41      | maxSize _            = 4      | maxSize _            = 4
42    
43    fun isSdi instr = let    fun isSdi(I.ANNOTATION{i,...}) =isSdi i
44        | isSdi(I.LIVE _)             = true
45        | isSdi(I.KILL _)             = true
46        | isSdi(I.INSTR instr) = let
47    
48      fun opnd (I.LabExp _) = true      fun opnd (I.LabExp _) = true
49        | opnd _ = false        | opnd _ = false
50    in    in
# Line 56  Line 62 
62       | I.COMICLR_LDO{i1, ...}   => opnd i1       | I.COMICLR_LDO{i1, ...}   => opnd i1
63       | I.FCOPY _                => true       | I.FCOPY _                => true
64       | I.COPY _                 => true       | I.COPY _                 => true
      | I.ANNOTATION{i,...}      => isSdi i  
65       | _                        => false       | _                        => false
66    end    end
67        | isSdi _ = error "isSdi"
68    
69    fun im11 n = ~1024 <= n andalso n < 1024    fun im11 n = ~1024 <= n andalso n < 1024
70    fun im12 n = ~2048 <= n andalso n < 2048    fun im12 n = ~2048 <= n andalso n < 2048
71    fun im14 n = ~8192 <= n andalso n < 8192    fun im14 n = ~8192 <= n andalso n < 8192
72    fun im17 n = ~65536 <= n andalso n < 65536    fun im17 n = ~65536 <= n andalso n < 65536
73    
74    fun sdiSize(instr, labMap, loc) = let    fun sdiSize(I.ANNOTATION{i, ...}, labMap, loc) = sdiSize(i, labMap, loc)
75        | sdiSize(I.LIVE _, _, _) = 0
76        | sdiSize(I.KILL _, _, _) = 0
77        | sdiSize(I.INSTR(instr), labMap, loc) = let
78      fun branchOffset lab = ((labMap lab) - loc - 8) div 4      fun branchOffset lab = ((labMap lab) - loc - 8) div 4
79      fun branch(lab,nop) = let      fun branch(lab,nop) = let
80        val offset = branchOffset lab        val offset = branchOffset lab
# Line 115  Line 124 
124            val instrs = Shuffle.shufflefp {tmp=tmp, dst=dst, src=src}            val instrs = Shuffle.shufflefp {tmp=tmp, dst=dst, src=src}
125          in impl := SOME instrs;  4 * length instrs          in impl := SOME instrs;  4 * length instrs
126          end          end
       | I.ANNOTATION{i,...} => sdiSize(i,labMap,loc)  
127        | _  => error "sdiSize"        | _  => error "sdiSize"
128    end    end
129        | sdiSize _ = error "SdiSize"
130    
131     (* Note: A better sequence would be to use ADDIL, however     (* Note: A better sequence would be to use ADDIL, however
132      * the expansion is done after register allocation and      * the expansion is done after register allocation and
# Line 139  Line 148 
148    
149    fun longJump{lab, n} =    fun longJump{lab, n} =
150      (print "longJump used\n";      (print "longJump used\n";
151       [I.LONGJUMP{lab=lab, tmpLab=Label.anon(), n=n, tmp=C.asmTmpR}]       [I.longjump{lab=lab, tmpLab=Label.anon(), n=n, tmp=C.asmTmpR}]
152      )      )
153    
154    fun split11 n = let    fun split11 n = let
# Line 160  Line 169 
169      | loadIndexed I.LDH = I.LDHX      | loadIndexed I.LDH = I.LDHX
170      | loadIndexed I.LDB = I.LDBX      | loadIndexed I.LDB = I.LDBX
171    
172    fun expand(instr as I.LDO{i=I.LabExp lexp, t, b}, size, _) =    fun expand(I.ANNOTATION{i,...},size,pos) = expand(i,size,pos)
173        | expand(I.LIVE _, _, _) = []
174        | expand(I.KILL _, _, _) = []
175        | expand(instr as I.INSTR(i), size, pos) =
176          (case i
177            of I.LDO{i=I.LabExp lexp, t, b} =>
178        (case size        (case size
179          of 4 => [instr]          of 4 => [instr]
180           | 12 => [I.LDIL{i=I.HILabExp lexp, t=C.asmTmpR},               | 12 => [I.ldil{i=I.HILabExp lexp, t=C.asmTmpR},
181                    I.LDO{i=I.LOLabExp lexp, b=C.asmTmpR, t=C.asmTmpR},                        I.ldo{i=I.LOLabExp lexp, b=C.asmTmpR, t=C.asmTmpR},
182                    I.ARITH{a=I.ADD, r1=C.asmTmpR, r2=b, t=t}]                        I.arith{a=I.ADD, r1=C.asmTmpR, r2=b, t=t}]
183        (*esac*))        (*esac*))
184      | expand(instr as I.COMICLR_LDO{cc, i1=I.LabExp lexp, r2, t1, b, i2, t2},           | I.COMICLR_LDO{cc, i1=I.LabExp lexp, r2, t1, b, i2, t2} =>
              size, _) =  
185         (case size         (case size
186          of 8 => [instr]          of 8 => [instr]
187           | 16 =>           | 16 =>
188              [I.LDIL{i=I.HILabExp lexp, t=C.asmTmpR},                  [I.ldil{i=I.HILabExp lexp, t=C.asmTmpR},
189               I.LDO{i=I.LOLabExp lexp, b=C.asmTmpR, t=C.asmTmpR},                   I.ldo{i=I.LOLabExp lexp, b=C.asmTmpR, t=C.asmTmpR},
190               I.COMCLR_LDO{cc=cc, r1=C.asmTmpR, r2=r2, t1=t1,                   I.comclr_ldo{cc=cc, r1=C.asmTmpR, r2=r2, t1=t1,
191                            b=b, i=i2, t2=t2}                            b=b, i=i2, t2=t2}
192              ]              ]
193        (*esac*))        (*esac*))
194      | expand(instr as I.STORE{st, d as I.LabExp lexp, b, r, mem}, size, _) =           | I.STORE{st, d as I.LabExp lexp, b, r, mem} =>
195        (case size        (case size
196         of 4 => [instr]         of 4 => [instr]
197          | 12 =>          | 12 =>
198              [I.LDIL{i=I.HILabExp lexp, t=C.asmTmpR},                  [I.ldil{i=I.HILabExp lexp, t=C.asmTmpR},
199               I.ARITH{a=I.ADD, r1=C.asmTmpR, r2=b, t=C.asmTmpR},                   I.arith{a=I.ADD, r1=C.asmTmpR, r2=b, t=C.asmTmpR},
200               I.STORE{st=st, b=C.asmTmpR, d=I.LOLabExp lexp, r=r, mem=mem}]                   I.store{st=st, b=C.asmTmpR, d=I.LOLabExp lexp, r=r, mem=mem}]
201        (*esac*))        (*esac*))
202      | expand(I.STORE _, _, _) = error "expand:STORE"           | I.STORE _ => error "expand:STORE"
203      | expand(instr as I.ARITHI{ai, r, i=I.LabExp lexp, t}, size, _) =           | I.ARITHI{ai, r, i=I.LabExp lexp, t} =>
204        (case size        (case size
205         of 4 => [instr]         of 4 => [instr]
206          | 12 =>          | 12 =>
# Line 195  Line 208 
208            * the expansion is done after register allocation and            * the expansion is done after register allocation and
209            * ADDIL defines %r1.            * ADDIL defines %r1.
210            *)            *)
211              [I.LDIL{i=I.HILabExp lexp, t=C.asmTmpR},                   [I.ldil{i=I.HILabExp lexp, t=C.asmTmpR},
212               I.LDO{i=I.LOLabExp lexp, b=C.asmTmpR, t=C.asmTmpR},                    I.ldo{i=I.LOLabExp lexp, b=C.asmTmpR, t=C.asmTmpR},
213               I.ARITH{                    I.arith{
214                  a = case ai of I.ADDI => I.ADD | I.ADDIO => I.ADDO                  a = case ai of I.ADDI => I.ADD | I.ADDIO => I.ADDO
215                               | I.SUBI => I.SUB | I.SUBIO => I.SUBO                               | I.SUBI => I.SUB | I.SUBIO => I.SUBO
216                               | _ => error "expand: I.ARITHI LabExp",                               | _ => error "expand: I.ARITHI LabExp",
# Line 205  Line 218 
218                  r1=C.asmTmpR,                  r1=C.asmTmpR,
219                  r2=r}]                  r2=r}]
220        (*esac*))        (*esac*))
221      | expand(instr as I.LOADI{li, r, i=I.LabExp lexp, t, mem} , size, _) =           | I.LOADI{li, r, i=I.LabExp lexp, t, mem} =>
222        (case size        (case size
223         of 4  => [instr]         of 4  => [instr]
224          | 12 => [I.LDIL{i=I.HILabExp lexp, t=C.asmTmpR},               | 12 => [I.ldil{i=I.HILabExp lexp, t=C.asmTmpR},
225                   I.ARITH{a=I.ADD, r1=C.asmTmpR, r2=r, t=C.asmTmpR},                        I.arith{a=I.ADD, r1=C.asmTmpR, r2=r, t=C.asmTmpR},
226                   I.LOADI{li=li, r=C.asmTmpR, i=I.LOLabExp lexp, t=t, mem=mem}]                        I.loadi{li=li, r=C.asmTmpR, i=I.LOLabExp lexp, t=t, mem=mem}]
227        (*esac*))        (*esac*))
228      | expand(instr as I.BCOND{cmp,bc, t, f, r1, r2, n, nop}, size, _) = let           | I.BCOND{cmp,bc, t, f, r1, r2, n, nop} => let
229          fun rev I.COMBT=I.BCOND{cmp=I.COMBF,bc=bc,t=f,f=f,r1=r1,r2=r2,n=true,nop=false}               fun rev I.COMBT=I.bcond{cmp=I.COMBF,bc=bc,t=f,f=f,r1=r1,r2=r2,n=true,nop=false}
230            | rev I.COMBF=I.BCOND{cmp=I.COMBT,bc=bc,t=f,f=f,r1=r1,r2=r2,n=true,nop=false}                 | rev I.COMBF=I.bcond{cmp=I.COMBT,bc=bc,t=f,f=f,r1=r1,r2=r2,n=true,nop=false}
231        in        in
232          case (size,nop)          case (size,nop)
233          of (4,false) => [instr]          of (4,false) => [instr]
234           | (8,true)  => [instr]           | (8,true)  => [instr]
235           | (8,_)     => [rev cmp, I.B{lab=t, n=n}]                | (8,_)     => [rev cmp, I.b{lab=t, n=n}]
236           | (16,_)    => rev cmp :: longJump{lab=t, n=n}           | (16,_)    => rev cmp :: longJump{lab=t, n=n}
237          (*esac*)          (*esac*)
238        end        end
239      | expand(instr as I.BCONDI{cmpi, bc, t, f, i, r2, n, nop}, size, _) = let           | I.BCONDI{cmpi, bc, t, f, i, r2, n, nop} => let
240          fun rev I.COMIBT=I.BCONDI{cmpi=I.COMIBF,bc=bc,i=i,r2=r2,t=f,f=f,n=true,nop=false}               fun rev I.COMIBT=I.bcondi{cmpi=I.COMIBF,bc=bc,i=i,r2=r2,t=f,f=f,n=true,nop=false}
241            | rev I.COMIBF=I.BCONDI{cmpi=I.COMIBT,bc=bc,i=i,r2=r2,t=f,f=f,n=true,nop=false}                 | rev I.COMIBF=I.bcondi{cmpi=I.COMIBT,bc=bc,i=i,r2=r2,t=f,f=f,n=true,nop=false}
242        in        in
243          case (size,nop)          case (size,nop)
244            of (4,false) => [instr]            of (4,false) => [instr]
245             | (8,true) => [instr]             | (8,true) => [instr]
246             | (8,_) => [rev cmpi, I.B{lab=t, n=n}]                  | (8,_) => [rev cmpi, I.b{lab=t, n=n}]
247             | (16,_) => rev cmpi :: longJump{lab=t, n=n}             | (16,_) => rev cmpi :: longJump{lab=t, n=n}
248          (*esac*)          (*esac*)
249        end        end
250      | expand(instr as I.BB{bc, r, p, t, f, n, nop}, size, _) = let           | I.BB{bc, r, p, t, f, n, nop} => let
251          fun rev I.BSET = I.BB{bc=I.BCLR,r=r,p=p,t=f,f=f,n=true,nop=false}               fun rev I.BSET = I.bb{bc=I.BCLR,r=r,p=p,t=f,f=f,n=true,nop=false}
252            | rev I.BCLR = I.BB{bc=I.BSET,r=r,p=p,t=f,f=f,n=true,nop=false}                 | rev I.BCLR = I.bb{bc=I.BSET,r=r,p=p,t=f,f=f,n=true,nop=false}
253        in case (size,nop) of        in case (size,nop) of
254             (4,false) => [instr]             (4,false) => [instr]
255           | (8,true) => [instr]           | (8,true) => [instr]
256           | (8,_) => [rev bc, I.B{lab=t,n=n}]                | (8,_) => [rev bc, I.b{lab=t,n=n}]
257           | (16,_) => rev bc :: longJump{lab=t, n=n}           | (16,_) => rev bc :: longJump{lab=t, n=n}
258        end        end
259      | expand(instr as I.B{lab=lab, n=n}, size, _) =           |I.B{lab=lab, n=n} =>
260        (case size        (case size
261          of 4 => [instr]          of 4 => [instr]
262           | 12 => longJump{lab=lab, n=n}           | 12 => longJump{lab=lab, n=n}
263        (*esac*))        (*esac*))
264      | expand(instr as I.FBRANCH{t, f, n, ...}, size, _) =           | I.FBRANCH{t, f, n, ...} =>
265        (case size        (case size
266          of 12 => [instr]          of 12 => [instr]
267           | 20 =>           | 20 =>
# Line 260  Line 273 
273                *)                *)
274                  error "FBRANCH"                  error "FBRANCH"
275        (*esac*))        (*esac*))
276      | expand(I.BLR{labs,n,t,x,...},size, _) =           | I.BLR{labs,n,t,x,...} =>
277         (if size = 8 + 8 * length labs then         (if size = 8 + 8 * length labs then
278             I.BLR{labs=[],n=n,t=t,x=x}::                  I.blr{labs=[],n=n,t=t,x=x}::
279             I.NOP::                  I.nop::
280             foldr (fn (l,is) => I.B{lab=l,n=true}::I.NOP::is) [] labs                  foldr (fn (l,is) => I.b{lab=l,n=true}::I.nop::is) [] labs
281          else error "BLR"          else error "BLR"
282         )         )
283      | expand(I.COPY{impl=ref(SOME instrs),...}, _, _) = instrs           | I.COPY{impl=ref(SOME instrs),...} => instrs
     | expand(I.FCOPY{impl=ref(SOME instrs),...}, _, _) = instrs  
     | expand(I.ANNOTATION{i,...},size,pos) = expand(i,size,pos)  
     | expand _ = error "expand"  
284    
285             | I.FCOPY{impl=ref(SOME instrs),...} => instrs
286             | _ => error "expand")
287        | expand _ = error "expand"
288  end  end
289    

Legend:
Removed from v.1002  
changed lines
  Added in v.1003

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