This is the mail archive of the mailing list for the GCC project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Another clobber problem

What's the right way of telling gcc that an input register is 

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 

--- 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");
  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 Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]