[erlang-patches] [PATCH] Modify pp_arm to decode imm8m constants

Mikael Pettersson mikpe@REDACTED
Tue Apr 6 08:14:31 CEST 2010


Johan Bengtsson writes:
 > Improve readability by decoding imm8m constants before printing them.
 > 
 > Signed-off-by: Johan Bengtsson <johanb@REDACTED>
 > ---
 >  lib/hipe/arm/hipe_arm_pp.erl |    8 +++++++-
 >  1 files changed, 7 insertions(+), 1 deletions(-)
 > 
 > diff --git a/lib/hipe/arm/hipe_arm_pp.erl b/lib/hipe/arm/hipe_arm_pp.erl
 > index 7ce8421..a98f8fc 100644
 > --- a/lib/hipe/arm/hipe_arm_pp.erl
 > +++ b/lib/hipe/arm/hipe_arm_pp.erl
 > @@ -246,6 +246,12 @@ stop_suffix(StOp) ->
 >      'strb' -> "b"
 >    end.
 >  
 > +imm8m_decode(Value, 0) ->
 > +  Value;
 > +imm8m_decode(Value, Rot) ->
 > +  (Value bsr (2 * Rot)) bor (Value bsl (2 * (16 - Rot))).
 > +
 > +

One newline too many here.

 >  pp_temp(Dev, Temp=#arm_temp{reg=Reg, type=Type}) ->
 >    case hipe_arm:temp_is_precoloured(Temp) of
 >      true ->
 > @@ -292,7 +298,7 @@ pp_am1(Dev, Am1) ->
 >  	  io:format(Dev, "#~w", [Imm5])
 >        end;
 >      {Imm8,Imm4} ->
 > -      io:format(Dev, "#~w, 2*~w", [Imm8,Imm4])
 > +      io:format(Dev, "#~s", [to_hex(imm8m_decode(Imm8, Imm4))])
 >    end.
 >  
 >  pp_am2(Dev, #am2{src=Src,sign=Sign,offset=Am2Offset}) ->

Please show a before/after diff for the output of pp_arm on some small
function, preferably one using an immediate with a non-zero rotate.


More information about the erlang-patches mailing list