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

SCM Repository

[smlnj] Diff of /sml/trunk/src/MLRISC/alpha32/alpha32Props.sml
ViewVC logotype

Diff of /sml/trunk/src/MLRISC/alpha32/alpha32Props.sml

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 93, Tue May 12 21:56:22 1998 UTC revision 106, Thu May 28 21:30:17 1998 UTC
# Line 6  Line 6 
6    
7  functor Alpha32Props  functor Alpha32Props
8    (structure Alpha32Instr : ALPHA32INSTR    (structure Alpha32Instr : ALPHA32INSTR
9     val exnptrR : int list) : INSN_PROPERTIES =     structure Shuffle : ALPHA32SHUFFLE
10         sharing Shuffle.I = Alpha32Instr):INSN_PROPERTIES =
11  struct  struct
12      structure I = Alpha32Instr      structure I = Alpha32Instr
13      structure C = I.C      structure C = I.C
14      structure LE = LabelExp      structure LE = LabelExp
15    
16        exception NegateConditional
17    
18      fun error msg = MLRiscErrorMsg.impossible ("alpha32Props."^msg)      fun error msg = MLRiscErrorMsg.impossible ("alpha32Props."^msg)
19    
20      val zeroR = 31      val zeroR = 31
# Line 19  Line 22 
22      datatype kind = IK_JUMP | IK_NOP | IK_INSTR      datatype kind = IK_JUMP | IK_NOP | IK_INSTR
23      datatype target = LABELLED of Label.label | FALLTHROUGH | ESCAPES      datatype target = LABELLED of Label.label | FALLTHROUGH | ESCAPES
24    
25       (*========================================================================
26        *  Instruction Kinds
27        *========================================================================*)
28      fun instrKind(I.BRANCH _)  = IK_JUMP      fun instrKind(I.BRANCH _)  = IK_JUMP
29        | instrKind(I.FBRANCH _) = IK_JUMP        | instrKind(I.FBRANCH _) = IK_JUMP
30        | instrKind(I.JMPL _)    = IK_JUMP        | instrKind(I.JMPL _)    = IK_JUMP
31        | instrKind _            = IK_INSTR        | instrKind _            = IK_INSTR
32    
33      fun branchTargets(I.BRANCH(I.BR, _, lab)) = [LABELLED lab]      fun moveInstr(I.COPY _)  = true
34        | branchTargets(I.BRANCH(_, _, lab))  = [LABELLED lab, FALLTHROUGH]        | moveInstr(I.FCOPY _) = true
35        | branchTargets(I.FBRANCH(_, _, lab)) = [LABELLED lab, FALLTHROUGH]        | moveInstr _          = false
       | branchTargets(I.JMPL(_,[]))       = [ESCAPES]  
       | branchTargets(I.JMPL(_,labs))     = map LABELLED labs  
       | branchTargets _ = error "branchTargets"  
