This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
divmod , division+modulo problem in rtl
- From: Pierre Mallard <pierremallard at yahoo dot fr>
- To: gcc at gcc dot gnu dot org
- Date: Mon, 14 Oct 2002 16:17:32 +0200 (CEST)
- Subject: divmod , division+modulo problem in rtl
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