From 52964d9fbc8031298c977d5e4a9ef7b5605875ae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Magnus=20L=C3=A5ng?= Date: Thu, 23 Jun 2016 17:55:12 +0200 Subject: hipe_ppc: Add code rewrite RA callbacks These will not only be useful for hipe_regalloc_prepass, but also, after the introduction of a mk_move/2 (or similar) callback, for the purpose of range splitting. Since the substitution needed to case over all the instructions, a new module, hipe_ppc_subst, was introduced to the ppc backend. --- lib/hipe/regalloc/hipe_ppc_specific_fp.erl | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) (limited to 'lib/hipe/regalloc/hipe_ppc_specific_fp.erl') diff --git a/lib/hipe/regalloc/hipe_ppc_specific_fp.erl b/lib/hipe/regalloc/hipe_ppc_specific_fp.erl index 7805d347d6..5ec625daaf 100644 --- a/lib/hipe/regalloc/hipe_ppc_specific_fp.erl +++ b/lib/hipe/regalloc/hipe_ppc_specific_fp.erl @@ -53,6 +53,12 @@ %% callbacks for hipe_regalloc_loop -export([check_and_rewrite/2]). +%% callbacks for hipe_regalloc_prepass +-export([new_reg_nr/0, + update_reg_nr/2, + update_bb/3, + subst_temps/2]). + check_and_rewrite(CFG, Coloring) -> hipe_ppc_ra_postconditions_fp:check_and_rewrite(CFG, Coloring). @@ -106,6 +112,9 @@ number_of_temporaries(_CFG) -> bb(CFG, L) -> hipe_ppc_cfg:bb(CFG, L). +update_bb(CFG,L,BB) -> + hipe_ppc_cfg:bb_add(CFG,L,BB). + %% PowerPC stuff def_use(I) -> @@ -126,6 +135,23 @@ is_move(I) -> reg_nr(Reg) -> hipe_ppc:temp_reg(Reg). +new_reg_nr() -> + hipe_gensym:get_next_var(ppc). + +update_reg_nr(Nr, _Temp) -> + hipe_ppc:mk_temp(Nr, 'double'). + +subst_temps(SubstFun, Instr) -> + hipe_ppc_subst:insn_temps( + fun(Op) -> + case hipe_ppc:temp_is_allocatable(Op) + andalso hipe_ppc:temp_type(Op) =:= 'double' + of + true -> SubstFun(Op); + false -> Op + end + end, Instr). + -ifdef(notdef). new_spill_index(SpillIndex) -> SpillIndex+1. -- cgit v1.2.3