[LLVMdev] Swaps of FP registers

Fernando Magno Quintao Pereira fernando at CS.UCLA.EDU
Tue Jul 3 12:27:30 PDT 2007


Dear guys,

     what is the best way to implement a swap of floating point registers 
in X86? For the integer registers, I am using xchg. Is there a similar 
instruction for floating point?

My function to insert swaps is like:

void X86RegisterInfo::swapRegs(
     MachineBasicBlock & mbb,
     MachineBasicBlock::iterator mi,
     unsigned r1,
     unsigned r2,
     const TargetRegisterClass *rc
) const {
     unsigned Opc;
     if (rc == &X86::GR32RegClass) {
         Opc = X86::XCHG32rr;
     } else if (rc == &X86::GR16RegClass) {
         Opc = X86::XCHG16rr;
     } else if (rc == &X86::GR8RegClass) {
         Opc = X86::XCHG8rr;
     } else {
         assert(0 && "Unknown regclass in add swap");
         abort();
     }
     BuildMI(mbb, mi, Opc, 1, r1).addReg(r2);
}

thanks,

Fernando



More information about the llvm-dev mailing list