public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
* divmod , division+modulo problem in rtl
@ 2002-10-14  9:14 Pierre Mallard
  2002-10-14  9:16 ` Momchil Velikov
  0 siblings, 1 reply; 5+ messages in thread
From: Pierre Mallard @ 2002-10-14  9:14 UTC (permalink / raw)
  To: gcc

Hi,
I need someone's help to output a single operation for
an operation such as a (div a b)+(mod a b) in c
language only...

For this I did this in unsigned QI-char- op :
1)
(define_expand "udivmodqi4"
  [(set (match_operand:QI 0 "register_operand" "=r")
        	(udiv:QI (match_operand:HI 1
"register_operand" "r")
                	 (match_operand:QI 2
"register_operand"  "r")))
   (set (match_operand:QI 3 "register_operand"
"=r")(umod:QI (match_dup 1) (match_dup 2)))]
  ""
  "{
  	rtx res = gen_reg_rtx(HImode);
  	rtx opa = gen_rtx_SUBREG(QImode,res,0);
  	rtx opb = gen_rtx_SUBREG(QImode,res,1);

emit_insn(gen__udivmodqi4(res,operands[1],operands[2]));
  	emit_move_insn(operands[0],opa);
  	emit_move_insn(operands[3],opb);
  }")

(define_insn "_udivmodqi4"
  [(set (subreg:QI (match_operand:HI 0
"register_operand" "=r")0)
        (udiv:QI (match_operand:HI 1
"register_operand" "r")
                (match_operand:QI 2 "register_operand"
 "r")))
   (set (subreg:QI (match_dup 0) 1)
        (umod:QI (match_dup 1) (match_dup 2)))]
  ""
  "nop
  	divuu %0,%1,%2"
    [(set_attr "length" "2")
   (set_attr "cc" "none")])
and that's working fine ... 
But when I try to put it for an unsigned HI(short) op:
(define_expand "udivmodhi4"
  [(set (match_operand:HI 0 "register_operand" "=r")
        	(udiv:HI (match_operand:HI 1
"register_operand" "r")
                	 (match_operand:HI 2
"register_operand"  "r")))
   (set (match_operand:HI 3 "register_operand"
"=r")(umod:HI (match_dup 1) (match_dup 2)))]
  ""
  "{
      emit_move_insn (gen_rtx_REG (HImode, 24),
operands[1]);
      emit_move_insn (gen_rtx_REG (HImode, 26),
operands[2]);
     
emit_library_call_value(gen_rtx_SYMBOL_REF(Pmode,\"__udivmodhi4\"),
gen_rtx_REG (SImode, 24) , 0, SImode, 2 , gen_rtx_REG
(HImode, 24) , HImode , gen_rtx_REG (HImode, 26) ,
HImode);
      emit_move_insn (operands[0], gen_rtx_REG
(HImode, 24));
      emit_move_insn (operands[3], gen_rtx_REG
(HImode, 26));
      DONE;
  }")

The gcc output two calls to the library function
__divmodhi4 !!!! and to the define_expand then ..

So I'm wondering what's the point I missed in writing
this ...

2)And if u got any idea how a Signed Qi division can
be handle by a Qi signed division ... let me just show
u :
My goal is 
this in c :
signed char a = (signed char)b / (signed char)c
handle by
this in rtl :
(define_expand "divmodqi4"
  [(set (match_operand:QI 0 "register_operand" "=r")
        	(div:QI (match_operand:HI 1
"register_operand" "r")
                	 (match_operand:QI 2
"register_operand"  "r")))
   (set (match_operand:QI 3 "register_operand"
"=r")(mod:QI (match_dup 1) (match_dup 2)))]
  ""
  "{
  	rtx res = gen_reg_rtx(HImode);
  	rtx opa = gen_rtx_SUBREG(QImode,res,0);
  	rtx opb = gen_rtx_SUBREG(QImode,res,1);

emit_insn(gen__divmodqi4(res,operands[1],operands[2]));
  	emit_move_insn(operands[0],opa);
  	emit_move_insn(operands[3],opb);
  }")

Well just like HI is in fact ... ? 

Thanks for u're help
Pierre

___________________________________________________________
Do You Yahoo!? -- Une adresse @yahoo.fr gratuite et en français !
Yahoo! Mail : http://fr.mail.yahoo.com

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

* Re: divmod , division+modulo problem in rtl
  2002-10-14  9:14 divmod , division+modulo problem in rtl Pierre Mallard
@ 2002-10-14  9:16 ` Momchil Velikov
  2002-10-16  7:31   ` Pierre Mallard
                     ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Momchil Velikov @ 2002-10-14  9:16 UTC (permalink / raw)
  To: Pierre Mallard; +Cc: gcc

>>>>> "Pierre" == Pierre Mallard <pierremallard@yahoo.fr> writes:

Pierre> Hi,
Pierre> I need someone's help to output a single operation for
Pierre> an operation such as a (div a b)+(mod a b) in c
Pierre> language only...

See if this patch will help
http://gcc.gnu.org/ml/gcc-patches/2002-07/msg01207.html

Pierre> 2)And if u got any idea how a Signed Qi division can
Pierre> be handle by a Qi signed division ... let me just show
It can't, in C at least.

~velco

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

* Re: divmod , division+modulo problem in rtl
  2002-10-14  9:16 ` Momchil Velikov
