From: Chris Lattner Date: Fri, 5 Feb 2010 19:04:37 +0000 (+0000) Subject: add some more encodings. X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=daa45557931bb72e6b9f6b4725ac2cb1bd5168e9;p=oota-llvm.git add some more encodings. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@95403 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Target/X86/X86MCCodeEmitter.cpp b/lib/Target/X86/X86MCCodeEmitter.cpp index 40903c59e1d..4b4f8ce234f 100644 --- a/lib/Target/X86/X86MCCodeEmitter.cpp +++ b/lib/Target/X86/X86MCCodeEmitter.cpp @@ -146,7 +146,7 @@ void X86MCCodeEmitter::EmitMemModRMByte(const MCInst &MI, unsigned Op, if (Op3.isImm()) { DispVal = Op3.getImm(); } else { - assert(0 && "Unknown operand"); + assert(0 && "relocatable operand"); #if 0 if (Op3.isGlobal()) { DispForReloc = &Op3; @@ -416,6 +416,41 @@ EncodeInstruction(const MCInst &MI, raw_ostream &OS) const { EmitConstant(MI.getOperand(CurOp++).getImm(), X86InstrInfo::sizeOfImm(&Desc), OS); break; + + case X86II::MRMSrcReg: + EmitByte(BaseOpcode, OS); + EmitRegModRMByte(MI.getOperand(CurOp+1), GetX86RegNum(MI.getOperand(CurOp)), + OS); + CurOp += 2; + if (CurOp != NumOps) + EmitConstant(MI.getOperand(CurOp++).getImm(), + X86InstrInfo::sizeOfImm(&Desc), OS); + break; + + case X86II::MRMSrcMem: { + EmitByte(BaseOpcode, OS); + + // FIXME: Maybe lea should have its own form? This is a horrible hack. + int AddrOperands; + if (Opcode == X86::LEA64r || Opcode == X86::LEA64_32r || + Opcode == X86::LEA16r || Opcode == X86::LEA32r) + AddrOperands = X86AddrNumOperands - 1; // No segment register + else + AddrOperands = X86AddrNumOperands; + + // FIXME: What is this actually doing? + intptr_t PCAdj = (CurOp + AddrOperands + 1 != NumOps) ? + X86InstrInfo::sizeOfImm(&Desc) : 0; + + EmitMemModRMByte(MI, CurOp+1, GetX86RegNum(MI.getOperand(CurOp)), + PCAdj, OS); + CurOp += AddrOperands + 1; + if (CurOp != NumOps) + EmitConstant(MI.getOperand(CurOp++).getImm(), + X86InstrInfo::sizeOfImm(&Desc), OS); + break; + } + } #ifndef NDEBUG