36    
37        val nop =
38          fn () => I.OPERATE{oper=I.BIS, ra=zeroR, rb=I.REGop zeroR, rc=zeroR}
39    
40       (*========================================================================
41        *  Parallel Move
42        *========================================================================*)
43      fun moveTmpR(I.COPY{tmp=SOME(I.Direct r), ...}) = SOME r      fun moveTmpR(I.COPY{tmp=SOME(I.Direct r), ...}) = SOME r
44        | moveTmpR(I.FCOPY{tmp=SOME(I.FDirect f), ...}) = SOME f        | moveTmpR(I.FCOPY{tmp=SOME(I.FDirect f), ...}) = SOME f
45        | moveTmpR _ = NONE        | moveTmpR _ = NONE
# Line 39  Line 48 
48        | moveDstSrc(I.FCOPY{dst, src, ...}) = (dst, src)        | moveDstSrc(I.FCOPY{dst, src, ...}) = (dst, src)
49        | moveDstSrc _ = error "moveDstSrc"        | moveDstSrc _ = error "moveDstSrc"
50    
51      fun moveInstr(I.COPY _) = true      fun copy{src, dst} =
52        | moveInstr(I.FCOPY _) = true        I.COPY{src=src, dst=dst, impl=ref NONE,
53                 tmp=case src of [_] => NONE | _ => SOME(I.Direct(C.newReg()))}
54    
55        fun fcopy{src,dst} = let
56          fun trans r = if r >= 32 andalso r < 64 then r-32 else r
57          val src = map trans src
58          val dst = map trans dst
59        in
60          I.FCOPY{src=src,dst=dst,impl=ref NONE,
61                  tmp=case src of [_] => NONE | _   => SOME(I.FDirect(C.newFreg()))}
62        end
63    
64  (* Technically these are valid move instructions however they are      fun splitCopies{regmap,insns} = let
65     not emitted by the code generator when emitting a move.        val shuffle = Shuffle.shuffle
66     I expect them to occur rarely so don't bother with them.        val shufflefp = Shuffle.shufflefp
67        | moveInstr(I.FOPERATE{oper=I.CPYS, fa, fb, ...})       = fa = fb        fun scan([],is') = rev is'
68        | moveInstr(I.OPERATE{oper=I.BIS, rb=I.REGop 31, ...})  = true          | scan(I.COPY{dst,src,tmp,...}::is,is') =
69        | moveInstr(I.ADDL(_,I.IMMop 0,_))    = true              scan(is,shuffle{regMap=regmap,src=src,dst=dst,temp=tmp}@is')
70        | moveInstr(I.BIS(31,_,_))            = true          | scan(I.FCOPY{dst,src,tmp,...}::is,is') =
71        | moveInstr(I.SUBL(_,I.IMMop 0, _))   = true              scan(is,shufflefp{regMap=regmap,src=src,dst=dst,temp=tmp}@is')
72        | moveInstr(I.ADDL(_,I.REGop 31,_))   = true          | scan(i::is,is') = scan(is,i::is')
73        | moveInstr(I.SUBL(_,I.REGop 31,_))   = true      in scan(insns,[])
74        | moveInstr(I.LDA{d=I.IMMop 0, ...})  = true      end
       | moveInstr(I.LDAH{d=I.IMMop 0, ...}) = true  
 *)  
       | moveInstr _                       = false  
75    
76      val nop =     (*========================================================================
77        fn () => I.OPERATE{oper=I.BIS, ra=zeroR, rb=I.REGop zeroR, rc=zeroR}      *  Branches and Calls/Returns
78        *========================================================================*)
79        fun branchTargets(I.BRANCH(I.BR, _, lab)) = [LABELLED lab]
80          | branchTargets(I.BRANCH(_, _, lab))  = [LABELLED lab, FALLTHROUGH]
81          | branchTargets(I.FBRANCH(_, _, lab)) = [LABELLED lab, FALLTHROUGH]
82          | branchTargets(I.JMPL(_,[]))       = [ESCAPES]
83          | branchTargets(I.JMPL(_,labs))     = map LABELLED labs
84          | branchTargets _ = error "branchTargets"
85    
86      (* Resource usage *)      fun jump label = I.BRANCH(I.BR,31,label)
87    
88        fun setTargets(I.BRANCH(I.BR,0,_),[L]) = I.BRANCH(I.BR,0,L)
89          | setTargets(I.BRANCH(b,r,_),[F,T])  = I.BRANCH(b,r,T)
90          | setTargets(I.FBRANCH(b,r,_),[F,T]) = I.FBRANCH(b,r,T)
91          | setTargets(I.JMPL(x,_),labs)       = I.JMPL(x,labs)
92          | setTargets(i,_) = i
93    
94        fun negateConditional br = let
95          fun revBranch I.BEQ  = I.BNE
96            | revBranch I.BGE  = I.BLT
97            | revBranch I.BGT  = I.BLE
98            | revBranch I.BLE  = I.BGT
99            | revBranch I.BLT  = I.BGE
100            | revBranch I.BLBC = I.BLBS
101            | revBranch I.BLBS = I.BLBC
102            | revBranch _ = raise NegateConditional
103        in
104          case br
105          of I.BRANCH(br,r,label) => I.BRANCH(revBranch br,r,label)
106           | I.FBRANCH(br,r,label) => I.FBRANCH(revBranch br,r,label)
107           | _ => raise NegateConditional
108        end
109    
110       (*========================================================================
111        *  Definition and use (for register allocation mainly)
112        *========================================================================*)
113      fun defUseR instr =      fun defUseR instr =
114        let        let
115          fun Oper {oper, ra, rb=I.REGop rb, rc} = ([rc], [ra, rb])          fun Oper {oper, ra, rb=I.REGop rb, rc} = ([rc], [ra, rb])
116            | Oper {oper, ra, rb, rc} = ([rc], [ra])            | Oper {oper, ra, rb, rc} = ([rc], [ra])
117          fun FMem (freg, (rd, _)) = ([], [rd])          fun FMem (freg, (rd, _)) = ([], [rd])
118          fun trap (def,use) =(def, exnptrR @ use)          fun trap (def,use) =(def, use)
119        in        in
120          case instr of          case instr of
121            (* load/store instructions *)            (* load/store instructions *)
# Line 115  Line 164 
164        | I.JSR(_,def,use)             => (#2 def,#2 use)        | I.JSR(_,def,use)             => (#2 def,#2 use)
165        | _ => ([],[])        | _ => ([],[])
166    
167        fun defUse C.GP = defUseR
168      (* These numbers are true of the DECchip 21064-AA implementation. *)        | defUse C.FP = defUseF
169      (* Load class *)        | defUse _ = error "defUse"
     fun latency(I.LOAD _)       = 5  
       | latency(I.FLOAD _)      = 5  
   
       | latency(I.OPERATE{oper, ...}) =  
          (case oper  
           of I.SRA      => 2  
            | I.SRL      => 2  
            | I.SLL      => 2  
            | I.INSBL    => 2  
            | I.EXTBL    => 2  
            | I.EXTQH    => 2  
            | I.MSKBL    => 2  
            | I.MSKLH    => 2  
            | I.CMPULE   => 3  
            | I.CMPULT   => 3  
            | I.CMPEQ    => 3  
            | I.CMPLE    => 3  
            | I.CMPLT    => 3  
            | I.MULL     => 21  
            | _ => 1  
           (*esac*))  
       | latency (I.OPERATEV{oper=I.MULLV, ...}) = 21  
   
       (* Floating point *)  
       | latency(I.FOPERATEV{oper=I.DIVT, ...}) = 63  
       | latency(I.FOPERATEV _) = 6  
       | latency(I.FOPERATE _)  = 6  
   
       | latency(I.CALL_PAL _)   = 30  
   
       | latency _               = 1  
170  end  end
171    
172    
   
173  (*  (*
174   * $Log: alpha32Props.sml,v $   * $Log: alpha32Props.sml,v $
175     * Revision 1.2  1998/05/19 15:42:12  george
176     *   Added a whole bunch of functions to support global scheduling.
177     *
178   * Revision 1.1.1.1  1998/04/08 18:39:01  george   * Revision 1.1.1.1  1998/04/08 18:39:01  george
179   * Version 110.5   * Version 110.5
180   *   *

Legend:
Removed from v.93  
changed lines
  Added in v.106

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