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/pseudoOpsLittle.sml
ViewVC logotype

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 228 - (view) (download)

1 : monnier 16 (* PseudoOpsLittle.sml -- pseudo ops for the little endian machines
2 :     *
3 :     * COPYRIGHT (c) 1996 AT&T Bell Laboratories.
4 :     *
5 :     *)
6 :    
7 :     functor PseudoOpsLittle(M: MACH_SPEC) = struct
8 :     structure T = M.ObjDesc
9 :    
10 : monnier 223 datatype pseudo_op = JUMPTABLE of {base:Label.label,targets:Label.label list}
11 : monnier 16
12 :     val >> = Word.>>
13 :     val ~>> = Word.~>>
14 :     val & = Word.andb
15 :     infix >> ~>> &
16 :     val itow = Word.fromInt
17 :    
18 :     (* since we never compile assembly code, we don't really care
19 :     * about this, but it is good enough for debugging purposes.
20 :     *)
21 : monnier 223 fun toString (JUMPTABLE{base, targets}) =
22 : monnier 16 Label.nameOf base ^ ":\t.jumptable " ^
23 :     List.foldr (op ^) "" (map (fn l => Label.nameOf l ^ " ") targets) ^
24 :     "\n"
25 :    
26 : monnier 223 fun emitValue{pOp = JUMPTABLE{base, targets}, loc, emit} = let
27 : monnier 16 fun emitByte n = emit(Word8.fromLargeWord(Word.toLargeWord n))
28 :     fun emitWord n = (emitByte(n & 0w255); emitByte((n >> 0w8) & 0w255))
29 : monnier 223 fun emitLongX n = let val w = itow n
30 : monnier 16 in emitWord(w & 0w65535); emitWord(w ~>> 0w16)
31 :     end
32 : monnier 223 val baseOff = Label.addrOf base
33 :     fun emitOffset lab = emitLongX(Label.addrOf lab - baseOff)
34 : monnier 16 in
35 : monnier 223 app emitOffset targets
36 : monnier 16 end
37 :    
38 :     fun align n = Word.toIntX(Word.andb(0w7+Word.fromInt n, Word.notb 0w7))
39 :    
40 : monnier 223 fun sizeOf (JUMPTABLE {targets, ...}, _) = 4 * length targets
41 : monnier 16
42 : monnier 223 fun adjustLabels (JUMPTABLE{base, ...}, loc) = Label.setAddr(base, loc)
43 :    
44 : monnier 16 end
45 :    
46 :    
47 :    
48 :    
49 :    
50 :     (*
51 : monnier 223 * $Log: pseudoOpsLittle.sml,v $
52 :     * Revision 1.6 1998/11/18 03:53:10 jhr
53 :     * New array representations.
54 :     *
55 :     * Revision 1.5 1998/10/28 18:20:41 jhr
56 :     * Removed code generator support for STRING/REAL constants.
57 :     *
58 :     * Revision 1.4 1998/05/23 14:09:19 george
59 :     * Fixed RCS keyword syntax
60 :     *
61 : monnier 16 *)

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