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

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