| 1 |
structure AMD64MLTree = |
| 2 |
MLTreeF (structure Constant = UserConst |
| 3 |
structure Region = UserRegion |
| 4 |
structure Extension = UserExtension) |
| 5 |
|
| 6 |
structure AMD64MLTreeEval = |
| 7 |
MLTreeEval (structure T = AMD64MLTree |
| 8 |
fun eq _ _ = false |
| 9 |
val eqRext = eq val eqFext = eq |
| 10 |
val eqCCext = eq val eqSext = eq) |
| 11 |
|
| 12 |
structure AMD64PseudoOps = |
| 13 |
struct |
| 14 |
structure Client = |
| 15 |
struct |
| 16 |
datatype pseudo_op_ext = COMM of (Label.label * int) |
| 17 |
structure AsmPseudoOps = AMD64GasPseudoOps ( |
| 18 |
structure T = AMD64MLTree |
| 19 |
structure MLTreeEval = AMD64MLTreeEval) |
| 20 |
type pseudo_op = pseudo_op_ext |
| 21 |
fun toString (COMM(lab, sz)) = concat[ |
| 22 |
"\t.comm\t"(*, P.lexpToString(P.T.LABEL lab)*), |
| 23 |
",", Int.toString sz] |
| 24 |
fun emitValue {pOp, loc, emit} = raise Fail "emitValue" |
| 25 |
fun sizeOf _ = 0 |
| 26 |
fun adjustLabels _ = false |
| 27 |
end (* Client *) |
| 28 |
|
| 29 |
structure T = AMD64MLTree |
| 30 |
type pseudo_op = (T.labexp, Client.pseudo_op) PseudoOpsBasisTyp.pseudo_op |
| 31 |
fun toString _ = "" |
| 32 |
fun emitValue _ = () |
| 33 |
fun sizeOf _ = 0 |
| 34 |
fun adjustLabels _ = false |
| 35 |
end (* AMD64PseudoOps *) |
| 36 |
|
| 37 |
structure PS = PseudoOps (structure Client = AMD64PseudoOps.Client) |
| 38 |
|
| 39 |
structure Stream = InstructionStream(PS) |
| 40 |
|
| 41 |
|
| 42 |
structure AMD64Instr = AMD64Instr (AMD64MLTree) |
| 43 |
|
| 44 |
structure AMD64Shuffle = AMD64Shuffle(AMD64Instr) |
| 45 |
|
| 46 |
|
| 47 |
structure AMD64MLTreeHash = |
| 48 |
MLTreeHash (structure T = AMD64MLTree |
| 49 |
fun h _ _ = 0w0 |
| 50 |
val hashRext = h val hashFext = h |
| 51 |
val hashCCext = h val hashSext = h) |
| 52 |
|
| 53 |
structure AMD64Asm = AMD64AsmEmitter |
| 54 |
(structure Instr = AMD64Instr |
| 55 |
structure S = Stream |
| 56 |
structure MLTreeEval = AMD64MLTreeEval |
| 57 |
structure Shuffle = AMD64Shuffle |
| 58 |
) |
| 59 |
|
| 60 |
structure AMD64InsnProps = AMD64Props |
| 61 |
(structure Instr = AMD64Instr |
| 62 |
structure MLTreeHash = AMD64MLTreeHash |
| 63 |
structure MLTreeEval = AMD64MLTreeEval) |
| 64 |
|
| 65 |
structure AMD64CFG = ControlFlowGraph ( |
| 66 |
structure I = AMD64Asm.I |
| 67 |
structure GraphImpl = DirectedGraph |
| 68 |
structure InsnProps = AMD64InsnProps |
| 69 |
structure Asm = AMD64Asm) |
| 70 |
|
| 71 |
structure AMD64Stream = InstructionStream(AMD64PseudoOps) |
| 72 |
structure AMD64MLTStream = MLTreeStream ( |
| 73 |
structure T = AMD64MLTree |
| 74 |
structure S = AMD64Stream) |
| 75 |
|
| 76 |
structure AMD64MTC = struct |
| 77 |
structure T = AMD64MLTree |
| 78 |
structure TS = AMD64MLTStream |
| 79 |
structure I = AMD64Instr |
| 80 |
structure CFG = AMD64CFG |
| 81 |
structure C = I.C |
| 82 |
type reducer = |
| 83 |
(I.instruction,C.cellset,I.operand,I.addressing_mode,AMD64CFG.cfg) TS.reducer |
| 84 |
fun unimplemented _ = MLRiscErrorMsg.impossible "UserMLTreeExtComp" |
| 85 |
val compileSext = unimplemented |
| 86 |
val compileRext = unimplemented |
| 87 |
val compileFext = unimplemented |
| 88 |
val compileCCext = unimplemented |
| 89 |
|
| 90 |
structure AMD64MLTreeUtils : MLTREE_UTILS = |
| 91 |
struct |
| 92 |
structure T = AMD64MLTree |
| 93 |
structure IX = AMD64InstrExt |
| 94 |
structure U = MLTreeUtils ( |
| 95 |
structure T = T |
| 96 |
fun hashSext _ _ = 0w0 |
| 97 |
fun hashRext _ _ = 0w0 |
| 98 |
fun hashFext _ _ = 0w0 |
| 99 |
fun hashCCext _ _ = 0w0 |
| 100 |
fun eqSext _ _ = raise Fail "eqSext" |
| 101 |
fun eqRext _ _ = raise Fail "eqRext" |
| 102 |
fun eqFext _ _ = raise Fail "eqFext" |
| 103 |
fun eqCCext _ _ = raise Fail "eqCCext" |
| 104 |
fun showSext (prt : T.printer) ext = raise Fail "todo" |
| 105 |
fun showRext _ _ = raise Fail "showRext" |
| 106 |
fun showFext _ _ = raise Fail "showFext" |
| 107 |
fun showCCext _ _ = raise Fail "showCCext") |
| 108 |
open U |
| 109 |
end |
| 110 |
end |
| 111 |
|
| 112 |
structure AMD64 = AMD64Gen ( |
| 113 |
structure I = AMD64Instr |
| 114 |
structure MLTreeUtils = AMD64MTC.AMD64MLTreeUtils |
| 115 |
structure ExtensionComp = AMD64MTC |
| 116 |
fun signBit _ = raise Fail "todo" |
| 117 |
fun negateSignBit _ = raise Fail "todo" |
| 118 |
val floats16ByteAligned = true |
| 119 |
) |
| 120 |
|
| 121 |
structure AMD64Emit = CFGEmit ( |
| 122 |
structure CFG = AMD64CFG |
| 123 |
structure E = AMD64Asm) |
| 124 |
|
| 125 |
|
| 126 |
structure AMD64FlowGraph = BuildFlowgraph |
| 127 |
(structure Props = AMD64InsnProps |
| 128 |
structure Stream = AMD64Stream |
| 129 |
structure CFG = AMD64CFG) |
| 130 |
|
| 131 |
structure AMD64Expand = CFGExpandCopies (structure CFG=AMD64CFG |
| 132 |
structure Shuffle = AMD64Shuffle) |
| 133 |
structure AMD64BlockPlacement = DefaultBlockPlacement(AMD64CFG) |
| 134 |
|
| 135 |
structure RASpill = RASpillWithRenaming ( |
| 136 |
structure Asm = AMD64Asm |
| 137 |
structure InsnProps = AMD64InsnProps |
| 138 |
val max_dist = ref 4 |
| 139 |
val keep_multiple_values = ref false) |
| 140 |
|
| 141 |
structure C = AMD64Cells |
| 142 |
|
| 143 |
datatype spill_operand_kind = SPILL_LOC |
| 144 |
| CONST_VAL |
| 145 |
|
| 146 |
datatype ra_phase = SPILL_PROPAGATION |
| 147 |
| SPILL_COLORING |
| 148 |
|
| 149 |
structure IntRA = |
| 150 |
struct |
| 151 |
val dedicated = [C.rsp, C.rbp] |
| 152 |
val allRegs = C.Regs CellsBasis.GP {from=0, to=15, step=1} |
| 153 |
val allRegsSet = foldl C.addReg C.empty allRegs |
| 154 |
val avail = let |
| 155 |
val availSet = foldl C.rmvReg allRegsSet dedicated |
| 156 |
in |
| 157 |
C.getReg availSet |
| 158 |
end |
| 159 |
fun spillInit _ = () |
| 160 |
fun spillLoc {info=frame, an, cell, id=loc} = |
| 161 |
{opnd = AMD64Instr.Immed 0, kind = SPILL_LOC} |
| 162 |
val phases = [SPILL_PROPAGATION, SPILL_COLORING] |
| 163 |
end (* IntRA *) |
| 164 |
|
| 165 |
structure FloatRA = |
| 166 |
struct |
| 167 |
val avail = C.Regs CellsBasis.FP {from=0, to=15, step=1} |
| 168 |
val dedicated = [] |
| 169 |
fun spillInit _ = () |
| 170 |
fun spillLoc (info, ans, id) = AMD64Instr.Immed 0 |
| 171 |
val phases = [SPILL_PROPAGATION, SPILL_COLORING] |
| 172 |
end (* FloatRA *) |
| 173 |
|
| 174 |
(* register allocation *) |
| 175 |
structure AMD64RA = AMD64RegAlloc ( |
| 176 |
structure I = AMD64Instr |
| 177 |
structure CFG = AMD64CFG |
| 178 |
structure Asm = AMD64Asm |
| 179 |
structure SpillHeur = ChowHennessySpillHeur |
| 180 |
structure Spill = RASpill |
| 181 |
structure Props = AMD64InsnProps |
| 182 |
type spill_info = unit |
| 183 |
fun beforeRA (Graph.GRAPH graph) = () |
| 184 |
datatype spill_operand_kind = datatype spill_operand_kind |
| 185 |
datatype ra_phase = datatype ra_phase |
| 186 |
structure Int = IntRA |
| 187 |
structure Float = FloatRA |
| 188 |
val floats16ByteAligned = true) |
| 189 |
|
| 190 |
structure CCalls = X86_64SVIDFn ( |
| 191 |
structure T = AMD64MLTree |
| 192 |
val frameAlign = 8) |
| 193 |
|
| 194 |
structure AMD64Expand = CFGExpandCopies ( |
| 195 |
structure CFG=AMD64CFG |
| 196 |
structure Shuffle = AMD64Shuffle) |