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 731 - (download) (annotate)
Fri Nov 10 22:57:45 2000 UTC (18 years, 11 months ago) by leunga
File size: 8009 byte(s)

A new x86 floating point code generator.  By default it is off.
See HISTORY for details.   CVS tag=leunga-20001110-new-x86-fp
(*
 * This file was automatically generated by MDGen (v2.0)
 * from the machine description file "x86/x86.md".
 *)


signature X86CELLS =
sig
   datatype mycellkind =
     GP
   | FP
   | CC
   | MEM
   | CTRL
   | UNKNOWN
   withtype cellset = (int list * int list * int list)
   include CELLS_BASIS where type cellkind = mycellkind
   val showGP : cell -> string
   val showFP : cell -> string
   val showCC : cell -> string
   val showMEM : cell -> string
   val showCTRL : cell -> string
   val showGPWithType : (cell * ty) -> string
   val showFPWithType : (cell * ty) -> string
   val showCCWithType : (cell * ty) -> string
   val showMEMWithType : (cell * ty) -> string
   val showCTRLWithType : (cell * ty) -> string
   val eax : cell
   val ecx : cell
   val edx : cell
   val ebx : cell
   val esp : cell
   val ebp : cell
   val esi : cell
   val edi : cell
   val stackptrR : cell
   val ST : int -> cell
   val asmTmpR : cell
   val fasmTmp : cell
   val addGP : (cell * cellset) -> cellset
   val addFP : (cell * cellset) -> cellset
   val addCC : (cell * cellset) -> cellset
   val zeroReg : cellkind -> cell option
   val toString : cellkind -> cell -> string
   val toStringWithType : cellkind -> cell * ty -> string
   val addCell : cellkind -> cell * cellset -> cellset
   val rmvCell : cellkind -> cell * cellset -> cellset
   val addReg : cell * cellset -> cellset
   val rmvReg : cell * cellset -> cellset
   val addFreg : cell * cellset -> cellset
   val rmvFreg : cell * cellset -> cellset
   val getCell : cellkind -> cellset -> cell list
   val updateCell : cellkind -> cellset * cell list -> cellset
   val empty : cellset
   val cellsetToString : cellset -> string
   val cellsetToString' : (cell -> cell) -> cellset -> string
   val cellsetToCells : cellset -> cell list
end

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

   open MyCellsBasis
   val offsetGP = 0
   and offsetFP = 32
   and offsetCC = 64
   and offsetMEM = 64
   and offsetCTRL = 64
   val eax = (0 + offsetGP)
   val ecx = (1 + offsetGP)
   val edx = (2 + offsetGP)
   val ebx = (3 + offsetGP)
   val esp = (4 + offsetGP)
   val ebp = (5 + offsetGP)
   val esi = (6 + offsetGP)
   val edi = (7 + offsetGP)
   val stackptrR = (4 + offsetGP)
   val ST = (fn x => (x + offsetFP)
            )
   val asmTmpR = ~ 1
   val fasmTmp = ~ 1
   fun zeroReg _ = NONE
   fun showGPWithType (r, ty) = (fn (0, 8) => "%al"
                                  | (0, 16) => "%ax"
                                  | (0, 32) => "%eax"
                                  | (1, 8) => "%cl"
                                  | (1, 16) => "%cx"
                                  | (1, 32) => "%ecx"
                                  | (2, 8) => "%dl"
                                  | (2, 16) => "%dx"
                                  | (2, 32) => "%edx"
                                  | (3, 8) => "%bl"
                                  | (3, 16) => "%bx"
                                  | (3, 32) => "%ebx"
                                  | (4, 16) => "%sp"
                                  | (4, 32) => "%esp"
                                  | (5, 16) => "%bp"
                                  | (5, 32) => "%ebp"
                                  | (6, 16) => "%si"
                                  | (6, 32) => "%esi"
                                  | (7, 16) => "%di"
                                  | (7, 32) => "%edi"
                                  | (r, _) => "%" ^ (Int.toString r)
                                ) (r, ty)
   and showFPWithType (r, ty) = let
          val r = (if (r <= 63)
                 then (r - 32)
                 else r)
       in (fn (f, _) => (if (f < 8)
                 then (("%st(" ^ (Int.toString f)) ^ ")")
                 else ("%f" ^ (Int.toString f)))
          ) (r, ty)
       end

   and showCCWithType (r, ty) = let
          val r = (if (r <= 63)
                 then (r - 64)
                 else r)
       in (fn _ => "cc"
          ) (r, ty)
       end

   and showMEMWithType (r, ty) = let
          val r = (if (r <= 63)
                 then (r - 64)
                 else r)
       in (fn (r, _) => "m" ^ (Int.toString r)
          ) (r, ty)
       end

   and showCTRLWithType (r, ty) = let
          val r = (if (r <= 63)
                 then (r - 64)
                 else r)
       in (fn (r, _) => "ctrl" ^ (Int.toString r)
          ) (r, ty)
       end

   fun showGP r = showGPWithType (r, 32)
   fun showFP r = showFPWithType (r, 80)
   fun showCC r = showCCWithType (r, 32)
   fun showMEM r = showMEMWithType (r, 8)
   fun showCTRL r = showCTRLWithType (r, 8)
   fun toStringWithType GP = showGPWithType
     | toStringWithType FP = showFPWithType
     | toStringWithType CC = showCCWithType
     | toStringWithType MEM = showMEMWithType
     | toStringWithType CTRL = showCTRLWithType
     | toStringWithType UNKNOWN = (fn (r, ty) => "unknown" ^ (Int.toString r)
                                  )
   fun toString GP = showGP
     | toString FP = showFP
     | toString CC = showCC
     | toString MEM = showMEM
     | toString CTRL = showCTRL
     | toString UNKNOWN = (fn r => "unknown" ^ (Int.toString r)
                          )
   val cellsetnames = ["GP", "FP", "CC"]
   val empty = ([], [], [])
   fun addCell GP = addGP
     | addCell FP = addFP
     | addCell CC = addCC
     | addCell _ = error "addCell"
   and rmvCell GP = rmvGP
     | rmvCell FP = rmvFP
     | rmvCell CC = rmvCC
     | rmvCell _ = error "rmvCell"
   and getCell GP = getGP
     | getCell FP = getFP
     | getCell CC = getCC
     | getCell _ = error "getCell"
   and updateCell GP = updateGP
     | updateCell FP = updateFP
     | updateCell CC = updateCC
     | 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 rmvGP (r, (setGP, setFP, setCC)) = (SL.rmv (r, setGP), setFP, setCC)
   and rmvFP (r, (setGP, setFP, setCC)) = (setGP, SL.rmv (r, setFP), setCC)
   and rmvCC (r, (setGP, setFP, setCC)) = (setGP, setFP, SL.rmv (r, setCC))
   and getGP (setGP, setFP, setCC) = setGP
   and getFP (setGP, setFP, setCC) = setFP
   and getCC (setGP, setFP, setCC) = setCC
   and updateGP ((setGP, setFP, setCC), r) = (r, setFP, setCC)
   and updateFP ((setGP, setFP, setCC), r) = (setGP, r, setCC)
   and updateCC ((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) => cellsetToString (map regmap setGP, map regmap setFP, map regmap setCC)
                                 )
   and cellsetToCells (setGP, setFP, setCC) = setGP @ (setFP @ setCC)
   val addReg = addGP
   val addFreg = addFP
   val rmvReg = rmvGP
   val rmvFreg = rmvFP
end


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