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 93 - (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 :     structure HppaCells : CELLS = struct
7 :     structure SL = SortedList
8 :    
9 :     exception HppaCells
10 :    
11 :     val stackptrR = 30
12 :     val asmTmpR = 29
13 :     val fasmTmp = 31
14 :    
15 :     val firstPseudoReg = 128
16 :    
17 :     val counter = ref firstPseudoReg
18 :     val regCnt = ref 0
19 :     val fregCnt = ref 0
20 :     fun bump (r as ref c) = (r := c+1; c)
21 :     fun downto0 0 = [0]
22 :     | downto0 n = n::downto0(n-1)
23 :     val physicalRegs = downto0 31
24 :    
25 :     fun newReg () = (bump regCnt; bump counter)
26 :     fun newFreg() = (bump fregCnt; bump counter)
27 :     fun newCCreg()= (bump regCnt; bump counter)
28 :     fun maxReg() = !counter
29 :     fun maxFreg() = !counter
30 :     fun numRegs() = !regCnt
31 :     fun numFregs() = !fregCnt
32 :     fun resetRegs() = let
33 :     val regmap = Intmap.new(64, HppaCells)
34 :     val enter = Intmap.add regmap
35 :     in
36 :     counter:=firstPseudoReg;
37 :     regCnt :=0;
38 :     fregCnt:=0;
39 :     app (fn r => enter(r,r)) physicalRegs;
40 :     regmap
41 :     end
42 :    
43 :     type cellset = (int list * int list)
44 :    
45 :     val empty = ([], [])
46 :     fun cellset2string(regs, fregs) = let
47 :     val gp = "gp=" :: map (fn r => (" %r" ^ Int.toString r)) regs
48 :     val fp = " fp=" :: map (fn f => (" %f" ^ Int.toString f)) fregs
49 :     in String.concat(gp @ fp)
50 :     end
51 :     fun addReg(r, (rc,fc)) = (SL.enter(r,rc), fc)
52 :     fun addFreg(f, (rc,fc)) = (rc, SL.enter(f, fc))
53 :     val addCCreg = addReg
54 :    
55 :     fun cellsetToRegs(regmap, (regs,fregs)) = let
56 :     val lookup = Intmap.map regmap
57 :     fun trans [] = []
58 :     | trans(r::rs) = let
59 :     val r = lookup r handle _ => r
60 :     in if r = 0 then trans rs else r::trans rs
61 :     end
62 :     fun ftrans r = let
63 :     val r = lookup r handle _ => r
64 :     in if r < 32 then r + 32 else r
65 :     end
66 :     in (map ftrans fregs @ trans regs)
67 :     end
68 :     end
69 :    
70 :    
71 :     (*
72 :     * $Log: hppaCells.sml,v $
73 : monnier 93 * Revision 1.1.1.1 1998/04/08 18:39:01 george
74 :     * Version 110.5
75 : monnier 16 *
76 :     *)

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