From: "Pierre Mallard" <pierremallard@yahoo.fr>
To: gcc@gcc.gnu.org
Subject: divmod , division+modulo problem in rtl
Date: Mon, 14 Oct 2002 09:14:00 -0000 [thread overview]
Message-ID: <20021014141732.75118.qmail@web20305.mail.yahoo.com> (raw)
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
next reply other threads:[~2002-10-14 14:17 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2002-10-14 9:14 Pierre Mallard [this message]
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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20021014141732.75118.qmail@web20305.mail.yahoo.com \
--to=pierremallard@yahoo.fr \
--cc=gcc@gcc.gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).