Home My Page Projects Code Snippets Project Openings SML/NJ
Summary Activity Forums Tracker Lists Tasks Docs Surveys News SCM Files

SCM Repository

[smlnj] Annotation of /sml/trunk/src/compiler/CodeGen/cpscompile/regmaskConst.sml
ViewVC logotype

Annotation of /sml/trunk/src/compiler/CodeGen/cpscompile/regmaskConst.sml

Parent Directory Parent Directory | Revision Log Revision Log


Revision 168 - (view) (download)

1 : monnier 16 (* regmaskConst.sml --- the only special constant used is a list of registers.
2 :     *
3 :     * COPYRIGHT (c) 1996 AT&T Bell Laboratories.
4 :     *
5 :     *)
6 :    
7 :     functor RegMaskConst(structure RegMask : REGMASK) : CONST_TYPE =
8 :     struct
9 :     datatype root = Reg of int | Mem of int
10 :     datatype const = REGLIST of root list * int Intmap.intmap
11 :    
12 :     fun toString(REGLIST(regs, regmap)) = let
13 :     val lookup = Intmap.map regmap
14 :     fun doRegs(Reg(r)::rest, acc) = let
15 :     val reg = lookup r handle _ => r
16 :     in doRegs(rest, "r" ^ Int.toString reg::acc)
17 :     end
18 :     | doRegs([], acc) = "("::acc
19 :     in concat(doRegs(regs, [")"]))
20 :     end
21 :    
22 :     fun valueOf(REGLIST(regs, regmap)) = let
23 : monnier 167 val lookup = Intmap.map regmap
24 : monnier 16 fun add(Reg r, mask) = RegMask.regMask(lookup r, mask)
25 :     | add(Mem m, mask) = RegMask.memMask(m, mask)
26 :     in Word.toIntX (List.foldl add 0w0 regs)
27 :     end
28 :     end
29 :    
30 :     (*
31 : monnier 167 * $Log: regmaskConst.sml,v $
32 :     * Revision 1.1.1.1 1998/04/08 18:39:54 george
33 :     * Version 110.5
34 :     *
35 : monnier 16 *)

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