[PATCH] Modify pp_arm to decode imm8m constants

Johan Bengtsson mortior@REDACTED
Mon Apr 5 22:59:14 CEST 2010


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))).
+
+
 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}) ->
-- 
1.6.3.3



More information about the erlang-patches mailing list