Debian Codegraph @

lib/mlrisc-lib/MLRISC/mips/instructions/mipsFreqProps.sml

raw
1 (*
2 * Extract frequency information from the MIPS architecture
3 *
4 * -- Allen
5 *)
6
7 functor MIPSFreqProps(MIPSInstr : MIPSINSTR) : FREQUENCY_PROPERTIES =
8 struct
9
10 structure I = MIPSInstr
11
12 fun branchProb(I.ANNOTATION{a, i, ...}) =
13 (case #peek MLRiscAnnotations.BRANCH_PROB a of
14 SOME b => b
15 | NONE => branchProb i
16 )
17 | branchProb(I.BRANCH{likely,...}) = 50 (* default *)
18 | branchProb(I.FBRANCH{likely,...}) = 50 (* default *)
19 | branchProb(I.J _) = 100 (* unconditional *)
20 | branchProb(I.JR{labels,...}) = 100 div length labels (* assume equal prob *)
21 | branchProb _ = 0 (* non-branch *)
22
23 end