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 1009 - (download) (annotate)
Wed Jan 9 19:44:22 2002 UTC (17 years, 9 months ago) by george
File size: 5860 byte(s)
	Removed the native COPY and FCOPY instructions
	from all the architectures and replaced it with the
	explicit COPY instruction from the previous commit.

	It is now possible to simplify many of the optimizations
	modules that manipulate copies. This has not been
	done in this change.
(*
 * Hppa specific backend
 *)
structure HppaCG = 
  MachineGen
  ( structure MachSpec   = HppaSpec
    structure CB         = CellsBasis
    structure ClientPseudoOps = HppaClientPseudoOps
    structure PseudoOps  = HppaPseudoOps
    structure Ext        = SMLNJMLTreeExt(* generic extension *)
    structure CpsRegs    = HppaCpsRegs
    structure InsnProps  = HppaProps
    structure Asm        = HppaAsmEmitter
    structure Shuffle    = HppaShuffle

    structure CCalls     = DummyCCallsFn (HppaMLTree)

    structure OmitFramePtr = struct
      exception NotImplemented
      structure CFG=HppaCFG
      structure I=HppaInstr
      val vfp = CpsRegs.vfp
      fun omitframeptr _ = raise NotImplemented
    end

    structure HppaMillicode = HppaMillicode(HppaInstr)

    structure HppaLabelComp = HppaLabelComp(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
		structure CFG = HppaCFG
		structure TS = HppaMLTreeStream
               )
            val costOfMultiply = ref 7
            val costOfDivision = ref 7
           )

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

    structure BackPatch =
       SpanDependencyResolution
         (structure CFG = HppaCFG
	  structure Placement = DefaultBlockPlacement(HppaCFG)
          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 = HppaCFG
          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.INSTR(I.LOAD _)) = true
            | pure(I.INSTR(I.LOADI _)) = true
            | pure(I.INSTR(I.FLOAD _)) = true
            | pure(I.INSTR(I.FLOADX _)) = true
            | pure(I.INSTR(I.ARITH _)) = true
            | pure(I.INSTR(I.ARITHI _)) = true
            | pure(I.INSTR(I.FARITH _)) = true
            | pure(I.INSTR(I.FUNARY _)) = true
            | pure(I.INSTR(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, rss), I.COPY{k=CB.GP, sz, tmp, ...}) = let
	       val tmp = (case (rds, rss) of ([_], [_]) => NONE | _ => tmp)
	     in I.COPY{k=CB.GP, sz=sz, dst=rds, src=rss, tmp=tmp}
	     end

	     (* spill copy temp *)
	     fun spillCopyTmp(an, I.COPY{k=CB.GP, sz, tmp,dst,src, ...},loc) =
		 I.COPY{k=CB.GP, sz=sz,  dst=dst,src=src,
			tmp=SOME(I.Displace{base=sp, 
					    disp= ~(SpillTable.getRegLoc loc)})}

             (* spill register *) 
             fun spillInstr{src,spilledCell,spillLoc,an} =
                 [I.store{st=I.STW, b=sp, 
                          d=I.IMMED(~(SpillTable.getRegLoc spillLoc)), 
                          r=src, mem=spill}]

             (* reload register *) 
             fun reloadInstr{dst,spilledCell,spillLoc,an} =
                 [I.loadi{li=I.LDW, 
                          i=I.IMMED(~(SpillTable.getRegLoc spillLoc)), 
                          r=sp, t=dst, mem=spill}
                 ]

             val mode = RACore.NO_OPTIMIZATION
          end

          structure Float = 
          struct
             val avail = HppaCpsRegs.availF
             val dedicated = HppaCpsRegs.dedicatedF
 
	     fun copy((fds, fss), I.COPY{k=CB.FP, sz, tmp, ...}) = let
	       val tmp =(case (fds, fss) of ([_],[_]) => NONE | _ => tmp)
	     in I.COPY{k=CB.FP, sz=sz, dst=fds, src=fss, tmp=tmp}
	     end

	     fun spillCopyTmp(an, I.COPY{k=CB.FP, sz, tmp,dst,src},loc) =
		 I.COPY{k=CB.FP, sz=sz, dst=dst,src=src,
			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

             val mode = RACore.NO_OPTIMIZATION
          end
         )
  )

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