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

Annotation of /sml/trunk/src/MLRISC/alpha32/alpha32Cells.sml

Parent Directory Parent Directory | Revision Log Revision Log


Revision 168 - (view) (download)

1 : monnier 16 (* alpha32Cells.sml
2 :     *
3 :     * COPYRIGHT (c) 1996 Bell Laboratories.
4 :     *
5 :     *)
6 :    
7 : monnier 106 structure Alpha32Cells : ALPHA32CELLS = struct
8 : monnier 16 structure S = SortedList
9 :    
10 : monnier 167 type register = int
11 : monnier 106 type regmap = int Intmap.intmap
12 :     datatype cellclass = GP | FP | CC | CR | MEM | CTRL
13 : monnier 16
14 : monnier 106 exception Cells
15 :    
16 : monnier 16 val stackptrR = 30
17 :     val asmTmpR = 28
18 :     val fasmTmp = 30
19 : monnier 106 val firstPseudo = 256
20 : monnier 16
21 : monnier 106 val counter = ref firstPseudo
22 : monnier 16 val regCnt = ref 0
23 :     val fregCnt = ref 0
24 :     fun bump (r as ref c) = (r := c+1; c)
25 :     fun downto0 0 = [0]
26 :     | downto0 n = n::downto0(n-1)
27 :     val physicalRegs = downto0 31
28 :    
29 :     fun newReg () = (bump regCnt; bump counter)
30 :     fun newFreg() = (bump fregCnt; bump counter)
31 :     fun newCCreg() = (bump regCnt; bump counter)
32 :     fun resetRegs() = let
33 : monnier 106 val regmap = Intmap.new(64, Cells)
34 : monnier 16 val enter = Intmap.add regmap
35 :     in
36 : monnier 106 counter:=firstPseudo;
37 : monnier 16 regCnt :=0;
38 :     fregCnt:=0;
39 :     app (fn r => enter(r,r)) physicalRegs;
40 :     regmap
41 :     end
42 :    
43 : monnier 106 fun newCell GP = newReg
44 :     | newCell FP = newFreg
45 :     | newCell CC = newReg
46 :     | newCell _ = fn () => bump counter
47 :    
48 :     fun maxCell () = !counter
49 :     fun numCell GP = (fn () => !regCnt)
50 :     | numCell FP = (fn () => !fregCnt)
51 :     | numCell _ = raise Cells
52 :    
53 :     fun cellToString(r,class) = prefix class^Int.toString r
54 :     and prefix GP = "r"
55 :     | prefix FP = "f"
56 :     | prefix CC = "cc"
57 :     | prefix MEM = "m"
58 :     | prefix CTRL = "ctrl"
59 :    
60 :     fun zero GP = SOME 31
61 :     | zero FP = SOME 31
62 :     | zero _ = NONE
63 :    
64 : monnier 16 type cellset = int list * int list (* (regs * fregs) *)
65 :     fun cellset2string(regs, fregs) = let
66 :     val gp = "gp=" :: map (fn r => (" $" ^ Int.toString r)) regs
67 :     val fp = " fp=" :: map (fn f => (" $f" ^ Int.toString f)) fregs
68 :     in String.concat(gp @ fp)
69 :     end
70 :     val empty = ([], [])
71 :     fun addReg(r, (rc,fc)) = (S.enter(r,rc), fc)
72 :     fun addFreg(f, (rc,fc)) = (rc, S.enter(f, fc))
73 : monnier 106 fun addCell GP = addReg
74 :     | addCell FP = addFreg
75 :     | addCell CC = addReg
76 :     | addCell _ = raise Cells
77 : monnier 16
78 :     fun cellsetToRegs(regmap, (regs,fregs)) = let
79 :     val lookup = Intmap.map regmap
80 :     fun trans r = lookup r handle _ => r
81 :     fun ftrans r = let
82 :     val r = lookup r handle _ => r
83 :     in if r < 32 then r + 32 else r
84 :     end
85 :     in (map ftrans fregs @ map trans regs)
86 :     end
87 :    
88 :     end
89 :    
90 :    
91 :     (*
92 : monnier 167 * $Log: alpha32Cells.sml,v $
93 :     * Revision 1.3 1998/05/25 15:10:46 george
94 :     * Fixed RCS keywords
95 :     *
96 : monnier 16 *)

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