Change hw6 to an unsolved version.
Signed-off-by: jmug <u.g.a.mariano@gmail.com>
This commit is contained in:
parent
0c04936ccf
commit
ee01a8f5b2
186 changed files with 9605 additions and 4019 deletions
|
|
@ -2,16 +2,6 @@
|
|||
open Ll
|
||||
module Platform = Util.Platform
|
||||
|
||||
(*
|
||||
This file drives the optimization for the compilation. For the leaderboard,
|
||||
you may optionally implement additional optimizations by editing this file.
|
||||
|
||||
NOTE: your additional optimizations should run only if !opt_level = 2.
|
||||
|
||||
That is, your additional optimizations should be enabled only when the
|
||||
flag -O2 is passed to main.native.
|
||||
*)
|
||||
|
||||
(* dead code elimination ---------------------------------------------------- *)
|
||||
let dce (g:Cfg.t) : Cfg.t =
|
||||
let ag = Alias.analyze g in
|
||||
|
|
@ -32,22 +22,19 @@ let rec pass n (g:Cfg.t) =
|
|||
(* optimize an fdecl -------------------------------------------------------- *)
|
||||
(* runs (two) passes of dce followed by constant propagation on the supplied
|
||||
LL IR fdecl. *)
|
||||
let opt_fdecl (gid,fdecl:Ll.gid * Ll.fdecl) : Ll.gid * Ll.fdecl =
|
||||
let opt_fdecl_O1 (gid,fdecl:Ll.gid * Ll.fdecl) : Ll.gid * Ll.fdecl =
|
||||
let g = pass 2 (Cfg.of_ast fdecl) in
|
||||
gid, Cfg.to_ast g
|
||||
|
||||
(* optimization level, set by the main compiler driver *)
|
||||
let opt_level = ref 0
|
||||
(* flag for the main compiler driver *)
|
||||
let do_opt = ref false
|
||||
|
||||
(* optimize each fdecl in the program *)
|
||||
let optimize (p:Ll.prog) : Ll.prog =
|
||||
if !opt_level = 2 then
|
||||
(* OPTIONAL TASK: implement additional optimizations *)
|
||||
failwith "No -O2 optimizations implemented! This is an optional task."
|
||||
else if !opt_level = 1
|
||||
if !do_opt
|
||||
then begin
|
||||
Platform.verb @@ Printf.sprintf "..optimizing";
|
||||
{ p with Ll.fdecls = List.map opt_fdecl p.Ll.fdecls }
|
||||
{ p with Ll.fdecls = List.map opt_fdecl_O1 p.Ll.fdecls }
|
||||
end
|
||||
else p
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue