aboutsummaryrefslogtreecommitdiffstats
path: root/lib/hipe/sparc
diff options
context:
space:
mode:
authorMagnus Lång <[email protected]>2017-03-16 14:55:23 +0100
committerMagnus Lång <[email protected]>2017-03-16 20:49:42 +0100
commitdbe626aa7beb0f04403f6782443f3a78d0f1fdb0 (patch)
tree80624d8951ff6ab6f0dc665d5fa606ae7d3c38ae /lib/hipe/sparc
parent040f6e240a80cb8576ddb3e7b2b49fd7f98aa3dc (diff)
downloadotp-dbe626aa7beb0f04403f6782443f3a78d0f1fdb0.tar.gz
otp-dbe626aa7beb0f04403f6782443f3a78d0f1fdb0.tar.bz2
otp-dbe626aa7beb0f04403f6782443f3a78d0f1fdb0.zip
hipe: Add basic range splitting ra callbacks
In addition to the temporary name rewriting that hipe_regalloc_prepass does, range splitters also need to be able to insert move instructions, as well as inserting new basic blocks in the control flow graph. The following four callbacks are added for that purpose: * Target:mk_move(Src, Dst, Context) Returns a move instruction from the temporary (not just register number) Src to Dst. * Target:mk_goto(Label, Context) Returns a unconditional control flow instruction that branches to the label with name Label. * Target:redirect_jmp(Instr, ToOld, ToNew, Context) Modifies the control flow instruction Instr so that any control flow that would go to a label with name ToOld instead goes to the label with name ToNew. * Target:new_label(Context) Returns a fresh label name that does not belong to any existing block in the current function, and is to be used to create a new basic block in the control flow graph by calling Target:update_bb/4 with this new name.
Diffstat (limited to 'lib/hipe/sparc')
-rw-r--r--lib/hipe/sparc/hipe_sparc_cfg.erl24
1 files changed, 15 insertions, 9 deletions
diff --git a/lib/hipe/sparc/hipe_sparc_cfg.erl b/lib/hipe/sparc/hipe_sparc_cfg.erl
index 27374d187b..b31c90a03a 100644
--- a/lib/hipe/sparc/hipe_sparc_cfg.erl
+++ b/lib/hipe/sparc/hipe_sparc_cfg.erl
@@ -23,6 +23,7 @@
-export([linearise/1]).
-export([params/1]).
-export([arity/1]). % for linear scan
+-export([redirect_jmp/3]).
-define(SPARC_CFG, true). % needed for cfg.inc
@@ -81,24 +82,29 @@ branch_successors(Branch) ->
fails_to(_Instr) -> [].
-endif.
--ifdef(notdef).
redirect_jmp(I, Old, New) ->
case I of
- #b_label{label=Label} ->
- if Old =:= Label -> I#b_label{label=New};
+ #bp{'cond'='a',label=Label} ->
+ if Old =:= Label -> I#bp{label=New};
true -> I
end;
- #pseudo_bc{true_label=TrueLab, false_label=FalseLab} ->
- I1 = if Old =:= TrueLab -> I#pseudo_bc{true_label=New};
+ #pseudo_bp{true_label=TrueLab, false_label=FalseLab} ->
+ I1 = if Old =:= TrueLab -> I#pseudo_bp{true_label=New};
true -> I
end,
- if Old =:= FalseLab -> I1#pseudo_bc{false_label=New};
+ if Old =:= FalseLab -> I1#pseudo_bp{false_label=New};
true -> I1
end;
- %% handle pseudo_call too?
- _ -> I
+ #pseudo_call{contlab=ContLab0, sdesc=SDesc0} ->
+ SDesc = case SDesc0 of
+ #sparc_sdesc{exnlab=Old} -> SDesc0#sparc_sdesc{exnlab=New};
+ #sparc_sdesc{exnlab=_} -> SDesc0
+ end,
+ ContLab = if Old =:= ContLab0 -> New;
+ true -> ContLab0
+ end,
+ I#pseudo_call{sdesc=SDesc, contlab=ContLab}
end.
--endif.
mk_goto(Label) ->
hipe_sparc:mk_b_label(Label).