Home My Page Projects Code Snippets Project Openings SML/NJ
 Summary Activity Forums Tracker Lists Tasks Docs Surveys News SCM Files

# SCM Repository

[smlnj] Diff of /sml/trunk/src/MLRISC/ra/ra-core.sml
 [smlnj] / sml / trunk / src / MLRISC / ra / ra-core.sml

# Diff of /sml/trunk/src/MLRISC/ra/ra-core.sml

revision 732, Mon Nov 13 21:59:12 2000 UTC revision 733, Fri Nov 17 05:13:45 2000 UTC
# Line 412  Line 412
412
413    in  pr("=========== K="^Int.toString K^" ===========\n");    in  pr("=========== K="^Int.toString K^" ===========\n");
414        app prAdj (ListMergeSort.sort (fn ((x, _),(y, _)) => x > y)        app prAdj (ListMergeSort.sort (fn ((x, _),(y, _)) => x > y)
415                      (Intmap.intMapToList nodes))                      (IntHashTable.listItemsi nodes))
416    end    end
417
418
# Line 421  Line 421
421     * Note: it is up to the caller to remove all dedicated registers.     * Note: it is up to the caller to remove all dedicated registers.
422     *)     *)
423    fun newNodes(G.GRAPH{nodes, firstPseudoR,  ...}) =    fun newNodes(G.GRAPH{nodes, firstPseudoR,  ...}) =
424    let val getnode = Intmap.map nodes    let val getnode = IntHashTable.lookup nodes
426
427        fun defUse{defs, uses, pt, cost} =        fun defUse{defs, uses, pt, cost} =
428        let  fun def reg =        let  fun def reg =
# Line 628  Line 628
628                  else filter(moves, MV.EMPTY, [])                  else filter(moves, MV.EMPTY, [])
629
630    in  memMoves := mem;  (* memory moves *)    in  memMoves := mem;  (* memory moves *)
631        collect(Intmap.values nodes, [], FZ.EMPTY, mvs, [], 0, 0)        collect(IntHashTable.listItems nodes, [], FZ.EMPTY, mvs, [], 0, 0)
632    end    end
633
634    (*    (*
# Line 636  Line 636
636     * Spilled registers are given the special value ~1     * Spilled registers are given the special value ~1
637     *)     *)
638    fun regmap(G.GRAPH{nodes,...}) =    fun regmap(G.GRAPH{nodes,...}) =
639    let val getnode = Intmap.map nodes    let val getnode = IntHashTable.lookup nodes
640        fun num(NODE{color=ref(COLORED r),...}) = r        fun num(NODE{color=ref(COLORED r),...}) = r
641          | num(NODE{color=ref(ALIASED n),...}) = num n          | num(NODE{color=ref(ALIASED n),...}) = num n
642          | num(NODE{color=ref(SPILL_LOC _), ...}) = ~1          | num(NODE{color=ref(SPILL_LOC _), ...}) = ~1
# Line 653  Line 653
653     * during spilling.     * during spilling.
654     *)     *)
655    fun spillRegmap(G.GRAPH{nodes,...}) =    fun spillRegmap(G.GRAPH{nodes,...}) =
656    let val getnode = Intmap.map nodes    let val getnode = IntHashTable.lookup nodes
657        fun num(NODE{color=ref(COLORED r),...}) = r        fun num(NODE{color=ref(COLORED r),...}) = r
658          | num(NODE{color=ref(ALIASED n),...}) = num n          | num(NODE{color=ref(ALIASED n),...}) = num n
659          | num(NODE{color=ref(SPILL_LOC _), number, ...}) = number          | num(NODE{color=ref(SPILL_LOC _), number, ...}) = number
# Line 670  Line 670
670     * during spilling.     * during spilling.
671     *)     *)
672    fun spillLoc(G.GRAPH{nodes,...}) =    fun spillLoc(G.GRAPH{nodes,...}) =
673    let val getnode = Intmap.map nodes    let val getnode = IntHashTable.lookup nodes
674        fun num(NODE{color=ref(ALIASED n), ...}) = num n        fun num(NODE{color=ref(ALIASED n), ...}) = num n
675          | num(NODE{color=ref(SPILLED), number, ...}) = number          | num(NODE{color=ref(SPILLED), number, ...}) = number
676          | num(NODE{color=ref(SPILL_LOC s), number, ...}) = ~s          | num(NODE{color=ref(SPILL_LOC s), number, ...}) = ~s
# Line 1420  Line 1420
1420    fun moveSavings(GRAPH{memMoves=ref [], ...}) = (fn node => 0)    fun moveSavings(GRAPH{memMoves=ref [], ...}) = (fn node => 0)
1421      | moveSavings(GRAPH{memMoves, bitMatrix, ...}) =      | moveSavings(GRAPH{memMoves, bitMatrix, ...}) =
1422    let exception Savings    let exception Savings
1423        val savingsMap = Intmap.new(32, Savings)        val savingsMap = IntHashTable.mkTable(32, Savings)
1424                 : {pinned:int,cost:int} Intmap.intmap                 : {pinned:int,cost:int} IntHashTable.hash_table
1425        val savings = Intmap.mapWithDefault(savingsMap, {pinned= ~1, cost=0})        fun savings i = getOpt (IntHashTable.find savingsMap i,
1426        val addSavings = Intmap.add savingsMap                                { pinned = ~1, cost = 0 })
1427          val addSavings = IntHashTable.insert savingsMap
1428        val member     = BM.member(!bitMatrix)        val member     = BM.member(!bitMatrix)
1429        fun incSavings(u, v, c) =        fun incSavings(u, v, c) =
1430        let val {pinned, cost} = savings u        let val {pinned, cost} = savings u
# Line 1452  Line 1453
1453     * All nodes must have been colored.     * All nodes must have been colored.
1454     *)     *)
1455    fun finishRA(GRAPH{regmap, nodes, deadCopies, ...}) =    fun finishRA(GRAPH{regmap, nodes, deadCopies, ...}) =
1456    let val enter = Intmap.add regmap    let val enter = IntHashTable.insert regmap
1457        fun set(r, NODE{color=ref(COLORED c),...}) = enter(r, c)        fun set(r, NODE{color=ref(COLORED c),...}) = enter(r, c)
1458          | set(r, NODE{color=ref(ALIASED n),...}) = set(r, n)          | set(r, NODE{color=ref(ALIASED n),...}) = set(r, n)
1459          | set(r, NODE{color=ref(SPILLED),...}) =  enter(r, ~1)          | set(r, NODE{color=ref(SPILLED),...}) =  enter(r, ~1)
1460          | set(r, NODE{color=ref(SPILL_LOC s),...}) =  enter(r, ~1)          | set(r, NODE{color=ref(SPILL_LOC s),...}) =  enter(r, ~1)
1461          | set(r, NODE{color=ref(MEMREG m),...}) =  enter(r, m)          | set(r, NODE{color=ref(MEMREG m),...}) =  enter(r, m)
1462          | set(r, _) = error("finishRA "^Int.toString r)          | set(r, _) = error("finishRA "^Int.toString r)
1463    in  Intmap.app set nodes;    in  IntHashTable.appi set nodes;
1465          [] => ()          [] => ()
# Line 1469  Line 1470
1470     * Update the regmap, after copy propagation     * Update the regmap, after copy propagation
1471     *)     *)
1472    fun finishCP(GRAPH{regmap, nodes,...}) =    fun finishCP(GRAPH{regmap, nodes,...}) =
1473    let val enter = Intmap.add regmap    let val enter = IntHashTable.insert regmap
1474    in  Intmap.app    in  IntHashTable.appi
1475          (fn (r, node as NODE{color as ref(ALIASED _),...}) =>          (fn (r, node as NODE{color as ref(ALIASED _),...}) =>
1476              (case chase node of              (case chase node of
1477                 NODE{color=ref(COLORED c),...} => enter(r, c)                 NODE{color=ref(COLORED c),...} => enter(r, c)
# Line 1502  Line 1503
1503                         movecost, defs, uses, ...}) =                         movecost, defs, uses, ...}) =
1504              (pri := 0; degree := 0; adj := []; movecnt := 0; movelist := [];              (pri := 0; degree := 0; adj := []; movecnt := 0; movelist := [];
1505               defs := []; uses := []; movecost := 0)               defs := []; uses := []; movecost := 0)
1506    in  Intmap.app init nodes    in  IntHashTable.appi init nodes
1507    end    end
1508
1509    end (* local *)    end (* local *)

Legend:
 Removed from v.732 changed lines Added in v.733