diff --git a/lib/Target/X86/MachineCodeEmitter.cpp b/lib/Target/X86/MachineCodeEmitter.cpp index dc9f4c08a73..79c1dbfe007 100644 --- a/lib/Target/X86/MachineCodeEmitter.cpp +++ b/lib/Target/X86/MachineCodeEmitter.cpp @@ -238,7 +238,8 @@ void Emitter::emitInstruction(MachineInstr &MI) { break; case X86II::AddRegFrm: MCE.emitByte(BaseOpcode + getX86RegNum(MI.getOperand(0).getReg())); - if (MI.getNumOperands() == 2) { + if (MI.getNumOperands() == 2 && (MI.getOperand(1).isImmediate() || + MI.getOperand(1).getVRegValueOrNull())) { unsigned Size = sizeOfPtr(Desc); if (Value *V = MI.getOperand(1).getVRegValueOrNull()) { assert(Size == 4 && "Don't know how to emit non-pointer values!"); diff --git a/lib/Target/X86/Printer.cpp b/lib/Target/X86/Printer.cpp index 84b43a06785..385172dc0de 100644 --- a/lib/Target/X86/Printer.cpp +++ b/lib/Target/X86/Printer.cpp @@ -196,20 +196,22 @@ void X86InstrInfo::print(const MachineInstr *MI, std::ostream &O, // or it takes a register and an immediate of the same size as the register // (move immediate f.e.). Note that this immediate value might be stored as // an LLVM value, to represent, for example, loading the address of a global - // into a register. + // into a register. The initial register might be duplicated if this is a + // M_2_ADDR_REG instruction // assert(MI->getOperand(0).isRegister() && (MI->getNumOperands() == 1 || (MI->getNumOperands() == 2 && (MI->getOperand(1).getVRegValueOrNull() || - MI->getOperand(1).isImmediate()))) && + MI->getOperand(1).isImmediate() || + MI->getOperand(1).isRegister()))) && "Illegal form for AddRegFrm instruction!"); unsigned Reg = MI->getOperand(0).getReg(); O << getName(MI->getOpCode()) << " "; printOp(O, MI->getOperand(0), RI); - if (MI->getNumOperands() == 2) { + if (MI->getNumOperands() == 2 && !MI->getOperand(1).isRegister()) { O << ", "; printOp(O, MI->getOperand(1), RI); } diff --git a/lib/Target/X86/X86AsmPrinter.cpp b/lib/Target/X86/X86AsmPrinter.cpp index 84b43a06785..385172dc0de 100644 --- a/lib/Target/X86/X86AsmPrinter.cpp +++ b/lib/Target/X86/X86AsmPrinter.cpp @@ -196,20 +196,22 @@ void X86InstrInfo::print(const MachineInstr *MI, std::ostream &O, // or it takes a register and an immediate of the same size as the register // (move immediate f.e.). Note that this immediate value might be stored as // an LLVM value, to represent, for example, loading the address of a global - // into a register. + // into a register. The initial register might be duplicated if this is a + // M_2_ADDR_REG instruction // assert(MI->getOperand(0).isRegister() && (MI->getNumOperands() == 1 || (MI->getNumOperands() == 2 && (MI->getOperand(1).getVRegValueOrNull() || - MI->getOperand(1).isImmediate()))) && + MI->getOperand(1).isImmediate() || + MI->getOperand(1).isRegister()))) && "Illegal form for AddRegFrm instruction!"); unsigned Reg = MI->getOperand(0).getReg(); O << getName(MI->getOpCode()) << " "; printOp(O, MI->getOperand(0), RI); - if (MI->getNumOperands() == 2) { + if (MI->getNumOperands() == 2 && !MI->getOperand(1).isRegister()) { O << ", "; printOp(O, MI->getOperand(1), RI); } diff --git a/lib/Target/X86/X86CodeEmitter.cpp b/lib/Target/X86/X86CodeEmitter.cpp index dc9f4c08a73..79c1dbfe007 100644 --- a/lib/Target/X86/X86CodeEmitter.cpp +++ b/lib/Target/X86/X86CodeEmitter.cpp @@ -238,7 +238,8 @@ void Emitter::emitInstruction(MachineInstr &MI) { break; case X86II::AddRegFrm: MCE.emitByte(BaseOpcode + getX86RegNum(MI.getOperand(0).getReg())); - if (MI.getNumOperands() == 2) { + if (MI.getNumOperands() == 2 && (MI.getOperand(1).isImmediate() || + MI.getOperand(1).getVRegValueOrNull())) { unsigned Size = sizeOfPtr(Desc); if (Value *V = MI.getOperand(1).getVRegValueOrNull()) { assert(Size == 4 && "Don't know how to emit non-pointer values!");