-1

Could anybody help me in identifying reason for the below compiler error.

"..\TestRT\TDP\PPCGNU\lib\custom.h:428: error: impossible constraint in ‘asm’"

Code: enter image description here

Thanks in advance!

1 Answers1

0

I think documentation answers this question. You probably have x86 code that you are building for x86-64. A is valid for x86, but not for x86-64. GCC documentation explains how to replace A by a for x86-64:

"This is not correct on x86-64 as it would allocate tick in either ax or dx. You have to use the following variant instead:"

unsigned long long rdtsc (void)
{
  unsigned int tickl, tickh;
  __asm__ __volatile__("rdtsc":"=a"(tickl),"=d"(tickh));
  return ((unsigned long long)tickh << 32)|tickl;
}
dbrank0
  • 9,026
  • 2
  • 37
  • 55
  • `"=A"` is *valid* in terms of compiling; for an operand that isn't 2 registers wide, it's equivalent to `"=ad"`, letting the compiler pick either, at its choice, not EDX:EAX. So it's a bug and yes you need to change the code, but it doesn't explain the compile-time error. See [Negative clock cycle measurements with back-to-back rdtsc?](https://stackoverflow.com/a/51916030) for examples of how it compiles. (Unless different versions of GCC were different.) See [How to get the CPU cycle count in x86\_64 from C++?](https://stackoverflow.com/q/13772567) for what to actually do; this is fine. – Peter Cordes Mar 20 '22 at 04:21