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/trunk/src/MLRISC/alpha/backpatch/alphaJumps.sml
ViewVC logotype

Annotation of /sml/trunk/src/MLRISC/alpha/backpatch/alphaJumps.sml

Parent Directory Parent Directory | Revision Log Revision Log


Revision 889 - (view) (download)

1 : monnier 409 (* alphaJumps.sml --- information to resolve jumps.
2 :     *
3 :     * COPYRIGHT (c) 1996 Bell Laboratories.
4 :     *
5 :     *)
6 :     functor AlphaJumps
7 :     (structure Instr : ALPHAINSTR
8 :     structure Shuffle : ALPHASHUFFLE
9 :     sharing Shuffle.I = Instr) : SDI_JUMPS =
10 :     struct
11 :     structure I = Instr
12 :     structure C = I.C
13 :     structure Const = I.Constant
14 : george 545 structure LE = I.LabelExp
15 : monnier 409
16 :     fun error msg = MLRiscErrorMsg.error("AlphaJumps",msg)
17 :    
18 :     val branchDelayedArch = false
19 :    
20 :     fun isSdi(I.DEFFREG _) = true
21 :     | isSdi(I.LDA{d=I.LABop _, ...}) = true
22 : george 545 | isSdi(I.LOAD{d=I.LABop _, ...}) = true
23 :     | isSdi(I.STORE{d=I.LABop _, ...}) = true
24 :     | isSdi(I.FSTORE{d=I.LABop _, ...}) = true
25 :     | isSdi(I.FLOAD{d=I.LABop _, ...}) = true
26 :     | isSdi(I.OPERATE{rb=I.LABop _, ...})= true
27 :     | isSdi(I.OPERATEV{rb=I.LABop _, ...})= true
28 :     | isSdi(I.CMOVE{rb=I.LABop _, ...}) = true
29 : monnier 409 | isSdi(I.COPY _) = true
30 :     | isSdi(I.FCOPY _) = true
31 :     | isSdi(I.ANNOTATION{i,...}) = isSdi i
32 :     | isSdi _ = false
33 :    
34 :     fun minSize(I.DEFFREG _) = 0
35 :     | minSize(I.COPY _) = 0
36 :     | minSize(I.FCOPY _) = 0
37 :     | minSize(I.ANNOTATION{i,...}) = minSize i
38 :     | minSize _ = 4
39 :    
40 :     (* max Size is not used for the alpha span dependency analysis. *)
41 :     fun maxSize _ = error "maxSize"
42 :    
43 :     fun immed16 n = ~32768 <= n andalso n < 32768
44 :     fun im16load n = if immed16 n then 4 else 8
45 : george 545 fun im16Oper le = if immed16 (LE.valueOf le) then 4 else 12
46 : monnier 409
47 :     fun immed8 n = n >= 0 andalso n < 256
48 : george 545 fun im8Oper le = if immed8 (LE.valueOf le) then 4 else 12
49 : monnier 409
50 : leunga 744 fun sdiSize(I.DEFFREG _, _, _) = 0
51 :     | sdiSize(I.LDA{d=I.LABop le, ...}, _, _) = im16load(LE.valueOf le)
52 :     | sdiSize(I.LOAD{d=I.LABop le, ...}, _, _) = im16Oper le
53 :     | sdiSize(I.STORE{d=I.LABop le, ...}, _, _) = im16Oper le
54 :     | sdiSize(I.FLOAD{d=I.LABop le, ...}, _, _) = im16Oper le
55 :     | sdiSize(I.FSTORE{d=I.LABop le, ...}, _, _) = im16Oper le
56 :     | sdiSize(I.OPERATE{rb=I.LABop le, ...}, _, _) = im8Oper le
57 :     | sdiSize(I.OPERATEV{rb=I.LABop le, ...}, _, _) = im8Oper le
58 :     | sdiSize(I.CMOVE{rb=I.LABop le, ...}, _, _) = im8Oper le
59 :     | sdiSize(I.COPY{impl=ref(SOME l),...}, _, _) = 4 * length l
60 :     | sdiSize(I.FCOPY{impl=ref(SOME l),...}, _, _) = 4 * length l
61 :     | sdiSize(I.COPY{dst, src, impl as ref NONE, tmp}, _, _) = let
62 :     val instrs = Shuffle.shuffle{tmp=tmp, dst=dst, src=src}
63 : monnier 409 in impl := SOME instrs; 4 * length instrs
64 :     end
65 : leunga 744 | sdiSize(I.FCOPY{dst, src, impl as ref NONE, tmp}, _, _) = let
66 :     val instrs = Shuffle.shufflefp{tmp=tmp, dst=dst, src=src}
67 : monnier 409 in impl := SOME(instrs); 4 * length instrs
68 :     end
69 : leunga 744 | sdiSize(I.ANNOTATION{i,...},x,y) = sdiSize(i,x,y)
70 : monnier 409 | sdiSize _ = error "sdiSize"
71 :    
72 :     (* NOTE: All sdis must use a dedicated physical register as a
73 :     * temporaries, since sdi expansion is performed after register
74 :     * allocation.
75 :     *)
76 : george 889 val zeroR = Option.valOf(C.zeroReg CellsBasis.GP)
77 : monnier 409
78 :     fun expand(instr, size, pos) = let
79 : george 545 fun load(ldClass, ldOp, r, b, d as I.LABop le, mem) =
80 : monnier 409 (case size
81 : george 545 of 4 => [ldClass{ldOp=ldOp, r=r, b=b, d=I.IMMop(LE.valueOf le), mem=mem}]
82 : monnier 409 | 12 => let
83 :     val instrs = expand(I.LDA{r=r, b=b, d=d}, 8, pos)
84 :     in instrs @ [ldClass{ldOp=ldOp, r=r, b=r, d=I.IMMop 0, mem=mem}]
85 :     end)
86 :    
87 : george 545 fun store(stClass, stOp, r, b, d as I.LABop le, mem) =
88 : monnier 409 (case size
89 : george 545 of 4 => [stClass{stOp=stOp, r=r, b=b, d=I.IMMop(LE.valueOf le), mem=mem}]
90 : monnier 409 | 12 => let
91 :     val instrs = expand(I.LDA{r=C.asmTmpR, b=b, d=d}, 8, pos)
92 :     in instrs @ [stClass{stOp=stOp, r=r, b=C.asmTmpR, d=I.IMMop 0, mem=mem}]
93 :     end)
94 :    
95 : george 545 fun operate(opClass, oper, ra, rb as I.LABop le, rc) =
96 : monnier 409 (case size
97 : george 545 of 4 => [opClass{oper=oper, ra=ra, rb=I.IMMop(LE.valueOf le), rc=rc}]
98 : monnier 409 | 12 => let
99 :     val instrs = expand(I.LDA{r=C.asmTmpR, b=zeroR, d=rb}, 8, pos)
100 :     in instrs @ [opClass{oper=oper, ra=ra, rb=I.REGop C.asmTmpR, rc=rc}]
101 :     end)
102 :     in
103 :     case instr
104 :     of I.DEFFREG _ => []
105 :     | I.LDA{r=rd, b=rs, d=I.LABop le} =>
106 :     (case size of
107 :     4 => [I.LDA{r=rd, b=rs, d=I.LOLABop le}]
108 :     | 8 => [I.LDA{r=rd, b=rs, d=I.LOLABop le},
109 :     I.LDAH{r=rd, b=rd, d=I.HILABop le}]
110 : george 545 | _ => error "expand:LDA"
111 :     )
112 : monnier 409 | I.COPY{impl=ref(SOME instrs),...} => instrs
113 :     | I.FCOPY{impl=ref(SOME instrs),...} => instrs
114 :     | I.LOAD{ldOp, r, b, d, mem} => load(I.LOAD, ldOp, r, b, d, mem)
115 :     | I.FLOAD{ldOp, r, b, d, mem} => load(I.FLOAD, ldOp, r, b, d, mem)
116 :     | I.STORE{stOp, r, b, d, mem} => store(I.STORE, stOp, r, b, d, mem)
117 :     | I.FSTORE{stOp, r, b, d, mem} => store(I.FSTORE, stOp, r, b, d, mem)
118 :     | I.OPERATE{oper, ra, rb, rc} => operate(I.OPERATE, oper, ra, rb, rc)
119 :     | I.OPERATEV{oper, ra, rb, rc} => operate(I.OPERATEV, oper, ra, rb, rc)
120 :     | I.CMOVE{oper, ra, rb, rc} =>
121 :     (case size
122 :     of 4 => [instr]
123 :     | 12 =>
124 :     let val instrs = expand(I.LDA{r=C.asmTmpR, b=zeroR, d=rb}, 8, pos)
125 :     in instrs @ [I.CMOVE{oper=oper, ra=ra, rb=I.REGop C.asmTmpR, rc=rc}]
126 :     end)
127 :     | I.ANNOTATION{i,...} => expand(i,size,pos)
128 :     | _ => error "expand"
129 :     end
130 :    
131 :     end
132 :    
133 :    

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