Home My Page Projects Code Snippets Project Openings SML/NJ
Summary Activity Forums Tracker Lists Tasks Docs Surveys News SCM Files

SCM Repository

[smlnj] Diff of /sml/branches/SMLNJ/src/MLRISC/hppa/instructions/hppaCells.sml
ViewVC logotype

Diff of /sml/branches/SMLNJ/src/MLRISC/hppa/instructions/hppaCells.sml

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 410, Fri Sep 3 00:25:03 1999 UTC revision 411, Fri Sep 3 00:25:03 1999 UTC
# Line 1  Line 1 
1  (* hppaCells.sml  (*
2   *   * This file was automatically generated by MDGen
3   * COPYRIGHT (c) 1996 Bell Laboratories.   * from the machine description file "hppa/hppa.md".
  *  
4   *)   *)
 structure HppaCells : HPPACELLS = struct  
   structure SL = SortedList  
5    
   type register = int  
   type regmap = int Intmap.intmap  
   datatype cellclass = GP | FP | CC | CR | MEM | CTRL  
   
   exception Cells  
   
   val stackptrR         = 30  
   val asmTmpR           = 29  
   val fasmTmp           = 31  
   val sar               = 64+11  
   fun cr r              = 64+r  
6    
7    signature HPPACELLS =
8    sig
9       datatype mycellkind =
10         UNKNOWN
11       | MEM
12       | CTRL
13       | CC
14       | CR
15       | GP
16       | FP
17       withtype cellset = (int list * int list)
18       include CELLS_BASIS where type cellkind = mycellkind
19       val showCC : register -> string
20       val showCR : register -> string
21       val showGP : register -> string
22       val showFP : register -> string
23       val newCC : unit -> register
24       val newCR : unit -> register
25       val newGP : unit -> register
26       val newFP : unit -> register
27       val addGP : (register * cellset) -> cellset
28       val addFP : (register * cellset) -> cellset
29       val returnPtr : register
30       val asmTmpR : register
31       val stackptrR : register
32       val fasmTmp : register
33       val sar : register
34       val zeroReg : cellkind -> register option
35       val toString : cellkind -> register -> string
36       val addCell : cellkind -> register * cellset -> cellset
37       val addReg : register * cellset -> cellset
38       val addFreg : register * cellset -> cellset
39       val getCell : cellkind -> cellset -> register list
40       val updateCell : cellkind -> cellset * register list -> cellset
41       val empty : cellset
42       val cellsetToString : cellset -> string
43       val cellsetToString' : (register -> register) -> cellset -> string
44       val cellsetToRegs : cellset -> register list
45    end
46    
47    structure HppaCells : HPPACELLS =
48    struct
49       datatype mycellkind =
50         UNKNOWN
51       | MEM
52       | CTRL
53       | CC
54       | CR
55       | GP
56       | FP
57       withtype cellset = (int list * int list)
58       exception HppaCells
59       structure SL = SortedList
60       fun error msg = MLRiscErrorMsg.error("HppaCells",msg)
61       val cellkindToString = (fn CC => "CC"
62                                | CR => "CR"
63                                | GP => "GP"
64                                | FP => "FP"
65                                | MEM => "MEM"
66                                | CTRL => "CTRL"
67                                | UNKNOWN => "UNKNOWN"
68                              )
69       structure MyCellsBasis = CellsBasisFn
70          (type cellkind = mycellkind
71           exception Cells = HppaCells
72           val unknown = UNKNOWN
73           val cellkindToString = cellkindToString
74           val INT = GP
75           val FLOAT = FP
76    val firstPseudo       = 256    val firstPseudo       = 256
77           val kinds = [CC, CR, GP, FP, MEM, CTRL]
78    val counter = ref firstPseudo         val physical = [{from=96, to=0, kind=CC}, {from=64, to=95, kind=CR}, {from=0, to=31, kind=GP}, {from=32, to=63, kind=FP}]
79    val regCnt = ref 0        )
80    val fregCnt = ref 0  
81    fun bump (r as ref c) = (r := c+1; c)     open MyCellsBasis
82    fun downto0 0 = [0]     val offsetCC = 96
83      | downto0 n = n::downto0(n-1)    and offsetCR = 64
84    val physicalRegs = downto0 31    and offsetGP = 0
85      and offsetFP = 32
86    fun newReg () = (bump regCnt; bump counter)    and newCC = (newCell CC)
87    fun newFreg() = (bump fregCnt; bump counter)    and newCR = (newCell CR)
88    fun newCCreg () = (bump regCnt; bump counter)    and newGP = (newCell GP)
89      and newFP = (newCell FP)
90    fun resetRegs() = let    and cellnames = ["CC", "CR", "GP", "FP"]
91      val regmap = Intmap.new(64, Cells)    and cellsetnames = ["GP", "FP"]
92      val enter = Intmap.add regmap     val returnPtr = (2 + offsetGP)
93    in     val asmTmpR = (29 + offsetGP)
94      counter:=firstPseudo;     val stackptrR = (30 + offsetGP)
95      regCnt :=0;     val fasmTmp = (31 + offsetFP)
96      fregCnt:=0;     val sar = (11 + offsetCR)
97      app (fn r => enter(r,r)) physicalRegs;  
98      regmap     fun showCC r = let
99    end            val r = (if (r <= 0)
100                    then (r - 96)
101    fun newCell GP  = newReg                  else r)
102      | newCell FP  = newFreg         in ((fn _ => "cc"
103      | newCell CC  = newReg             ) r)
104      | newCell _   = (fn () => bump counter)         end
105    
106    fun maxCell () = !counter     and showCR r = let
107              val r = (if (r <= 95)
108    fun numCell GP = (fn () => !regCnt)                  then (r - 64)
109      | numCell FP = (fn () => !fregCnt)                  else r)
110      | numCell _  = raise Cells         in ((fn cr => ("%cr" ^ (Int.toString cr))
111               ) r)
112    fun cellToString(r,class) = prefix class^Int.toString r         end
113    and prefix GP   = "r"  
114      | prefix FP   = "f"     and showGP r = ((fn r => ("%r" ^ (Int.toString r))
115      | prefix CC   = "cc"                     ) r)
116      | prefix CR   = "cr"     and showFP r = let
117      | prefix MEM  = "m"            val r = (if (r <= 63)
118      | prefix CTRL = "ctrl"                  then (r - 32)
119                    else r)
120    fun zero GP = SOME 0         in ((fn f => ("%f" ^ (Int.toString f))
121      | zero _  = NONE             ) r)
122           end
123    type cellset  = (int list * int list)  
124       and toString CC = showCC
125         | toString CR = showCR
126         | toString GP = showGP
127         | toString FP = showFP
128         | toString MEM = (fn r => ("m" ^ (Int.toString r))
129                          )
130         | toString CTRL = (fn r => ("ctrl" ^ (Int.toString r))
131                           )
132         | toString UNKNOWN = (fn r => ("unknown" ^ (Int.toString r))
133                              )
134    val empty = ([], [])    val empty = ([], [])
   fun cellset2string(regs, fregs) = let  
     val gp = "gp=" :: map (fn r => (" %r" ^ Int.toString r)) regs  
     val fp = " fp=" :: map (fn f => (" %f" ^ Int.toString f)) fregs  
   in String.concat(gp @ fp)  
   end  
   fun addReg(r, (rc,fc)) = (SL.enter(r,rc), fc)  
   fun addFreg(f, (rc,fc)) = (rc, SL.enter(f, fc))  
   fun addCell GP = addReg  
     | addCell FP = addFreg  
     | addCell CC = addReg  
     | addCell _  = raise Cells  
   
   fun cellsetToRegs(regmap, (regs,fregs)) = let  
     val lookup = Intmap.map regmap  
     fun trans [] = []  
       | trans(r::rs) = let  
           val r = lookup r handle _ => r  
         in  if r = 0 then trans rs else r::trans rs  
         end  
     fun ftrans r = let  
       val r = lookup r handle _ => r  
     in  if r < 32 then r + 32 else r  
     end  
   in (map ftrans fregs @ trans regs)  
   end  
 end  
