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/primop-branch/src/compiler/CodeGen/x86/x86CG.sml
ViewVC logotype

Annotation of /sml/branches/primop-branch/src/compiler/CodeGen/x86/x86CG.sml

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1372 - (view) (download)

1 : monnier 429 (*
2 : monnier 498 * X86 specific backend. This one uses the new RA8 scheme.
3 : monnier 429 *)
4 :     structure X86CG =
5 :     MachineGen
6 :     ( structure I = X86Instr
7 : leunga 744 structure C = I.C
8 : george 909 structure F = X86CFG
9 : monnier 429 structure R = X86CpsRegs
10 :     structure CG = Control.CG
11 : monnier 247
12 : monnier 429 structure MachSpec = X86Spec
13 : george 984 structure ClientPseudoOps = X86ClientPseudoOps
14 : monnier 429 structure PseudoOps = X86PseudoOps
15 : blume 773 structure Ext = X86_SMLNJMLTreeExt(* x86-specific *)
16 : monnier 429 structure CpsRegs = X86CpsRegs
17 : george 555 structure InsnProps = X86Props
18 : monnier 429 structure Asm = X86AsmEmitter
19 : george 555 structure Shuffle = X86Shuffle
20 : monnier 247
21 : blume 1126 val fast_floating_point =
22 :     MLRiscControl.mkFlag ("x86-fast-fp",
23 :     "whether to use the fast-fp backend (x86)")
24 : leunga 972
25 : george 823 structure CCalls =
26 : leunga 972 IA32SVID_CCalls (structure T = X86MLTree fun ix x = x
27 :     val fast_floating_point = fast_floating_point)
28 : blume 773
29 : george 823 structure OmitFramePtr =
30 : george 909 X86OmitFramePointer(structure I=X86Instr
31 : george 823 structure MemRegs=X86MemRegs
32 : george 909 structure CFG=X86CFG
33 : george 823 val memRegBase = SOME(X86CpsRegs.vfp))
34 :    
35 : monnier 498 val spill = CPSRegions.spill
36 :     val stack = CPSRegions.stack
37 : monnier 247
38 : monnier 429 fun error msg = MLRiscErrorMsg.error("X86CG",msg)
39 : monnier 247
40 : george 823 fun base() = (* XXXX *)
41 :     if !ClusterAnnotation.useVfp then X86CpsRegs.vfp else I.C.esp
42 :    
43 :    
44 : monnier 429 structure MLTreeComp=
45 :     X86(structure X86Instr=X86Instr
46 : george 984 structure MLTreeUtils = MLTreeUtils
47 : leunga 797 (structure T = X86MLTree
48 :     fun hashSext _ _ = 0w0
49 :     fun hashRext _ _ = 0w0
50 :     fun hashFext _ _ = 0w0
51 :     fun hashCCext _ _ = 0w0
52 :    
53 :     (* Equality extensions *)
54 :     fun eqSext _ _ = false
55 :     fun eqRext _ _ = false
56 :     fun eqFext _ _ = false
57 :     fun eqCCext _ _ = false
58 :    
59 :     (* Pretty printing extensions *)
60 :     fun showSext _ _ = ""
61 :     fun showRext _ _ = ""
62 :     fun showFext _ _ = ""
63 :     fun showCCext _ _ = ""
64 : george 555 )
65 : george 984 structure ExtensionComp = X86MLTreeExtComp
66 :     (structure I = X86Instr
67 :     structure T = X86MLTree
68 :     structure CFG = X86CFG
69 :     structure TS = X86MLTreeStream
70 : blume 1126 val fast_fp = fast_floating_point
71 : george 984 )
72 :     structure MLTreeStream = X86MLTreeStream
73 :     datatype arch = Pentium | PentiumPro | PentiumII | PentiumIII
74 :     val arch = ref Pentium (* Lowest common denominator *)
75 : george 823 fun cvti2f{src,ty,an} = let (* ty is always 32 for SML/NJ *)
76 :     val tempMem = I.Displace{base=base(), disp=I.Immed 304, mem=stack}
77 :     in
78 : george 1003 {instrs = [I.move{mvOp=I.MOVL, src=src, dst=tempMem}],
79 : george 823 tempMem = tempMem,
80 : leunga 593 cleanup = []
81 :     }
82 : george 823 end
83 : leunga 731 val fast_floating_point = fast_floating_point
84 : monnier 429 )
85 : monnier 247
86 : leunga 657 structure Jumps =
87 : monnier 429 X86Jumps(structure Instr=X86Instr
88 :     structure AsmEmitter=X86AsmEmitter
89 : george 984 structure Eval=X86MLTreeEval
90 : monnier 429 structure Shuffle=X86Shuffle
91 :     structure MCEmitter=X86MCEmitter)
92 :    
93 :     structure BackPatch =
94 : leunga 657 BackPatch(structure Jumps=Jumps
95 : monnier 429 structure Emitter=X86MCEmitter
96 :     structure Props=InsnProps
97 : george 909 structure CFG = X86CFG
98 : monnier 429 structure Asm=X86AsmEmitter
99 :     structure CodeString=CodeString)
100 : monnier 247
101 : leunga 744 structure RA =
102 :     X86RA
103 :     (structure I = X86Instr
104 : george 889 structure CB = CellsBasis
105 : leunga 744 structure InsnProps = InsnProps
106 :     structure Asm = X86AsmEmitter
107 : george 909 structure CFG = X86CFG
108 : leunga 744 structure SpillHeur = ChowHennessySpillHeur
109 :     structure Spill = RASpill
110 :     (structure Asm = X86AsmEmitter
111 :     structure InsnProps = InsnProps
112 :     )
113 : leunga 731
114 : leunga 796 type spill_info = unit
115 :    
116 :     fun beforeRA _ = X86StackSpills.init()
117 : leunga 744 val fast_floating_point = fast_floating_point
118 : monnier 247
119 : leunga 744 val toInt32 = Int32.fromInt
120 :     fun cacheOffset r = I.Immed(toInt32(X86Runtime.vregStart +
121 : monnier 469 Word.toIntX(Word.<<(Word.fromInt(r-8),0w2))))
122 : leunga 744 fun cacheFPOffset f = I.Immed(toInt32(X86Runtime.vFpStart +
123 : leunga 731 Word.toIntX(Word.<<(Word.fromInt(f-40),0w3))))
124 : monnier 247
125 : leunga 744 datatype raPhase = SPILL_PROPAGATION | SPILL_COLORING
126 : leunga 815 datatype spillOperandKind = SPILL_LOC | CONST_VAL
127 : leunga 731
128 : leunga 744 structure Int =
129 :     struct
130 :     val avail = R.availR
131 :     val dedicated = R.dedicatedR
132 : george 889 val memRegs = C.Regs CB.GP {from=8,to=31,step=1}
133 : leunga 744 val phases = [SPILL_PROPAGATION,SPILL_COLORING]
134 : monnier 469
135 : leunga 744 (* We try to make unused memregs available for spilling
136 :     * This is necessary because of the stupid SML code generator
137 :     * doesn't keep track of which are being used.
138 :     *)
139 :     fun spillInit(RAGraph.GRAPH{nodes, ...}) =
140 :     let val lookup = IntHashTable.lookup nodes
141 :     fun find(r, free) =
142 :     if r >= 10 then (* note, %8 and %9 are reserved! *)
143 :     let val free =
144 :     case lookup r of
145 :     RAGraph.NODE{uses=ref [], defs=ref [], ...} =>
146 :     cacheOffset r::free
147 :     | _ => free
148 :     in find(r-1, free) end
149 :     else
150 :     free
151 :     val free = find(31 (* X86Runtime.numVregs+8-1 *), [])
152 :     in X86StackSpills.setAvailableOffsets free
153 :     end
154 :    
155 :     val getRegLoc' = X86StackSpills.getRegLoc
156 :    
157 : leunga 815 fun spillLoc{info, an, cell, id} =
158 : george 823 {opnd=I.Displace{base=base(), disp=getRegLoc' id, mem=spill},
159 : leunga 815 kind=SPILL_LOC
160 :     }
161 : leunga 744
162 :     end
163 : monnier 469
164 : leunga 744 structure Float =
165 :     struct
166 :     val avail = R.availF
167 :     val dedicated = R.dedicatedF
168 :     val memRegs = []
169 :     val phases = [SPILL_PROPAGATION]
170 : george 546
171 : leunga 744 fun spillInit(RAGraph.GRAPH{nodes, ...}) =
172 :     if !fast_floating_point then
173 : blume 733 let val lookup = IntHashTable.lookup nodes
174 : leunga 731 fun find(r, free) =
175 :     if r >= 32+8 then
176 :     let val free =
177 :     case lookup r of
178 : leunga 744 RAGraph.NODE{uses=ref [], defs=ref [],...} =>
179 : leunga 731 cacheFPOffset r::free
180 :     | _ => free
181 :     in find(r-1, free) end
182 :     else
183 :     free
184 :     val free = find(63, [])
185 : leunga 744 in X86StackSpills.setAvailableFPOffsets free
186 : leunga 731 end
187 :     else ()
188 : monnier 469
189 : leunga 796 fun spillLoc(S, an, loc) =
190 : george 823 I.Displace{base=base(), disp=X86StackSpills.getFregLoc loc, mem=spill}
191 : monnier 498
192 : george 889 val fastMemRegs = C.Regs CB.FP {from=8, to=31, step=1}
193 : leunga 744 val fastPhases = [SPILL_PROPAGATION,SPILL_COLORING]
194 : monnier 247 end
195 : leunga 744 ) (* X86RA *)
196 : monnier 429 )
197 : monnier 247

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