[LLVMdev] Adding xadd instruction to X86

John Criswell criswell at cs.uiuc.edu
Thu Dec 2 14:13:19 PST 2004


Brent Monroe wrote:
> Hi,
> 
> I'm trying to add the xadd instruction to the X86 back end. 
> xadd r/m32, r32 
> exchanges r/m32 and r32, and loads the sum into r/m32.  I'm
> interested in the case where the destination operand is a
> memory location.

I think it might be easier if you drop by my office.  I'll be here until 
5:30, and I'll be here until 5:00 tomorrow.

> 
> I've added the following entry to X86InstrInfo.td:
> def XADD32mr  : I<0x87, MRMDestMem,
>                 (ops i32mem:$src1, R32:$src2),
>                 "xadd{l} {$src1|$src2}, {$src2|$src1}">;

Comparing it to the XCHG32mr instruction, the last line as $src1 and 
$src2 reversed.  Is this correct?

> 
> The xadd is emitted for the intrinsic function:
> call int (<integer type>*, <integer type>)*
> %llvm.atomic_fetch_add_store(<integer type>* <pointer>,      
>                                                            
> <integer type> <value>)
> 
> I currently have the following code (PtrReg contains the
> pointer argument, ValReg the value arg, and TmpReg an unused
> register.):
> 
> addDirectMem(BuildMI(BB, X86::XADD32mr, 4,
> TmpReg).addReg(TwoReg), ValReg);
> 
> This fails the assertion isMem.  Any help with this would be
> appreciated.
> 
> Thanks,
> 
> Brent
> 
> _______________________________________________
> LLVM Developers mailing list
> LLVMdev at cs.uiuc.edu         http://llvm.cs.uiuc.edu
> http://mail.cs.uiuc.edu/mailman/listinfo/llvmdev

-- John T.

-- 
*********************************************************************
* John T. Criswell                         Email: criswell at uiuc.edu *
* Research Programmer                                               *
* University of Illinois at Urbana-Champaign                        *
*                                                                   *
* "It's today!" said Piglet. "My favorite day," said Pooh.          *
*********************************************************************




More information about the llvm-dev mailing list