-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chapter 20: register allocation with conservative coalescing
- Loading branch information
Showing
4 changed files
with
157 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,6 +17,7 @@ | |
constant_folding | ||
copy_prop | ||
dead_store_elim | ||
disjoint_sets | ||
emit | ||
initializers | ||
instruction_fixup | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
module type S = sig | ||
type t | ||
type elt | ||
|
||
val init : t | ||
val union : elt -> elt -> t -> t | ||
val find : elt -> t -> elt | ||
val is_empty : t -> bool | ||
end | ||
|
||
module Make (Ord : Map.OrderedType) = struct | ||
module M = Map.Make (Ord) | ||
|
||
type t = Ord.t M.t | ||
type elt = Ord.t | ||
|
||
let init = M.empty | ||
let union x y disj_sets = M.add x y disj_sets | ||
|
||
let rec find x disj_sets = | ||
if M.mem x disj_sets then | ||
let mapped_to = M.find x disj_sets in | ||
find mapped_to disj_sets | ||
else x | ||
|
||
let is_empty = M.is_empty | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
module type S = sig | ||
type t | ||
type elt | ||
val init : t | ||
val union : elt -> elt -> t -> t | ||
val find : elt -> t -> elt | ||
val is_empty : t -> bool | ||
end | ||
|
||
module Make: functor (Ord: Map.OrderedType) -> S with type elt = Ord.t |