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/compiler/CodeGen/hppa/hppaCG.sml
ViewVC logotype

View of /sml/trunk/src/compiler/CodeGen/hppa/hppaCG.sml

Parent Directory Parent Directory | Revision Log Revision Log


Revision 744 - (download) (annotate)
Fri Dec 8 04:11:42 2000 UTC (19 years, 8 months ago) by leunga
File size: 5411 byte(s)

   A CVS update record!

   Changed type cell from int to datatype, and numerous other changes.
   Affect every client of MLRISC.  Lal says this can be bootstrapped on all
   machines.  See smlnj/HISTORY for details.

   Tag:  leunga-20001207-cell-monster-hack
(*
 * Hppa specific backend
 *)
structure HppaCG = 
  MachineGen
  ( structure MachSpec   = HppaSpec
    structure PseudoOps  = HppaPseudoOps
    structure CpsRegs    = HppaCpsRegs
    structure InsnProps  = HppaProps
    structure Asm        = HppaAsmEmitter
    structure Shuffle    = HppaShuffle

    structure HppaMillicode =
      HppaMillicode(structure MLTree=HppaMLTree
                    structure Instr=HppaInstr)

    structure HppaLabelComp =
      HppaLabelComp(structure MLTree=HppaMLTree
                    structure Instr=HppaInstr)

    structure MLTreeComp=
       Hppa(structure HppaInstr = HppaInstr
            structure HppaMLTree = HppaMLTree
            structure MilliCode=HppaMillicode
            structure LabelComp=HppaLabelComp
            structure ExtensionComp = SMLNJMLTreeExtComp
               (structure I = HppaInstr
                structure T = HppaMLTree
               )
            val costOfMultiply = ref 7
            val costOfDivision = ref 7
           )

    structure Jumps =
       HppaJumps(structure Instr=HppaInstr
                 structure Shuffle=HppaShuffle)

    structure BackPatch =
       SpanDependencyResolution
         (structure Flowgraph = HppaFlowGraph
          structure Jumps     = Jumps
          structure Emitter   = HppaMCEmitter
          structure DelaySlot = HppaDelaySlots
             (structure I=HppaInstr
              structure P=InsnProps)
          structure Props = InsnProps
         )

    structure RA = 
       RISC_RA
         (structure I         = HppaInstr
          structure Flowgraph = HppaFlowGraph
          structure InsnProps = InsnProps 
          structure Rewrite   = HppaRewrite(HppaInstr) 
          structure Asm       = HppaAsmEmitter
          structure SpillHeur = ChaitinSpillHeur
          structure Spill     = RASpill(structure InsnProps = InsnProps
                                        structure Asm = HppaAsmEmitter)

          (* NOTE: the spill offset grows backwards on the stack! 
           *)
          structure SpillTable = SpillTable(HppaSpec)

          val beginRA = SpillTable.spillInit

          val architecture = HppaSpec.architecture

          val sp        = I.C.stackptrR
          val spill     = CPSRegions.spill
          val tmpR      = I.C.asmTmpR
          val itow      = Word.fromInt
          val wtoi      = Word.toIntX
          fun low11(n)  = wtoi(Word.andb(itow n, 0wx7ff))
          fun high21(n) = wtoi(Word.~>>(itow n, 0w11))

          fun pure(I.LOAD _) = true
            | pure(I.LOADI _) = true
            | pure(I.FLOAD _) = true
            | pure(I.FLOADX _) = true
            | pure(I.ARITH _) = true
            | pure(I.ARITHI _) = true
            | pure(I.FARITH _) = true
            | pure(I.FUNARY _) = true
            | pure(I.FCNV _) = true
            | pure(I.ANNOTATION{i,...}) = pure i
            | pure _ = false
 
          (* make copy *) 
          structure Int =
          struct
             val avail = HppaCpsRegs.availR
             val dedicated = HppaCpsRegs.dedicatedR

             fun copy((rds as [_], rss as [_]), _) =
                 I.COPY{dst=rds, src=rss, impl=ref NONE, tmp=NONE}
               | copy((rds, rss), I.COPY{tmp, ...}) =
                 I.COPY{dst=rds, src=rss, impl=ref NONE, tmp=tmp}

             (* spill copy temp *) 
             fun spillCopyTmp(_, I.COPY{dst,src,tmp,impl},loc) =
                 I.COPY{dst=dst, src=src, impl=impl,
                        tmp=SOME(I.Displace{base=sp, 
                                           disp= ~(SpillTable.getRegLoc loc)})}

             (* spill register *) 
             fun spillInstr(_, r,loc) =
                 [I.STORE{st=I.STW, b=sp, 
                          d=I.IMMED(~(SpillTable.getRegLoc loc)), 
                          r=r, mem=spill}]

             (* reload register *) 
             fun reloadInstr(_, t,loc) =
                 [I.LOADI{li=I.LDW, i=I.IMMED(~(SpillTable.getRegLoc loc)), 
                          r=sp, t=t, mem=spill}
                 ]
          end

          structure Float = 
          struct
             val avail = HppaCpsRegs.availF
             val dedicated = HppaCpsRegs.dedicatedF
 
             fun copy((fds as [_], fss as [_]), _) =
                 I.FCOPY{dst=fds, src=fss, impl=ref NONE, tmp=NONE}
               | copy((fds, fss), I.FCOPY{tmp, ...}) =
                 I.FCOPY{dst=fds, src=fss, impl=ref NONE, tmp=tmp}
   
             fun spillCopyTmp(_,I.FCOPY{dst,src,tmp,impl},loc) =
                 I.FCOPY{dst=dst, src=src, impl=impl,
                        tmp=SOME(I.Displace{base=sp, 
                                        disp= ~(SpillTable.getFregLoc loc)})}
   
             fun spillInstr(_,r,loc) =
             let val offset = SpillTable.getFregLoc loc
             in  [I.LDIL{i=I.IMMED(high21(~offset)), t=tmpR},
                  I.LDO{i=I.IMMED(low11(~offset)), b=tmpR, t=tmpR},
                  I.FSTOREX{fstx=I.FSTDX, b=sp, x=tmpR, r=r, mem=spill}
                 ]
             end
   
             fun reloadInstr(_,t,loc) =
             let val offset = SpillTable.getFregLoc loc
             in  [I.LDIL{i=I.IMMED(high21(~offset)), t=tmpR}, 
                  I.LDO{i=I.IMMED(low11(~offset)), b=tmpR, t=tmpR},
                  I.FLOADX{flx=I.FLDDX, b=sp, x=tmpR, t=t, mem=spill} 
                 ]
             end
          end
         )
  )

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