Erlang Mailing Lists

Author Message

<  Erlang patches mailing list  ~  [PATCH] Modify pp_arm to decode imm8m constants

Guest
Posted: Mon Apr 05, 2010 10:00 pm Reply with quote
Guest
Improve readability by decoding imm8m constants before printing them.

Signed-off-by: Johan Bengtsson <johanb@update.uu.se>
---
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


________________________________________________________________
erlang-patches (at) erlang.org mailing list.
See http://www.erlang.org/faq.html
To unsubscribe; mailto:erlang-patches-unsubscribe@erlang.org

Post received from mailinglist
Guest
Posted: Mon Apr 05, 2010 10:06 pm Reply with quote
Guest
Improve readability by decoding imm8m constants before printing them.

Signed-off-by: Johan Bengtsson <johanb@update.uu.se>
---
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


________________________________________________________________
erlang-patches (at) erlang.org mailing list.
See http://www.erlang.org/faq.html
To unsubscribe; mailto:erlang-patches-unsubscribe@erlang.org

Post received from mailinglist
Guest
Posted: Tue Apr 06, 2010 6:03 am Reply with quote
Guest
On Mon, Apr 5, 2010 at 10:59 PM, Johan Bengtsson <mortior@yahoo.se> wrote:
> Improve readability by decoding imm8m constants before printing them.

Thanks! Included in 'pu'.

--
Björn Gustavsson, Erlang/OTP, Ericsson AB

________________________________________________________________
erlang-patches (at) erlang.org mailing list.
See http://www.erlang.org/faq.html
To unsubscribe; mailto:erlang-patches-unsubscribe@erlang.org

Post received from mailinglist
Guest
Posted: Tue Apr 06, 2010 6:04 am Reply with quote
Guest
On Mon, Apr 5, 2010 at 10:59 PM, Johan Bengtsson <mortior@yahoo.se> wrote:
> Improve readability by decoding imm8m constants before printing them.

Thanks! Included in 'pu'.

--
Björn Gustavsson, Erlang/OTP, Ericsson AB

________________________________________________________________
erlang-patches (at) erlang.org mailing list.
See http://www.erlang.org/faq.html
To unsubscribe; mailto:erlang-patches-unsubscribe@erlang.org

Post received from mailinglist
Guest
Posted: Tue Apr 06, 2010 6:14 am Reply with quote
Guest
Johan Bengtsson writes:
> Improve readability by decoding imm8m constants before printing them.
>
> Signed-off-by: Johan Bengtsson <johanb@update.uu.se>
> ---
> 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.

________________________________________________________________
erlang-patches (at) erlang.org mailing list.
See http://www.erlang.org/faq.html
To unsubscribe; mailto:erlang-patches-unsubscribe@erlang.org

Post received from mailinglist
Guest
Posted: Tue Apr 06, 2010 6:15 am Reply with quote
Guest
Johan Bengtsson writes:
> Improve readability by decoding imm8m constants before printing them.
>
> Signed-off-by: Johan Bengtsson <johanb@update.uu.se>
> ---
> 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.

________________________________________________________________
erlang-patches (at) erlang.org mailing list.
See http://www.erlang.org/faq.html
To unsubscribe; mailto:erlang-patches-unsubscribe@erlang.org

Post received from mailinglist
Guest
Posted: Tue Apr 06, 2010 7:41 pm Reply with quote
Guest
On Tue, 2010-04-06 at 08:14 +0200, Mikael Pettersson wrote:
> Johan Bengtsson writes:
> > Improve readability by decoding imm8m constants before printing them.
> >
> > Signed-off-by: Johan Bengtsson <johanb@update.uu.se>
> > ---
> > 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.

For the attached file the difference is

--- test2-before.txt 2010-04-06 08:27:06.000000000 +0200
+++ test2-after.txt 2010-04-06 08:27:35.000000000 +0200
@@ -30,28 +30,28 @@
.global test2_knas_1
test2_knas_1:
.test2_knas_1_12:
- sub r10, r10, #4, 2*0
+ sub r10, r10, #0x4
str r14, [r10,#0]
.test2_knas_1_11:
mov r1, r1
.test2_knas_1_6:
- and r0, r1, #15, 2*0
- cmp r0, #15, 2*0
+ and r0, r1, #0xf
+ cmp r0, #0xf
bne .test2_knas_1_3
.test2_knas_1_5:
mov r4, r1, asr #4
- mov r0, #255, 2*12
+ mov r0, #0xff00
smull r3, r2, r4, r0
mov r0, r3, asr #31
cmp r0, r2
bne .test2_knas_1_3
.test2_knas_1_4:
- add r0, r3, #15, 2*0
+ add r0, r3, #0xf
mov r0, r0
.test2_knas_1_2:
mov r0, r0
ldr r14, [r10,#0]
- add r10, r10, #4, 2*0
+ add r10, r10, #0x4
mov r15, r14
.test2_knas_1_3:
mov r1, r1





Post received from mailinglist
Guest
Posted: Tue Apr 06, 2010 7:42 pm Reply with quote
Guest
On Tue, 2010-04-06 at 08:14 +0200, Mikael Pettersson wrote:
> Johan Bengtsson writes:
> > Improve readability by decoding imm8m constants before printing them.
> >
> > Signed-off-by: Johan Bengtsson <johanb@update.uu.se>
> > ---
> > 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.

For the attached file the difference is

--- test2-before.txt 2010-04-06 08:27:06.000000000 +0200
+++ test2-after.txt 2010-04-06 08:27:35.000000000 +0200
@@ -30,28 +30,28 @@
.global test2_knas_1
test2_knas_1:
.test2_knas_1_12:
- sub r10, r10, #4, 2*0
+ sub r10, r10, #0x4
str r14, [r10,#0]
.test2_knas_1_11:
mov r1, r1
.test2_knas_1_6:
- and r0, r1, #15, 2*0
- cmp r0, #15, 2*0
+ and r0, r1, #0xf
+ cmp r0, #0xf
bne .test2_knas_1_3
.test2_knas_1_5:
mov r4, r1, asr #4
- mov r0, #255, 2*12
+ mov r0, #0xff00
smull r3, r2, r4, r0
mov r0, r3, asr #31
cmp r0, r2
bne .test2_knas_1_3
.test2_knas_1_4:
- add r0, r3, #15, 2*0
+ add r0, r3, #0xf
mov r0, r0
.test2_knas_1_2:
mov r0, r0
ldr r14, [r10,#0]
- add r10, r10, #4, 2*0
+ add r10, r10, #0x4
mov r15, r14
.test2_knas_1_3:
mov r1, r1





Post received from mailinglist
Guest
Posted: Tue Apr 06, 2010 8:44 pm Reply with quote
Guest
Johan Bengtsson writes:
> On Tue, 2010-04-06 at 08:14 +0200, Mikael Pettersson wrote:
> > Johan Bengtsson writes:
> > > Improve readability by decoding imm8m constants before printing them.
> > >
> > > Signed-off-by: Johan Bengtsson <johanb@update.uu.se>
> > > ---
> > > 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.
>
> For the attached file the difference is
>
> --- test2-before.txt 2010-04-06 08:27:06.000000000 +0200
> +++ test2-after.txt 2010-04-06 08:27:35.000000000 +0200
> @@ -30,28 +30,28 @@
> .global test2_knas_1
> test2_knas_1:
> .test2_knas_1_12:
> - sub r10, r10, #4, 2*0
> + sub r10, r10, #0x4
> str r14, [r10,#0]
> .test2_knas_1_11:
> mov r1, r1
> .test2_knas_1_6:
> - and r0, r1, #15, 2*0
> - cmp r0, #15, 2*0
> + and r0, r1, #0xf
> + cmp r0, #0xf
> bne .test2_knas_1_3
> .test2_knas_1_5:
> mov r4, r1, asr #4
> - mov r0, #255, 2*12
> + mov r0, #0xff00
> smull r3, r2, r4, r0
> mov r0, r3, asr #31
> cmp r0, r2
> bne .test2_knas_1_3
> .test2_knas_1_4:
> - add r0, r3, #15, 2*0
> + add r0, r3, #0xf
> mov r0, r0
> .test2_knas_1_2:
> mov r0, r0
> ldr r14, [r10,#0]
> - add r10, r10, #4, 2*0
> + add r10, r10, #0x4
> mov r15, r14
> .test2_knas_1_3:
> mov r1, r1

Ok. Approved if you fix the too many newlines style issue.

________________________________________________________________
erlang-patches (at) erlang.org mailing list.
See http://www.erlang.org/faq.html
To unsubscribe; mailto:erlang-patches-unsubscribe@erlang.org

Post received from mailinglist
Guest
Posted: Tue Apr 06, 2010 8:44 pm Reply with quote
Guest
Johan Bengtsson writes:
> On Tue, 2010-04-06 at 08:14 +0200, Mikael Pettersson wrote:
> > Johan Bengtsson writes:
> > > Improve readability by decoding imm8m constants before printing them.
> > >
> > > Signed-off-by: Johan Bengtsson <johanb@update.uu.se>
> > > ---
> > > 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.
>
> For the attached file the difference is
>
> --- test2-before.txt 2010-04-06 08:27:06.000000000 +0200
> +++ test2-after.txt 2010-04-06 08:27:35.000000000 +0200
> @@ -30,28 +30,28 @@
> .global test2_knas_1
> test2_knas_1:
> .test2_knas_1_12:
> - sub r10, r10, #4, 2*0
> + sub r10, r10, #0x4
> str r14, [r10,#0]
> .test2_knas_1_11:
> mov r1, r1
> .test2_knas_1_6:
> - and r0, r1, #15, 2*0
> - cmp r0, #15, 2*0
> + and r0, r1, #0xf
> + cmp r0, #0xf
> bne .test2_knas_1_3
> .test2_knas_1_5:
> mov r4, r1, asr #4
> - mov r0, #255, 2*12
> + mov r0, #0xff00
> smull r3, r2, r4, r0
> mov r0, r3, asr #31
> cmp r0, r2
> bne .test2_knas_1_3
> .test2_knas_1_4:
> - add r0, r3, #15, 2*0
> + add r0, r3, #0xf
> mov r0, r0
> .test2_knas_1_2:
> mov r0, r0
> ldr r14, [r10,#0]
> - add r10, r10, #4, 2*0
> + add r10, r10, #0x4
> mov r15, r14
> .test2_knas_1_3:
> mov r1, r1

Ok. Approved if you fix the too many newlines style issue.

________________________________________________________________
erlang-patches (at) erlang.org mailing list.
See http://www.erlang.org/faq.html
To unsubscribe; mailto:erlang-patches-unsubscribe@erlang.org

Post received from mailinglist
Guest
Posted: Wed Apr 07, 2010 9:50 am Reply with quote
Guest
On Tue, Apr 6, 2010 at 10:44 PM, Mikael Pettersson <mikpe@it.uu.se> wrote:
>
> Ok. Approved if you fix the too many newlines style issue.

There is no need to re-submit the patch. I have fixed the newline issue.
--
Björn Gustavsson, Erlang/OTP, Ericsson AB

________________________________________________________________
erlang-patches (at) erlang.org mailing list.
See http://www.erlang.org/faq.html
To unsubscribe; mailto:erlang-patches-unsubscribe@erlang.org

Post received from mailinglist
Guest
Posted: Wed Apr 07, 2010 9:50 am Reply with quote
Guest
On Tue, Apr 6, 2010 at 10:44 PM, Mikael Pettersson <mikpe@it.uu.se> wrote:
>
> Ok. Approved if you fix the too many newlines style issue.

There is no need to re-submit the patch. I have fixed the newline issue.
--
Björn Gustavsson, Erlang/OTP, Ericsson AB

________________________________________________________________
erlang-patches (at) erlang.org mailing list.
See http://www.erlang.org/faq.html
To unsubscribe; mailto:erlang-patches-unsubscribe@erlang.org

Post received from mailinglist

Display posts from previous:  

All times are GMT
Page 1 of 1
This forum is locked: you cannot post, reply to, or edit topics.

Jump to:  

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You cannot download files in this forum