MFENCE encoding


I have a problem with creating a MFENCE on X86 with SSE

In, a MFENCE is
def MFENCE : I<0xAE, MRM6m, (outs), (ins),
               "mfence", [(int_x86_sse2_mfence)]>, TB, Requires<[HasSSE2]>;

In X86CodeEmitter.cpp in emitInstruction

  case X86II::MRM6m: case X86II::MRM7m: {
    intptr_t PCAdj = (CurOp+4 != NumOps) ?
      (MI.getOperand(CurOp+4).isImm() ? X86InstrInfo::sizeOfImm(Desc) : 4) : 0;

If I'm reading the code correctly, the NumOps is 0 and CurOp is 0 so we to get the 4th operand from the MFENCE operation which has no operands so we get an error. I'm not sure what this code is trying to do. Should the condition be < NumOps?

  -- Mon Ping

Hmm. mfence and lfence needs special handling. I'll take a look.


I've fixed this (untested though).



   -- Mon Ping