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/hppa/hppaCells.sml
ViewVC logotype

Annotation of /sml/trunk/src/MLRISC/hppa/hppaCells.sml

Parent Directory Parent Directory | Revision Log Revision Log


Revision 223 - (view) (download)
Original Path: sml/branches/SMLNJ/src/MLRISC/hppa/hppaCells.sml

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

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