From: Chris Lattner Date: Wed, 6 Apr 2005 04:21:07 +0000 (+0000) Subject: Add (untested) support for MULHS and MULHU. X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=8db0af1c8d92635579464a970dec61377e9b06b8;p=oota-llvm.git Add (untested) support for MULHS and MULHU. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@21107 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Target/X86/X86ISelPattern.cpp b/lib/Target/X86/X86ISelPattern.cpp index a1716fa12d6..830dcc06a02 100644 --- a/lib/Target/X86/X86ISelPattern.cpp +++ b/lib/Target/X86/X86ISelPattern.cpp @@ -1818,6 +1818,57 @@ unsigned ISel::SelectExpr(SDOperand N) { BuildMI(BB, X86::FCHS, 1, Result).addReg(Tmp1); return Result; + case ISD::MULHU: + switch (N.getValueType()) { + default: assert(0 && "Unsupported VT!"); + case MVT::i8: Tmp2 = X86::MUL8r; break; + case MVT::i16: Tmp2 = X86::MUL16r; break; + case MVT::i32: Tmp2 = X86::MUL32r; break; + } + // FALL THROUGH + case ISD::MULHS: { + unsigned MovOpc, LowReg, HiReg; + switch (N.getValueType()) { + default: assert(0 && "Unsupported VT!"); + case MVT::i8: + MovOpc = X86::MOV8rr; + LowReg = X86::AL; + HiReg = X86::AH; + Opc = X86::IMUL8r; + break; + case MVT::i16: + MovOpc = X86::MOV16rr; + LowReg = X86::AX; + HiReg = X86::DX; + Opc = X86::IMUL16r; + break; + case MVT::i32: + MovOpc = X86::MOV32rr; + LowReg = X86::EAX; + HiReg = X86::EDX; + Opc = X86::IMUL32r; + break; + } + if (Node->getOpcode() != ISD::MULHS) + Opc = Tmp2; // Get the MULHU opcode. + + Op0 = Node->getOperand(0); + Op1 = Node->getOperand(1); + if (getRegPressure(Op0) > getRegPressure(Op1)) { + Tmp1 = SelectExpr(Op0); + Tmp2 = SelectExpr(Op1); + } else { + Tmp2 = SelectExpr(Op1); + Tmp1 = SelectExpr(Op0); + } + + // FIXME: Implement folding of loads into the memory operands here! + BuildMI(BB, MovOpc, 1, LowReg).addReg(Tmp1); + BuildMI(BB, Opc, 1).addReg(Tmp2); + BuildMI(BB, MovOpc, 1, Result).addReg(HiReg); + return Result; + } + case ISD::SUB: case ISD::MUL: case ISD::AND: