317 |
(String.tokens (fn #" " => true | _ => false) text) |
(String.tokens (fn #" " => true | _ => false) text) |
318 |
end |
end |
319 |
|
|
320 |
fun dump (outS, title, cfg as G.GRAPH g) = let |
fun dumpBlock (outS, cfg as G.GRAPH g) = let |
321 |
fun pr str = TextIO.output(outS, str) |
fun pr str = TextIO.output(outS, str) |
322 |
fun prList [] = () |
fun prList [] = () |
323 |
| prList [i] = pr i |
| prList [i] = pr i |
324 |
| prList (h::t) = (pr (h ^ ", "); prList t) |
| prList (h::t) = (pr (h ^ ", "); prList t) |
325 |
val annotations = !(annotations cfg) |
val Asm.S.STREAM{emit,defineLabel,annotation,...} = |
326 |
val Asm.S.STREAM{emit,pseudoOp,defineLabel,annotation,...} = |
AsmStream.withStream outS Asm.makeStream [] |
|
AsmStream.withStream outS Asm.makeStream annotations |
|
327 |
fun showFreq (ref w) = F.format "[%s]" [F.STR(W.toString w)] |
fun showFreq (ref w) = F.format "[%s]" [F.STR(W.toString w)] |
328 |
fun showEdge (blknum,e) = |
fun showEdge (blknum,e) = |
329 |
F.format "%d:%s" [F.INT blknum, F.STR(show_edge e)] |
F.format "%d:%s" [F.INT blknum, F.STR(show_edge e)] |
348 |
) = ( |
) = ( |
349 |
pr (F.format "BLOCK %d %s\n" [F.INT id, F.STR(showFreq freq)]); |
pr (F.format "BLOCK %d %s\n" [F.INT id, F.STR(showFreq freq)]); |
350 |
case !align of NONE => () | SOME p => (pr (P.toString p ^ "\n")); |
case !align of NONE => () | SOME p => (pr (P.toString p ^ "\n")); |
351 |
app annotation (!annotations); |
List.app annotation (!annotations); |
352 |
app defineLabel (!labels); |
List.app defineLabel (!labels); |
353 |
showSuccs id; |
showSuccs id; |
354 |
showPreds id; |
showPreds id; |
355 |
List.app emit (List.rev (!insns))) |
List.app emit (List.rev (!insns))) |
356 |
|
in |
357 |
|
printBlock |
358 |
|
end |
359 |
|
|
360 |
|
fun dump (outS, title, cfg as G.GRAPH g) = let |
361 |
|
fun pr str = TextIO.output(outS, str) |
362 |
|
val annotations = !(annotations cfg) |
363 |
|
val Asm.S.STREAM{annotation, ...} = |
364 |
|
AsmStream.withStream outS Asm.makeStream annotations |
365 |
fun printData () = let |
fun printData () = let |
366 |
val INFO{data, ...} = #graph_info g |
val INFO{data, ...} = #graph_info g |
367 |
in |
in |
371 |
pr(F.format "[ %s ]\n" [F.STR title]); |
pr(F.format "[ %s ]\n" [F.STR title]); |
372 |
List.app annotation annotations; |
List.app annotation annotations; |
373 |
(* printBlock entry; *) |
(* printBlock entry; *) |
374 |
AsmStream.withStream outS (#forall_nodes g) printBlock; |
AsmStream.withStream outS (#forall_nodes g) (dumpBlock (outS, cfg)); |
375 |
(* printBlock exit; *) |
(* printBlock exit; *) |
376 |
AsmStream.withStream outS printData (); |
AsmStream.withStream outS printData (); |
377 |
TextIO.flushOut outS |
TextIO.flushOut outS |