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

SCM Repository

[smlnj] View of /sml/trunk/src/MLRISC/x86/instructions/x86Cells.sml
ViewVC logotype

View of /sml/trunk/src/MLRISC/x86/instructions/x86Cells.sml

Parent Directory Parent Directory | Revision Log Revision Log


Revision 411 - (download) (annotate)
Fri Sep 3 00:25:03 1999 UTC (20 years ago) by monnier
Original Path: sml/branches/SMLNJ/src/MLRISC/x86/instructions/x86Cells.sml
File size: 5710 byte(s)
version 110.19
(*
 * This file was automatically generated by MDGen
 * from the machine description file "x86/x86.md".
 *)


signature X86CELLS =
sig
   datatype mycellkind =
     UNKNOWN
   | MEM
   | CTRL
   | CC
   | GP
   | FP
   withtype cellset = (int list * int list * int list)
   include CELLS_BASIS where type cellkind = mycellkind
   val showCC : register -> string
   val showGP : register -> string
   val showFP : register -> string
   val newCC : unit -> register
   val newGP : unit -> register
   val newFP : unit -> register
   val addGP : (register * cellset) -> cellset
   val addFP : (register * cellset) -> cellset
   val addCC : (register * cellset) -> cellset
   val ebp : register
   val eax : register
   val ecx : register
   val esp : register
   val asmTmpR : register
   val stackptrR : register
   val fasmTmp : register
   val edi : register
   val ebx : register
   val esi : register
   val edx : register
   val zeroReg : cellkind -> register option
   val toString : cellkind -> register -> string
   val addCell : cellkind -> register * cellset -> cellset
   val addReg : register * cellset -> cellset
   val addFreg : register * cellset -> cellset
   val getCell : cellkind -> cellset -> register list
   val updateCell : cellkind -> cellset * register list -> cellset
   val empty : cellset
   val cellsetToString : cellset -> string
   val cellsetToString' : (register -> register) -> cellset -> string
   val cellsetToRegs : cellset -> register list
end

structure X86Cells : X86CELLS =
struct
   datatype mycellkind =
     UNKNOWN
   | MEM
   | CTRL
   | CC
   | GP
   | FP
   withtype cellset = (int list * int list * int list)
   exception X86Cells
   structure SL = SortedList
   fun error msg = MLRiscErrorMsg.error("X86Cells",msg)
   val cellkindToString = (fn CC => "CC"
                            | GP => "GP"
                            | FP => "FP"
                            | MEM => "MEM"
                            | CTRL => "CTRL"
                            | UNKNOWN => "UNKNOWN"
                          )
   structure MyCellsBasis = CellsBasisFn
      (type cellkind = mycellkind
       exception Cells = X86Cells
       val unknown = UNKNOWN
       val cellkindToString = cellkindToString
       val INT = GP
       val FLOAT = FP
       val firstPseudo = 256
       val kinds = [CC, GP, FP, MEM, CTRL]
       val physical = [{from=64, to=0, kind=CC}, {from=0, to=31, kind=GP}, {from=32, to=63, kind=FP}]
      )

   open MyCellsBasis
   val offsetCC = 64
  and offsetGP = 0
  and offsetFP = 32
  and newCC = (newCell CC)
  and newGP = (newCell GP)
  and newFP = (newCell FP)
  and cellnames = ["CC", "GP", "FP"]
  and cellsetnames = ["GP", "FP", "CC"]
   val ebp = (5 + offsetGP)
   val eax = (0 + offsetGP)
   val ecx = (1 + offsetGP)
   val esp = (4 + offsetGP)
   val asmTmpR = (~ 1)
   val stackptrR = esp
   val fasmTmp = (~ 1)
   val edi = (7 + offsetGP)
   val ebx = (3 + offsetGP)
   val esi = (6 + offsetGP)
   val edx = (2 + offsetGP)

   fun showCC r = let
          val r = (if (r <= 0)
                then (r - 64)
                else r)
       in ((fn _ => "cc"
           ) r)
       end

   and showGP r = ((fn 0 => "%eax"
                     | 1 => "%ecx"
                     | 2 => "%edx"
                     | 3 => "%ebx"
                     | 4 => "%esp"
                     | 5 => "%ebp"
                     | 6 => "%esi"
                     | 7 => "%edi"
                     | r => ("%" ^ (Int.toString r))
                   ) r)
   and showFP r = let
          val r = (if (r <= 63)
                then (r - 32)
                else r)
       in ((fn f => (if (f >= 0)andalso (f < 8)
                  then (("%st(" ^ (Int.toString f)) ^ ")")
                  else ("%f" ^ (Int.toString f)))
           ) r)
       end

   and toString CC = showCC
     | toString GP = showGP
     | toString FP = showFP
     | toString MEM = (fn r => ("m" ^ (Int.toString r))
                      )
     | toString CTRL = (fn r => ("ctrl" ^ (Int.toString r))
                       )
     | toString UNKNOWN = (fn r => ("unknown" ^ (Int.toString r))
                          )
   val empty = ([], [], [])

   fun addCell CC = addCC
     | addCell GP = addGP
     | addCell FP = addFP
     | addCell _ = (error "addCell")
   and getCell CC = getCellCC
     | getCell GP = getCellGP
     | getCell FP = getCellFP
     | getCell _ = (error "getCell")
   and updateCell CC = updateCellCC
     | updateCell GP = updateCellGP
     | updateCell FP = updateCellFP
     | updateCell _ = (error "updateCell")
   and addGP (r, (setGP, setFP, setCC)) = ((SL.enter (r, setGP)), setFP, setCC)
   and addFP (r, (setGP, setFP, setCC)) = (setGP, (SL.enter (r, setFP)), setCC)
   and addCC (r, (setGP, setFP, setCC)) = (setGP, setFP, (SL.enter (r, setCC)))
   and getCellGP (setGP, setFP, setCC) = setGP
   and getCellFP (setGP, setFP, setCC) = setFP
   and getCellCC (setGP, setFP, setCC) = setCC
   and updateCellGP ((setGP, setFP, setCC), r) = (r, setFP, setCC)
   and updateCellFP ((setGP, setFP, setCC), r) = (setGP, r, setCC)
   and updateCellCC ((setGP, setFP, setCC), r) = (setGP, setFP, r)
   and cellsetToString (setGP, setFP, setCC) = (printTuple (cellsetnames, [((printSet showGP) setGP), ((printSet showFP) setFP), ((printSet showCC) setCC)]))
   and cellsetToString' regmap = (fn (setGP, setFP, setCC) => (printTuple (cellsetnames, [((printSet showGP) ((map regmap) setGP)), ((printSet showFP) ((map regmap) setFP)), ((printSet showCC) ((map regmap) setCC))]))
                                 )
   and cellsetToRegs (setGP, setFP, setCC) = (setGP @ (setFP @ setCC))
   val addReg = addGP
   val addFreg = addFP

   fun zeroReg _ = NONE
end


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