aboutsummaryrefslogtreecommitdiffstats
path: root/lib/hipe/opt/hipe_spillmin.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.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.erl')
-rw-r--r--lib/hipe/opt/hipe_spillmin.erl30
1 files changed, 18 insertions, 12 deletions
diff --git a/lib/hipe/opt/hipe_spillmin.erl b/lib/hipe/opt/hipe_spillmin.erl
index 6bb6980ad5..a2efd35d26 100644
--- a/lib/hipe/opt/hipe_spillmin.erl
+++ b/lib/hipe/opt/hipe_spillmin.erl
@@ -29,7 +29,8 @@
%% ==========================================================================
%% Exported functions (short description):
%%
-%% stackalloc(CFG, StackSlots, SpillIndex, Options, Target, TempMap) ->
+%% stackalloc(CFG, StackSlots, SpillIndex, Options, TgtMod, TgtCtx,
+%% TempMap) ->
%% {Coloring, NumberOfSpills}
%% Takes a CFG and the TempMap from register allocation and returns
%% a coloring of stack slots.
@@ -49,7 +50,7 @@
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-module(hipe_spillmin).
--export([stackalloc/6, stackalloc/7, mapmerge/2]).
+-export([stackalloc/7, stackalloc/8, mapmerge/2]).
%%-define(DEBUG, 1).
-define(HIPE_INSTRUMENT_COMPILER, true).
@@ -59,6 +60,8 @@
-include("../main/hipe.hrl").
-include("../flow/cfg.hrl").
+-type target_context() :: any().
+
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%
%% stackalloc(CFG, StackSlots, SpillIndex, Options, Target, TempMap)
@@ -68,26 +71,29 @@
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-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, StackSlots, SpillIndex, Options, Target, TempMap) ->
- Liveness = Target:analyze(CFG),
- stackalloc(CFG, Liveness, StackSlots, SpillIndex, Options, Target, TempMap).
+stackalloc(CFG, StackSlots, SpillIndex, Options, TgtMod, TgtCtx, TempMap) ->
+ Liveness = TgtMod:analyze(CFG,TgtCtx),
+ stackalloc(CFG, Liveness, StackSlots, SpillIndex, Options, TgtMod, TgtCtx, TempMap).
-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, Liveness, StackSlots, SpillIndex, Options, Target, TempMap) ->
+stackalloc(CFG, Liveness, StackSlots, SpillIndex, Options, TgtMod, TgtCtx,
+ TempMap) ->
case proplists:get_bool(spillmin_color, Options) of
false ->
- ?option_time(hipe_spillmin_scan:stackalloc(CFG, Liveness, StackSlots, SpillIndex,
- Options, Target, TempMap),
+ ?option_time(hipe_spillmin_scan:stackalloc(
+ CFG, Liveness, StackSlots, SpillIndex, Options, TgtMod,
+ TgtCtx, TempMap),
"Spill minimize, linear scan", Options);
true ->
- ?option_time(hipe_spillmin_color:stackalloc(CFG, Liveness, StackSlots, SpillIndex,
- Options, Target, TempMap),
+ ?option_time(hipe_spillmin_color:stackalloc(
+ CFG, Liveness, StackSlots, SpillIndex, Options, TgtMod,
+ TgtCtx, TempMap),
"Spill minimize, graph coloring", Options)
end.