@ 2002-10-16  7:31   ` Pierre Mallard
  2002-10-16  7:32   ` Pierre Mallard
  2002-10-16  7:37   ` Char as long as one Word , Int twice a Word Pierre Mallard
  2 siblings, 0 replies; 5+ messages in thread
From: Pierre Mallard @ 2002-10-16  7:31 UTC (permalink / raw)
  To: Momchil Velikov; +Cc: gcc

-gcc-3.0.4, c language-
Hi and thanks a lot.
I did not get any better things after having change
those few lines.
Anyway ok I just leave it now for catching div and mod
the same time..

But the problem I got here right now is the matching
of a divmodqi4 describe in a define_expand:

My word are define as being 16 bits long same as for
my char whereas my int are 32 bits long.

when I do 
char a,b,c;
c=a/b

I can't make gcc understand I need divmodqi4 and not
divmodhi4..

Gcc is always passing throw divmodhi4 and never in
divmodqi4...

I'm really disappointed think I may have missed
something cause lots of different proc implements
divmodqi4 especially avr one which as approximately
the same definition as me for the words , char and int
except it's twice less...

In my configuration divmodqi4 dosn't look as it can be
match once...

Pierre
--- Momchil Velikov <velco@fadata.bg> a écrit : >
>>>>> "Pierre" == Pierre Mallard
> <pierremallard@yahoo.fr> writes:
> 
> Pierre> Hi,
> Pierre> I need someone's help to output a single
> operation for
> Pierre> an operation such as a (div a b)+(mod a b)
> in c
> Pierre> language only...
> 
> See if this patch will help
>
http://gcc.gnu.org/ml/gcc-patches/2002-07/msg01207.html
> 
> Pierre> 2)And if u got any idea how a Signed Qi
> division can
> Pierre> be handle by a Qi signed division ... let me
> just show
> It can't, in C at least.
> 
> ~velco
>  

___________________________________________________________
Do You Yahoo!? -- Une adresse @yahoo.fr gratuite et en français !
Yahoo! Mail : http://fr.mail.yahoo.com

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

* Re: divmod , division+modulo problem in rtl
  2002-10-14  9:16 ` Momchil Velikov
  2002-10-16  7:31   ` Pierre Mallard
@ 2002-10-16  7:32   ` Pierre Mallard
  2002-10-16  7:37   ` Char as long as one Word , Int twice a Word Pierre Mallard
  2 siblings, 0 replies; 5+ messages in thread
From: Pierre Mallard @ 2002-10-16  7:32 UTC (permalink / raw)
  To: Momchil Velikov; +Cc: gcc

-gcc-3.0.4, c language-
Hi and thanks a lot.
I did not get any better things after having change
those few lines.
Anyway ok I just leave it now for catching div and mod
the same time..

But the problem I got here right now is the matching
of a divmodqi4 describe in a define_expand:

My word are define as being 16 bits long same as for
my char whereas my int are 32 bits long.

when I do 
char a,b,c;
c=a/b

I can't make gcc understand I need divmodqi4 and not
divmodhi4..

Gcc is always passing throw divmodhi4 and never in
divmodqi4...

I'm really disappointed think I may have missed
something cause lots of different proc implements
divmodqi4 especially avr one which as approximately
the same definition as me for the words , char and int
except it's twice less...

In my configuration divmodqi4 dosn't look as it can be
match once...

Pierre
--- Momchil Velikov <velco@fadata.bg> a écrit : >
>>>>> "Pierre" == Pierre Mallard
> <pierremallard@yahoo.fr> writes:
> 
> Pierre> Hi,
> Pierre> I need someone's help to output a single
> operation for
> Pierre> an operation such as a (div a b)+(mod a b)
> in c
> Pierre> language only...
> 
> See if this patch will help
>
http://gcc.gnu.org/ml/gcc-patches/2002-07/msg01207.html
> 
> Pierre> 2)And if u got any idea how a Signed Qi
> division can
> Pierre> be handle by a Qi signed division ... let me
> just show
> It can't, in C at least.
> 
> ~velco
>  

___________________________________________________________
Do You Yahoo!? -- Une adresse @yahoo.fr gratuite et en français !
Yahoo! Mail : http://fr.mail.yahoo.com

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

* Char as long as one Word , Int twice a Word
  2002-10-14  9:16 ` Momchil Velikov
  2002-10-16  7:31   ` Pierre Mallard
  2002-10-16  7:32   ` Pierre Mallard
