| 1 |
(* |
| 2 |
* WARNING: This file was automatically generated by MDLGen (v3.0) |
| 3 |
* from the machine description file "mips/mips.mdl". |
| 4 |
* DO NOT EDIT this file directly |
| 5 |
*) |
| 6 |
|
| 7 |
|
| 8 |
functor MIPSRTLProps(structure Instr : MIPSINSTR |
| 9 |
structure RegionProps : REGION_PROPERTIES |
| 10 |
structure RTL : MLTREE_RTL |
| 11 |
structure OperandTable : OPERAND_TABLE where I = Instr |
| 12 |
structure Asm : INSTRUCTION_EMITTER where I = Instr |
| 13 |
sharing Instr.T = RTL.T |
| 14 |
) : RTL_PROPERTIES = |
| 15 |
struct |
| 16 |
structure I = Instr |
| 17 |
structure C = I.C |
| 18 |
structure RTL = RTL |
| 19 |
structure T = RTL.T |
| 20 |
structure OT = OperandTable |
| 21 |
|
| 22 |
datatype value = CELL of C.cell |
| 23 |
| OPERAND of I.operand |
| 24 |
|
| 25 |
fun error msg = MLRiscErrorMsg.error("MIPSRTLProps",msg) |
| 26 |
fun bug(msg,instr) = |
| 27 |
let val Asm.S.STREAM{emit, ...} = Asm.makeStream [] |
| 28 |
in emit instr; error msg end |
| 29 |
structure MIPSRTL = MIPSRTL |
| 30 |
(structure RTL = RTL |
| 31 |
structure C = C |
| 32 |
) |
| 33 |
|
| 34 |
structure Arch = struct |
| 35 |
local |
| 36 |
val TMP0 = {rt=T.PARAM 0, b=T.PARAM 1, d=T.PARAM 0, mem=T.PARAM 0} |
| 37 |
in |
| 38 |
val LB = RTL.new (MIPSRTL.LB TMP0) |
| 39 |
val LBU = RTL.new (MIPSRTL.LBU TMP0) |
| 40 |
val LH = RTL.new (MIPSRTL.LH TMP0) |
| 41 |
val LHU = RTL.new (MIPSRTL.LHU TMP0) |
| 42 |
val LW = RTL.new (MIPSRTL.LW TMP0) |
| 43 |
val LD = RTL.new (MIPSRTL.LD TMP0) |
| 44 |
end |
| 45 |
end |
| 46 |
|
| 47 |
fun rtl instr = |
| 48 |
let fun undefined() = bug("rtl",instr) |
| 49 |
fun query (I.LOAD{l, rt, b, d, mem}) = |
| 50 |
(case l of |
| 51 |
I.LD => Arch.LD |
| 52 |
| I.LW => Arch.LW |
| 53 |
| I.LH => Arch.LH |
| 54 |
| I.LHU => Arch.LHU |
| 55 |
| I.LB => Arch.LB |
| 56 |
| I.LBU => Arch.LBU |
| 57 |
| _ => undefined () |
| 58 |
) |
| 59 |
| query _ = undefined () |
| 60 |
in query instr |
| 61 |
end |
| 62 |
fun defUse valueNumberingMethods instr = |
| 63 |
let fun undefined() = bug("defUse",instr) |
| 64 |
(* methods for computing value numbers *) |
| 65 |
val OT.VALUE_NUMBERING |
| 66 |
{int, int32, intinf, word, word32, operand, ...} = |
| 67 |
valueNumberingMethods |
| 68 |
(* methods for type conversion *) |
| 69 |
fun get_int(x,L) = CELL(int x)::L |
| 70 |
fun get_int32(x,L) = CELL(int32 x)::L |
| 71 |
fun get_intinf(x,L) = CELL(intinf x)::L |
| 72 |
fun get_word(x,L) = CELL(word x)::L |
| 73 |
fun get_word32(x,L) = CELL(word32 x)::L |
| 74 |
fun get_cell(x,L) = CELL x::L |
| 75 |
fun get_label(x,L) = L |
| 76 |
fun get_cellset(x,L) = map CELL (C.CellSet.toCellList x)@L |
| 77 |
fun get_operand(x,L) = OPERAND x::L |
| 78 |
fun get_int'(x) = [CELL(int x)] |
| 79 |
fun get_int32'(x) = [CELL(int32 x)] |
| 80 |
fun get_intinf'(x) = [CELL(intinf x)] |
| 81 |
fun get_word'(x) = [CELL(word x)] |
| 82 |
fun get_word32'(x) = [CELL(word32 x)] |
| 83 |
fun get_cell'(x) = [CELL x] |
| 84 |
fun get_label'(x) = [] |
| 85 |
fun get_cellset'(x) = map CELL (C.CellSet.toCellList x) |
| 86 |
fun get_operand'(x) = [OPERAND x] |
| 87 |
fun query (I.LOAD{l, rt, b, d, mem}) = |
| 88 |
(case l of |
| 89 |
(I.LD | I.LW | I.LH | I.LHU | I.LB | I.LBU) => (get_cell (rt, |
| 90 |
[]), get_operand (d, get_cell (b, []))) |
| 91 |
| _ => undefined () |
| 92 |
) |
| 93 |
| query _ = undefined () |
| 94 |
in query instr |
| 95 |
end |
| 96 |
end |
| 97 |
|