From: "tom@womack.net" <tom@womack.net>
To: gcc-help@gcc.gnu.org
Subject: Another clobber problem
Date: Tue, 21 Nov 2006 14:24:00 -0000 [thread overview]
Message-ID: <12011776.1164119032361.JavaMail.?@fh1035.dia.cp.net> (raw)
What's the right way of telling gcc that an input register is
clobbered?
I've two asm statements in the same function, both of which have "a"
(a) as an input constraint; the code corrupts RAX, and the optimiser is
not reloading a into RAX before starting the second bit of code.
If I add "rax" to the clobbers list, I get an error
modp2.cpp:55: error: can't find a register in class ___AREG___ while
reloading ___asm___
Also: how do I refer to r8 through r15 in register constraints on
x64? If I replace "r" (p) by "r9" (p) in the second asm statement, I
get an error
modp2.cpp:64: error: matching constraint references invalid operand
number
--- the function
asm("mulq %2\n mov %%rdx, %%r12 \n mov %%rax, %%r13 \n" \
"mov %3,%%rax \n mulq %%r13 \n mov %%rdx, %%r10 \n mov %%rax, %%
r11 \n" \
"mov %4,%%rax \n mulq %%r12 \n mov %%rdx, %%r8 \n mov %%rax, %%
r9 \n" \
"mov %3,%%rax \n mulq %%r12 \n add %%rax, %%r10 \n adc %%rdx, %%
r9 \n adc $0, %%r8 \n" \
"mov %4,%%rax \n mulq %%r13 \n add %%rax, %%r10 \n adc %%rdx, %%
r9 \n adc $0, %%r8 \n" \
"shrd %%cl, %%r8, %%r9\n mov %%r9, %%rdx"
: "=&d" (aus)
: "a" (a), "r" (b), "r" (il), "r" (ih), "c" (pis)
: "r8", "r9", "r10", "r11", "r12", "r13");
quotient=aus;
u64 rem;
asm("mulq %2\nmov %%rdx,%%r12 \n mov %%rax, %%r13 \n" \
"mov %3,%%rax\nmulq %4\n" \
"sub %%rax,%%r13 \n" \
"mov %%r13, %%rdx"
: "=&d" (rem)
: "a" (a), "r" (b), "c" (aus), "r" (p)
: "r12", "r13");
reply other threads:[~2006-11-21 14:24 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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='12011776.1164119032361.JavaMail.?@fh1035.dia.cp.net' \
--to=tom@womack.net \
--cc=gcc-help@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).