Can't find a register in class `CREG' while reloading `asm'

ma, yi mikema@cc.gatech.edu
Sun Oct 14 10:56:00 GMT 2001


On Sep 11, 2001, Kallol Biswas <kallolbiswas@yahoo.com> wrote:

> Can't find a register in class `CREG' while reloading
> `asm'.
>main()
>{
>char *dst_ep, *src_ep;
>int nbytes = 10;
> 
>    do                                                
>                       \
>    {                                                 
>                       \
>      asm volatile (/* Set the direction flag, so
>copying goes backwards.  */  \                  
>"std\n"                                               
>    \
>                   /* Copy bytes.  */                 
>                       \
>                   "rep\n"                            
>                       \
>                   "movsb\n"                          
>                       \
>                   /* Clear the dir flag.  Convention
>says it should be 0. */ \
>                   "cld" :                            
>                       \
>                   "=D" (dst_ep), "=S" (src_ep) :     
>                       \
>                   "0" (dst_ep - 1), "1" (src_ep - 1),
>"c" (nbytes) :         \
>                   "cx");                             
>                       \
>      dst_ep += 1;                                    
>                       \
>      src_ep += 1;                                    
>                       \
>    } while (0);
> 
> 
> 
> 
>}
>xx.c: In function `main':
>xx.c:6: Can't find a register in class `CREG' while
>reloading `asm'.
>
>[root@localhost /tmp]# rpm -qa|grep gcc
>gcc-2.96-81
>gcc-g77-2.96-81
>gcc-c++-2.96-81
>[root@localhost /tmp]#
>
>[root@localhost /tmp]# rpm -qa|grep kernel
>kernel-2.4.2-2
>kernel-doc-2.4.2-2
>kernel-source-2.4.2-2
>kernel-headers-2.4.2-2
>
>[root@localhost /tmp]# uname -a
>Linux localhost.localdomain 2.4.2-2 #1 Sun Apr 8
>20:41:30 EDT 2001 i686 unknown
>
>

and on sep 28, Alexandre Oliva wrote:
>Note that the asm statement says it clobbers "cx", but since ecx is
>the only register in class c, so there's no register in which GCC
>could store nbytes.
>
>Previous versions of GCC wouldn't detect this problem, and would
>silently generate possibly-wrong code.


I also meet a similar problem:

I have a software that can been compiled and run well under redhat 5.2 (gcc 2.7). However I can not compile it now under redhat7.1(gcc 2.96). I don't know why! 

 The error is: 

  i586-msrs.h:122: Can't find a register in class 'AREG' while reloading
'asm'

the  error happened in the lines below:

/* In a minimal tight loop with no unrolling, a micro benchmark shows this
   as requiring 16 cycles */
extern __inline__ void
read_tsc(uint64 *dst)
{
        __asm__ __volatile__("rdtsc" 
                             : "=a" (*(uint32 *)dst), "=d" (*(((uint32 *)dst) + 1))
                             :
                             : "eax", "edx");
}           

Where are no input thich uses eax and edx. Why do the error:"can't find a register the class "AREG" while reloading asm" also happen?

Any help is greatly appreciated.


More information about the Gcc-help mailing list