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/x86/backpatch/x86Jumps.sml
ViewVC logotype

Diff of /sml/trunk/src/MLRISC/x86/backpatch/x86Jumps.sml

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

revision 1002, Fri Nov 30 17:11:33 2001 UTC revision 1003, Fri Dec 7 02:45:32 2001 UTC
# Line 21  Line 21 
21    
22    fun imm8 i = ~128 <= i andalso i < 128    fun imm8 i = ~128 <= i andalso i < 128
23    
24    fun isSdi instr = let    fun isSdi(I.ANNOTATION{i, ...}) = isSdi i
25        | isSdi(I.LIVE _)             = true
26        | isSdi(I.KILL _)             = true
27        | isSdi(I.INSTR instr) = let
28      fun operand(I.ImmedLabel _) = true      fun operand(I.ImmedLabel _) = true
29        | operand(I.LabelEA _) = true        | operand(I.LabelEA _) = true
30        | operand(I.Displace{disp, ...}) = operand disp        | operand(I.Displace{disp, ...}) = operand disp
# Line 57  Line 60 
60       | I.FILD opnd => operand opnd       | I.FILD opnd => operand opnd
61       | I.FILDL opnd => operand opnd       | I.FILDL opnd => operand opnd
62       | I.FILDLL opnd => operand opnd       | I.FILDLL opnd => operand opnd
      | I.ANNOTATION{i,...} => isSdi i  
63       | _ => false       | _ => false
64    end    end
65        | isSdi _ = error "isSdi"
66    
67      fun minSize(I.ANNOTATION{i, ...}) = minSize i
68        | minSize(I.LIVE _)  = 0
69        | minSize(I.KILL _)  = 0
70        | minSize(I.INSTR i) =
71          (case i
72            of I.JMP _ => 2
73             | I.JCC _ => 2
74             | I.LEA _ => 2
75             |  _ => 1)
76        | minSize _ = error"minSize"
77    
   fun minSize(I.JMP _) = 2  
     | minSize(I.JCC _) = 2  
     | minSize(I.LEA _) = 2  
     | minSize(I.ANNOTATION{i,...}) = minSize i  
     | minSize _ = 1  
78    
79    fun maxSize _ = 12    fun maxSize _ = 12
80    
# Line 74  Line 83 
83      | operand(I.LabelEA le) = Eval.valueOf le      | operand(I.LabelEA le) = Eval.valueOf le
84      | operand _ = error "operand"      | operand _ = error "operand"
85    
86    fun sdiSize(instr, labmap, loc) = let    val encode = MCEmitter.emitInstr
87    
88      fun sdiSize(I.ANNOTATION{i, ...}, labmap, loc) = sdiSize(i, labmap, loc)
89        | sdiSize(I.LIVE _, _, _) = 0
90        | sdiSize(I.KILL _, _, _) = 0
91        | sdiSize(I.INSTR instr, labmap, loc) = let
92      fun branch(opnd, short, long) = let      fun branch(opnd, short, long) = let
93        val offset = operand opnd - loc        val offset = operand opnd - loc
94      in if imm8(offset - 2) then short else long      in if imm8(offset - 2) then short else long
95      end      end
   
     val encode = MCEmitter.emitInstr  
96    in    in
97      case instr      case instr
98      of I.JMP(opnd, _) => branch(opnd, 2, 5)      of I.JMP(opnd, _) => branch(opnd, 2, 5)
99       | I.JCC{opnd, ...} => branch(opnd, 2, 6)       | I.JCC{opnd, ...} => branch(opnd, 2, 6)
100       | I.ANNOTATION{i,...} => sdiSize(i, labmap, loc)           | _ => Word8Vector.length(encode(I.INSTR instr))
      | _ => Word8Vector.length(encode(instr))  
101    end  (*sdiSize*)    end  (*sdiSize*)
102        | sdiSize _ = error "sdiSize"
103    
104    fun expand(instr, size, loc) =    fun expand(I.ANNOTATION{i,...}, size, loc) = expand(i, size, loc)
105      case instr      | expand(I.LIVE _, _, _) = []
106      of I.JMP(opnd, labs)  => [I.JMP(I.Relative(operand opnd-loc), labs)]      | expand(I.KILL _, _, _) = []
107        | expand(I.INSTR instr, size, loc) =
108           (case instr
109            of I.JMP(opnd, labs)  => [I.jmp(I.Relative(operand opnd-loc), labs)]
110       | I.JCC{cond, opnd} =>       | I.JCC{cond, opnd} =>
111          [I.JCC{cond=cond, opnd=I.Relative(operand opnd-loc)}]              [I.jcc{cond=cond, opnd=I.Relative(operand opnd-loc)}]
112       | I.ANNOTATION{i,...} => expand(i, size, loc)           | opnd => [I.INSTR opnd])
113       | opnd => [opnd]      | expand _ = error "expand"
114  end  end
115    

Legend:
Removed from v.1002  
changed lines
  Added in v.1003

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