File: alignment.sml

package info (click to toggle)
smlnj 110.79-8
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, sid
  • size: 82,564 kB
  • sloc: ansic: 32,532; asm: 6,314; sh: 2,296; makefile: 1,821; perl: 1,170; pascal: 295; yacc: 190; cs: 78; python: 77; lisp: 19
file content (41 lines) | stat: -rw-r--r-- 1,404 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
(* alignment.sml --- determine if the allocation pointer should be
 *		     aligned on entry to function.
 *)
signature ALIGNMENT = sig
  val build : CPS.function list -> (int -> bool) 
end

structure Alignment = struct
  structure C = CPS

  exception Alignment

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

  fun build(cluster) = let
    (* SortedList should be replaced by int-binary-set *)
    fun hasFloats(C.RECORD(rk, _, _, e)) = 
	 (case rk of (C.RK_FCONT | C.RK_FBLOCK) => true | _ => hasFloats(e))
      | hasFloats(C.SELECT(_, _, _, _, e)) = hasFloats(e)
      | hasFloats(C.OFFSET(_, _, _, e)) = hasFloats(e)
      | hasFloats(C.APP _) = false
      | hasFloats(C.FIX _) = error "hasFloats: FIX"
      | hasFloats(C.SWITCH(_, _, el)) = let
	  fun iter [] = false
	    | iter(e::el) = hasFloats(e) orelse iter(el)
	in iter el
	end
      | hasFloats(C.BRANCH(_, _, _, e1, e2)) = 
	  hasFloats(e1) orelse hasFloats(e2)
      | hasFloats(C.SETTER(_, _, e)) = hasFloats(e)
      | hasFloats(C.LOOKER(_, _, _, _, e)) = hasFloats(e)
      | hasFloats(C.ARITH(_, _, _, _, e)) = hasFloats(e)
      | hasFloats(C.PURE(C.P.fwrap, _, _, _, _)) = true
      | hasFloats(C.PURE(_, _, _, _, e)) = hasFloats(e)

    fun doFunction((_,f,_,_,e), set) = 
      if hasFloats e then SortedList.enter(f, set) else set
  in SortedList.member (List.foldl doFunction [] cluster)
  end (* build *)
end