Skip to content
Snippets Groups Projects
Commit 4ed9e44a authored by Ferreol Axel's avatar Ferreol Axel :speech_balloon:
Browse files

TP6 allocation des registres ok : rectifications allocations des registres

parent 474c1d47
No related branches found
No related tags found
No related merge requests found
......@@ -90,7 +90,13 @@ let make_interf_live
(rig: (reg, reg Set.t) Hashtbl.t)
(live_out : (int, reg Set.t) Hashtbl.t) : unit =
(* TODO *)
Hashtbl.iter (fun i s -> Set.iter (fun elt -> add_interf rig i elt) s) live_out
Hashtbl.iter (fun _ s ->
Set.iter (fun elt1 ->
Set.iter (fun elt2 ->
if elt1 <> elt2 then add_interf rig elt1 elt2 else () )
s)
s)
live_out
(* [build_interference_graph live_out] construit, en utilisant les fonctions que
vous avez écrites, le graphe d'interférence en fonction de la vivacité des
......@@ -162,13 +168,13 @@ type regalloc_decision =
let pick_node_with_fewer_than_n_neighbors (rig : (reg, reg Set.t) Hashtbl.t) (n: int) : reg option =
(* TODO *)
let l_candidate = Hashtbl.fold (fun k d (candidate,cardinal_candidate) ->
if (cardinal_candidate <Set.cardinal d )&& (Set.cardinal d < n)
if (cardinal_candidate <Set.cardinal d) && (Set.cardinal d < n)
then (k,Set.cardinal d)
else (candidate,cardinal_candidate))
rig (-1,-1 ) in
if fst l_candidate <0
then None
else Some(fst l_candidate)
if fst l_candidate <0
then None
else Some(fst l_candidate)
(* Lorsque la fonction précédente échoue (i.e. aucun sommet n'a moins de [n]
voisins), on choisit un pseudo-registre à évincer.
......@@ -184,9 +190,9 @@ let pick_spilling_candidate (rig : (reg, reg Set.t) Hashtbl.t) : reg option =
then (k,Set.cardinal d)
else (candidate,cardinal_candidate))
rig (-1,-1 ) in
if fst l_candidate < 0
then None
else Some(fst l_candidate)
if fst l_candidate < 0
then None
else Some(fst l_candidate)
(* [make_stack rig stack ncolors] construit la pile, selon l'algorithme vu en
cours (slides 60 à 63 du cours "Allocation de registres - Autres slides"
......@@ -242,8 +248,7 @@ let color (allocation: (reg, loc) Hashtbl.t) (rig: (reg, reg Set.t) Hashtbl.t)
|Some(Reg(i)) -> Some(i)
) set_neighbours in
let number_of_color = Set.find_first (fun elt -> true) (Set.diff all_colors set_used_colors) in
Reg(number_of_color)
Reg(number_of_color)
let allocate (allocation: (reg, loc) Hashtbl.t) (rig: (reg, reg Set.t) Hashtbl.t)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment