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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 228 - (view) (download)

1 : monnier 16 (* PseudoOpsBig.sml -- pseudo ops for big endian machines.
2 :     *
3 :     * COPYRIGHT (c) 1996 AT&T Bell Laboratories.
4 :     *
5 :     *)
6 :    
7 :     functor PseudoOpsBig(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 w = (emitByte((w >> 0w8) & 0w255); emitByte(w & 0w255))
29 : monnier 223 fun emitLongX n = let val w = itow n
30 : monnier 16 in emitWord(w ~>> 0w16); emitWord(w & 0w65535)
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, ...}, loc) = 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: pseudoOpsBig.sml,v $
52 :     * Revision 1.3 1998/11/18 03:53:09 jhr
53 :     * New array representations.
54 :     *
55 :     * Revision 1.2 1998/10/28 18:20:40 jhr
56 :     * Removed code generator support for STRING/REAL constants.
57 :     *
58 :     * Revision 1.1.1.1 1998/04/08 18:39:54 george
59 :     * Version 110.5
60 :     *
61 : monnier 16 *)

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