public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
* Another clobber problem
@ 2006-11-21 14:24 tom
  0 siblings, 0 replies; only message in thread
From: tom @ 2006-11-21 14:24 UTC (permalink / raw)
  To: gcc-help

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");

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2006-11-21 14:24 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-11-21 14:24 Another clobber problem tom

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