public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
* How "arm_gen_constant" Function In arm.c works?
@ 2010-03-02  9:49 Prashant Purohit
  2010-03-02 15:53 ` Ian Lance Taylor
  0 siblings, 1 reply; 4+ messages in thread
From: Prashant Purohit @ 2010-03-02  9:49 UTC (permalink / raw)
  To: gcc-help


Hi all,

        As ARM has only 8 bit for immediate value, "arm_gen_constant"
function in "arm.c" is used to generate those value which are not generated
by 8-bit rotation scheme in ARM Processor.

        But my question is how we decide these constants in that function &
how that function proceed or work (i.e the logic behind generating those
constants) as I am not able to get it by just looking at the code.

        Please, help me by giving some more description about how the
function works?

        Any help in this regard is appreciated.

        Thanks in advance.

Regards,
Prashant.
-- 
View this message in context: http://old.nabble.com/How-%22arm_gen_constant%22-Function-In-arm.c-works--tp27753882p27753882.html
Sent from the gcc - Help mailing list archive at Nabble.com.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: How "arm_gen_constant" Function In arm.c works?
  2010-03-02  9:49 How "arm_gen_constant" Function In arm.c works? Prashant Purohit
@ 2010-03-02 15:53 ` Ian Lance Taylor
  2010-03-03  5:16   ` Prashant Purohit
  0 siblings, 1 reply; 4+ messages in thread
From: Ian Lance Taylor @ 2010-03-02 15:53 UTC (permalink / raw)
  To: Prashant Purohit; +Cc: gcc-help

Prashant Purohit <prashantpurohit025@gmail.com> writes:

>         As ARM has only 8 bit for immediate value, "arm_gen_constant"
> function in "arm.c" is used to generate those value which are not generated
> by 8-bit rotation scheme in ARM Processor.
>
>         But my question is how we decide these constants in that function &
> how that function proceed or work (i.e the logic behind generating those
> constants) as I am not able to get it by just looking at the code.
>
>         Please, help me by giving some more description about how the
> function works?

I'm not sure I understand the question.  When you say "how we decide
these constants in that function," to which constants are you
referring?

Some ARM instructions let you shift and rotate operands before
applying them.  The arm_gen_constant function is so complicated
because it is looking for different ways to exploit that fact in order
to generate the constants in the fewest instructions.  The function is
also considering the context in which the constant is used--this is
the code parameter--since that permits some further optimizations.

To understand what this code is doing, first get a clear understanding
of the ARM architecture.  Then consider how to most efficiently
implement various operations using constants.

Ian

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: How "arm_gen_constant" Function In arm.c works?
  2010-03-02 15:53 ` Ian Lance Taylor
@ 2010-03-03  5:16   ` Prashant Purohit
  2010-03-03  6:52     ` Ian Lance Taylor
  0 siblings, 1 reply; 4+ messages in thread
From: Prashant Purohit @ 2010-03-03  5:16 UTC (permalink / raw)
  To: gcc-help


Hi Ian,

   Thanks for the reply.

>I'm not sure I understand the question.  When you say "how we decide
>these constants in that function," to which constants are you
>referring?

   Sorry for not mentioning my question clearly.
   I mean to say, as we can not generate all the constants from 8 bit
rotation scheme supported in ARM architecture, I just wanted to know the
logic behind that function which generates one Mov and one Add/Sub
instruction if that constant is not being generated by rotation scheme
alone.
   e:g : suppose, the immediate constant is 1234 then that function will do
it as 

       mov r3, #1232
       add r3, r3, #2  (In case of ARM)
   Please tell me, how it splits that constant in to 1232 and 2.

>Some ARM instructions let you shift and rotate operands before
>applying them.  The arm_gen_constant function is so complicated
>because it is looking for different ways to exploit that fact in order
>to generate the constants in the fewest instructions.  The function is
>also considering the context in which the constant is used--this is
>the code parameter--since that permits some further optimizations.

>To understand what this code is doing, first get a clear understanding
>of the ARM architecture.  Then consider how to most efficiently
>implement various operations using constants.

Yes, I am well aware about ARM architecture and so only asked the logic of
"arm_gen_constant" function.

Please, let me know if any one know it.

Thanks & Regards,
Prashant.



-- 
View this message in context: http://old.nabble.com/How-%22arm_gen_constant%22-Function-In-arm.c-works--tp27753882p27764440.html
Sent from the gcc - Help mailing list archive at Nabble.com.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: How "arm_gen_constant" Function In arm.c works?
  2010-03-03  5:16   ` Prashant Purohit
@ 2010-03-03  6:52     ` Ian Lance Taylor
  0 siblings, 0 replies; 4+ messages in thread
From: Ian Lance Taylor @ 2010-03-03  6:52 UTC (permalink / raw)
  To: Prashant Purohit; +Cc: gcc-help

Prashant Purohit <prashantpurohit025@gmail.com> writes:

>    I mean to say, as we can not generate all the constants from 8 bit
> rotation scheme supported in ARM architecture, I just wanted to know the
> logic behind that function which generates one Mov and one Add/Sub
> instruction if that constant is not being generated by rotation scheme
> alone.
>    e:g : suppose, the immediate constant is 1234 then that function will do
> it as 
>
>        mov r3, #1232
>        add r3, r3, #2  (In case of ARM)
>    Please tell me, how it splits that constant in to 1232 and 2.

I don't know how to answer except to simply read the function.  The
code is right there.  In this case I expect it happens in the loop at
the end of the function.  If you have any questions about how the
function works, can you be more specific?

Ian

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2010-03-03  6:52 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-03-02  9:49 How "arm_gen_constant" Function In arm.c works? Prashant Purohit
2010-03-02 15:53 ` Ian Lance Taylor
2010-03-03  5:16   ` Prashant Purohit
2010-03-03  6:52     ` Ian Lance Taylor

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).