aboutsummaryrefslogtreecommitdiffstats
path: root/lib/hipe/opt/hipe_spillmin_color.erl
diff options
context:
space:
mode:
authorMagnus Lång <[email protected]>2016-09-05 14:55:01 +0200
committerMagnus Lång <[email protected]>2016-09-05 19:17:50 +0200
commitea710644b198f7800f0daf2de0d152cf8e3e9bb3 (patch)
tree46842f5dab3fcdbb4055d11ee55c28506eeac7fc /lib/hipe/opt/hipe_spillmin_color.erl
parent1039c0196a7e643c63ce71b2c6daa2b78b3aa832 (diff)
downloadotp-ea710644b198f7800f0daf2de0d152cf8e3e9bb3.tar.gz
otp-ea710644b198f7800f0daf2de0d152cf8e3e9bb3.tar.bz2
otp-ea710644b198f7800f0daf2de0d152cf8e3e9bb3.zip
hipe: Refactor ra callbacks to accept context arg
This allows us to pass around the context data that hipe_regalloc_prepass needs cleanly, without using process dictionary or parameterised modules (like it was previous to this change).
Diffstat (limited to 'lib/hipe/opt/hipe_spillmin_color.erl')
-rw-r--r--lib/hipe/opt/hipe_spillmin_color.erl33
1 files changed, 20 insertions, 13 deletions
diff --git a/lib/hipe/opt/hipe_spillmin_color.erl b/lib/hipe/opt/hipe_spillmin_color.erl
index 9c62fdf11a..a0d6b03503 100644
--- a/lib/hipe/opt/hipe_spillmin_color.erl
+++ b/lib/hipe/opt/hipe_spillmin_color.erl
@@ -41,7 +41,7 @@
-module(hipe_spillmin_color).
--export([stackalloc/7]).
+-export([stackalloc/8]).
%%-ifndef(DO_ASSERT).
%%-define(DO_ASSERT, true).
@@ -66,11 +66,15 @@
%% where Location is {spill,M}.
%% {spill,M} denotes the Mth spilled node
+-type target_context() :: any().
+
-spec stackalloc(#cfg{}, _, [_], non_neg_integer(),
- comp_options(), module(), hipe_temp_map()) ->
+ comp_options(), module(), target_context(), hipe_temp_map()) ->
{hipe_spill_map(), non_neg_integer()}.
-stackalloc(CFG, Live, _StackSlots, SpillIndex, _Options, Target, TempMap) ->
+stackalloc(CFG, Live, _StackSlots, SpillIndex, _Options, TargetMod,
+ TargetContext, TempMap) ->
+ Target = {TargetMod, TargetContext},
?report2("building IG~n", []),
{IG, NumNodes} = build_ig(CFG, Live, Target, TempMap),
{Cols, MaxColors} =
@@ -189,7 +193,7 @@ build_ig0(CFG, Live, Target, TempMap) ->
TempMapping = map_spilled_temporaries(TempMap),
TempMappingTable = setup_ets(TempMapping),
NumSpilled = length(TempMapping),
- IG = build_ig_bbs(Target:labels(CFG), CFG, Live, empty_ig(NumSpilled),
+ IG = build_ig_bbs(labels(CFG, Target), CFG, Live, empty_ig(NumSpilled),
Target, TempMap, TempMappingTable),
ets:delete(TempMappingTable),
{normalize_ig(IG), NumSpilled}.
@@ -539,18 +543,21 @@ is_visited(X, Vis) ->
%% *** INTERFACES TO OTHER MODULES ***
%%
-liveout(CFG, L, Target) ->
- ordsets:from_list(reg_names(Target:liveout(CFG, L), Target)).
+labels(CFG, {TgtMod,TgtCtx}) ->
+ TgtMod:labels(CFG, TgtCtx).
+
+liveout(CFG, L, Target={TgtMod,TgtCtx}) ->
+ ordsets:from_list(reg_names(TgtMod:liveout(CFG, L, TgtCtx), Target)).
-bb(CFG, L, Target) ->
- hipe_bb:code(Target:bb(CFG, L)).
+bb(CFG, L, {TgtMod,TgtCtx}) ->
+ hipe_bb:code(TgtMod:bb(CFG, L, TgtCtx)).
-def_use(X, Target, TempMap) ->
- Defines = [Y || Y <- reg_names(Target:defines(X), Target),
+def_use(X, Target={TgtMod,TgtCtx}, TempMap) ->
+ Defines = [Y || Y <- reg_names(TgtMod:defines(X,TgtCtx), Target),
hipe_temp_map:is_spilled(Y, TempMap)],
- Uses = [Z || Z <- reg_names(Target:uses(X), Target),
+ Uses = [Z || Z <- reg_names(TgtMod:uses(X,TgtCtx), Target),
hipe_temp_map:is_spilled(Z, TempMap)],
{Defines, Uses}.
-reg_names(Regs, Target) ->
- [Target:reg_nr(X) || X <- Regs].
+reg_names(Regs, {TgtMod,TgtCtx}) ->
+ [TgtMod:reg_nr(X,TgtCtx) || X <- Regs].