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/branches/SMLNJ/src/compiler/CodeGen/x86/x86StackSpills.sml
ViewVC logotype

View of /sml/branches/SMLNJ/src/compiler/CodeGen/x86/x86StackSpills.sml

Parent Directory Parent Directory | Revision Log Revision Log


Revision 247 - (download) (annotate)
Sat Apr 17 18:47:13 1999 UTC (20 years, 10 months ago) by monnier
File size: 1402 byte(s)
version 110.16
signature X86STACKSPILLS = sig
  structure I : X86INSTR
  val init : unit -> unit
  val getRegLoc : int -> I.operand
  val getFregLoc : int -> I.operand
end

structure X86StackSpills : X86STACKSPILLS = 
struct
  exception RegSpills 
  structure I = X86Instr

  fun error msg = ErrorMsg.impossible ("X86CG." ^ msg)

  val initialSpillOffset = X86Runtime.spillStart
  val spillOffset = ref initialSpillOffset
  val spillAreaSz = X86Runtime.spillAreaSz
  fun newOffset n =
    if (n > spillAreaSz) then error "newOffset - spill area is too small"
    else spillOffset := n
  
  val spillTbl : Int32.int Intmap.intmap ref = ref(Intmap.new(0, RegSpills))

  fun init () = 
    (spillOffset:=initialSpillOffset; 
     spillTbl:=Intmap.new(16, RegSpills))

  val toInt32 = Int32.fromInt

  fun getRegLoc (reg:int) = let
    val tbl = !spillTbl
  in
    I.Immed
     (Intmap.map tbl reg
	handle RegSpills => let
	  val offset = !spillOffset
	  val i32 = toInt32 offset
	in 
	  newOffset(offset+4);
	  Intmap.add tbl (reg,i32);
	  i32
	end)
  end

  fun getFregLoc freg = let
    val tbl = !spillTbl
  in
    I.Immed
     (Intmap.map tbl freg
	handle RegSpills => let
	  val offset = !spillOffset
	  val fromInt = Word.fromInt
	  val aligned = Word.toIntX(Word.andb(fromInt offset+0w7, fromInt ~8))
	  val i32 = toInt32 aligned
	in
	  newOffset(aligned+8);
	  Intmap.add tbl (freg, i32);
	  i32
	end)
  end
end

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