diff options
author | Magnus Lång <[email protected]> | 2016-05-28 20:22:34 +0200 |
---|---|---|
committer | Magnus Lång <[email protected]> | 2016-09-02 15:04:45 +0200 |
commit | 85bd166647e7f260fd665eb44da9151c0d88f208 (patch) | |
tree | 84878ab624fcc22246bae89b75a6857415508539 /lib/hipe/regalloc/hipe_temp_map.erl | |
parent | c2f8b61ca3682281752fa0984699214dfcbf7ccd (diff) | |
download | otp-85bd166647e7f260fd665eb44da9151c0d88f208.tar.gz otp-85bd166647e7f260fd665eb44da9151c0d88f208.tar.bz2 otp-85bd166647e7f260fd665eb44da9151c0d88f208.zip |
hipe: Add hipe_regalloc_prepass
hipe_regalloc_prepass speeds up register allocation by spilling any temp
that is live over a call (which clobbers all register).
In order to detect these, a new function was added to the target
interface; defines_all_alloc/1, that takes an instruction and returns a
boolean.
Diffstat (limited to 'lib/hipe/regalloc/hipe_temp_map.erl')
-rw-r--r-- | lib/hipe/regalloc/hipe_temp_map.erl | 17 |
1 files changed, 8 insertions, 9 deletions
diff --git a/lib/hipe/regalloc/hipe_temp_map.erl b/lib/hipe/regalloc/hipe_temp_map.erl index 4085a0e1a7..171c2fb019 100644 --- a/lib/hipe/regalloc/hipe_temp_map.erl +++ b/lib/hipe/regalloc/hipe_temp_map.erl @@ -33,7 +33,7 @@ -module(hipe_temp_map). --export([cols2tuple/2, is_spilled/2, to_substlist/1]). +-export([cols2tuple/2, find/2, is_spilled/2, to_substlist/1]). -include("../main/hipe.hrl"). @@ -50,12 +50,10 @@ -spec cols2tuple(hipe_map(), atom()) -> hipe_temp_map(). cols2tuple(Map, Target) -> - ?ASSERT(check_list(Map)), - SortedMap = lists:keysort(1, Map), + SortedMap = lists:keysort(1, Map), cols2tuple(0, SortedMap, [], Target). %% sorted_cols2tuple(Map, Target) -> -%% ?ASSERT(check_list(Map)), %% ?ASSERT(Map =:= lists:keysort(1, Map)), %% cols2tuple(0, Map, [], Target). @@ -66,7 +64,7 @@ cols2tuple(_, [], Vs, _) -> cols2tuple(N, [{R, C}|Ms], Vs, Target) when N =:= R -> %% N makes sure the mapping is dense. N is he next key. cols2tuple(N+1, Ms, [C|Vs], Target); -cols2tuple(N, SourceMapping, Vs, Target) -> +cols2tuple(N, SourceMapping=[{R,_}|_], Vs, Target) when N < R -> %% The source was sparse, make up some placeholders... Val = case Target:is_precoloured(N) of @@ -82,7 +80,7 @@ cols2tuple(N, SourceMapping, Vs, Target) -> -spec is_spilled(non_neg_integer(), hipe_temp_map()) -> boolean(). is_spilled(Temp, Map) -> - case element(Temp+1, Map) of + case find(Temp, Map) of {reg, _R} -> false; {fp_reg, _R}-> false; {spill, _N} -> true; @@ -106,9 +104,10 @@ is_spilled(Temp, Map) -> %% {spill, _N} -> false; %% unknown -> false %% end. -%% -%% %% Returns the inf temp Temp is mapped to. -%% find(Temp, Map) -> element(Temp+1, Map). + +%% Returns the inf temp Temp is mapped to. +find(Temp, Map) when Temp < tuple_size(Map) -> element(Temp+1, Map); +find(_, Map) when is_tuple(Map) -> unknown. % consistency with cols2tuple/2 %% |