diff options
Diffstat (limited to 'asmcomp/asmgen.ml')
-rw-r--r-- | asmcomp/asmgen.ml | 61 |
1 files changed, 36 insertions, 25 deletions
diff --git a/asmcomp/asmgen.ml b/asmcomp/asmgen.ml index 10758d0772..416f2ace6e 100644 --- a/asmcomp/asmgen.ml +++ b/asmcomp/asmgen.ml @@ -22,43 +22,54 @@ type error = Assembler_error of string exception Error of error +let liveness phrase = + Liveness.fundecl phrase; phrase + +let dump_if flag message phrase = + if !flag then Printmach.phase message phrase; + phrase + +let dump_linear_if flag message phrase = + if !flag then begin + print_string "*** "; print_string message; print_newline(); + Printlinear.fundecl phrase; print_newline() + end; + phrase + let rec regalloc fd = - if !dump_live then Printmach.phase "Liveness analysis" fd; + dump_if dump_live "Liveness analysis" fd; Interf.build_graph fd; if !dump_interf then Printmach.interferences(); if !dump_prefer then Printmach.preferences(); Coloring.allocate_registers(); - if !dump_regalloc then - Printmach.phase "After register allocation" fd; + dump_if dump_regalloc "After register allocation" fd; let (newfd, redo_regalloc) = Reload.fundecl fd in - if !dump_reload then - Printmach.phase "After insertion of reloading code" newfd; + dump_if dump_reload "After insertion of reloading code" newfd; if redo_regalloc then begin Reg.reinit(); Liveness.fundecl newfd; regalloc newfd end else newfd +let (++) x f = f x + let compile_fundecl fd_cmm = Reg.reset(); - let fd_sel = Selection.fundecl fd_cmm in - if !dump_selection then - Printmach.phase "After instruction selection" fd_sel; - Liveness.fundecl fd_sel; - if !dump_live then Printmach.phase "Liveness analysis" fd_sel; - let fd_spill = Spill.fundecl fd_sel in - Liveness.fundecl fd_spill; - if !dump_spill then - Printmach.phase "After spilling" fd_spill; - let fd_split = Split.fundecl fd_spill in - Liveness.fundecl fd_split; - if !dump_split then - Printmach.phase "After live range splitting" fd_split; - let fd_reload = regalloc fd_split in - let fd_linear = Linearize.fundecl fd_reload in - if !dump_linear then begin - print_string "*** Linearized code"; print_newline(); - Printlinear.fundecl fd_linear; print_newline() - end; - Emit.fundecl fd_linear + fd_cmm + ++ Selection.fundecl + ++ dump_if dump_selection "After instruction selection" + ++ liveness + ++ dump_if dump_live "Liveness analysis" + ++ Spill.fundecl + ++ liveness + ++ dump_if dump_spill "After spilling" + ++ Split.fundecl + ++ dump_if dump_split "After live range splitting" + ++ liveness + ++ regalloc + ++ Linearize.fundecl + ++ dump_linear_if dump_linear "Linearized code" + ++ Scheduling.fundecl + ++ dump_linear_if dump_scheduling "After instruction scheduling" + ++ Emit.fundecl let compile_phrase p = if !dump_cmm then begin Printcmm.phrase p; print_newline() end; |