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/ppc/instructions/ppcCells.sml
ViewVC logotype

Annotation of /sml/trunk/src/MLRISC/ppc/instructions/ppcCells.sml

Parent Directory Parent Directory | Revision Log Revision Log


Revision 234 - (view) (download)
Original Path: sml/branches/SMLNJ/src/MLRISC/ppc/instructions/ppcCells.sml

1 : monnier 233
2 :     structure PPCCells : PPCCELLS = struct
3 :     structure SL = SortedList
4 :     exception Cells
5 :     type register = int
6 :     type regmap = register Intmap.intmap
7 :    
8 :     datatype cellclass =
9 :     GP | FP | CC| MEM | CTRL (* required components*)
10 :     | LR | CTR (* ppc specific *)
11 :    
12 :    
13 :     val stackptrR = 1
14 :     val asmTmpR = 28
15 :     val fasmTmp = 0
16 :    
17 :     val firstPseudo = 256
18 :    
19 :     val counter = ref firstPseudo
20 :     val regCnt = ref 0
21 :     val fregCnt = ref 0
22 :     val ccregCnt = ref 0
23 :     fun bump (r as ref c) = (r := c+1; c)
24 :     fun downto0 0 = [0]
25 :     | downto0 n = n::downto0(n-1)
26 :     val physicalRegs = downto0 31
27 :    
28 :     fun newReg () = (bump regCnt; bump counter)
29 :     fun newFreg() = (bump fregCnt; bump counter)
30 :     fun newCCreg () = (bump ccregCnt; bump counter)
31 :    
32 :     fun resetRegs() = let
33 :     val regmap = Intmap.new(64, Cells)
34 :     val enter = Intmap.add regmap
35 :     in
36 :     counter:=firstPseudo;
37 :     regCnt :=0;
38 :     fregCnt:=0;
39 :     ccregCnt:=0;
40 :     app (fn r => enter(r,r)) physicalRegs;
41 :     regmap
42 :     end
43 :    
44 :     fun zero _ = NONE
45 :    
46 :     fun newCell GP = newReg
47 :     | newCell FP = newFreg
48 :     | newCell CC = newCCreg
49 :     | newCell _ = (fn () => bump counter)
50 :    
51 :     fun numCell GP = (fn () => !regCnt)
52 :     | numCell FP = (fn () => !fregCnt)
53 :     | numCell CC = (fn () => !ccregCnt)
54 :     | numCell _ = raise Cells
55 :    
56 :     fun maxCell () = !counter
57 :    
58 :     fun cellToString(r, _) = Int.toString r
59 :    
60 :     type cellset = register list * register list * register list
61 :     val empty = ([],[],[])
62 :    
63 :     fun cellset2string(regs, fregs, ccregs) = let
64 :     val gp = "gp="::map Int.toString regs
65 :     val fp = "fp="::map Int.toString fregs
66 :     val cc = "cc="::map Int.toString ccregs
67 :     in String.concat(gp @ fp @cc)
68 :     end
69 :    
70 :     fun addReg(r, (rc,fc, cc)) = (SL.enter(r,rc), fc, cc)
71 :     fun addFreg(f, (rc,fc, cc)) = (rc, SL.enter(f, fc), cc)
72 :     fun addCCreg(c, (rc,fc, cc)) = (rc, fc, SL.enter(c,cc))
73 :    
74 :     fun addCell GP = addReg
75 :     | addCell FP = addFreg
76 :     | addCell CC = addCCreg
77 :     | addCell _ = raise Cells
78 :    
79 :     (* mapping:
80 :     0..31 gp
81 :     32..63 fp
82 :     64..71 cc
83 :     *)
84 :     fun cellsetToRegs(regmap, (regs,fregs,ccregs)) = let
85 :     val lookup = Intmap.map regmap
86 :     fun trans (K, R) r = let
87 :     val r = lookup r handle _ => r
88 :     in if r < K then r+R else r
89 :     end
90 :     val rtrans = map (trans (32, 0)) regs
91 :     val ftrans = map (trans (32, 32)) fregs
92 :     val cctrans = map (trans (8, 64)) ccregs
93 :     in cctrans @ (ftrans @ rtrans)
94 :     end
95 :     end

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