X-Git-Url: http://git.joshuawise.com/snipe.git/blobdiff_plain/12aa4087bee3e70f170d7457794921de4e385227..0a24e44d4e9f82f8d3d83de8e58c83c8cf2868b6:/codegen/coloring.sml diff --git a/codegen/coloring.sml b/codegen/coloring.sml index e1c2bcd..eeca849 100644 --- a/codegen/coloring.sml +++ b/codegen/coloring.sml @@ -1,21 +1,22 @@ -(* colorizer - * Gathers tiberium, fires rockets +(* L2 compiler + * colorizer * colors a graph and returns a list of nodes with associated colors - * Author: Chris Lu + * Author: Joshua Wise + * Author: Chris Lu *) signature COLORIZER = sig - type tiberium = Temp.temp list + type temps = Temp.temp list type colorlist = (Temp.temp * int) list type igraph = (Temp.temp * x86.oper list) list - val colorize : tiberium -> igraph -> colorlist + val colorize : temps -> igraph -> colorlist end structure Colorizer :> COLORIZER = struct - type tiberium = Temp.temp list + type temps = Temp.temp list type colorlist = (Temp.temp * int) list type igraph = (Temp.temp * x86.oper list) list @@ -58,6 +59,7 @@ struct @ (List.map (fn X.REG X.EAX => 0 | X.REG X.EDX => 3 + | X.REG X.ECX => 2 | _ => raise ErrorMsg.InternalError "Bad kind of specreg") fixeds) (* Greedy-colorize -- pick the lowest number that isn't used by a neighbor *) @@ -67,12 +69,12 @@ struct else i val newcolor = greedy 0 ints - val () = print (" Assigned color "^(Int.toString newcolor)^" to temp "^(Temp.name temp)^"\n") + (* val () = print (" Assigned color "^(Int.toString newcolor)^" to temp "^(Temp.name temp)^"\n") *) in (temp, (greedy 0 ints)) :: regs end - (* val colorize : tiberium -> igraph -> colorlist + (* val colorize : temps -> igraph -> colorlist * colorizes a graph given the graph representation and the order in which to color * nodes, returns a list of nodes numbered with their respective color *) fun colorize order graph = foldl (color_single graph) nil order