public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
* How to write pattern for addition with carry operation
@ 2008-06-07  5:37 Mohamed Shafi
  0 siblings, 0 replies; 5+ messages in thread
From: Mohamed Shafi @ 2008-06-07  5:37 UTC (permalink / raw)
  To: GCC

Hello all,

The 16bit target that i am porting to gcc4.1.2 doesn't have any
instructions for 32bit operations. But for addition and subtraction
there is
addc
subc
instructions that consider carry bit also. Presently i have patterns
for SImode addition and subtraction such that the template will have

add %0, %1\naddc %N0, %N1
sub %0, %1\nsubc %N0, %N1

Will it be possible for me to write separate patterns for the
instructions add and addc?

Regards,
Shafi

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

* Re: How to write pattern for addition with carry operation
  2008-06-07  9:19 ` Mohamed Shafi
  2008-06-07 11:40   ` Uros Bizjak
@ 2008-06-08  1:30   ` Ian Lance Taylor
  1 sibling, 0 replies; 5+ messages in thread
From: Ian Lance Taylor @ 2008-06-08  1:30 UTC (permalink / raw)
  To: Mohamed Shafi; +Cc: Uros Bizjak, GCC

"Mohamed Shafi" <shafitvm@gmail.com> writes:

>> You can look into config/i386.md, how i.e. adddi3 is expanded and split in
>> case of !TARGET_64BIT.
>
> But is it scheduling safe?
> I mean you can't have addc executed before add. If i am right there
> will be no dependency between the two instructions. So there can be a
> case where addc gets scheduled before add. Am i right on both counts?

You are right in the sense that you must express the dependency
between the insns in the RTL.

The i386 backend is safe.  It expresses this dependency via (reg:CC
FLAGS_REG).

Ian

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

* Re: How to write pattern for addition with carry operation
  2008-06-07  9:19 ` Mohamed Shafi
@ 2008-06-07 11:40   ` Uros Bizjak
  2008-06-08  1:30   ` Ian Lance Taylor
  1 sibling, 0 replies; 5+ messages in thread
From: Uros Bizjak @ 2008-06-07 11:40 UTC (permalink / raw)
  To: Mohamed Shafi; +Cc: GCC

On Sat, Jun 7, 2008 at 11:18 AM, Mohamed Shafi <shafitvm@gmail.com> wrote:

>>> The 16bit target that i am porting to gcc4.1.2 doesn't have any
>>> instructions for 32bit operations. But for addition and subtraction
>>> there is
>>> addc
>>> subc
>>> instructions that consider carry bit also. Presently i have patterns
>>> for SImode addition and subtraction such that the template will have
>>>
>>> add %0, %1\naddc %N0, %N1
>>> sub %0, %1\nsubc %N0, %N1
>>>
>>> Will it be possible for me to write separate patterns for the
>>> instructions add and addc?
>>>
>>
>> You can look into config/i386.md, how i.e. adddi3 is expanded and split in
>> case of !TARGET_64BIT.
>
> But is it scheduling safe?
> I mean you can't have addc executed before add. If i am right there
> will be no dependency between the two instructions. So there can be a
> case where addc gets scheduled before add. Am i right on both counts?

No, they are connected through carry flag in the sense that "add" is
the producer "and addc" is the consumer of CC reg, At least this is
the way i386 pattern works for a couple of decades without problems.

Uros.

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

* Re: How to write pattern for addition with carry operation
  2008-06-07  7:33 Uros Bizjak
@ 2008-06-07  9:19 ` Mohamed Shafi
  2008-06-07 11:40   ` Uros Bizjak
  2008-06-08  1:30   ` Ian Lance Taylor
  0 siblings, 2 replies; 5+ messages in thread
From: Mohamed Shafi @ 2008-06-07  9:19 UTC (permalink / raw)
  To: Uros Bizjak; +Cc: GCC

2008/6/7 Uros Bizjak <ubizjak@gmail.com>:
> Hello!
>
>> The 16bit target that i am porting to gcc4.1.2 doesn't have any
>> instructions for 32bit operations. But for addition and subtraction
>> there is
>> addc
>> subc
>> instructions that consider carry bit also. Presently i have patterns
>> for SImode addition and subtraction such that the template will have
>>
>> add %0, %1\naddc %N0, %N1
>> sub %0, %1\nsubc %N0, %N1
>>
>> Will it be possible for me to write separate patterns for the
>> instructions add and addc?
>>
>
> You can look into config/i386.md, how i.e. adddi3 is expanded and split in
> case of !TARGET_64BIT.

But is it scheduling safe?
I mean you can't have addc executed before add. If i am right there
will be no dependency between the two instructions. So there can be a
case where addc gets scheduled before add. Am i right on both counts?

Regards,
Shafi

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

* Re: How to write pattern for addition with carry operation
@ 2008-06-07  7:33 Uros Bizjak
  2008-06-07  9:19 ` Mohamed Shafi
  0 siblings, 1 reply; 5+ messages in thread
From: Uros Bizjak @ 2008-06-07  7:33 UTC (permalink / raw)
  To: GCC; +Cc: Mohamed Shafi

Hello!

> The 16bit target that i am porting to gcc4.1.2 doesn't have any
> instructions for 32bit operations. But for addition and subtraction
> there is
> addc
> subc
> instructions that consider carry bit also. Presently i have patterns
> for SImode addition and subtraction such that the template will have
>
> add %0, %1\naddc %N0, %N1
> sub %0, %1\nsubc %N0, %N1
>
> Will it be possible for me to write separate patterns for the
> instructions add and addc?
>   

You can look into config/i386.md, how i.e. adddi3 is expanded and split 
in case of !TARGET_64BIT.

Uros.

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

end of thread, other threads:[~2008-06-08  1:30 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-06-07  5:37 How to write pattern for addition with carry operation Mohamed Shafi
2008-06-07  7:33 Uros Bizjak
2008-06-07  9:19 ` Mohamed Shafi
2008-06-07 11:40   ` Uros Bizjak
2008-06-08  1:30   ` 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).