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/alpha32/backpatch/alpha32Jumps.sml
ViewVC logotype

Annotation of /sml/branches/SMLNJ/src/MLRISC/alpha32/backpatch/alpha32Jumps.sml

Parent Directory Parent Directory | Revision Log Revision Log


Revision 247 - (view) (download)

1 : monnier 247 (* alpha32Jumps.sml --- information to resolve jumps.
2 :     *
3 :     * COPYRIGHT (c) 1996 Bell Laboratories.
4 :     *
5 :     *)
6 :     functor Alpha32Jumps
7 :     (structure Instr : ALPHA32INSTR
8 :     structure Shuffle : ALPHA32SHUFFLE
9 :     sharing Shuffle.I = Instr) : SDI_JUMPS =
10 :     struct
11 :     structure I = Instr
12 :     structure C = I.C
13 :     structure Const = I.Constant
14 :     structure LE = LabelExp
15 :    
16 :     fun error msg = MLRiscErrorMsg.impossible ("Alpha32Jumps." ^ msg)
17 :    
18 :     val branchDelayedArch = false
19 :    
20 :     fun isSdi(I.DEFFREG _) = true
21 :     | isSdi(I.LDA{d=I.CONSTop _, ...}) = true
22 :     | isSdi(I.LDA{d=I.LABop _, ...}) = true
23 :     | isSdi(I.LOAD{d=I.CONSTop _, ...}) = true
24 :     | isSdi(I.STORE{d=I.CONSTop _, ...}) = true
25 :     | isSdi(I.FSTORE{d=I.CONSTop _, ...}) = true
26 :     | isSdi(I.FLOAD{d=I.CONSTop _, ...}) = true
27 :     | isSdi(I.OPERATE{rb=I.CONSTop _, ...})= true
28 :     | isSdi(I.OPERATEV{rb=I.CONSTop _, ...})= true
29 :     | isSdi(I.COPY _) = true
30 :     | isSdi(I.FCOPY _) = true
31 :     | isSdi _ = false
32 :    
33 :     fun minSize(I.DEFFREG _) = 0
34 :     | minSize(I.COPY _) = 0
35 :     | minSize(I.FCOPY _) = 0
36 :     | minSize _ = 4
37 :    
38 :     (* max Size is not used for the alpha span dependency analysis. *)
39 :     fun maxSize _ = error "maxSize"
40 :    
41 :     fun immed16 n = ~32768 <= n andalso n < 32768
42 :     fun im16load n = if immed16 n then 4 else 8
43 :     fun im16Oper c = if immed16 (Const.valueOf c) then 4 else 12
44 :    
45 :     fun sdiSize(I.DEFFREG _, _, _, _) = 0
46 :     | sdiSize(I.LDA{d=I.LABop le, ...}, _, _, _) = im16load(LE.valueOf le)
47 :     | sdiSize(I.LDA{d=I.CONSTop c, ...}, _, _, _) = im16load(Const.valueOf c)
48 :     | sdiSize(I.LOAD{d=I.CONSTop c, ...}, _, _, _) = im16Oper c
49 :     | sdiSize(I.STORE{d=I.CONSTop c, ...}, _, _, _) = im16Oper c
50 :     | sdiSize(I.FLOAD{d=I.CONSTop c, ...}, _, _, _) = im16Oper c
51 :     | sdiSize(I.FSTORE{d=I.CONSTop c, ...}, _, _, _) = im16Oper c
52 :     | sdiSize(I.OPERATE{rb=I.CONSTop c, ...}, _, _, _) = im16Oper c
53 :     | sdiSize(I.OPERATEV{rb=I.CONSTop c, ...}, _, _, _) = im16Oper c
54 :     | sdiSize(I.COPY{impl=ref(SOME l),...}, _, _, _) = 4 * length l
55 :     | sdiSize(I.FCOPY{impl=ref(SOME l),...}, _, _, _) = 4 * length l
56 :     | sdiSize(I.COPY{dst, src, impl as ref NONE, tmp}, regmap, _, _) = let
57 :     val lookup = Intmap.map regmap
58 :     val instrs = Shuffle.shuffle{regMap=lookup, temp=tmp, dst=dst, src=src}
59 :     in impl := SOME instrs; 4 * length instrs
60 :     end
61 :     | sdiSize(I.FCOPY{dst, src, impl as ref NONE, tmp}, regmap, _, _) = let
62 :     val lookup = Intmap.map regmap
63 :     val instrs =
64 :     Shuffle.shufflefp{regMap=lookup, temp=tmp, dst=dst, src=src}
65 :     in impl := SOME(instrs); 4 * length instrs
66 :     end
67 :     | sdiSize _ = error "sdiSize"
68 :    
69 :     (* NOTE: All sdis must use a dedicated physical register as a
70 :     * temporaries, since sdi expansion is performed after register
71 :     * allocation.
72 :     *)
73 :     val zeroR = 31
74 :    
75 :     fun expand(instr, size, loc) = let
76 :     fun load(ldClass, ldOp, r, b, d as I.CONSTop c, mem) =
77 :     (case size
78 :     of 4 => [ldClass{ldOp=ldOp, r=r, b=b, d=I.IMMop(Const.valueOf c), mem=mem}]
79 :     | 12 => let
80 :     val instrs = expand(I.LDA{r=r, b=b, d=d}, 8, loc)
81 :     in instrs @ [ldClass{ldOp=ldOp, r=r, b=r, d=I.IMMop 0, mem=mem}]
82 :     end)
83 :    
84 :     fun store(stClass, stOp, r, b, d as I.CONSTop c, mem) =
85 :     (case size
86 :     of 4 => [stClass{stOp=stOp, r=r, b=b, d=I.IMMop(Const.valueOf c), mem=mem}]
87 :     | 12 => let
88 :     val instrs = expand(I.LDA{r=C.asmTmpR, b=b, d=d}, 8, loc)
89 :     in instrs @ [stClass{stOp=stOp, r=r, b=C.asmTmpR, d=I.IMMop 0, mem=mem}]
90 :     end)
91 :    
92 :     fun operate(opClass, oper, ra, rb as I.CONSTop c, rc) =
93 :     (case size
94 :     of 4 => [opClass{oper=oper, ra=ra, rb=I.IMMop(Const.valueOf c), rc=rc}]
95 :     | 12 => let
96 :     val instrs = expand(I.LDA{r=C.asmTmpR, b=zeroR, d=rb}, 8, loc)
97 :     in instrs @ [opClass{oper=oper, ra=ra, rb=I.REGop C.asmTmpR, rc=rc}]
98 :     end)
99 :     in
100 :     case instr
101 :     of I.DEFFREG _ => []
102 :     | I.LDA{r=rd, b=rs, d=I.LABop le} =>
103 :     (case size of
104 :     4 => [I.LDA{r=rd, b=rs, d=I.LOLABop le}]
105 :     | 8 => [I.LDA{r=rd, b=rs, d=I.LOLABop le},
106 :     I.LDAH{r=rd, b=rd, d=I.HILABop le}]
107 :     | _ => error "expand:LDA")
108 :    
109 :     | I.LDA{r=rd, b=rs, d=I.CONSTop c} =>
110 :     (case size of
111 :     4 => [I.LDA{r=rd, b=rs, d=I.IMMop(Const.valueOf c)}]
112 :     | 8 => let
113 :     val itow = Word.fromInt
114 :    
115 :     val n = Const.valueOf c
116 :     val low = Word.toIntX(Word.andb(itow n, 0w65535))
117 :     val high = n div 65536
118 :     val (lowsgn, highsgn) =
119 :     if low <= 32767 then (low, high) else (low -65536, high+1)
120 :     in
121 :     [I.LDA{r=rd, b=rs, d=I.IMMop lowsgn},
122 :     I.LDAH{r=rd, b=rd, d=I.IMMop highsgn}]
123 :     end)
124 :     | I.COPY{impl=ref(SOME instrs),...} => instrs
125 :     | I.FCOPY{impl=ref(SOME instrs),...} => instrs
126 :     | I.LOAD{ldOp, r, b, d, mem} => load(I.LOAD, ldOp, r, b, d, mem)
127 :     | I.FLOAD{ldOp, r, b, d, mem} => load(I.FLOAD, ldOp, r, b, d, mem)
128 :     | I.STORE{stOp, r, b, d, mem} => store(I.STORE, stOp, r, b, d, mem)
129 :     | I.FSTORE{stOp, r, b, d, mem} => store(I.FSTORE, stOp, r, b, d, mem)
130 :     | I.OPERATE{oper, ra, rb, rc} => operate(I.OPERATE, oper, ra, rb, rc)
131 :     | I.OPERATEV{oper, ra, rb, rc} => operate(I.OPERATEV, oper, ra, rb, rc)
132 :     | _ => error "expand"
133 :     end
134 :    
135 :     end
136 :    
137 :    
138 :     (*
139 :     * $Log: alpha32Jumps.sml,v $
140 :     * Revision 1.1.1.1 1999/01/04 21:55:13 george
141 :     * Version 110.12
142 :     *
143 :     * Revision 1.1.1.1 1998/04/08 18:39:01 george
144 :     * Version 110.5
145 :     *
146 :     *)

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