Debian Codegraph @

lib/mlrisc-lib/MLRISC/mips/backpatch/mipsJumps.sml

raw
1 (* mipsJumps.sml --- information to resolve jumps.
2 *
3 *)
4 functor MIPSJumps
5 (structure Instr : MIPSINSTR
6 structure Shuffle : MIPSSHUFFLE
7 sharing Shuffle.I = Instr) : SDI_JUMPS =
8 struct
9 structure I = Instr
10 structure C = I.C
11 structure Const = I.Constant
12 structure LE = I.LabelExp
13
14 fun error msg = MLRiscErrorMsg.error("MIPSJumps",msg)
15
16 val branchDelayedArch = true
17
18 fun isSdi instr =
19 let fun opnd (I.Lab _) = true
20 | opnd _ = false
21 in case instr of
22 I.LUI{imm, ...} => opnd imm
23 | I.ARITH{i, ...} => opnd i
24 | I.LOAD{d, ...} => opnd d
25 | I.STORE{d, ...} => opnd d
26 | I.FLOAD{d, ...} => opnd d
27 | I.FSTORE{d, ...} => opnd d
28 | I.J _ => true
29 | I.JR _ => true
30 | I.JAL _ => true
31 | I.JALR _ => true
32 | I.RET _ => true
33 | I.BRANCH _ => true
34 | I.FBRANCH _ => true
35 | I.ANNOTATION{i,...} => isSdi i
36 | _ => false
37 end
38
39 fun minSize(I.COPY _) = 0
40 | minSize(I.FCOPY _) = 0
41 | minSize(I.ANNOTATION{i,...}) = minSize i
42 | minSize _ = 4
43
44 (* max Size is not used for the mips span dependency analysis. *)
45 fun maxSize _ = error "maxSize"
46
47 fun sdiSize(instr, labMap, loc) =
48 let fun branchOffset lab = (labMap lab - loc - 8) div 4
49 fun delay nop = if nop then 8 else 4
50 fun branch(nop, label) = delay nop (* XXX *)
51 in case instr of
52 I.J{nop, lab, ...} => branch(nop,lab)
53 | I.JAL{nop, lab, ...} => branch(nop,lab)
54 | I.BRANCH{nop, lab, ...} => branch(nop,lab)
55 | I.FBRANCH{nop, lab, ...} => branch(nop,lab)
56 | I.JR{nop, ...} => delay nop
57 | I.JALR{nop, ...} => delay nop
58 | I.ANNOTATION{i, ...} => sdiSize(i, labMap, loc)
59 | _ => error "sdiSize"
60 end
61
62 fun expand(instr, size, pos) = error "expand"
63
64 end