Bug 21398 - gcc emits invalid operands for xchgb %b0, %h0
Summary: gcc emits invalid operands for xchgb %b0, %h0
Status: RESOLVED INVALID
Alias: None
Product: gcc
Classification: Unclassified
Component: other (show other bugs)
Version: 4.0.0
: P2 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-05-05 13:44 UTC by Pawel Sikora
Modified: 2005-07-23 22:49 UTC (History)
2 users (show)

See Also:
Host: amd64-pld-linux
Target: amd64-pld-linux
Build: amd64-pld-linux
Known to work:
Known to fail:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Pawel Sikora 2005-05-05 13:44:53 UTC
the code like this: 
 
unsigned short swap16(unsigned short x) 
{ 
    asm volatile ("xchgb %b0, %h0" : "=q" (x) : "0" (x)); 
    return x; 
} 
 
produces: 
 
swap16: xchgb   %dil, %di   <== %di isn't valid high 8-bit form. 
        movzwl  %di,  %eax 
        ret 
 
IIRC the %rdi, %rsi, %rsp, %rbp haven't a high 8-bit form.
Comment 1 Andrew Pinski 2005-05-05 13:49:28 UTC
"`a', b, c, or d register for the i386. For x86-64 it is equivalent to `r' class (for 8-bit instructions that 
do not use upper halves). "
Comment 2 Pawel Sikora 2005-05-05 14:22:37 UTC
in online docs i see that "q" means "byte addressable register (a,b,c,d)". 
in i386.h i see something differ for x86_64. did i miss something in docs? 
 
#define REG_CLASS_FROM_LETTER(C)        \ 
  ((C) == 'r' ? GENERAL_REGS :                                  \ 
   (C) == 'R' ? LEGACY_REGS :                                   \ 
   (C) == 'q' ? TARGET_64BIT ? GENERAL_REGS : Q_REGS :          \ 
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^ 
   (C) == 'Q' ? Q_REGS :                                        \ 
 
Comment 3 Andrew Pinski 2005-05-05 14:24:53 UTC
(In reply to comment #2)
> in online docs i see that "q" means "byte addressable register (a,b,c,d)". 
> in i386.h i see something differ for x86_64. did i miss something in docs? 

Yes see comment #1 which is a quote from the docs.
Comment 4 Pawel Sikora 2005-05-05 14:41:14 UTC
(In reply to comment #3) 
> (In reply to comment #2) 
> > in online docs i see that "q" means "byte addressable register (a,b,c,d)".  
> > in i386.h i see something differ for x86_64. did i miss something in docs?  
>  
> Yes see comment #1 which is a quote from the docs. 
 
ohh, i should fix my /dev/brain :)  i'll use the "=Q" format.