135    
136       fun addCell CC = addGP
137         | addCell GP = addGP
138         | addCell FP = addFP
139         | addCell _ = (error "addCell")
140       and getCell GP = getCellGP
141         | getCell FP = getCellFP
142         | getCell _ = (error "getCell")
143       and updateCell GP = updateCellGP
144         | updateCell FP = updateCellFP
145         | updateCell _ = (error "updateCell")
146       and addGP (r, (setGP, setFP)) = ((SL.enter (r, setGP)), setFP)
147       and addFP (r, (setGP, setFP)) = (setGP, (SL.enter (r, setFP)))
148       and getCellGP (setGP, setFP) = setGP
149       and getCellFP (setGP, setFP) = setFP
150       and updateCellGP ((setGP, setFP), r) = (r, setFP)
151       and updateCellFP ((setGP, setFP), r) = (setGP, r)
152       and cellsetToString (setGP, setFP) = (printTuple (cellsetnames, [((printSet showGP) setGP), ((printSet showFP) setFP)]))
153       and cellsetToString' regmap = (fn (setGP, setFP) => (printTuple (cellsetnames, [((printSet showGP) ((map regmap) setGP)), ((printSet showFP) ((map regmap) setFP))]))
154                                     )
155       and cellsetToRegs (setGP, setFP) = (setGP @ setFP)
156       val addReg = addGP
157       val addFreg = addFP
158    
159       fun zeroReg GP = (SOME (0 + offsetGP))
160         | zeroReg FP = (SOME (0 + offsetFP))
161         | zeroReg _ = NONE
162    end
163    
 (*  
  * $Log: hppaCells.sml,v $  
  * Revision 1.4  1998/10/06 14:04:29  george  
  *   The instruction sequence FCMP, FTEST, FBCC is being replaced  
  *   by the composite instruction FBRANCH.  This makes scheduling and  
  *   other tasks easier.  Also, added BLR and BL in the instruction set.  
  *                                                      [leunga]  
  *  
  * Revision 1.3  1998/05/25 15:10:54  george  
  *   Fixed RCS keywords  
  *  
  *)  

Legend:
Removed from v.410  
changed lines
  Added in v.411

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