@ 2002-10-16  7:37   ` Pierre Mallard
  2 siblings, 0 replies; 5+ messages in thread
From: Pierre Mallard @ 2002-10-16  7:37 UTC (permalink / raw)
  To: Momchil Velikov; +Cc: gcc

I've tryed to define a int as long as one word on my
proc, and then automatically char is well computed...
So if my register are 16 bits long I'm forced to
define int as 16 and not 32 as I wanted first, to
solve the problem of having my char div being computed
as an int div...

Do u know if it's possible to turn of this behaviour
in gcc (make a signed char op being cast in int op)
when int are twice a register ?

 --- Momchil Velikov <velco@fadata.bg> a écrit : >
>>>>> "Pierre" == Pierre Mallard
> <pierremallard@yahoo.fr> writes:
> 
> Pierre> Hi,
> Pierre> I need someone's help to output a single
> operation for
> Pierre> an operation such as a (div a b)+(mod a b)
> in c
> Pierre> language only...
> 
> See if this patch will help
>
http://gcc.gnu.org/ml/gcc-patches/2002-07/msg01207.html
> 
> Pierre> 2)And if u got any idea how a Signed Qi
> division can
> Pierre> be handle by a Qi signed division ... let me
> just show
> It can't, in C at least.
> 
> ~velco
>  

___________________________________________________________
Do You Yahoo!? -- Une adresse @yahoo.fr gratuite et en français !
Yahoo! Mail : http://fr.mail.yahoo.com

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

end of thread, other threads:[~2002-10-16 12:32 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-10-14  9:14 divmod , division+modulo problem in rtl Pierre Mallard
2002-10-14  9:16 ` Momchil Velikov
2002-10-16  7:31   ` Pierre Mallard
2002-10-16  7:32   ` Pierre Mallard
2002-10-16  7:37   ` Char as long as one Word , Int twice a Word Pierre Mallard

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).