extended asm - memory constraint

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

 



What is the proper way to inform g++ that a structure is altered by an asm
__volatile__ statement? Adding "memory" to the clobber list works but is an
overkill because then the compiler discards register copies of everything,
not only copies of fields from the relevant structure.

I have been trying on an x86 Ubuntu 9.04 system running in 32-bit mode,
using g++ 4.3.3. Here is the code snippet:

struct int96 {
   unsigned long long lo; // 64-bit
   unsigned int hi;          // 32-bit
   unsigned int padding;

  //.... bunch of functions

};


int96 sqr96(unsigned long long a) {
  // preparations for loads to xmm registers
  unsinged long long alo = (unsigned int) a;
  unsigned long long ahi = (a >>.32);
  // storage for the result
  int96 res;
  // compute square of 'a' using SSE2
  asm __volatile__ (
    "  // bunch of SSE statements "
    :  // HERE several things have been tried but nothing compiled
    : "rV" (&alo), "rV" (&ahi), "rV" (&res)
    : "%xmm5", "%xmm6", "%xmm7", "memory"
  );
  // return result
  return res;
}

The problem is that removing "memory" from the clobber list gives wrong code
because the compiler stores copies of res.lo and res.hi in other registers
and is not aware that these get obsolete. Adding memory output constraints
at "HERE" did not work. I tried for example these two

 i)  : "=m" (res)      
 ii) : "=V" (res)
 
but these generate errors

int96.h:261: Error: junk `(%ebp))' after expression
int96.h:261: Error: missing ')'
[...]

or

int96.h:261: error: inconsistent operand constraints in an ‘asm’
[...]

-- 
View this message in context: http://old.nabble.com/extended-asm---memory-constraint-tp28725485p28725485.html
Sent from the gcc - Help mailing list archive at Nabble.com.




[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