]> Joshua Wise's Git repositories - snipe.git/blobdiff - codegen/colororder.sml
Initial import of l2c
[snipe.git] / codegen / colororder.sml
index 588086dd64b988082272ddc49b10c9f8d624c4a5..f533cead3e680c51c4a88d9e7f37b60f5097cba4 100644 (file)
@@ -1,15 +1,15 @@
-(* L1 Compiler
- * Gathers tiberium, fires rockets
+(* L2 Compiler
  * Takes a interference graph and generates an ordering for coloring
  * Author: Joshua Wise <jwise@andrew.cmu.edu>
+ * Author: Chris Lu <czl@aundrew.cmu.edu>
  *)
 
 signature COLORORDER =
 sig
-  type tiberium = (Temp.temp * x86.oper list) list
-  type rockets = Temp.temp list
+  type igraph = (Temp.temp * x86.oper list) list
+  type ordering = Temp.temp list
   
-  val colororder : tiberium -> rockets
+  val colororder : igraph -> ordering
 end
 
 structure ColorOrder :> COLORORDER =
@@ -17,34 +17,26 @@ struct
   structure T = Temp
   structure X = x86
   
-  type tiberium = (Temp.temp * x86.oper list) list
-  type rockets = Temp.temp list
+  type igraph = (Temp.temp * x86.oper list) list
+  type ordering = Temp.temp list
   
-  fun colororder (graph : tiberium) : rockets =
+  fun colororder graph =
     let
-      val () = print ("Ordering colors...\n");
       val initialWeights = map (fn (t, _) => (t, 0)) graph
       
       fun sortWeights weights =        (* Sort the weights such that the largest is at left, ready to be grabbed. *)
         ListMergeSort.sort (fn ((_, a), (_, b)) => a < b) weights
-      
+
       (* Chooses one temporary to pick, and updates the weights. *)
       fun orderOne (weights : (Temp.temp * int) list) : Temp.temp * (Temp.temp * int) list =
         let
           val sorted = sortWeights weights
           val (chosen, w) = List.hd sorted     (* Grab the temp with the highest weight. *)
-          val () = print ("  Chose "^(Temp.name chosen)^" with weight "^(Int.toString w)^"\n");
           val remaining = List.tl sorted
-          val neighbors =      (* Grab all the neighbors for some given temp. *)
+          val neighbors =                      (* Grab all the neighbors for some given temp. *)
             List.hd
               (List.map (fn (_, neighbors) => neighbors)
                 (List.filter (fn (t, _) => T.compare (t, chosen) = EQUAL) graph))
-          val () = List.app
-                     (fn (X.TEMP t) => (print ("    Neighbor "^(Temp.name t)^"\n"))
-                       | (X.REG X.EAX) => (print "    Fixed color EAX\n")
-                       | (X.REG X.EDX) => (print "    Fixed color EDX\n")
-                       | _ => raise ErrorMsg.InternalError "Unknown neighbor type -- const?"
-                     ) neighbors;
           val newWeights =
             List.map
               (fn (t, wt) =>
This page took 0.024965 seconds and 4 git commands to generate.