Another clobber problem

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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

[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux